Merge branch 'T1189-MG-implement-create-node-cursor-mf' into T1190-MG-Implement-ScanAll-and-ScanAllByLabel-with-MultiFrame_2
This commit is contained in:
commit
82203fa1ca
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -734,7 +734,7 @@ std::optional<plan::ProfilingStatsWithTotalTime> PullPlan::PullMultiple(AnyStrea
|
|||||||
// Returns true if a result was pulled.
|
// Returns true if a result was pulled.
|
||||||
const auto pull_result = [&]() -> bool {
|
const auto pull_result = [&]() -> bool {
|
||||||
cursor_->PullMultiple(multi_frame_, ctx_);
|
cursor_->PullMultiple(multi_frame_, ctx_);
|
||||||
return multi_frame_.HasValidFrame();
|
return !multi_frame_.HasInvalidFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto stream_values = [&output_symbols, &stream](const Frame &frame) {
|
const auto stream_values = [&output_symbols, &stream](const Frame &frame) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -48,6 +48,10 @@ bool MultiFrame::HasValidFrame() const noexcept {
|
|||||||
return std::any_of(frames_.begin(), frames_.end(), [](auto &frame) { return frame.IsValid(); });
|
return std::any_of(frames_.begin(), frames_.end(), [](auto &frame) { return frame.IsValid(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MultiFrame::HasInvalidFrame() const noexcept {
|
||||||
|
return std::any_of(frames_.rbegin(), frames_.rend(), [](auto &frame) { return !frame.IsValid(); });
|
||||||
|
}
|
||||||
|
|
||||||
// NOLINTNEXTLINE (bugprone-exception-escape)
|
// NOLINTNEXTLINE (bugprone-exception-escape)
|
||||||
void MultiFrame::DefragmentValidFrames() noexcept {
|
void MultiFrame::DefragmentValidFrames() noexcept {
|
||||||
/*
|
/*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -81,6 +81,7 @@ class MultiFrame {
|
|||||||
void MakeAllFramesInvalid() noexcept;
|
void MakeAllFramesInvalid() noexcept;
|
||||||
|
|
||||||
bool HasValidFrame() const noexcept;
|
bool HasValidFrame() const noexcept;
|
||||||
|
bool HasInvalidFrame() const noexcept;
|
||||||
|
|
||||||
inline utils::MemoryResource *GetMemoryResource() { return frames_[0].GetMemoryResource(); }
|
inline utils::MemoryResource *GetMemoryResource() { return frames_[0].GetMemoryResource(); }
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -171,9 +171,8 @@ uint64_t ComputeProfilingKey(const T *obj) {
|
|||||||
class DistributedCreateNodeCursor : public Cursor {
|
class DistributedCreateNodeCursor : public Cursor {
|
||||||
public:
|
public:
|
||||||
using InputOperator = std::shared_ptr<memgraph::query::v2::plan::LogicalOperator>;
|
using InputOperator = std::shared_ptr<memgraph::query::v2::plan::LogicalOperator>;
|
||||||
DistributedCreateNodeCursor(const InputOperator &op, utils::MemoryResource *mem,
|
DistributedCreateNodeCursor(const InputOperator &op, utils::MemoryResource *mem, const NodeCreationInfo &node_info)
|
||||||
std::vector<const NodeCreationInfo *> nodes_info)
|
: input_cursor_(op->MakeCursor(mem)), node_info_(node_info) {}
|
||||||
: input_cursor_(op->MakeCursor(mem)), nodes_info_(std::move(nodes_info)) {}
|
|
||||||
|
|
||||||
bool Pull(Frame &frame, ExecutionContext &context) override {
|
bool Pull(Frame &frame, ExecutionContext &context) override {
|
||||||
SCOPED_PROFILE_OP("CreateNode");
|
SCOPED_PROFILE_OP("CreateNode");
|
||||||
@ -193,7 +192,7 @@ class DistributedCreateNodeCursor : public Cursor {
|
|||||||
void PullMultiple(MultiFrame &multi_frame, ExecutionContext &context) override {
|
void PullMultiple(MultiFrame &multi_frame, ExecutionContext &context) override {
|
||||||
SCOPED_PROFILE_OP("CreateNodeMF");
|
SCOPED_PROFILE_OP("CreateNodeMF");
|
||||||
input_cursor_->PullMultiple(multi_frame, context);
|
input_cursor_->PullMultiple(multi_frame, context);
|
||||||
auto &request_router = context.request_router;
|
auto *request_router = context.request_router;
|
||||||
{
|
{
|
||||||
SCOPED_REQUEST_WAIT_PROFILE;
|
SCOPED_REQUEST_WAIT_PROFILE;
|
||||||
request_router->CreateVertices(NodeCreationInfoToRequests(context, multi_frame));
|
request_router->CreateVertices(NodeCreationInfoToRequests(context, multi_frame));
|
||||||
@ -207,27 +206,24 @@ class DistributedCreateNodeCursor : public Cursor {
|
|||||||
|
|
||||||
void PlaceNodeOnTheFrame(Frame &frame, ExecutionContext &context) {
|
void PlaceNodeOnTheFrame(Frame &frame, ExecutionContext &context) {
|
||||||
// TODO(kostasrim) Make this work with batching
|
// TODO(kostasrim) Make this work with batching
|
||||||
const auto primary_label = msgs::Label{.id = nodes_info_[0]->labels[0]};
|
const auto primary_label = msgs::Label{.id = node_info_.labels[0]};
|
||||||
msgs::Vertex v{.id = std::make_pair(primary_label, primary_keys_[0])};
|
msgs::Vertex v{.id = std::make_pair(primary_label, primary_keys_[0])};
|
||||||
frame[nodes_info_.front()->symbol] =
|
frame[node_info_.symbol] =
|
||||||
TypedValue(query::v2::accessors::VertexAccessor(std::move(v), src_vertex_props_[0], context.request_router));
|
TypedValue(query::v2::accessors::VertexAccessor(std::move(v), src_vertex_props_[0], context.request_router));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<msgs::NewVertex> NodeCreationInfoToRequest(ExecutionContext &context, Frame &frame) {
|
std::vector<msgs::NewVertex> NodeCreationInfoToRequest(ExecutionContext &context, Frame &frame) {
|
||||||
std::vector<msgs::NewVertex> requests;
|
std::vector<msgs::NewVertex> requests;
|
||||||
// TODO(kostasrim) this assertion should be removed once we support multiple vertex creation
|
|
||||||
MG_ASSERT(nodes_info_.size() == 1);
|
|
||||||
msgs::PrimaryKey pk;
|
msgs::PrimaryKey pk;
|
||||||
for (const auto &node_info : nodes_info_) {
|
|
||||||
msgs::NewVertex rqst;
|
msgs::NewVertex rqst;
|
||||||
MG_ASSERT(!node_info->labels.empty(), "Cannot determine primary label");
|
MG_ASSERT(!node_info_.labels.empty(), "Cannot determine primary label");
|
||||||
const auto primary_label = node_info->labels[0];
|
const auto primary_label = node_info_.labels[0];
|
||||||
// TODO(jbajic) Fix properties not send,
|
// TODO(jbajic) Fix properties not send,
|
||||||
// suggestion: ignore distinction between properties and primary keys
|
// suggestion: ignore distinction between properties and primary keys
|
||||||
// since schema validation is done on storage side
|
// since schema validation is done on storage side
|
||||||
ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, nullptr,
|
ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, nullptr,
|
||||||
storage::v3::View::NEW);
|
storage::v3::View::NEW);
|
||||||
if (const auto *node_info_properties = std::get_if<PropertiesMapList>(&node_info->properties)) {
|
if (const auto *node_info_properties = std::get_if<PropertiesMapList>(&node_info_.properties)) {
|
||||||
for (const auto &[key, value_expression] : *node_info_properties) {
|
for (const auto &[key, value_expression] : *node_info_properties) {
|
||||||
TypedValue val = value_expression->Accept(evaluator);
|
TypedValue val = value_expression->Accept(evaluator);
|
||||||
if (context.request_router->IsPrimaryKey(primary_label, key)) {
|
if (context.request_router->IsPrimaryKey(primary_label, key)) {
|
||||||
@ -236,7 +232,7 @@ class DistributedCreateNodeCursor : public Cursor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto property_map = evaluator.Visit(*std::get<ParameterLookup *>(node_info->properties)).ValueMap();
|
auto property_map = evaluator.Visit(*std::get<ParameterLookup *>(node_info_.properties)).ValueMap();
|
||||||
for (const auto &[key, value] : property_map) {
|
for (const auto &[key, value] : property_map) {
|
||||||
auto key_str = std::string(key);
|
auto key_str = std::string(key);
|
||||||
auto property_id = context.request_router->NameToProperty(key_str);
|
auto property_id = context.request_router->NameToProperty(key_str);
|
||||||
@ -247,45 +243,42 @@ class DistributedCreateNodeCursor : public Cursor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node_info->labels.empty()) {
|
|
||||||
throw QueryRuntimeException("Primary label must be defined!");
|
|
||||||
}
|
|
||||||
// TODO(kostasrim) Copy non primary labels as well
|
// TODO(kostasrim) Copy non primary labels as well
|
||||||
rqst.label_ids.push_back(msgs::Label{.id = primary_label});
|
rqst.label_ids.push_back(msgs::Label{.id = primary_label});
|
||||||
src_vertex_props_.push_back(rqst.properties);
|
src_vertex_props_.push_back(rqst.properties);
|
||||||
requests.push_back(std::move(rqst));
|
requests.push_back(std::move(rqst));
|
||||||
}
|
|
||||||
primary_keys_.push_back(std::move(pk));
|
primary_keys_.push_back(std::move(pk));
|
||||||
return requests;
|
return requests;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaceNodesOnTheMultiFrame(MultiFrame &multi_frame, ExecutionContext &context) {
|
void PlaceNodesOnTheMultiFrame(MultiFrame &multi_frame, ExecutionContext &context) {
|
||||||
auto multi_frame_reader = multi_frame.GetValidFramesConsumer();
|
auto multi_frame_modifier = multi_frame.GetValidFramesModifier();
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
MG_ASSERT(std::distance(multi_frame_reader.begin(), multi_frame_reader.end()));
|
MG_ASSERT(std::distance(multi_frame_modifier.begin(), multi_frame_modifier.end()));
|
||||||
for (auto &frame : multi_frame_reader) {
|
for (auto &frame : multi_frame_modifier) {
|
||||||
const auto primary_label = msgs::Label{.id = nodes_info_[0]->labels[0]};
|
const auto primary_label = msgs::Label{.id = node_info_.labels[0]};
|
||||||
msgs::Vertex v{.id = std::make_pair(primary_label, primary_keys_[i])};
|
msgs::Vertex v{.id = std::make_pair(primary_label, primary_keys_[i])};
|
||||||
frame[nodes_info_.front()->symbol] = TypedValue(
|
frame[node_info_.symbol] = TypedValue(
|
||||||
query::v2::accessors::VertexAccessor(std::move(v), src_vertex_props_[i++], context.request_router));
|
query::v2::accessors::VertexAccessor(std::move(v), src_vertex_props_[i++], context.request_router));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<msgs::NewVertex> NodeCreationInfoToRequests(ExecutionContext &context, MultiFrame &multi_frame) {
|
std::vector<msgs::NewVertex> NodeCreationInfoToRequests(ExecutionContext &context, MultiFrame &multi_frame) {
|
||||||
std::vector<msgs::NewVertex> requests;
|
std::vector<msgs::NewVertex> requests;
|
||||||
auto multi_frame_reader = multi_frame.GetValidFramesConsumer();
|
auto multi_frame_modifier = multi_frame.GetValidFramesModifier();
|
||||||
for (auto &frame : multi_frame_reader) {
|
for (auto &frame : multi_frame_modifier) {
|
||||||
msgs::PrimaryKey pk;
|
msgs::PrimaryKey pk;
|
||||||
for (const auto &node_info : nodes_info_) {
|
|
||||||
msgs::NewVertex rqst;
|
msgs::NewVertex rqst;
|
||||||
MG_ASSERT(!node_info->labels.empty(), "Cannot determine primary label");
|
MG_ASSERT(!node_info_.labels.empty(), "Cannot determine primary label");
|
||||||
const auto primary_label = node_info->labels[0];
|
const auto primary_label = node_info_.labels[0];
|
||||||
|
MG_ASSERT(context.request_router->IsPrimaryLabel(primary_label), "First label has to be a primary label!");
|
||||||
// TODO(jbajic) Fix properties not send,
|
// TODO(jbajic) Fix properties not send,
|
||||||
// suggestion: ignore distinction between properties and primary keys
|
// suggestion: ignore distinction between properties and primary keys
|
||||||
// since schema validation is done on storage side
|
// since schema validation is done on storage side
|
||||||
ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, nullptr,
|
ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, nullptr,
|
||||||
storage::v3::View::NEW);
|
storage::v3::View::NEW);
|
||||||
if (const auto *node_info_properties = std::get_if<PropertiesMapList>(&node_info->properties)) {
|
if (const auto *node_info_properties = std::get_if<PropertiesMapList>(&node_info_.properties)) {
|
||||||
for (const auto &[key, value_expression] : *node_info_properties) {
|
for (const auto &[key, value_expression] : *node_info_properties) {
|
||||||
TypedValue val = value_expression->Accept(evaluator);
|
TypedValue val = value_expression->Accept(evaluator);
|
||||||
if (context.request_router->IsPrimaryKey(primary_label, key)) {
|
if (context.request_router->IsPrimaryKey(primary_label, key)) {
|
||||||
@ -294,7 +287,7 @@ class DistributedCreateNodeCursor : public Cursor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto property_map = evaluator.Visit(*std::get<ParameterLookup *>(node_info->properties)).ValueMap();
|
auto property_map = evaluator.Visit(*std::get<ParameterLookup *>(node_info_.properties)).ValueMap();
|
||||||
for (const auto &[key, value] : property_map) {
|
for (const auto &[key, value] : property_map) {
|
||||||
auto key_str = std::string(key);
|
auto key_str = std::string(key);
|
||||||
auto property_id = context.request_router->NameToProperty(key_str);
|
auto property_id = context.request_router->NameToProperty(key_str);
|
||||||
@ -305,22 +298,19 @@ class DistributedCreateNodeCursor : public Cursor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node_info->labels.empty()) {
|
|
||||||
throw QueryRuntimeException("Primary label must be defined!");
|
|
||||||
}
|
|
||||||
// TODO(kostasrim) Copy non primary labels as well
|
// TODO(kostasrim) Copy non primary labels as well
|
||||||
rqst.label_ids.push_back(msgs::Label{.id = primary_label});
|
rqst.label_ids.push_back(msgs::Label{.id = primary_label});
|
||||||
src_vertex_props_.push_back(rqst.properties);
|
src_vertex_props_.push_back(rqst.properties);
|
||||||
requests.push_back(std::move(rqst));
|
requests.push_back(std::move(rqst));
|
||||||
}
|
|
||||||
primary_keys_.push_back(std::move(pk));
|
primary_keys_.push_back(std::move(pk));
|
||||||
}
|
}
|
||||||
|
|
||||||
return requests;
|
return requests;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const UniqueCursorPtr input_cursor_;
|
const UniqueCursorPtr input_cursor_;
|
||||||
std::vector<const NodeCreationInfo *> nodes_info_;
|
NodeCreationInfo node_info_;
|
||||||
std::vector<std::vector<std::pair<storage::v3::PropertyId, msgs::Value>>> src_vertex_props_;
|
std::vector<std::vector<std::pair<storage::v3::PropertyId, msgs::Value>>> src_vertex_props_;
|
||||||
std::vector<msgs::PrimaryKey> primary_keys_;
|
std::vector<msgs::PrimaryKey> primary_keys_;
|
||||||
};
|
};
|
||||||
@ -365,7 +355,7 @@ ACCEPT_WITH_INPUT(CreateNode)
|
|||||||
UniqueCursorPtr CreateNode::MakeCursor(utils::MemoryResource *mem) const {
|
UniqueCursorPtr CreateNode::MakeCursor(utils::MemoryResource *mem) const {
|
||||||
EventCounter::IncrementCounter(EventCounter::CreateNodeOperator);
|
EventCounter::IncrementCounter(EventCounter::CreateNodeOperator);
|
||||||
|
|
||||||
return MakeUniqueCursorPtr<DistributedCreateNodeCursor>(mem, input_, mem, std::vector{&this->node_info_});
|
return MakeUniqueCursorPtr<DistributedCreateNodeCursor>(mem, input_, mem, this->node_info_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Symbol> CreateNode::ModifiedSymbols(const SymbolTable &table) const {
|
std::vector<Symbol> CreateNode::ModifiedSymbols(const SymbolTable &table) const {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -36,6 +36,7 @@ struct Value;
|
|||||||
struct Label {
|
struct Label {
|
||||||
LabelId id;
|
LabelId id;
|
||||||
friend bool operator==(const Label &lhs, const Label &rhs) { return lhs.id == rhs.id; }
|
friend bool operator==(const Label &lhs, const Label &rhs) { return lhs.id == rhs.id; }
|
||||||
|
friend bool operator==(const Label &lhs, const LabelId &rhs) { return lhs.id == rhs; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(kostasrim) update this with CompoundKey, same for the rest of the file.
|
// TODO(kostasrim) update this with CompoundKey, same for the rest of the file.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -88,14 +88,14 @@ TEST_P(SingleNodeBfsTest, All) {
|
|||||||
|
|
||||||
std::unique_ptr<SingleNodeDb> SingleNodeBfsTest::db_{nullptr};
|
std::unique_ptr<SingleNodeDb> SingleNodeBfsTest::db_{nullptr};
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(DirectionAndExpansionDepth, SingleNodeBfsTest,
|
INSTANTIATE_TEST_SUITE_P(DirectionAndExpansionDepth, SingleNodeBfsTest,
|
||||||
testing::Combine(testing::Range(-1, kVertexCount), testing::Range(-1, kVertexCount),
|
testing::Combine(testing::Range(-1, kVertexCount), testing::Range(-1, kVertexCount),
|
||||||
testing::Values(EdgeAtom::Direction::OUT, EdgeAtom::Direction::IN,
|
testing::Values(EdgeAtom::Direction::OUT, EdgeAtom::Direction::IN,
|
||||||
EdgeAtom::Direction::BOTH),
|
EdgeAtom::Direction::BOTH),
|
||||||
testing::Values(std::vector<std::string>{}), testing::Bool(),
|
testing::Values(std::vector<std::string>{}), testing::Bool(),
|
||||||
testing::Values(FilterLambdaType::NONE)));
|
testing::Values(FilterLambdaType::NONE)));
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
EdgeType, SingleNodeBfsTest,
|
EdgeType, SingleNodeBfsTest,
|
||||||
testing::Combine(testing::Values(-1), testing::Values(-1),
|
testing::Combine(testing::Values(-1), testing::Values(-1),
|
||||||
testing::Values(EdgeAtom::Direction::OUT, EdgeAtom::Direction::IN, EdgeAtom::Direction::BOTH),
|
testing::Values(EdgeAtom::Direction::OUT, EdgeAtom::Direction::IN, EdgeAtom::Direction::BOTH),
|
||||||
@ -103,7 +103,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
std::vector<std::string>{"b"}, std::vector<std::string>{"a", "b"}),
|
std::vector<std::string>{"b"}, std::vector<std::string>{"a", "b"}),
|
||||||
testing::Bool(), testing::Values(FilterLambdaType::NONE)));
|
testing::Bool(), testing::Values(FilterLambdaType::NONE)));
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(FilterLambda, SingleNodeBfsTest,
|
INSTANTIATE_TEST_SUITE_P(FilterLambda, SingleNodeBfsTest,
|
||||||
testing::Combine(testing::Values(-1), testing::Values(-1),
|
testing::Combine(testing::Values(-1), testing::Values(-1),
|
||||||
testing::Values(EdgeAtom::Direction::OUT, EdgeAtom::Direction::IN,
|
testing::Values(EdgeAtom::Direction::OUT, EdgeAtom::Direction::IN,
|
||||||
EdgeAtom::Direction::BOTH),
|
EdgeAtom::Direction::BOTH),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -294,7 +294,7 @@ std::shared_ptr<Base> gAstGeneratorTypes[] = {
|
|||||||
std::make_shared<CachedAstGenerator>(),
|
std::make_shared<CachedAstGenerator>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(AstGeneratorTypes, CypherMainVisitorTest, ::testing::ValuesIn(gAstGeneratorTypes));
|
INSTANTIATE_TEST_SUITE_P(AstGeneratorTypes, CypherMainVisitorTest, ::testing::ValuesIn(gAstGeneratorTypes));
|
||||||
|
|
||||||
// NOTE: The above used to use *Typed Tests* functionality of gtest library.
|
// NOTE: The above used to use *Typed Tests* functionality of gtest library.
|
||||||
// Unfortunately, the compilation time of this test increased to full 2 minutes!
|
// Unfortunately, the compilation time of this test increased to full 2 minutes!
|
||||||
@ -308,7 +308,7 @@ INSTANTIATE_TEST_CASE_P(AstGeneratorTypes, CypherMainVisitorTest, ::testing::Val
|
|||||||
// ClonedAstGenerator, CachedAstGenerator>
|
// ClonedAstGenerator, CachedAstGenerator>
|
||||||
// AstGeneratorTypes;
|
// AstGeneratorTypes;
|
||||||
//
|
//
|
||||||
// TYPED_TEST_CASE(CypherMainVisitorTest, AstGeneratorTypes);
|
// TYPED_TEST_SUITE(CypherMainVisitorTest, AstGeneratorTypes);
|
||||||
|
|
||||||
TEST_P(CypherMainVisitorTest, SyntaxException) {
|
TEST_P(CypherMainVisitorTest, SyntaxException) {
|
||||||
auto &ast_generator = *GetParam();
|
auto &ast_generator = *GetParam();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -67,7 +67,7 @@ TEST_P(ExpressiontoStringTest, Example) {
|
|||||||
EXPECT_EQ(rewritten_expression, rewritten_expression2);
|
EXPECT_EQ(rewritten_expression, rewritten_expression2);
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
PARAMETER, ExpressiontoStringTest,
|
PARAMETER, ExpressiontoStringTest,
|
||||||
::testing::Values(
|
::testing::Values(
|
||||||
std::make_pair(std::string("2 / 1"), std::string("(2 / 1)")),
|
std::make_pair(std::string("2 / 1"), std::string("(2 / 1)")),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -90,7 +90,7 @@ void DeleteListContent(std::list<BaseOpChecker *> *list) {
|
|||||||
delete ptr;
|
delete ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TYPED_TEST_CASE(TestPlanner, PlannerTypes);
|
TYPED_TEST_SUITE(TestPlanner, PlannerTypes);
|
||||||
|
|
||||||
TYPED_TEST(TestPlanner, MatchNodeReturn) {
|
TYPED_TEST(TestPlanner, MatchNodeReturn) {
|
||||||
// Test MATCH (n) RETURN n
|
// Test MATCH (n) RETURN n
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -63,7 +63,6 @@ TEST(CreateExpandTest, Cursor) {
|
|||||||
node.symbol = symbol_table.CreateSymbol("u", true);
|
node.symbol = symbol_table.CreateSymbol("u", true);
|
||||||
|
|
||||||
auto once_op = std::make_shared<plan::Once>();
|
auto once_op = std::make_shared<plan::Once>();
|
||||||
auto once_cur = once_op->MakeCursor(utils::NewDeleteResource());
|
|
||||||
|
|
||||||
auto create_expand = plan::CreateExpand(node, edge, once_op, src, true);
|
auto create_expand = plan::CreateExpand(node, edge, once_op, src, true);
|
||||||
auto cursor = create_expand.MakeCursor(utils::NewDeleteResource());
|
auto cursor = create_expand.MakeCursor(utils::NewDeleteResource());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// 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
|
// by the Apache License, Version 2.0, included in the file
|
||||||
// licenses/APL.txt.
|
// licenses/APL.txt.
|
||||||
|
|
||||||
|
#include "gmock/gmock.h"
|
||||||
#include "mock_helpers.hpp"
|
#include "mock_helpers.hpp"
|
||||||
|
|
||||||
#include "query/v2/bindings/frame.hpp"
|
#include "query/v2/bindings/frame.hpp"
|
||||||
@ -26,50 +27,56 @@ namespace memgraph::query::v2 {
|
|||||||
MultiFrame CreateMultiFrame(const size_t max_pos) {
|
MultiFrame CreateMultiFrame(const size_t max_pos) {
|
||||||
static constexpr size_t frame_size = 100;
|
static constexpr size_t frame_size = 100;
|
||||||
MultiFrame multi_frame(max_pos, frame_size, utils::NewDeleteResource());
|
MultiFrame multi_frame(max_pos, frame_size, utils::NewDeleteResource());
|
||||||
auto frames_populator = multi_frame.GetInvalidFramesPopulator();
|
|
||||||
for (auto &frame : frames_populator) {
|
|
||||||
frame.MakeValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
return multi_frame;
|
return multi_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CreateNodeTest, CreateNodeCursor) {
|
TEST(CreateNodeTest, CreateNodeCursor) {
|
||||||
using testing::_;
|
using testing::_;
|
||||||
|
using testing::IsEmpty;
|
||||||
using testing::Return;
|
using testing::Return;
|
||||||
|
|
||||||
AstStorage ast;
|
AstStorage ast;
|
||||||
SymbolTable symbol_table;
|
SymbolTable symbol_table;
|
||||||
|
|
||||||
plan::NodeCreationInfo node;
|
plan::NodeCreationInfo node;
|
||||||
plan::EdgeCreationInfo edge;
|
|
||||||
edge.edge_type = msgs::EdgeTypeId::FromUint(1);
|
|
||||||
edge.direction = EdgeAtom::Direction::IN;
|
|
||||||
auto id_alloc = IdAllocator(0, 100);
|
auto id_alloc = IdAllocator(0, 100);
|
||||||
|
|
||||||
node.symbol = symbol_table.CreateSymbol("n", true);
|
node.symbol = symbol_table.CreateSymbol("n", true);
|
||||||
node.labels.push_back(msgs::LabelId::FromUint(2));
|
const auto primary_label_id = msgs::LabelId::FromUint(2);
|
||||||
|
node.labels.push_back(primary_label_id);
|
||||||
auto literal = PrimitiveLiteral();
|
auto literal = PrimitiveLiteral();
|
||||||
literal.value_ = TypedValue(static_cast<int64_t>(200));
|
literal.value_ = TypedValue(static_cast<int64_t>(200));
|
||||||
auto p = plan::PropertiesMapList{};
|
auto p = plan::PropertiesMapList{};
|
||||||
p.push_back(std::make_pair(msgs::PropertyId::FromUint(2), &literal));
|
p.push_back(std::make_pair(msgs::PropertyId::FromUint(3), &literal));
|
||||||
node.properties.emplace<0>(std::move(p));
|
node.properties.emplace<0>(std::move(p));
|
||||||
|
|
||||||
auto once_cur = plan::MakeUniqueCursorPtr<MockedCursor>(utils::NewDeleteResource());
|
auto once_op = std::make_shared<plan::Once>();
|
||||||
EXPECT_CALL(BaseToMock(once_cur.get()), PullMultiple(_, _)).Times(1);
|
|
||||||
|
|
||||||
std::shared_ptr<plan::LogicalOperator> once_op = std::make_shared<MockedLogicalOperator>();
|
|
||||||
EXPECT_CALL(BaseToMock(once_op.get()), MakeCursor(_)).Times(1).WillOnce(Return(std::move(once_cur)));
|
|
||||||
|
|
||||||
auto create_expand = plan::CreateNode(once_op, node);
|
auto create_expand = plan::CreateNode(once_op, node);
|
||||||
auto cursor = create_expand.MakeCursor(utils::NewDeleteResource());
|
auto cursor = create_expand.MakeCursor(utils::NewDeleteResource());
|
||||||
MockedRequestRouter router;
|
MockedRequestRouter router;
|
||||||
EXPECT_CALL(router, CreateVertices(testing::_))
|
EXPECT_CALL(router, CreateVertices(_)).Times(1).WillOnce(Return(std::vector<msgs::CreateVerticesResponse>{}));
|
||||||
.Times(1)
|
EXPECT_CALL(router, IsPrimaryLabel(_)).WillRepeatedly(Return(true));
|
||||||
.WillOnce(::testing::Return(std::vector<msgs::CreateVerticesResponse>{}));
|
EXPECT_CALL(router, IsPrimaryKey(_, _)).WillRepeatedly(Return(true));
|
||||||
EXPECT_CALL(router, IsPrimaryKey(testing::_, testing::_)).WillRepeatedly(::testing::Return(true));
|
|
||||||
auto context = MakeContext(ast, symbol_table, &router, &id_alloc);
|
auto context = MakeContext(ast, symbol_table, &router, &id_alloc);
|
||||||
auto multi_frame = CreateMultiFrame(context.symbol_table.max_position());
|
auto multi_frame = CreateMultiFrame(context.symbol_table.max_position());
|
||||||
cursor->PullMultiple(multi_frame, context);
|
cursor->PullMultiple(multi_frame, context);
|
||||||
|
|
||||||
|
auto frames = multi_frame.GetValidFramesReader();
|
||||||
|
auto number_of_valid_frames = 0;
|
||||||
|
for (auto &frame : frames) {
|
||||||
|
++number_of_valid_frames;
|
||||||
|
EXPECT_EQ(frame[node.symbol].IsVertex(), true);
|
||||||
|
const auto &n = frame[node.symbol].ValueVertex();
|
||||||
|
EXPECT_THAT(n.Labels(), IsEmpty());
|
||||||
|
EXPECT_EQ(n.PrimaryLabel(), primary_label_id);
|
||||||
|
// TODO(antaljanosbenjamin): Check primary key
|
||||||
|
}
|
||||||
|
EXPECT_EQ(number_of_valid_frames, 1);
|
||||||
|
|
||||||
|
auto invalid_frames = multi_frame.GetInvalidFramesPopulator();
|
||||||
|
auto number_of_invalid_frames = std::distance(invalid_frames.begin(), invalid_frames.end());
|
||||||
|
EXPECT_EQ(number_of_invalid_frames, 99);
|
||||||
}
|
}
|
||||||
} // namespace memgraph::query::v2
|
} // namespace memgraph::query::v2
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -299,7 +299,7 @@ std::shared_ptr<Base> gAstGeneratorTypes[] = {
|
|||||||
std::make_shared<CachedAstGenerator>(),
|
std::make_shared<CachedAstGenerator>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(AstGeneratorTypes, CypherMainVisitorTest, ::testing::ValuesIn(gAstGeneratorTypes));
|
INSTANTIATE_TEST_SUITE_P(AstGeneratorTypes, CypherMainVisitorTest, ::testing::ValuesIn(gAstGeneratorTypes));
|
||||||
|
|
||||||
// NOTE: The above used to use *Typed Tests* functionality of gtest library.
|
// NOTE: The above used to use *Typed Tests* functionality of gtest library.
|
||||||
// Unfortunately, the compilation time of this test increased to full 2 minutes!
|
// Unfortunately, the compilation time of this test increased to full 2 minutes!
|
||||||
@ -313,7 +313,7 @@ INSTANTIATE_TEST_CASE_P(AstGeneratorTypes, CypherMainVisitorTest, ::testing::Val
|
|||||||
// ClonedAstGenerator, CachedAstGenerator>
|
// ClonedAstGenerator, CachedAstGenerator>
|
||||||
// AstGeneratorTypes;
|
// AstGeneratorTypes;
|
||||||
//
|
//
|
||||||
// TYPED_TEST_CASE(CypherMainVisitorTest, AstGeneratorTypes);
|
// TYPED_TEST_SUITE(CypherMainVisitorTest, AstGeneratorTypes);
|
||||||
|
|
||||||
TEST_P(CypherMainVisitorTest, SyntaxException) {
|
TEST_P(CypherMainVisitorTest, SyntaxException) {
|
||||||
auto &ast_generator = *GetParam();
|
auto &ast_generator = *GetParam();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -82,8 +82,8 @@ class StorageV3 : public ::testing::TestWithParam<bool> {
|
|||||||
Config{.gc = {.reclamation_interval = reclamation_interval}}};
|
Config{.gc = {.reclamation_interval = reclamation_interval}}};
|
||||||
coordinator::Hlc last_hlc{0, io::Time{}};
|
coordinator::Hlc last_hlc{0, io::Time{}};
|
||||||
};
|
};
|
||||||
INSTANTIATE_TEST_CASE_P(WithGc, StorageV3, ::testing::Values(true));
|
INSTANTIATE_TEST_SUITE_P(WithGc, StorageV3, ::testing::Values(true));
|
||||||
INSTANTIATE_TEST_CASE_P(WithoutGc, StorageV3, ::testing::Values(false));
|
INSTANTIATE_TEST_SUITE_P(WithoutGc, StorageV3, ::testing::Values(false));
|
||||||
|
|
||||||
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
||||||
TEST_P(StorageV3, Commit) {
|
TEST_P(StorageV3, Commit) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -60,8 +60,8 @@ class StorageEdgeTest : public ::testing::TestWithParam<bool> {
|
|||||||
coordinator::Hlc last_hlc{0, io::Time{}};
|
coordinator::Hlc last_hlc{0, io::Time{}};
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(EdgesWithProperties, StorageEdgeTest, ::testing::Values(true));
|
INSTANTIATE_TEST_SUITE_P(EdgesWithProperties, StorageEdgeTest, ::testing::Values(true));
|
||||||
INSTANTIATE_TEST_CASE_P(EdgesWithoutProperties, StorageEdgeTest, ::testing::Values(false));
|
INSTANTIATE_TEST_SUITE_P(EdgesWithoutProperties, StorageEdgeTest, ::testing::Values(false));
|
||||||
|
|
||||||
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
||||||
TEST_P(StorageEdgeTest, EdgeCreateFromSmallerCommit) {
|
TEST_P(StorageEdgeTest, EdgeCreateFromSmallerCommit) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -135,6 +135,6 @@ TEST_P(StorageIsolationLevelTest, Visibility) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(ParameterizedStorageIsolationLevelTests, StorageIsolationLevelTest,
|
INSTANTIATE_TEST_SUITE_P(ParameterizedStorageIsolationLevelTests, StorageIsolationLevelTest,
|
||||||
::testing::ValuesIn(isolation_levels), StorageIsolationLevelTest::PrintToStringParamName());
|
::testing::ValuesIn(isolation_levels), StorageIsolationLevelTest::PrintToStringParamName());
|
||||||
} // namespace memgraph::storage::v3::tests
|
} // namespace memgraph::storage::v3::tests
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -330,4 +330,4 @@ TEST_P(CsvReaderTest, EmptyColumns) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(NewlineParameterizedTest, CsvReaderTest, ::testing::Values("\n", "\r\n"));
|
INSTANTIATE_TEST_SUITE_P(NewlineParameterizedTest, CsvReaderTest, ::testing::Values("\n", "\r\n"));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -190,7 +190,7 @@ TEST_P(FileLockerParameterizedTest, RemovePath) {
|
|||||||
std::filesystem::current_path(save_path);
|
std::filesystem::current_path(save_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(FileLockerPathVariantTests, FileLockerParameterizedTest,
|
INSTANTIATE_TEST_SUITE_P(FileLockerPathVariantTests, FileLockerParameterizedTest,
|
||||||
::testing::Values(std::make_tuple(false, false), std::make_tuple(false, true),
|
::testing::Values(std::make_tuple(false, false), std::make_tuple(false, true),
|
||||||
std::make_tuple(true, false), std::make_tuple(true, true)));
|
std::make_tuple(true, false), std::make_tuple(true, true)));
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 Memgraph Ltd.
|
// Copyright 2023 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// 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
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -393,7 +393,7 @@ class AllocatorTest : public ::testing::Test {};
|
|||||||
|
|
||||||
using ContainersWithAllocators = ::testing::Types<ContainerWithAllocatorLast, ContainerWithAllocatorFirst>;
|
using ContainersWithAllocators = ::testing::Types<ContainerWithAllocatorLast, ContainerWithAllocatorFirst>;
|
||||||
|
|
||||||
TYPED_TEST_CASE(AllocatorTest, ContainersWithAllocators);
|
TYPED_TEST_SUITE(AllocatorTest, ContainersWithAllocators);
|
||||||
|
|
||||||
TYPED_TEST(AllocatorTest, PropagatesToStdUsesAllocator) {
|
TYPED_TEST(AllocatorTest, PropagatesToStdUsesAllocator) {
|
||||||
std::vector<TypeParam, memgraph::utils::Allocator<TypeParam>> vec(memgraph::utils::NewDeleteResource());
|
std::vector<TypeParam, memgraph::utils::Allocator<TypeParam>> vec(memgraph::utils::NewDeleteResource());
|
||||||
|
Loading…
Reference in New Issue
Block a user