Fix build for storage tests

This commit is contained in:
Aidar Samerkhanov 2023-04-12 21:38:52 +00:00
parent 3c0ae50a15
commit 2250cadd28
8 changed files with 344 additions and 324 deletions

View File

@ -6,11 +6,13 @@ set(storage_v2_src_files
durability/serialization.cpp
durability/snapshot.cpp
durability/wal.cpp
edge_accessor.cpp
indices.cpp
inmemory/edge_accessor.cpp
inmemory/storage.cpp
inmemory/vertex_accessor.cpp
property_store.cpp
storage.cpp
vertex_accessor.cpp)

View File

@ -18,8 +18,7 @@ namespace memgraph::storage {
std::unique_ptr<EdgeAccessor> EdgeAccessor::Create(EdgeRef edge, EdgeTypeId edge_type, Vertex *from_vertex,
Vertex *to_vertex, Transaction *transaction, Indices *indices,
Constraints *constraints, Config::Items config,
bool for_deleted = false) {
Constraints *constraints, Config::Items config, bool for_deleted) {
return std::make_unique<InMemoryEdgeAccessor>(edge, edge_type, from_vertex, to_vertex, transaction, indices,
constraints, config, for_deleted);
}

View File

@ -71,33 +71,34 @@ std::string RegisterReplicaErrorToString(InMemoryStorage::RegisterReplicaError e
}
} // namespace
auto AdvanceToVisibleVertex(utils::SkipList<Vertex>::Iterator it, utils::SkipList<Vertex>::Iterator end,
std::unique_ptr<VertexAccessor> &vertex, Transaction *tx, View view, Indices *indices,
Constraints *constraints, Config::Items config) {
while (it != end) {
vertex = VertexAccessor::Create(&*it, tx, indices, constraints, config, view);
if (!vertex) {
++it;
continue;
}
break;
}
return it;
}
// auto AdvanceToVisibleVertex(utils::SkipList<Vertex>::Iterator it, utils::SkipList<Vertex>::Iterator end,
// std::unique_ptr<VertexAccessor> &vertex, Transaction *tx, View view, Indices *indices,
// Constraints *constraints, Config::Items config) {
// while (it != end) {
// vertex = VertexAccessor::Create(&*it, tx, indices, constraints, config, view);
// if (!vertex) {
// ++it;
// continue;
// }
// break;
// }
// return it;
// }
AllVerticesIterable::Iterator::Iterator(AllVerticesIterable *self, utils::SkipList<Vertex>::Iterator it)
: self_(self),
it_(AdvanceToVisibleVertex(it, self->vertices_accessor_.end(), self->vertex_, self->transaction_, self->view_,
self->indices_, self_->constraints_, self->config_)) {}
// AllVerticesIterable::Iterator::Iterator(AllVerticesIterable *self, utils::SkipList<Vertex>::Iterator it)
// : self_(self),
// it_(AdvanceToVisibleVertex(it, self->vertices_accessor_.end(), self->vertex_, self->transaction_, self->view_,
// self->indices_, self_->constraints_, self->config_)) {}
VertexAccessor *AllVerticesIterable::Iterator::operator*() const { return self_->vertex_.get(); }
// VertexAccessor *AllVerticesIterable::Iterator::operator*() const { return self_->vertex_.get(); }
AllVerticesIterable::Iterator &AllVerticesIterable::Iterator::operator++() {
++it_;
it_ = AdvanceToVisibleVertex(it_, self_->vertices_accessor_.end(), self_->vertex_, self_->transaction_, self_->view_,
self_->indices_, self_->constraints_, self_->config_);
return *this;
}
// AllVerticesIterable::Iterator &AllVerticesIterable::Iterator::operator++() {
// ++it_;
// it_ = AdvanceToVisibleVertex(it_, self_->vertices_accessor_.end(), self_->vertex_, self_->transaction_,
// self_->view_,
// self_->indices_, self_->constraints_, self_->config_);
// return *this;
// }
InMemoryStorage::InMemoryStorage(Config config)
: indices_(&constraints_, config.items),
@ -243,8 +244,7 @@ InMemoryStorage::~InMemoryStorage() {
}
InMemoryStorage::InMemoryAccessor::InMemoryAccessor(InMemoryStorage *storage, IsolationLevel isolation_level)
: Accessor(),
storage_(storage),
: storage_(storage),
// The lock must be acquired before creating the transaction object to
// prevent freshly created transactions from dangling in an active state
// during exclusive operations.
@ -254,8 +254,7 @@ InMemoryStorage::InMemoryAccessor::InMemoryAccessor(InMemoryStorage *storage, Is
config_(storage->config_.items) {}
InMemoryStorage::InMemoryAccessor::InMemoryAccessor(InMemoryAccessor &&other) noexcept
: Accessor(),
storage_(other.storage_),
: storage_(other.storage_),
storage_guard_(std::move(other.storage_guard_)),
transaction_(std::move(other.transaction_)),
commit_timestamp_(other.commit_timestamp_),

View File

@ -15,16 +15,30 @@
namespace memgraph::storage {
auto AdvanceToVisibleVertex(utils::SkipList<Vertex>::Iterator it, utils::SkipList<Vertex>::Iterator end,
std::unique_ptr<VertexAccessor> &vertex, Transaction *tx, View view, Indices *indices,
Constraints *constraints, Config::Items config) {
while (it != end) {
vertex = VertexAccessor::Create(&*it, tx, indices, constraints, config, view);
if (!vertex) {
++it;
continue;
}
break;
}
return it;
}
AllVerticesIterable::Iterator::Iterator(AllVerticesIterable *self, utils::SkipList<Vertex>::Iterator it)
: self_(self),
it_(AdvanceToVisibleVertex(it, self->vertices_accessor_.end(), &self->vertex_, self->transaction_, self->view_,
it_(AdvanceToVisibleVertex(it, self->vertices_accessor_.end(), self->vertex_, self->transaction_, self->view_,
self->indices_, self_->constraints_, self->config_)) {}
VertexAccessor *AllVerticesIterable::Iterator::operator*() const { return self_->vertex_.get(); }
AllVerticesIterable::Iterator &AllVerticesIterable::Iterator::operator++() {
++it_;
it_ = AdvanceToVisibleVertex(it_, self_->vertices_accessor_.end(), &self_->vertex_, self_->transaction_, self_->view_,
it_ = AdvanceToVisibleVertex(it_, self_->vertices_accessor_.end(), self_->vertex_, self_->transaction_, self_->view_,
self_->indices_, self_->constraints_, self_->config_);
return *this;
}
@ -136,10 +150,12 @@ VerticesIterable::Iterator::Iterator(const VerticesIterable::Iterator &other) :
new (&all_it_) AllVerticesIterable::Iterator(other.all_it_);
break;
case Type::BY_LABEL:
new (&by_label_it_) LabelIndex::Iterable::Iterator(other.by_label_it_);
MG_ASSERT(false, "Cannot copy-construct iterator of type BY_LABEL");
// new (&by_label_it_) LabelIndex::Iterable::Iterator(other.by_label_it_);
break;
case Type::BY_LABEL_PROPERTY:
new (&by_label_property_it_) LabelPropertyIndex::Iterable::Iterator(other.by_label_property_it_);
MG_ASSERT(false, "Cannot copy-construct iterator of type BY_LABEL_PROPERTY");
// new (&by_label_property_it_) LabelPropertyIndex::Iterable::Iterator(std::move(other.by_label_property_it_));
break;
}
}
@ -152,10 +168,12 @@ VerticesIterable::Iterator &VerticesIterable::Iterator::operator=(const Vertices
new (&all_it_) AllVerticesIterable::Iterator(other.all_it_);
break;
case Type::BY_LABEL:
new (&by_label_it_) LabelIndex::Iterable::Iterator(other.by_label_it_);
MG_ASSERT(false, "Cannot copy-assign iterator of type BY_LABEL");
// new (&by_label_it_) LabelIndex::Iterable::Iterator(other.by_label_it_);
break;
case Type::BY_LABEL_PROPERTY:
new (&by_label_property_it_) LabelPropertyIndex::Iterable::Iterator(other.by_label_property_it_);
MG_ASSERT(false, "Cannot copy-assign iterator of type BY_LABEL_PROPERTY");
// new (&by_label_property_it_) LabelPropertyIndex::Iterable::Iterator(other.by_label_property_it_);
break;
}
return *this;
@ -208,7 +226,7 @@ void VerticesIterable::Iterator::Destroy() noexcept {
}
}
VertexAccessor VerticesIterable::Iterator::operator*() const {
VertexAccessor *VerticesIterable::Iterator::operator*() const {
switch (type_) {
case Type::ALL:
return *all_it_;

View File

@ -124,7 +124,7 @@ class VerticesIterable final {
~Iterator();
VertexAccessor operator*() const;
VertexAccessor *operator*() const;
Iterator &operator++();
@ -160,7 +160,7 @@ class Accessor {
// and iterators) are *invalid*. You have to get all derived objects again.
Accessor(Accessor &&other) noexcept;
virtual ~Accessor();
virtual ~Accessor() {}
/// @throw std::bad_alloc
virtual std::unique_ptr<VertexAccessor> CreateVertex() = 0;

View File

@ -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
@ -11,10 +11,11 @@
#include "storage_test_utils.hpp"
size_t CountVertices(memgraph::storage::Storage::Accessor &storage_accessor, memgraph::storage::View view) {
size_t CountVertices(memgraph::storage::InMemoryStorage::InMemoryAccessor &storage_accessor,
memgraph::storage::View view) {
auto vertices = storage_accessor.Vertices(view);
size_t count = 0U;
for (auto it = vertices.begin(); it != vertices.end(); ++it, ++count)
;
return count;
}
}

View File

@ -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
@ -11,7 +11,8 @@
#pragma once
#include "storage/v2/storage.hpp"
#include "storage/v2/inmemory/storage.hpp"
#include "storage/v2/view.hpp"
size_t CountVertices(memgraph::storage::Storage::Accessor &storage_accessor, memgraph::storage::View view);
size_t CountVertices(memgraph::storage::InMemoryStorage::InMemoryAccessor &storage_accessor,
memgraph::storage::View view);

File diff suppressed because it is too large Load Diff