forked from memgraph/memgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Experiment alternative storage #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
aa3e137
Add custom once cursor
gitbuda 96c6d65
Add produce and dummy custom_storage
gitbuda 664b8d0
Move custom_storage to memgraph.cpp
gitbuda b8be5e0
Add graphar, not working yet
gitbuda e16b202
Fix the basic code in the manual test
gitbuda 75cac2d
Add meaningful code for storing vertices
gitbuda 8256a20
Add edge storage example
gitbuda ed6fe4b
Add storage high-level ideas, part 1
gitbuda 308bb0d
Add prep for CreateNodeCursor implementation
gitbuda 157c012
Add custom vertex
gitbuda 5f0bbc0
Upgrade graphar and merge latest memgraph upstream
gitbuda 44d5f23
Merge branch 'master' into alternative-storage
gitbuda cdd841f
Sort the graphar schema a bit
gitbuda 5ea313a
Put config under custom storage
gitbuda b2a3fee
Merge branch 'master' into alternative-storage
gitbuda 9c87180
Merge master and update clang tidy
gitbuda f79e131
Wire GARDatabase and custom storage part 1
gitbuda 6553de1
Merge master
gitbuda 5a0da20
Merge master
gitbuda ebce4fa
Switch to the incubator URL
gitbuda 5bff383
Add more comments
gitbuda baef016
Merge master
gitbuda eb905f4
Patch GraphAR because it doesn't compile under the latest toolchain
gitbuda f9c9a1f
Merge branch 'master' into alternative-storage
gitbuda cf8a691
Merge branch 'master' into alternative-storage
gitbuda 1ac84d1
Merge master and a few new comments
gitbuda 4780d1a
Upgrade to GraphAr v0.12
gitbuda 30d027f
Merge master
gitbuda 10bf29d
Add example GAR graph metadata and reading
gitbuda ab7e434
Play with the PMR (WIP)
gitbuda 3e8fb3d
Add a bit more complex PMR example
gitbuda 574c70f
Change Vertex and Edge types
gitbuda aac9b79
Add print_alloc memory resource + create_container func
gitbuda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
set(mg_custom_cursors_sources | ||
create_node.cpp | ||
once.cpp | ||
scanall.cpp | ||
produce.cpp | ||
) | ||
add_library(mg_custom_cursors STATIC ${mg_custom_cursors_sources}) | ||
# TODO(gitbuda): Having mg-storage-v2 here is broken. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
target_link_libraries(mg_custom_cursors mg-utils mg-storage-v2 mg_custom_storage mg-query) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2024 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 | ||
// License, and you may not use this file except in compliance with the Business Source License. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
#pragma once | ||
|
||
#include "query/custom_cursors/create_node.hpp" | ||
#include "query/custom_cursors/once.hpp" | ||
#include "query/custom_cursors/produce.hpp" | ||
#include "query/custom_cursors/scanall.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2024 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 | ||
// License, and you may not use this file except in compliance with the Business Source License. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
#pragma once | ||
|
||
// TODO(gitbuda): To make BFS fast -> global cache required. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2024 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 | ||
// License, and you may not use this file except in compliance with the Business Source License. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
#pragma once | ||
|
||
// TODO(gitbuda): To make this Cypher CREATE edge fast -> add global cache. | ||
// TODO(gitbuda): To make create edge fast -> introduce a new semantic. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2024 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 | ||
// License, and you may not use this file except in compliance with the Business Source License. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
#include "query/custom_cursors/create_node.hpp" | ||
#include "query/context.hpp" | ||
#include "query/custom_cursors/utils.hpp" | ||
#include "query/interpret/eval.hpp" | ||
#include "query/interpret/frame.hpp" | ||
#include "query/plan/operator.hpp" | ||
#include "query/plan/scoped_profile.hpp" | ||
#include "storage/custom_storage/types.hpp" | ||
#include "utils/logging.hpp" | ||
|
||
namespace memgraph::query::custom_cursors { | ||
|
||
struct QueryVertex {}; | ||
|
||
// Creates a vertex on this GraphDb. Returns a reference to vertex placed on the | ||
// frame. | ||
QueryVertex CreateVertex(const plan::NodeCreationInfo &node_info, Frame *frame, ExecutionContext &context) { | ||
auto &dba = *context.db_accessor; | ||
if (node_info.labels.size() != 1) { | ||
throw QueryRuntimeException( | ||
"0 or multiple labels not yet supported under CreateNode. You have to provide exactly 1 lable for any given " | ||
"vertex/node."); | ||
} | ||
// NOTE: Evaluator should use the latest accessors, as modified in this query, when | ||
// setting properties on new nodes. | ||
// NOTE: Evaluator is using query::DBAccessor of default storage mode (IN_MEM_TX), for props mapping & storage mode. | ||
ExpressionEvaluator evaluator(frame, context.symbol_table, context.evaluation_context, context.db_accessor, | ||
storage::View::NEW); | ||
// TODO: PropsSetChecked allocates a PropertyValue, make it use context.memory | ||
// when we update PropertyValue with custom allocator. | ||
std::map<storage::PropertyId, storage::PropertyValue> properties; | ||
if (const auto *node_info_properties = std::get_if<plan::PropertiesMapList>(&node_info.properties)) { | ||
for (const auto &[key, value_expression] : *node_info_properties) { | ||
properties.emplace(key, value_expression->Accept(evaluator)); | ||
} | ||
} else { | ||
auto property_map = evaluator.Visit(*std::get<ParameterLookup *>(node_info.properties)); | ||
for (const auto &[key, value] : property_map.ValueMap()) { | ||
properties.emplace(dba.NameToProperty(key), value); | ||
} | ||
} | ||
// TODO(gitbuda): Put vertex on the frame. (*frame)[node_info.symbol] = new_node; | ||
// (*frame)[node_info.symbol] = new_node; | ||
// return (*frame)[node_info.symbol].ValueVertex(); | ||
|
||
// TODO(gitbuda): node_info.labels change type -> add the transformation. | ||
// auto new_node = memgraph::storage::custom_storage::Vertex{.labels = node_info.labels, .properties = properties}; | ||
auto new_node = memgraph::storage::custom_storage::Vertex{.labels = {}, .properties = properties}; | ||
auto *vertex_ptr = context.custom_storage->AddVertex(std::move(new_node)); | ||
SPDLOG_WARN("{}", context.custom_storage->VerticesNo()); | ||
return QueryVertex{}; | ||
} | ||
|
||
CreateNodeCursor::CreateNodeCursor(const plan::CreateNode &logical_operator, plan::UniqueCursorPtr input_cursor) | ||
: logical_operator_(logical_operator), input_cursor_(std::move(input_cursor)) {} | ||
|
||
bool CreateNodeCursor::Pull(Frame &frame, ExecutionContext &context) { | ||
utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; | ||
memgraph::query::plan::ScopedProfile profile{ComputeProfilingKey(this), "CreateNode", &context}; | ||
SPDLOG_WARN("CreateNodeCursor::Pull"); | ||
if (input_cursor_->Pull(frame, context)) { | ||
CreateVertex(logical_operator_.node_info_, &frame, context); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void CreateNodeCursor::Shutdown() { input_cursor_->Shutdown(); } | ||
|
||
void CreateNodeCursor::Reset() { input_cursor_->Reset(); } | ||
|
||
} // namespace memgraph::query::custom_cursors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2024 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 | ||
// License, and you may not use this file except in compliance with the Business Source License. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
#pragma once | ||
|
||
#include "query/plan/cursor.hpp" | ||
|
||
// TASKS: | ||
// 1. check label creation access rule | ||
// 2. create vertex | ||
// 3. inform the trigger | ||
|
||
namespace memgraph::query::plan { | ||
class CreateNode; | ||
} // namespace memgraph::query::plan | ||
|
||
namespace memgraph::query::custom_cursors { | ||
|
||
class CreateNodeCursor : public memgraph::query::plan::Cursor { | ||
public: | ||
explicit CreateNodeCursor(const plan::CreateNode &logical_operator, plan::UniqueCursorPtr input_cursor); | ||
bool Pull(Frame &frame, ExecutionContext &context) override; | ||
void Shutdown() override; | ||
void Reset() override; | ||
|
||
private: | ||
const plan::CreateNode &logical_operator_; | ||
const plan::UniqueCursorPtr input_cursor_; | ||
}; | ||
|
||
} // namespace memgraph::query::custom_cursors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2024 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 | ||
// License, and you may not use this file except in compliance with the Business Source License. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
#include "query/custom_cursors/once.hpp" | ||
#include "query/context.hpp" | ||
#include "query/custom_cursors/utils.hpp" | ||
#include "query/interpret/frame.hpp" | ||
#include "query/plan/scoped_profile.hpp" | ||
#include "utils/logging.hpp" | ||
|
||
namespace memgraph::query::custom_cursors { | ||
|
||
bool OnceCursor::Pull(Frame & /*unused*/, ExecutionContext &context) { | ||
utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; | ||
memgraph::query::plan::ScopedProfile profile{ComputeProfilingKey(this), "Once", &context}; | ||
SPDLOG_WARN("OnceCursor::Pull"); | ||
if (!did_pull_) { | ||
did_pull_ = true; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void OnceCursor::Shutdown() {} | ||
|
||
void OnceCursor::Reset() { did_pull_ = false; } | ||
|
||
} // namespace memgraph::query::custom_cursors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2024 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 | ||
// License, and you may not use this file except in compliance with the Business Source License. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
#pragma once | ||
|
||
#include "query/plan/cursor.hpp" | ||
|
||
namespace memgraph::query::custom_cursors { | ||
|
||
class OnceCursor : public memgraph::query::plan::Cursor { | ||
public: | ||
OnceCursor() = default; | ||
bool Pull(Frame & /*unused*/, ExecutionContext &context) override; | ||
void Shutdown() override; | ||
void Reset() override; | ||
|
||
private: | ||
bool did_pull_{false}; | ||
}; | ||
|
||
} // namespace memgraph::query::custom_cursors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2024 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 | ||
// License, and you may not use this file except in compliance with the Business Source License. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
#include "query/custom_cursors/produce.hpp" | ||
#include "query/context.hpp" | ||
#include "query/custom_cursors/utils.hpp" | ||
#include "query/interpret/frame.hpp" | ||
#include "spdlog/spdlog.h" | ||
#include "utils/logging.hpp" | ||
|
||
namespace memgraph::query::custom_cursors { | ||
|
||
ProduceCursor::ProduceCursor(plan::UniqueCursorPtr input_cursor) : input_cursor_(std::move(input_cursor)) {} | ||
|
||
bool ProduceCursor::Pull(Frame &frame, ExecutionContext &context) { | ||
utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; | ||
memgraph::query::plan::ScopedProfile profile{ComputeProfilingKey(this), "Produce", &context}; | ||
SPDLOG_WARN("Produce"); | ||
return input_cursor_->Pull(frame, context); | ||
} | ||
|
||
void ProduceCursor::Shutdown() { input_cursor_->Shutdown(); } | ||
|
||
void ProduceCursor::Reset() { input_cursor_->Reset(); } | ||
|
||
} // namespace memgraph::query::custom_cursors |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to apache incubator link