Add experimental/v1 of ON_DISK_TRANSACTIONAL storage (#850)
Co-authored-by: Andi Skrgat <andi8647@gmail.com> Co-authored-by: Aidar Samerkhanov <aidar.samerkhanov@memgraph.io>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -9,6 +9,7 @@
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -19,7 +20,9 @@
|
||||
#include <rapidcheck.h>
|
||||
#include <rapidcheck/gtest.h>
|
||||
|
||||
#include "storage/v2/inmemory/storage.hpp"
|
||||
#include "storage/v2/storage.hpp"
|
||||
#include "storage/v2/vertex_accessor.hpp"
|
||||
|
||||
/**
|
||||
* It is possible to run test with custom seed with:
|
||||
@@ -32,45 +35,45 @@ RC_GTEST_PROP(RandomGraph, RandomGraph, (std::vector<std::string> vertex_labels,
|
||||
int vertices_num = vertex_labels.size();
|
||||
int edges_num = edge_types.size();
|
||||
|
||||
memgraph::storage::Storage db;
|
||||
std::unique_ptr<memgraph::storage::Storage> db{new memgraph::storage::InMemoryStorage()};
|
||||
std::vector<memgraph::storage::VertexAccessor> vertices;
|
||||
std::unordered_map<memgraph::storage::VertexAccessor, std::string> vertex_label_map;
|
||||
std::unordered_map<memgraph::storage::EdgeAccessor, std::string> edge_type_map;
|
||||
|
||||
auto dba = db.Access();
|
||||
auto dba = db->Access();
|
||||
|
||||
for (auto label : vertex_labels) {
|
||||
auto vertex_accessor = dba.CreateVertex();
|
||||
RC_ASSERT(vertex_accessor.AddLabel(dba.NameToLabel(label)).HasValue());
|
||||
vertex_label_map.insert({vertex_accessor, label});
|
||||
auto vertex_accessor = dba->CreateVertex();
|
||||
RC_ASSERT(vertex_accessor.AddLabel(dba->NameToLabel(label)).HasValue());
|
||||
vertex_label_map.emplace(vertex_accessor, label);
|
||||
vertices.push_back(vertex_accessor);
|
||||
}
|
||||
|
||||
for (auto type : edge_types) {
|
||||
auto &from = vertices[*rc::gen::inRange(0, vertices_num)];
|
||||
auto &to = vertices[*rc::gen::inRange(0, vertices_num)];
|
||||
auto maybe_edge_accessor = dba.CreateEdge(&from, &to, dba.NameToEdgeType(type));
|
||||
auto maybe_edge_accessor = dba->CreateEdge(&from, &to, dba->NameToEdgeType(type));
|
||||
RC_ASSERT(maybe_edge_accessor.HasValue());
|
||||
edge_type_map.insert({*maybe_edge_accessor, type});
|
||||
}
|
||||
|
||||
dba.AdvanceCommand();
|
||||
dba->AdvanceCommand();
|
||||
|
||||
int edges_num_check = 0;
|
||||
int vertices_num_check = 0;
|
||||
for (auto vertex : dba.Vertices(memgraph::storage::View::OLD)) {
|
||||
for (auto vertex : dba->Vertices(memgraph::storage::View::OLD)) {
|
||||
auto label = vertex_label_map.at(vertex);
|
||||
auto maybe_labels = vertex.Labels(memgraph::storage::View::OLD);
|
||||
RC_ASSERT(maybe_labels.HasValue());
|
||||
const auto &labels = *maybe_labels;
|
||||
RC_ASSERT(labels.size() == 1);
|
||||
RC_ASSERT(dba.LabelToName(labels[0]) == label);
|
||||
RC_ASSERT(dba->LabelToName(labels[0]) == label);
|
||||
vertices_num_check++;
|
||||
auto maybe_edges = vertex.OutEdges(memgraph::storage::View::OLD);
|
||||
RC_ASSERT(maybe_edges.HasValue());
|
||||
for (auto &edge : *maybe_edges) {
|
||||
const auto &type = edge_type_map.at(edge);
|
||||
RC_ASSERT(dba.EdgeTypeToName(edge.EdgeType()) == type);
|
||||
RC_ASSERT(dba->EdgeTypeToName(edge.EdgeType()) == type);
|
||||
edges_num_check++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user