Address review comments

This commit is contained in:
jbajic 2022-03-09 15:53:33 +01:00 committed by János Benjamin Antal
parent 4f593c7fca
commit 60ad05acff
60 changed files with 525 additions and 703 deletions

View File

@ -42,4 +42,4 @@ for file in $modified_files; do
done; done;
return $((CODE || FAIL)) return ${FAIL}

View File

@ -18,8 +18,7 @@
#include "utils/logging.hpp" #include "utils/logging.hpp"
#include "utils/string.hpp" #include "utils/string.hpp"
namespace memgraph { namespace memgraph::audit {
namespace audit {
// Helper function that converts a `storage::PropertyValue` to `nlohmann::json`. // Helper function that converts a `storage::PropertyValue` to `nlohmann::json`.
inline nlohmann::json PropertyValueToJson(const storage::PropertyValue &pv) { inline nlohmann::json PropertyValueToJson(const storage::PropertyValue &pv) {
@ -144,5 +143,4 @@ void Log::Flush() {
log_.Sync(); log_.Sync();
} }
} // namespace audit } // namespace memgraph::audit
} // namespace memgraph

View File

@ -17,8 +17,7 @@
#include "utils/file.hpp" #include "utils/file.hpp"
#include "utils/scheduler.hpp" #include "utils/scheduler.hpp"
namespace memgraph { namespace memgraph::audit {
namespace audit {
const uint64_t kBufferSizeDefault = 100000; const uint64_t kBufferSizeDefault = 100000;
const uint64_t kBufferFlushIntervalMillisDefault = 200; const uint64_t kBufferFlushIntervalMillisDefault = 200;
@ -72,5 +71,4 @@ class Log {
std::mutex lock_; std::mutex lock_;
}; };
} // namespace audit } // namespace memgraph::audit
} // namespace memgraph

View File

@ -42,9 +42,7 @@ DEFINE_VALIDATED_int32(auth_module_timeout_ms, 10000,
"response from the auth module.", "response from the auth module.",
FLAG_IN_RANGE(100, 1800000)); FLAG_IN_RANGE(100, 1800000));
namespace memgraph { namespace memgraph::auth {
namespace auth {
const std::string kUserPrefix = "user:"; const std::string kUserPrefix = "user:";
const std::string kRolePrefix = "role:"; const std::string kRolePrefix = "role:";
const std::string kLinkPrefix = "link:"; const std::string kLinkPrefix = "link:";
@ -317,5 +315,4 @@ std::vector<auth::User> Auth::AllUsersForRole(const std::string &rolename_orig)
return ret; return ret;
} }
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -18,9 +18,7 @@
#include "kvstore/kvstore.hpp" #include "kvstore/kvstore.hpp"
#include "utils/settings.hpp" #include "utils/settings.hpp"
namespace memgraph { namespace memgraph::auth {
namespace auth {
/** /**
* This class serves as the main Authentication/Authorization storage. * This class serves as the main Authentication/Authorization storage.
* It provides functions for managing Users, Roles and Permissions. * It provides functions for managing Users, Roles and Permissions.
@ -164,5 +162,4 @@ class Auth final {
kvstore::KVStore storage_; kvstore::KVStore storage_;
auth::Module module_; auth::Module module_;
}; };
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -12,9 +12,7 @@
#include "auth/exceptions.hpp" #include "auth/exceptions.hpp"
namespace memgraph { namespace memgraph::auth {
namespace auth {
const std::string EncryptPassword(const std::string &password) { const std::string EncryptPassword(const std::string &password) {
char salt[BCRYPT_HASHSIZE]; char salt[BCRYPT_HASHSIZE];
char hash[BCRYPT_HASHSIZE]; char hash[BCRYPT_HASHSIZE];
@ -41,5 +39,4 @@ bool VerifyPassword(const std::string &password, const std::string &hash) {
return ret == 0; return ret == 0;
} }
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -10,14 +10,11 @@
#include <string> #include <string>
namespace memgraph { namespace memgraph::auth {
namespace auth {
/// @throw AuthException if unable to encrypt the password. /// @throw AuthException if unable to encrypt the password.
const std::string EncryptPassword(const std::string &password); const std::string EncryptPassword(const std::string &password);
/// @throw AuthException if unable to verify the password. /// @throw AuthException if unable to verify the password.
bool VerifyPassword(const std::string &password, const std::string &hash); bool VerifyPassword(const std::string &password, const std::string &hash);
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -13,9 +13,7 @@
#include "utils/exceptions.hpp" #include "utils/exceptions.hpp"
namespace memgraph { namespace memgraph::auth {
namespace auth {
/** /**
* This exception class is thrown for all exceptions that can occur when dealing * This exception class is thrown for all exceptions that can occur when dealing
* with the Auth library. * with the Auth library.
@ -24,5 +22,4 @@ class AuthException : public utils::BasicException {
public: public:
using utils::BasicException::BasicException; using utils::BasicException::BasicException;
}; };
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -28,9 +28,7 @@ DEFINE_string(auth_password_strength_regex, default_password_regex.data(),
"The regular expression that should be used to match the entire " "The regular expression that should be used to match the entire "
"entered password to ensure its strength."); "entered password to ensure its strength.");
namespace memgraph { namespace memgraph::auth {
namespace auth {
namespace { namespace {
// Constant list of all available permissions. // Constant list of all available permissions.
const std::vector<Permission> kPermissionsAll = { const std::vector<Permission> kPermissionsAll = {
@ -304,5 +302,4 @@ bool operator==(const User &first, const User &second) {
return first.username_ == second.username_ && first.password_hash_ == second.password_hash_ && return first.username_ == second.username_ && first.password_hash_ == second.password_hash_ &&
first.permissions_ == second.permissions_ && first.role_ == second.role_; first.permissions_ == second.permissions_ && first.role_ == second.role_;
} }
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -13,9 +13,7 @@
#include <json/json.hpp> #include <json/json.hpp>
namespace memgraph { namespace memgraph::auth {
namespace auth {
// These permissions must have values that are applicable for usage in a // These permissions must have values that are applicable for usage in a
// bitmask. // bitmask.
// clang-format off // clang-format off
@ -155,5 +153,4 @@ class User final {
}; };
bool operator==(const User &first, const User &second); bool operator==(const User &first, const User &second);
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -312,9 +312,7 @@ nlohmann::json GetData(int fd, int timeout_millisec) {
} // namespace } // namespace
namespace memgraph { namespace memgraph::auth {
namespace auth {
Module::Module(const std::filesystem::path &module_executable_path) { Module::Module(const std::filesystem::path &module_executable_path) {
if (!module_executable_path.empty()) { if (!module_executable_path.empty()) {
module_executable_path_ = std::filesystem::absolute(module_executable_path); module_executable_path_ = std::filesystem::absolute(module_executable_path);
@ -448,5 +446,4 @@ void Module::Shutdown() {
Module::~Module() { Shutdown(); } Module::~Module() { Shutdown(); }
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -16,9 +16,7 @@
#include <json/json.hpp> #include <json/json.hpp>
namespace memgraph { namespace memgraph::auth {
namespace auth {
struct TargetArguments { struct TargetArguments {
std::filesystem::path module_executable_path; std::filesystem::path module_executable_path;
int pipe_to_module{-1}; int pipe_to_module{-1};
@ -71,5 +69,4 @@ class Module final {
int pipe_from_module_[2] = {-1, -1}; int pipe_from_module_[2] = {-1, -1};
}; };
} // namespace auth } // namespace memgraph::auth
} // namespace memgraph

View File

@ -37,10 +37,10 @@ namespace memgraph::communication {
* that has `num_workers` threads. It is started automatically on constructor, * that has `num_workers` threads. It is started automatically on constructor,
* and stopped at destructor. * and stopped at destructor.
* *
* Current Server achitecture: * Current Server architecture:
* incoming connection -> server -> listener -> session * incoming connection -> server -> listener -> session
* *
* NOTE: If you use this server you **must** create `memgraph::communication::SSLInit` * NOTE: If you use this server you **must** create communication::SSLInit`
* from the `main` function before using the server! * from the `main` function before using the server!
* *
* @tparam TSession the server can handle different Sessions, each session * @tparam TSession the server can handle different Sessions, each session

View File

@ -13,49 +13,49 @@
namespace memgraph::glue { namespace memgraph::glue {
auth::Permission PrivilegeToPermission(memgraph::query::AuthQuery::Privilege privilege) { auth::Permission PrivilegeToPermission(query::AuthQuery::Privilege privilege) {
switch (privilege) { switch (privilege) {
case memgraph::query::AuthQuery::Privilege::MATCH: case query::AuthQuery::Privilege::MATCH:
return auth::Permission::MATCH; return auth::Permission::MATCH;
case memgraph::query::AuthQuery::Privilege::CREATE: case query::AuthQuery::Privilege::CREATE:
return auth::Permission::CREATE; return auth::Permission::CREATE;
case memgraph::query::AuthQuery::Privilege::MERGE: case query::AuthQuery::Privilege::MERGE:
return auth::Permission::MERGE; return auth::Permission::MERGE;
case memgraph::query::AuthQuery::Privilege::DELETE: case query::AuthQuery::Privilege::DELETE:
return auth::Permission::DELETE; return auth::Permission::DELETE;
case memgraph::query::AuthQuery::Privilege::SET: case query::AuthQuery::Privilege::SET:
return auth::Permission::SET; return auth::Permission::SET;
case memgraph::query::AuthQuery::Privilege::REMOVE: case query::AuthQuery::Privilege::REMOVE:
return auth::Permission::REMOVE; return auth::Permission::REMOVE;
case memgraph::query::AuthQuery::Privilege::INDEX: case query::AuthQuery::Privilege::INDEX:
return auth::Permission::INDEX; return auth::Permission::INDEX;
case memgraph::query::AuthQuery::Privilege::STATS: case query::AuthQuery::Privilege::STATS:
return auth::Permission::STATS; return auth::Permission::STATS;
case memgraph::query::AuthQuery::Privilege::CONSTRAINT: case query::AuthQuery::Privilege::CONSTRAINT:
return auth::Permission::CONSTRAINT; return auth::Permission::CONSTRAINT;
case memgraph::query::AuthQuery::Privilege::DUMP: case query::AuthQuery::Privilege::DUMP:
return auth::Permission::DUMP; return auth::Permission::DUMP;
case memgraph::query::AuthQuery::Privilege::REPLICATION: case query::AuthQuery::Privilege::REPLICATION:
return auth::Permission::REPLICATION; return auth::Permission::REPLICATION;
case memgraph::query::AuthQuery::Privilege::DURABILITY: case query::AuthQuery::Privilege::DURABILITY:
return auth::Permission::DURABILITY; return auth::Permission::DURABILITY;
case memgraph::query::AuthQuery::Privilege::READ_FILE: case query::AuthQuery::Privilege::READ_FILE:
return auth::Permission::READ_FILE; return auth::Permission::READ_FILE;
case memgraph::query::AuthQuery::Privilege::FREE_MEMORY: case query::AuthQuery::Privilege::FREE_MEMORY:
return auth::Permission::FREE_MEMORY; return auth::Permission::FREE_MEMORY;
case memgraph::query::AuthQuery::Privilege::TRIGGER: case query::AuthQuery::Privilege::TRIGGER:
return auth::Permission::TRIGGER; return auth::Permission::TRIGGER;
case memgraph::query::AuthQuery::Privilege::CONFIG: case query::AuthQuery::Privilege::CONFIG:
return auth::Permission::CONFIG; return auth::Permission::CONFIG;
case memgraph::query::AuthQuery::Privilege::AUTH: case query::AuthQuery::Privilege::AUTH:
return auth::Permission::AUTH; return auth::Permission::AUTH;
case memgraph::query::AuthQuery::Privilege::STREAM: case query::AuthQuery::Privilege::STREAM:
return auth::Permission::STREAM; return auth::Permission::STREAM;
case memgraph::query::AuthQuery::Privilege::MODULE_READ: case query::AuthQuery::Privilege::MODULE_READ:
return auth::Permission::MODULE_READ; return auth::Permission::MODULE_READ;
case memgraph::query::AuthQuery::Privilege::MODULE_WRITE: case query::AuthQuery::Privilege::MODULE_WRITE:
return auth::Permission::MODULE_WRITE; return auth::Permission::MODULE_WRITE;
case memgraph::query::AuthQuery::Privilege::WEBSOCKET: case query::AuthQuery::Privilege::WEBSOCKET:
return auth::Permission::WEBSOCKET; return auth::Permission::WEBSOCKET;
} }
} }

View File

@ -15,9 +15,9 @@
namespace memgraph::glue { namespace memgraph::glue {
/** /**
* This function converts memgraph::query::AuthQuery::Privilege to its corresponding * This function converts query::AuthQuery::Privilege to its corresponding
* auth::Permission. * auth::Permission.
*/ */
auth::Permission PrivilegeToPermission(memgraph::query::AuthQuery::Privilege privilege); auth::Permission PrivilegeToPermission(query::AuthQuery::Privilege privilege);
} // namespace memgraph::glue } // namespace memgraph::glue

View File

@ -24,28 +24,28 @@ using memgraph::communication::bolt::Value;
namespace memgraph::glue { namespace memgraph::glue {
memgraph::query::TypedValue ToTypedValue(const Value &value) { query::TypedValue ToTypedValue(const Value &value) {
switch (value.type()) { switch (value.type()) {
case Value::Type::Null: case Value::Type::Null:
return {}; return {};
case Value::Type::Bool: case Value::Type::Bool:
return memgraph::query::TypedValue(value.ValueBool()); return query::TypedValue(value.ValueBool());
case Value::Type::Int: case Value::Type::Int:
return memgraph::query::TypedValue(value.ValueInt()); return query::TypedValue(value.ValueInt());
case Value::Type::Double: case Value::Type::Double:
return memgraph::query::TypedValue(value.ValueDouble()); return query::TypedValue(value.ValueDouble());
case Value::Type::String: case Value::Type::String:
return memgraph::query::TypedValue(value.ValueString()); return query::TypedValue(value.ValueString());
case Value::Type::List: { case Value::Type::List: {
std::vector<memgraph::query::TypedValue> list; std::vector<query::TypedValue> list;
list.reserve(value.ValueList().size()); list.reserve(value.ValueList().size());
for (const auto &v : value.ValueList()) list.push_back(ToTypedValue(v)); for (const auto &v : value.ValueList()) list.push_back(ToTypedValue(v));
return memgraph::query::TypedValue(std::move(list)); return query::TypedValue(std::move(list));
} }
case Value::Type::Map: { case Value::Type::Map: {
std::map<std::string, memgraph::query::TypedValue> map; std::map<std::string, query::TypedValue> map;
for (const auto &kv : value.ValueMap()) map.emplace(kv.first, ToTypedValue(kv.second)); for (const auto &kv : value.ValueMap()) map.emplace(kv.first, ToTypedValue(kv.second));
return memgraph::query::TypedValue(std::move(map)); return query::TypedValue(std::move(map));
} }
case Value::Type::Vertex: case Value::Type::Vertex:
case Value::Type::Edge: case Value::Type::Edge:
@ -53,40 +53,39 @@ memgraph::query::TypedValue ToTypedValue(const Value &value) {
case Value::Type::Path: case Value::Type::Path:
throw communication::bolt::ValueException("Unsupported conversion from Value to TypedValue"); throw communication::bolt::ValueException("Unsupported conversion from Value to TypedValue");
case Value::Type::Date: case Value::Type::Date:
return memgraph::query::TypedValue(value.ValueDate()); return query::TypedValue(value.ValueDate());
case Value::Type::LocalTime: case Value::Type::LocalTime:
return memgraph::query::TypedValue(value.ValueLocalTime()); return query::TypedValue(value.ValueLocalTime());
case Value::Type::LocalDateTime: case Value::Type::LocalDateTime:
return memgraph::query::TypedValue(value.ValueLocalDateTime()); return query::TypedValue(value.ValueLocalDateTime());
case Value::Type::Duration: case Value::Type::Duration:
return memgraph::query::TypedValue(value.ValueDuration()); return query::TypedValue(value.ValueDuration());
} }
} }
storage::Result<communication::bolt::Vertex> ToBoltVertex(const memgraph::query::VertexAccessor &vertex, storage::Result<communication::bolt::Vertex> ToBoltVertex(const query::VertexAccessor &vertex,
const storage::Storage &db, storage::View view) { const storage::Storage &db, storage::View view) {
return ToBoltVertex(vertex.impl_, db, view); return ToBoltVertex(vertex.impl_, db, view);
} }
storage::Result<communication::bolt::Edge> ToBoltEdge(const memgraph::query::EdgeAccessor &edge, storage::Result<communication::bolt::Edge> ToBoltEdge(const query::EdgeAccessor &edge, const storage::Storage &db,
const storage::Storage &db, storage::View view) { storage::View view) {
return ToBoltEdge(edge.impl_, db, view); return ToBoltEdge(edge.impl_, db, view);
} }
storage::Result<Value> ToBoltValue(const memgraph::query::TypedValue &value, const storage::Storage &db, storage::Result<Value> ToBoltValue(const query::TypedValue &value, const storage::Storage &db, storage::View view) {
storage::View view) {
switch (value.type()) { switch (value.type()) {
case memgraph::query::TypedValue::Type::Null: case query::TypedValue::Type::Null:
return Value(); return Value();
case memgraph::query::TypedValue::Type::Bool: case query::TypedValue::Type::Bool:
return Value(value.ValueBool()); return Value(value.ValueBool());
case memgraph::query::TypedValue::Type::Int: case query::TypedValue::Type::Int:
return Value(value.ValueInt()); return Value(value.ValueInt());
case memgraph::query::TypedValue::Type::Double: case query::TypedValue::Type::Double:
return Value(value.ValueDouble()); return Value(value.ValueDouble());
case memgraph::query::TypedValue::Type::String: case query::TypedValue::Type::String:
return Value(std::string(value.ValueString())); return Value(std::string(value.ValueString()));
case memgraph::query::TypedValue::Type::List: { case query::TypedValue::Type::List: {
std::vector<Value> values; std::vector<Value> values;
values.reserve(value.ValueList().size()); values.reserve(value.ValueList().size());
for (const auto &v : value.ValueList()) { for (const auto &v : value.ValueList()) {
@ -96,7 +95,7 @@ storage::Result<Value> ToBoltValue(const memgraph::query::TypedValue &value, con
} }
return Value(std::move(values)); return Value(std::move(values));
} }
case memgraph::query::TypedValue::Type::Map: { case query::TypedValue::Type::Map: {
std::map<std::string, Value> map; std::map<std::string, Value> map;
for (const auto &kv : value.ValueMap()) { for (const auto &kv : value.ValueMap()) {
auto maybe_value = ToBoltValue(kv.second, db, view); auto maybe_value = ToBoltValue(kv.second, db, view);
@ -105,28 +104,28 @@ storage::Result<Value> ToBoltValue(const memgraph::query::TypedValue &value, con
} }
return Value(std::move(map)); return Value(std::move(map));
} }
case memgraph::query::TypedValue::Type::Vertex: { case query::TypedValue::Type::Vertex: {
auto maybe_vertex = ToBoltVertex(value.ValueVertex(), db, view); auto maybe_vertex = ToBoltVertex(value.ValueVertex(), db, view);
if (maybe_vertex.HasError()) return maybe_vertex.GetError(); if (maybe_vertex.HasError()) return maybe_vertex.GetError();
return Value(std::move(*maybe_vertex)); return Value(std::move(*maybe_vertex));
} }
case memgraph::query::TypedValue::Type::Edge: { case query::TypedValue::Type::Edge: {
auto maybe_edge = ToBoltEdge(value.ValueEdge(), db, view); auto maybe_edge = ToBoltEdge(value.ValueEdge(), db, view);
if (maybe_edge.HasError()) return maybe_edge.GetError(); if (maybe_edge.HasError()) return maybe_edge.GetError();
return Value(std::move(*maybe_edge)); return Value(std::move(*maybe_edge));
} }
case memgraph::query::TypedValue::Type::Path: { case query::TypedValue::Type::Path: {
auto maybe_path = ToBoltPath(value.ValuePath(), db, view); auto maybe_path = ToBoltPath(value.ValuePath(), db, view);
if (maybe_path.HasError()) return maybe_path.GetError(); if (maybe_path.HasError()) return maybe_path.GetError();
return Value(std::move(*maybe_path)); return Value(std::move(*maybe_path));
} }
case memgraph::query::TypedValue::Type::Date: case query::TypedValue::Type::Date:
return Value(value.ValueDate()); return Value(value.ValueDate());
case memgraph::query::TypedValue::Type::LocalTime: case query::TypedValue::Type::LocalTime:
return Value(value.ValueLocalTime()); return Value(value.ValueLocalTime());
case memgraph::query::TypedValue::Type::LocalDateTime: case query::TypedValue::Type::LocalDateTime:
return Value(value.ValueLocalDateTime()); return Value(value.ValueLocalDateTime());
case memgraph::query::TypedValue::Type::Duration: case query::TypedValue::Type::Duration:
return Value(value.ValueDuration()); return Value(value.ValueDuration());
} }
} }
@ -165,7 +164,7 @@ storage::Result<communication::bolt::Edge> ToBoltEdge(const storage::EdgeAccesso
return communication::bolt::Edge{id, from, to, type, properties}; return communication::bolt::Edge{id, from, to, type, properties};
} }
storage::Result<communication::bolt::Path> ToBoltPath(const memgraph::query::Path &path, const storage::Storage &db, storage::Result<communication::bolt::Path> ToBoltPath(const query::Path &path, const storage::Storage &db,
storage::View view) { storage::View view) {
std::vector<communication::bolt::Vertex> vertices; std::vector<communication::bolt::Vertex> vertices;
vertices.reserve(path.vertices().size()); vertices.reserve(path.vertices().size());

View File

@ -43,23 +43,23 @@ storage::Result<communication::bolt::Vertex> ToBoltVertex(const storage::VertexA
storage::Result<communication::bolt::Edge> ToBoltEdge(const storage::EdgeAccessor &edge, const storage::Storage &db, storage::Result<communication::bolt::Edge> ToBoltEdge(const storage::EdgeAccessor &edge, const storage::Storage &db,
storage::View view); storage::View view);
/// @param memgraph::query::Path for converting to communication::bolt::Path. /// @param query::Path for converting to communication::bolt::Path.
/// @param storage::Storage for ToBoltVertex and ToBoltEdge. /// @param storage::Storage for ToBoltVertex and ToBoltEdge.
/// @param storage::View for ToBoltVertex and ToBoltEdge. /// @param storage::View for ToBoltVertex and ToBoltEdge.
/// ///
/// @throw std::bad_alloc /// @throw std::bad_alloc
storage::Result<communication::bolt::Path> ToBoltPath(const memgraph::query::Path &path, const storage::Storage &db, storage::Result<communication::bolt::Path> ToBoltPath(const query::Path &path, const storage::Storage &db,
storage::View view); storage::View view);
/// @param memgraph::query::TypedValue for converting to communication::bolt::Value. /// @param query::TypedValue for converting to communication::bolt::Value.
/// @param storage::Storage for ToBoltVertex and ToBoltEdge. /// @param storage::Storage for ToBoltVertex and ToBoltEdge.
/// @param storage::View for ToBoltVertex and ToBoltEdge. /// @param storage::View for ToBoltVertex and ToBoltEdge.
/// ///
/// @throw std::bad_alloc /// @throw std::bad_alloc
storage::Result<communication::bolt::Value> ToBoltValue(const memgraph::query::TypedValue &value, storage::Result<communication::bolt::Value> ToBoltValue(const query::TypedValue &value, const storage::Storage &db,
const storage::Storage &db, storage::View view); storage::View view);
memgraph::query::TypedValue ToTypedValue(const communication::bolt::Value &value); query::TypedValue ToTypedValue(const communication::bolt::Value &value);
communication::bolt::Value ToBoltValue(const storage::PropertyValue &value); communication::bolt::Value ToBoltValue(const storage::PropertyValue &value);

View File

@ -16,16 +16,16 @@
namespace memgraph::slk { namespace memgraph::slk {
inline void Save(const io::network::Endpoint &endpoint, memgraph::slk::Builder *builder) { inline void Save(const io::network::Endpoint &endpoint, Builder *builder) {
memgraph::slk::Save(endpoint.address_, builder); Save(endpoint.address_, builder);
memgraph::slk::Save(endpoint.port_, builder); Save(endpoint.port_, builder);
memgraph::slk::Save(endpoint.family_, builder); Save(endpoint.family_, builder);
} }
inline void Load(io::network::Endpoint *endpoint, memgraph::slk::Reader *reader) { inline void Load(io::network::Endpoint *endpoint, Reader *reader) {
memgraph::slk::Load(&endpoint->address_, reader); Load(&endpoint->address_, reader);
memgraph::slk::Load(&endpoint->port_, reader); Load(&endpoint->port_, reader);
memgraph::slk::Load(&endpoint->family_, reader); Load(&endpoint->family_, reader);
} }
} // namespace memgraph::slk } // namespace memgraph::slk

View File

@ -5,7 +5,3 @@ find_package(ZLIB REQUIRED)
# STATIC library used to store key-value pairs # STATIC library used to store key-value pairs
add_library(mg-kvstore STATIC kvstore.cpp) add_library(mg-kvstore STATIC kvstore.cpp)
target_link_libraries(mg-kvstore stdc++fs mg-utils rocksdb BZip2::BZip2 ZLIB::ZLIB gflags) target_link_libraries(mg-kvstore stdc++fs mg-utils rocksdb BZip2::BZip2 ZLIB::ZLIB gflags)
# STATIC library for dummy key-value storage
# add_library(mg-kvstore-dummy STATIC kvstore_dummy.cpp)
# target_link_libraries(mg-kvstore-dummy mg-utils)

View File

@ -1,113 +0,0 @@
// Copyright 2022 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 "kvstore/kvstore.hpp"
#include "utils/file.hpp"
#include "utils/logging.hpp"
namespace memgraph::kvstore {
struct KVStore::impl {};
KVStore::KVStore(std::filesystem::path storage) {}
KVStore::~KVStore() {}
bool KVStore::Put(const std::string &key, const std::string &value) {
LOG_FATAL("Unsupported operation (KVStore::Put) -- this is a dummy kvstore");
}
bool KVStore::PutMultiple(const std::map<std::string, std::string> &items) {
LOG_FATAL(
"Unsupported operation (KVStore::PutMultiple) -- this is a "
"dummy kvstore");
}
std::optional<std::string> KVStore::Get(const std::string &key) const noexcept {
LOG_FATAL("Unsupported operation (KVStore::Get) -- this is a dummy kvstore");
}
bool KVStore::Delete(const std::string &key) {
LOG_FATAL("Unsupported operation (KVStore::Delete) -- this is a dummy kvstore");
}
bool KVStore::DeleteMultiple(const std::vector<std::string> &keys) {
LOG_FATAL(
"Unsupported operation (KVStore::DeleteMultiple) -- this is "
"a dummy kvstore");
}
bool KVStore::DeletePrefix(const std::string &prefix) {
LOG_FATAL(
"Unsupported operation (KVStore::DeletePrefix) -- this is a "
"dummy kvstore");
}
bool KVStore::PutAndDeleteMultiple(const std::map<std::string, std::string> &items,
const std::vector<std::string> &keys) {
LOG_FATAL(
"Unsupported operation (KVStore::PutAndDeleteMultiple) -- this is a "
"dummy kvstore");
}
// iterator
struct KVStore::iterator::impl {};
KVStore::iterator::iterator(const KVStore *kvstore, const std::string &prefix, bool at_end) : pimpl_(new impl()) {}
KVStore::iterator::iterator(KVStore::iterator &&other) { pimpl_ = std::move(other.pimpl_); }
KVStore::iterator::~iterator() {}
KVStore::iterator &KVStore::iterator::operator=(KVStore::iterator &&other) {
pimpl_ = std::move(other.pimpl_);
return *this;
}
KVStore::iterator &KVStore::iterator::operator++() {
LOG_FATAL(
"Unsupported operation (&KVStore::iterator::operator++) -- "
"this is a dummy kvstore");
}
bool KVStore::iterator::operator==(const iterator &other) const { return true; }
bool KVStore::iterator::operator!=(const iterator &other) const { return false; }
KVStore::iterator::reference KVStore::iterator::operator*() {
LOG_FATAL(
"Unsupported operation (KVStore::iterator::operator*)-- this "
"is a dummy kvstore");
}
KVStore::iterator::pointer KVStore::iterator::operator->() {
LOG_FATAL(
"Unsupported operation (KVStore::iterator::operator->) -- "
"this is a dummy kvstore");
}
void KVStore::iterator::SetInvalid() {}
bool KVStore::iterator::IsValid() { return false; }
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
size_t KVStore::Size(const std::string & /*prefix*/) const { return 0; }
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
bool KVStore::CompactRange(const std::string & /*begin_prefix*/, const std::string & /*end_prefix*/) {
LOG_FATAL(
"Unsupported operation (KVStore::Compact) -- this is a "
"dummy kvstore");
}
} // namespace memgraph::kvstore

View File

@ -56,7 +56,7 @@ NIL, returns a string."
(defun type-info-declaration-for-class (cpp-class) (defun type-info-declaration-for-class (cpp-class)
(assert (cpp-type-simple-class-p cpp-class)) (assert (cpp-type-simple-class-p cpp-class))
(with-output-to-string (s) (with-output-to-string (s)
(write-line "static const memgraph::utils::TypeInfo kType;" s) (write-line "static const utils::TypeInfo kType;" s)
(let* ((type-info-basep (type-info-opts-base (let* ((type-info-basep (type-info-opts-base
(cpp-class-type-info-opts cpp-class))) (cpp-class-type-info-opts cpp-class)))
(virtual (if (and (or type-info-basep (virtual (if (and (or type-info-basep
@ -68,7 +68,7 @@ NIL, returns a string."
(cpp-class-super-classes cpp-class)) (cpp-class-super-classes cpp-class))
"override" "override"
""))) "")))
(format s "~A const memgraph::utils::TypeInfo &GetTypeInfo() const ~A { return kType; }" (format s "~A const utils::TypeInfo &GetTypeInfo() const ~A { return kType; }"
virtual override)))) virtual override))))
(defun type-info-definition-for-class (cpp-class) (defun type-info-definition-for-class (cpp-class)

View File

@ -17,12 +17,12 @@ namespace memgraph::query {
class AuthChecker { class AuthChecker {
public: public:
virtual bool IsUserAuthorized(const std::optional<std::string> &username, virtual bool IsUserAuthorized(const std::optional<std::string> &username,
const std::vector<memgraph::query::AuthQuery::Privilege> &privileges) const = 0; const std::vector<query::AuthQuery::Privilege> &privileges) const = 0;
}; };
class AllowEverythingAuthChecker final : public memgraph::query::AuthChecker { class AllowEverythingAuthChecker final : public query::AuthChecker {
bool IsUserAuthorized(const std::optional<std::string> &username, bool IsUserAuthorized(const std::optional<std::string> &username,
const std::vector<memgraph::query::AuthQuery::Privilege> &privileges) const override { const std::vector<query::AuthQuery::Privilege> &privileges) const override {
return true; return true;
} }
}; };

View File

@ -37,7 +37,7 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::stri
auto it = params.find(param_pair.second); auto it = params.find(param_pair.second);
if (it == params.end()) { if (it == params.end()) {
throw memgraph::query::UnprovidedParameterError("Parameter ${} not provided.", param_pair.second); throw query::UnprovidedParameterError("Parameter ${} not provided.", param_pair.second);
} }
parameters.Add(param_pair.first, it->second); parameters.Add(param_pair.first, it->second);
@ -91,8 +91,7 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::stri
} }
if (visitor.GetQueryInfo().is_cacheable) { if (visitor.GetQueryInfo().is_cacheable) {
CachedQuery cached_query{std::move(ast_storage), visitor.query(), CachedQuery cached_query{std::move(ast_storage), visitor.query(), query::GetRequiredPrivileges(visitor.query())};
memgraph::query::GetRequiredPrivileges(visitor.query())};
it = accessor.insert({hash, std::move(cached_query)}).first; it = accessor.insert({hash, std::move(cached_query)}).first;
get_information_from_cache(it->second); get_information_from_cache(it->second);
@ -102,7 +101,7 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::stri
result.ast_storage.edge_types_ = ast_storage.edge_types_; result.ast_storage.edge_types_ = ast_storage.edge_types_;
result.query = visitor.query()->Clone(&result.ast_storage); result.query = visitor.query()->Clone(&result.ast_storage);
result.required_privileges = memgraph::query::GetRequiredPrivileges(visitor.query()); result.required_privileges = query::GetRequiredPrivileges(visitor.query());
is_cacheable = false; is_cacheable = false;
} }

View File

@ -17,7 +17,7 @@
namespace memgraph::query { namespace memgraph::query {
struct DiscardValueResultStream final { struct DiscardValueResultStream final {
void Result(const std::vector<memgraph::query::TypedValue> & /*values*/) { void Result(const std::vector<query::TypedValue> & /*values*/) {
// do nothing // do nothing
} }
}; };

View File

@ -153,7 +153,7 @@ void DumpPropertyValue(std::ostream *os, const storage::PropertyValue &value) {
} }
} }
void DumpProperties(std::ostream *os, memgraph::query::DbAccessor *dba, void DumpProperties(std::ostream *os, query::DbAccessor *dba,
const std::map<storage::PropertyId, storage::PropertyValue> &store, const std::map<storage::PropertyId, storage::PropertyValue> &store,
std::optional<int64_t> property_id = std::nullopt) { std::optional<int64_t> property_id = std::nullopt) {
*os << "{"; *os << "{";
@ -168,20 +168,20 @@ void DumpProperties(std::ostream *os, memgraph::query::DbAccessor *dba,
*os << "}"; *os << "}";
} }
void DumpVertex(std::ostream *os, memgraph::query::DbAccessor *dba, const memgraph::query::VertexAccessor &vertex) { void DumpVertex(std::ostream *os, query::DbAccessor *dba, const query::VertexAccessor &vertex) {
*os << "CREATE ("; *os << "CREATE (";
*os << ":" << kInternalVertexLabel; *os << ":" << kInternalVertexLabel;
auto maybe_labels = vertex.Labels(storage::View::OLD); auto maybe_labels = vertex.Labels(storage::View::OLD);
if (maybe_labels.HasError()) { if (maybe_labels.HasError()) {
switch (maybe_labels.GetError()) { switch (maybe_labels.GetError()) {
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get labels from a deleted node."); throw query::QueryRuntimeException("Trying to get labels from a deleted node.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get labels from a node that doesn't exist."); throw query::QueryRuntimeException("Trying to get labels from a node that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
throw memgraph::query::QueryRuntimeException("Unexpected error when getting labels."); throw query::QueryRuntimeException("Unexpected error when getting labels.");
} }
} }
for (const auto &label : *maybe_labels) { for (const auto &label : *maybe_labels) {
@ -192,20 +192,20 @@ void DumpVertex(std::ostream *os, memgraph::query::DbAccessor *dba, const memgra
if (maybe_props.HasError()) { if (maybe_props.HasError()) {
switch (maybe_props.GetError()) { switch (maybe_props.GetError()) {
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get properties from a deleted object."); throw query::QueryRuntimeException("Trying to get properties from a deleted object.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get properties from a node that doesn't exist."); throw query::QueryRuntimeException("Trying to get properties from a node that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
throw memgraph::query::QueryRuntimeException("Unexpected error when getting properties."); throw query::QueryRuntimeException("Unexpected error when getting properties.");
} }
} }
DumpProperties(os, dba, *maybe_props, vertex.CypherId()); DumpProperties(os, dba, *maybe_props, vertex.CypherId());
*os << ");"; *os << ");";
} }
void DumpEdge(std::ostream *os, memgraph::query::DbAccessor *dba, const memgraph::query::EdgeAccessor &edge) { void DumpEdge(std::ostream *os, query::DbAccessor *dba, const query::EdgeAccessor &edge) {
*os << "MATCH "; *os << "MATCH ";
*os << "(u:" << kInternalVertexLabel << "), "; *os << "(u:" << kInternalVertexLabel << "), ";
*os << "(v:" << kInternalVertexLabel << ")"; *os << "(v:" << kInternalVertexLabel << ")";
@ -219,13 +219,13 @@ void DumpEdge(std::ostream *os, memgraph::query::DbAccessor *dba, const memgraph
if (maybe_props.HasError()) { if (maybe_props.HasError()) {
switch (maybe_props.GetError()) { switch (maybe_props.GetError()) {
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get properties from a deleted object."); throw query::QueryRuntimeException("Trying to get properties from a deleted object.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get properties from an edge that doesn't exist."); throw query::QueryRuntimeException("Trying to get properties from an edge that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
throw memgraph::query::QueryRuntimeException("Unexpected error when getting properties."); throw query::QueryRuntimeException("Unexpected error when getting properties.");
} }
} }
if (maybe_props->size() > 0) { if (maybe_props->size() > 0) {
@ -235,23 +235,23 @@ void DumpEdge(std::ostream *os, memgraph::query::DbAccessor *dba, const memgraph
*os << "]->(v);"; *os << "]->(v);";
} }
void DumpLabelIndex(std::ostream *os, memgraph::query::DbAccessor *dba, const storage::LabelId label) { void DumpLabelIndex(std::ostream *os, query::DbAccessor *dba, const storage::LabelId label) {
*os << "CREATE INDEX ON :" << EscapeName(dba->LabelToName(label)) << ";"; *os << "CREATE INDEX ON :" << EscapeName(dba->LabelToName(label)) << ";";
} }
void DumpLabelPropertyIndex(std::ostream *os, memgraph::query::DbAccessor *dba, storage::LabelId label, void DumpLabelPropertyIndex(std::ostream *os, query::DbAccessor *dba, storage::LabelId label,
storage::PropertyId property) { storage::PropertyId property) {
*os << "CREATE INDEX ON :" << EscapeName(dba->LabelToName(label)) << "(" << EscapeName(dba->PropertyToName(property)) *os << "CREATE INDEX ON :" << EscapeName(dba->LabelToName(label)) << "(" << EscapeName(dba->PropertyToName(property))
<< ");"; << ");";
} }
void DumpExistenceConstraint(std::ostream *os, memgraph::query::DbAccessor *dba, storage::LabelId label, void DumpExistenceConstraint(std::ostream *os, query::DbAccessor *dba, storage::LabelId label,
storage::PropertyId property) { storage::PropertyId property) {
*os << "CREATE CONSTRAINT ON (u:" << EscapeName(dba->LabelToName(label)) << ") ASSERT EXISTS (u." *os << "CREATE CONSTRAINT ON (u:" << EscapeName(dba->LabelToName(label)) << ") ASSERT EXISTS (u."
<< EscapeName(dba->PropertyToName(property)) << ");"; << EscapeName(dba->PropertyToName(property)) << ");";
} }
void DumpUniqueConstraint(std::ostream *os, memgraph::query::DbAccessor *dba, storage::LabelId label, void DumpUniqueConstraint(std::ostream *os, query::DbAccessor *dba, storage::LabelId label,
const std::set<storage::PropertyId> &properties) { const std::set<storage::PropertyId> &properties) {
*os << "CREATE CONSTRAINT ON (u:" << EscapeName(dba->LabelToName(label)) << ") ASSERT "; *os << "CREATE CONSTRAINT ON (u:" << EscapeName(dba->LabelToName(label)) << ") ASSERT ";
utils::PrintIterable(*os, properties, ", ", [&dba](auto &stream, const auto &property) { utils::PrintIterable(*os, properties, ", ", [&dba](auto &stream, const auto &property) {
@ -536,8 +536,6 @@ PullPlanDump::PullChunk PullPlanDump::CreateInternalIndexCleanupPullChunk() {
}; };
} }
void DumpDatabaseToCypherQueries(memgraph::query::DbAccessor *dba, AnyStream *stream) { void DumpDatabaseToCypherQueries(query::DbAccessor *dba, AnyStream *stream) { PullPlanDump(dba).Pull(stream, {}); }
PullPlanDump(dba).Pull(stream, {});
}
} // namespace memgraph::query } // namespace memgraph::query

View File

@ -19,22 +19,22 @@
namespace memgraph::query { namespace memgraph::query {
void DumpDatabaseToCypherQueries(memgraph::query::DbAccessor *dba, AnyStream *stream); void DumpDatabaseToCypherQueries(query::DbAccessor *dba, AnyStream *stream);
struct PullPlanDump { struct PullPlanDump {
explicit PullPlanDump(memgraph::query::DbAccessor *dba); explicit PullPlanDump(query::DbAccessor *dba);
/// Pull the dump results lazily /// Pull the dump results lazily
/// @return true if all results were returned, false otherwise /// @return true if all results were returned, false otherwise
bool Pull(AnyStream *stream, std::optional<int> n); bool Pull(AnyStream *stream, std::optional<int> n);
private: private:
memgraph::query::DbAccessor *dba_ = nullptr; query::DbAccessor *dba_ = nullptr;
std::optional<storage::IndicesInfo> indices_info_ = std::nullopt; std::optional<storage::IndicesInfo> indices_info_ = std::nullopt;
std::optional<storage::ConstraintsInfo> constraints_info_ = std::nullopt; std::optional<storage::ConstraintsInfo> constraints_info_ = std::nullopt;
using VertexAccessorIterable = decltype(std::declval<memgraph::query::DbAccessor>().Vertices(storage::View::OLD)); using VertexAccessorIterable = decltype(std::declval<query::DbAccessor>().Vertices(storage::View::OLD));
using VertexAccessorIterableIterator = decltype(std::declval<VertexAccessorIterable>().begin()); using VertexAccessorIterableIterator = decltype(std::declval<VertexAccessorIterable>().begin());
using EdgeAccessorIterable = decltype(std::declval<VertexAccessor>().OutEdges(storage::View::OLD)); using EdgeAccessorIterable = decltype(std::declval<VertexAccessor>().OutEdges(storage::View::OLD));

View File

@ -43,7 +43,7 @@ cpp<#
(defun slk-save-ast-vector (member) (defun slk-save-ast-vector (member)
#>cpp #>cpp
size_t size = self.${member}.size(); size_t size = self.${member}.size();
memgraph::slk::Save(size, builder); slk::Save(size, builder);
for (const auto *val : self.${member}) { for (const auto *val : self.${member}) {
query::SaveAstPointer(val, builder); query::SaveAstPointer(val, builder);
} }
@ -53,7 +53,7 @@ cpp<#
(lambda (member) (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
self->${member}[i] = query::LoadAstPointer<query::${type}>(storage, reader); self->${member}[i] = query::LoadAstPointer<query::${type}>(storage, reader);
@ -63,9 +63,9 @@ cpp<#
(defun slk-save-property-map (member) (defun slk-save-property-map (member)
#>cpp #>cpp
size_t size = self.${member}.size(); size_t size = self.${member}.size();
memgraph::slk::Save(size, builder); slk::Save(size, builder);
for (const auto &entry : self.${member}) { for (const auto &entry : self.${member}) {
memgraph::slk::Save(entry.first, builder); slk::Save(entry.first, builder);
query::SaveAstPointer(entry.second, builder); query::SaveAstPointer(entry.second, builder);
} }
cpp<#) cpp<#)
@ -73,10 +73,10 @@ cpp<#
(defun slk-load-property-map (member) (defun slk-load-property-map (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
query::PropertyIx key; query::PropertyIx key;
memgraph::slk::Load(&key, reader, storage); slk::Load(&key, reader, storage);
auto *value = query::LoadAstPointer<query::Expression>(storage, reader); auto *value = query::LoadAstPointer<query::Expression>(storage, reader);
self->${member}.emplace(key, value); self->${member}.emplace(key, value);
} }
@ -93,7 +93,7 @@ cpp<#
(defun slk-save-expression-map (member) (defun slk-save-expression-map (member)
#>cpp #>cpp
size_t size = self.${member}.size(); size_t size = self.${member}.size();
memgraph::slk::Save(size, builder); slk::Save(size, builder);
for (const auto &entry : self.${member}) { for (const auto &entry : self.${member}) {
query::SaveAstPointer(entry.first, builder); query::SaveAstPointer(entry.first, builder);
query::SaveAstPointer(entry.second, builder); query::SaveAstPointer(entry.second, builder);
@ -103,7 +103,7 @@ cpp<#
(defun slk-load-expression-map (member) (defun slk-load-expression-map (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
auto *key = query::LoadAstPointer<query::Expression>(storage, reader); auto *key = query::LoadAstPointer<query::Expression>(storage, reader);
auto *value = query::LoadAstPointer<query::Expression>(storage, reader); auto *value = query::LoadAstPointer<query::Expression>(storage, reader);
@ -299,9 +299,9 @@ cpp<#
;;; Expressions ;;; Expressions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(lcp:define-class expression (tree "utils::Visitable<HierarchicalTreeVisitor>" (lcp:define-class expression (tree "::utils::Visitable<HierarchicalTreeVisitor>"
"utils::Visitable<ExpressionVisitor<TypedValue>>" "::utils::Visitable<ExpressionVisitor<TypedValue>>"
"utils::Visitable<ExpressionVisitor<void>>") "::utils::Visitable<ExpressionVisitor<void>>")
() ()
(:abstractp t) (:abstractp t)
(:public (:public
@ -320,7 +320,7 @@ cpp<#
(:clone :ignore-other-base-classes t) (:clone :ignore-other-base-classes t)
(:type-info :ignore-other-base-classes t)) (:type-info :ignore-other-base-classes t))
(lcp:define-class where (tree "utils::Visitable<HierarchicalTreeVisitor>") (lcp:define-class where (tree "::utils::Visitable<HierarchicalTreeVisitor>")
((expression "Expression *" :initval "nullptr" :scope :public ((expression "Expression *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer :slk-save #'slk-save-ast-pointer
:slk-load (slk-load-ast-pointer "Expression"))) :slk-load (slk-load-ast-pointer "Expression")))
@ -744,7 +744,7 @@ cpp<#
(property "PropertyIx" :scope :public (property "PropertyIx" :scope :public
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
memgraph::slk::Load(&self->${member}, reader, storage); slk::Load(&self->${member}, reader, storage);
cpp<#) cpp<#)
:clone (lambda (source dest) :clone (lambda (source dest)
#>cpp #>cpp
@ -783,10 +783,10 @@ cpp<#
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage); slk::Load(&self->${member}[i], reader, storage);
} }
cpp<#) cpp<#)
:clone (clone-name-ix-vector "Label"))) :clone (clone-name-ix-vector "Label")))
@ -1199,9 +1199,9 @@ cpp<#
(:serialize (:slk)) (:serialize (:slk))
(:clone)) (:clone))
(lcp:define-class named-expression (tree "utils::Visitable<HierarchicalTreeVisitor>" (lcp:define-class named-expression (tree "::utils::Visitable<HierarchicalTreeVisitor>"
"utils::Visitable<ExpressionVisitor<TypedValue>>" "::utils::Visitable<ExpressionVisitor<TypedValue>>"
"utils::Visitable<ExpressionVisitor<void>>") "::utils::Visitable<ExpressionVisitor<void>>")
((name "std::string" :scope :public) ((name "std::string" :scope :public)
(expression "Expression *" :initval "nullptr" :scope :public (expression "Expression *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer :slk-save #'slk-save-ast-pointer
@ -1253,7 +1253,7 @@ cpp<#
;;; END Expressions ;;; END Expressions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(lcp:define-class pattern-atom (tree "utils::Visitable<HierarchicalTreeVisitor>") (lcp:define-class pattern-atom (tree "::utils::Visitable<HierarchicalTreeVisitor>")
((identifier "Identifier *" :initval "nullptr" :scope :public ((identifier "Identifier *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer :slk-save #'slk-save-ast-pointer
:slk-load (slk-load-ast-pointer "Identifier"))) :slk-load (slk-load-ast-pointer "Identifier")))
@ -1294,10 +1294,10 @@ cpp<#
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage); slk::Load(&self->${member}[i], reader, storage);
} }
cpp<#) cpp<#)
:clone (clone-name-ix-vector "Label")) :clone (clone-name-ix-vector "Label"))
@ -1340,10 +1340,10 @@ cpp<#
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage); slk::Load(&self->${member}[i], reader, storage);
} }
cpp<#) cpp<#)
:clone (clone-name-ix-vector "EdgeType")) :clone (clone-name-ix-vector "EdgeType"))
@ -1364,13 +1364,13 @@ cpp<#
:documentation "Filter lambda for variable length expands. Can have an empty expression, but identifiers must be valid, because an optimization pass may inline other expressions into this lambda." :documentation "Filter lambda for variable length expands. Can have an empty expression, but identifiers must be valid, because an optimization pass may inline other expressions into this lambda."
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
memgraph::slk::Load(&self->${member}, reader, storage); slk::Load(&self->${member}, reader, storage);
cpp<#)) cpp<#))
(weight-lambda "Lambda" :scope :public (weight-lambda "Lambda" :scope :public
:documentation "Used in weighted shortest path. It must have valid expressions and identifiers. In all other expand types, it is empty." :documentation "Used in weighted shortest path. It must have valid expressions and identifiers. In all other expand types, it is empty."
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
memgraph::slk::Load(&self->${member}, reader, storage); slk::Load(&self->${member}, reader, storage);
cpp<#)) cpp<#))
(total-weight "Identifier *" :initval "nullptr" :scope :public (total-weight "Identifier *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer :slk-save #'slk-save-ast-pointer
@ -1457,7 +1457,7 @@ cpp<#
(:serialize (:slk)) (:serialize (:slk))
(:clone)) (:clone))
(lcp:define-class pattern (tree "utils::Visitable<HierarchicalTreeVisitor>") (lcp:define-class pattern (tree "::utils::Visitable<HierarchicalTreeVisitor>")
((identifier "Identifier *" :initval "nullptr" :scope :public ((identifier "Identifier *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer :slk-save #'slk-save-ast-pointer
:slk-load (slk-load-ast-pointer "Identifier")) :slk-load (slk-load-ast-pointer "Identifier"))
@ -1491,7 +1491,7 @@ cpp<#
(:clone :ignore-other-base-classes t) (:clone :ignore-other-base-classes t)
(:type-info :ignore-other-base-classes t)) (:type-info :ignore-other-base-classes t))
(lcp:define-class clause (tree "utils::Visitable<HierarchicalTreeVisitor>") (lcp:define-class clause (tree "::utils::Visitable<HierarchicalTreeVisitor>")
() ()
(:abstractp t) (:abstractp t)
(:public (:public
@ -1508,7 +1508,7 @@ cpp<#
(:clone :ignore-other-base-classes t) (:clone :ignore-other-base-classes t)
(:type-info :ignore-other-base-classes t)) (:type-info :ignore-other-base-classes t))
(lcp:define-class single-query (tree "utils::Visitable<HierarchicalTreeVisitor>") (lcp:define-class single-query (tree "::utils::Visitable<HierarchicalTreeVisitor>")
((clauses "std::vector<Clause *>" ((clauses "std::vector<Clause *>"
:scope :public :scope :public
:slk-save #'slk-save-ast-vector :slk-save #'slk-save-ast-vector
@ -1536,7 +1536,7 @@ cpp<#
(:clone :ignore-other-base-classes t) (:clone :ignore-other-base-classes t)
(:type-info :ignore-other-base-classes t)) (:type-info :ignore-other-base-classes t))
(lcp:define-class cypher-union (tree "utils::Visitable<HierarchicalTreeVisitor>") (lcp:define-class cypher-union (tree "::utils::Visitable<HierarchicalTreeVisitor>")
((single-query "SingleQuery *" :initval "nullptr" :scope :public ((single-query "SingleQuery *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer :slk-save #'slk-save-ast-pointer
:slk-load (slk-load-ast-pointer "SingleQuery")) :slk-load (slk-load-ast-pointer "SingleQuery"))
@ -1573,7 +1573,7 @@ cpp<#
(:clone :ignore-other-base-classes t) (:clone :ignore-other-base-classes t)
(:type-info :ignore-other-base-classes t)) (:type-info :ignore-other-base-classes t))
(lcp:define-class query (tree "utils::Visitable<QueryVisitor<void>>") (lcp:define-class query (tree "::utils::Visitable<QueryVisitor<void>>")
() ()
(:abstractp t) (:abstractp t)
(:public (:public
@ -1660,7 +1660,7 @@ cpp<#
(label "LabelIx" :scope :public (label "LabelIx" :scope :public
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
memgraph::slk::Load(&self->${member}, reader, storage); slk::Load(&self->${member}, reader, storage);
cpp<#) cpp<#)
:clone (lambda (source dest) :clone (lambda (source dest)
#>cpp #>cpp
@ -1670,10 +1670,10 @@ cpp<#
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage); slk::Load(&self->${member}[i], reader, storage);
} }
cpp<#) cpp<#)
:clone (clone-name-ix-vector "Property"))) :clone (clone-name-ix-vector "Property")))
@ -1844,10 +1844,10 @@ cpp<#
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage); slk::Load(&self->${member}[i], reader, storage);
} }
cpp<#) cpp<#)
:documentation "Expressions used for ordering the results.") :documentation "Expressions used for ordering the results.")
@ -1867,7 +1867,7 @@ cpp<#
((body "ReturnBody" :scope :public ((body "ReturnBody" :scope :public
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
memgraph::slk::Load(&self->${member}, reader, storage); slk::Load(&self->${member}, reader, storage);
cpp<#))) cpp<#)))
(:public (:public
#>cpp #>cpp
@ -1911,7 +1911,7 @@ cpp<#
((body "ReturnBody" :scope :public ((body "ReturnBody" :scope :public
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
memgraph::slk::Load(&self->${member}, reader, storage); slk::Load(&self->${member}, reader, storage);
cpp<#)) cpp<#))
(where "Where *" :initval "nullptr" :scope :public (where "Where *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer :slk-save #'slk-save-ast-pointer
@ -2056,10 +2056,10 @@ cpp<#
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage); slk::Load(&self->${member}[i], reader, storage);
} }
cpp<#) cpp<#)
:clone (clone-name-ix-vector "Label"))) :clone (clone-name-ix-vector "Label")))
@ -2121,10 +2121,10 @@ cpp<#
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage); slk::Load(&self->${member}[i], reader, storage);
} }
cpp<#) cpp<#)
:clone (clone-name-ix-vector "Label"))) :clone (clone-name-ix-vector "Label")))
@ -2314,7 +2314,7 @@ cpp<#
(label "LabelIx" :scope :public (label "LabelIx" :scope :public
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
memgraph::slk::Load(&self->${member}, reader, storage); slk::Load(&self->${member}, reader, storage);
cpp<#) cpp<#)
:clone (lambda (source dest) :clone (lambda (source dest)
#>cpp #>cpp
@ -2324,10 +2324,10 @@ cpp<#
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
size_t size = 0; size_t size = 0;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
self->${member}.resize(size); self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage); slk::Load(&self->${member}[i], reader, storage);
} }
cpp<#) cpp<#)
:clone (clone-name-ix-vector "Property"))) :clone (clone-name-ix-vector "Property")))
@ -2342,7 +2342,7 @@ cpp<#
(constraint "Constraint" :scope :public (constraint "Constraint" :scope :public
:slk-load (lambda (member) :slk-load (lambda (member)
#>cpp #>cpp
memgraph::slk::Load(&self->${member}, reader, storage); slk::Load(&self->${member}, reader, storage);
cpp<#))) cpp<#)))
(:public (:public
(lcp:define-enum action-type (lcp:define-enum action-type

View File

@ -22,8 +22,7 @@
#include "utils/exceptions.hpp" #include "utils/exceptions.hpp"
#include "utils/logging.hpp" #include "utils/logging.hpp"
namespace memgraph::query { namespace memgraph::query::frontend {
namespace frontend {
using antlropencypher::MemgraphCypher; using antlropencypher::MemgraphCypher;
@ -879,5 +878,4 @@ class CypherMainVisitor : public antlropencypher::MemgraphCypherBaseVisitor {
QueryInfo query_info_; QueryInfo query_info_;
}; };
} // namespace frontend } // namespace memgraph::query::frontend
} // namespace memgraph::query

View File

@ -18,9 +18,7 @@
#include "query/frontend/opencypher/generated/MemgraphCypher.h" #include "query/frontend/opencypher/generated/MemgraphCypher.h"
#include "query/frontend/opencypher/generated/MemgraphCypherLexer.h" #include "query/frontend/opencypher/generated/MemgraphCypherLexer.h"
namespace memgraph::query { namespace memgraph::query::frontend::opencypher {
namespace frontend {
namespace opencypher {
/** /**
* Generates openCypher AST * Generates openCypher AST
@ -38,7 +36,7 @@ class Parser {
parser_.addErrorListener(&error_listener_); parser_.addErrorListener(&error_listener_);
tree_ = parser_.cypher(); tree_ = parser_.cypher();
if (parser_.getNumberOfSyntaxErrors()) { if (parser_.getNumberOfSyntaxErrors()) {
throw memgraph::query::SyntaxException(error_listener_.error_); throw query::SyntaxException(error_listener_.error_);
} }
} }
@ -67,6 +65,4 @@ class Parser {
antlropencypher::MemgraphCypher parser_{&tokens_}; antlropencypher::MemgraphCypher parser_{&tokens_};
antlr4::tree::ParseTree *tree_ = nullptr; antlr4::tree::ParseTree *tree_ = nullptr;
}; };
} // namespace opencypher } // namespace memgraph::query::frontend::opencypher
} // namespace frontend
} // namespace memgraph::query

View File

@ -394,7 +394,7 @@ TypedValue Properties(const TypedValue *args, int64_t nargs, const FunctionConte
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get properties from a deleted object."); throw QueryRuntimeException("Trying to get properties from a deleted object.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get properties from an object that doesn't exist."); throw query::QueryRuntimeException("Trying to get properties from an object that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
@ -448,7 +448,7 @@ size_t UnwrapDegreeResult(storage::Result<size_t> maybe_degree) {
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get degree of a deleted node."); throw QueryRuntimeException("Trying to get degree of a deleted node.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get degree of a node that doesn't exist."); throw query::QueryRuntimeException("Trying to get degree of a node that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
@ -599,7 +599,7 @@ TypedValue Keys(const TypedValue *args, int64_t nargs, const FunctionContext &ct
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get keys from a deleted object."); throw QueryRuntimeException("Trying to get keys from a deleted object.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get keys from an object that doesn't exist."); throw query::QueryRuntimeException("Trying to get keys from an object that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
@ -632,7 +632,7 @@ TypedValue Labels(const TypedValue *args, int64_t nargs, const FunctionContext &
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get labels from a deleted node."); throw QueryRuntimeException("Trying to get labels from a deleted node.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get labels from a node that doesn't exist."); throw query::QueryRuntimeException("Trying to get labels from a node that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:

View File

@ -394,7 +394,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to access labels on a deleted node."); throw QueryRuntimeException("Trying to access labels on a deleted node.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to access labels from a node that doesn't exist."); throw query::QueryRuntimeException("Trying to access labels from a node that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
@ -705,7 +705,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get a property from a deleted object."); throw QueryRuntimeException("Trying to get a property from a deleted object.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get a property from an object that doesn't exist."); throw query::QueryRuntimeException("Trying to get a property from an object that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
@ -732,7 +732,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get a property from a deleted object."); throw QueryRuntimeException("Trying to get a property from a deleted object.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get a property from an object that doesn't exist."); throw query::QueryRuntimeException("Trying to get a property from an object that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:

View File

@ -103,7 +103,7 @@ TypedValue EvaluateOptionalExpression(Expression *expression, ExpressionEvaluato
} }
template <typename TResult> template <typename TResult>
std::optional<TResult> GetOptionalValue(memgraph::query::Expression *expression, ExpressionEvaluator &evaluator) { std::optional<TResult> GetOptionalValue(query::Expression *expression, ExpressionEvaluator &evaluator) {
if (expression != nullptr) { if (expression != nullptr) {
auto int_value = expression->Accept(evaluator); auto int_value = expression->Accept(evaluator);
MG_ASSERT(int_value.IsNull() || int_value.IsInt()); MG_ASSERT(int_value.IsNull() || int_value.IsInt());
@ -114,8 +114,7 @@ std::optional<TResult> GetOptionalValue(memgraph::query::Expression *expression,
return {}; return {};
}; };
std::optional<std::string> GetOptionalStringValue(memgraph::query::Expression *expression, std::optional<std::string> GetOptionalStringValue(query::Expression *expression, ExpressionEvaluator &evaluator) {
ExpressionEvaluator &evaluator) {
if (expression != nullptr) { if (expression != nullptr) {
auto value = expression->Accept(evaluator); auto value = expression->Accept(evaluator);
MG_ASSERT(value.IsNull() || value.IsString()); MG_ASSERT(value.IsNull() || value.IsString());
@ -126,7 +125,7 @@ std::optional<std::string> GetOptionalStringValue(memgraph::query::Expression *e
return {}; return {};
}; };
class ReplQueryHandler final : public memgraph::query::ReplicationQueryHandler { class ReplQueryHandler final : public query::ReplicationQueryHandler {
public: public:
explicit ReplQueryHandler(storage::Storage *db) : db_(db) {} explicit ReplQueryHandler(storage::Storage *db) : db_(db) {}
@ -142,7 +141,7 @@ class ReplQueryHandler final : public memgraph::query::ReplicationQueryHandler {
throw QueryRuntimeException("Port number invalid!"); throw QueryRuntimeException("Port number invalid!");
} }
if (!db_->SetReplicaRole( if (!db_->SetReplicaRole(
io::network::Endpoint(memgraph::query::kDefaultReplicationServerIp, static_cast<uint16_t>(*port)))) { io::network::Endpoint(query::kDefaultReplicationServerIp, static_cast<uint16_t>(*port)))) {
throw QueryRuntimeException("Couldn't set role to replica!"); throw QueryRuntimeException("Couldn't set role to replica!");
} }
} }
@ -180,7 +179,7 @@ class ReplQueryHandler final : public memgraph::query::ReplicationQueryHandler {
} }
auto maybe_ip_and_port = auto maybe_ip_and_port =
io::network::Endpoint::ParseSocketOrIpAddress(socket_address, memgraph::query::kDefaultReplicationPort); io::network::Endpoint::ParseSocketOrIpAddress(socket_address, query::kDefaultReplicationPort);
if (maybe_ip_and_port) { if (maybe_ip_and_port) {
auto [ip, port] = *maybe_ip_and_port; auto [ip, port] = *maybe_ip_and_port;
auto ret = auto ret =
@ -588,15 +587,14 @@ Callback::CallbackFunction GetKafkaCreateCallback(StreamQuery *stream_query, Exp
std::string bootstrap = bootstrap_servers std::string bootstrap = bootstrap_servers
? std::move(*bootstrap_servers) ? std::move(*bootstrap_servers)
: std::string{interpreter_context->config.default_kafka_bootstrap_servers}; : std::string{interpreter_context->config.default_kafka_bootstrap_servers};
interpreter_context->streams.Create<memgraph::query::stream::KafkaStream>( interpreter_context->streams.Create<query::stream::KafkaStream>(stream_name,
stream_name, {.common_info = std::move(common_stream_info),
{.common_info = std::move(common_stream_info), .topics = std::move(topic_names),
.topics = std::move(topic_names), .consumer_group = std::move(consumer_group),
.consumer_group = std::move(consumer_group), .bootstrap_servers = std::move(bootstrap),
.bootstrap_servers = std::move(bootstrap), .configs = std::move(configs),
.configs = std::move(configs), .credentials = std::move(credentials)},
.credentials = std::move(credentials)}, std::move(owner));
std::move(owner));
return std::vector<std::vector<TypedValue>>{}; return std::vector<std::vector<TypedValue>>{};
}; };
@ -616,7 +614,7 @@ Callback::CallbackFunction GetPulsarCreateCallback(StreamQuery *stream_query, Ex
owner = StringPointerToOptional(username)]() mutable { owner = StringPointerToOptional(username)]() mutable {
std::string url = std::string url =
service_url ? std::move(*service_url) : std::string{interpreter_context->config.default_pulsar_service_url}; service_url ? std::move(*service_url) : std::string{interpreter_context->config.default_pulsar_service_url};
interpreter_context->streams.Create<memgraph::query::stream::PulsarStream>( interpreter_context->streams.Create<query::stream::PulsarStream>(
stream_name, stream_name,
{.common_info = std::move(common_stream_info), .topics = std::move(topic_names), .service_url = std::move(url)}, {.common_info = std::move(common_stream_info), .topics = std::move(topic_names), .service_url = std::move(url)},
std::move(owner)); std::move(owner));

View File

@ -180,7 +180,7 @@ struct InterpreterContext {
std::atomic<bool> is_shutting_down{false}; std::atomic<bool> is_shutting_down{false};
AuthQueryHandler *auth{nullptr}; AuthQueryHandler *auth{nullptr};
memgraph::query::AuthChecker *auth_checker{nullptr}; AuthChecker *auth_checker{nullptr};
utils::SkipList<QueryCacheEntry> ast_cache; utils::SkipList<QueryCacheEntry> ast_cache;
utils::SkipList<PlanCacheEntry> plan_cache; utils::SkipList<PlanCacheEntry> plan_cache;
@ -190,7 +190,7 @@ struct InterpreterContext {
const InterpreterConfig config; const InterpreterConfig config;
memgraph::query::stream::Streams streams; query::stream::Streams streams;
}; };
/// Function that is used to tell all active interpreters that they should stop /// Function that is used to tell all active interpreters that they should stop
@ -208,7 +208,7 @@ class Interpreter final {
struct PrepareResult { struct PrepareResult {
std::vector<std::string> headers; std::vector<std::string> headers;
std::vector<memgraph::query::AuthQuery::Privilege> privileges; std::vector<query::AuthQuery::Privilege> privileges;
std::optional<int> qid; std::optional<int> qid;
}; };
@ -218,7 +218,7 @@ class Interpreter final {
* Preparing a query means to preprocess the query and save it for * Preparing a query means to preprocess the query and save it for
* future calls of `Pull`. * future calls of `Pull`.
* *
* @throw memgraph::query::QueryException * @throw query::QueryException
*/ */
PrepareResult Prepare(const std::string &query, const std::map<std::string, storage::PropertyValue> &params, PrepareResult Prepare(const std::string &query, const std::map<std::string, storage::PropertyValue> &params,
const std::string *username); const std::string *username);
@ -237,7 +237,7 @@ class Interpreter final {
* further. * further.
* *
* @throw utils::BasicException * @throw utils::BasicException
* @throw memgraph::query::QueryException * @throw query::QueryException
*/ */
template <typename TStream> template <typename TStream>
std::map<std::string, TypedValue> PullAll(TStream *result_stream) { std::map<std::string, TypedValue> PullAll(TStream *result_stream) {
@ -259,7 +259,7 @@ class Interpreter final {
* otherwise the last query should be used. * otherwise the last query should be used.
* *
* @throw utils::BasicException * @throw utils::BasicException
* @throw memgraph::query::QueryException * @throw query::QueryException
*/ */
template <typename TStream> template <typename TStream>
std::map<std::string, TypedValue> Pull(TStream *result_stream, std::optional<int> n = {}, std::map<std::string, TypedValue> Pull(TStream *result_stream, std::optional<int> n = {},

View File

@ -184,7 +184,7 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor {
// if the Unwind expression is a list literal, we can deduce cardinality // if the Unwind expression is a list literal, we can deduce cardinality
// exactly, otherwise we approximate // exactly, otherwise we approximate
double unwind_value; double unwind_value;
if (auto *literal = utils::Downcast<memgraph::query::ListLiteral>(unwind.input_expression_)) if (auto *literal = utils::Downcast<query::ListLiteral>(unwind.input_expression_))
unwind_value = literal->elements_.size(); unwind_value = literal->elements_.size();
else else
unwind_value = MiscParam::kUnwindNoLiteral; unwind_value = MiscParam::kUnwindNoLiteral;

View File

@ -620,7 +620,7 @@ auto UnwrapEdgesResult(storage::Result<TEdges> &&result) {
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get relationships of a deleted node."); throw QueryRuntimeException("Trying to get relationships of a deleted node.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get relationships from a node that doesn't exist."); throw query::QueryRuntimeException("Trying to get relationships from a node that doesn't exist.");
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
@ -1053,7 +1053,7 @@ class ExpandVariableCursor : public Cursor {
} }
}; };
class STShortestPathCursor : public memgraph::query::plan::Cursor { class STShortestPathCursor : public query::plan::Cursor {
public: public:
STShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem) STShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem)
: self_(self), input_cursor_(self_.input()->MakeCursor(mem)) { : self_(self), input_cursor_(self_.input()->MakeCursor(mem)) {
@ -1271,7 +1271,7 @@ class STShortestPathCursor : public memgraph::query::plan::Cursor {
} }
}; };
class SingleSourceShortestPathCursor : public memgraph::query::plan::Cursor { class SingleSourceShortestPathCursor : public query::plan::Cursor {
public: public:
SingleSourceShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem) SingleSourceShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem)
: self_(self), : self_(self),
@ -1427,7 +1427,7 @@ class SingleSourceShortestPathCursor : public memgraph::query::plan::Cursor {
utils::pmr::vector<std::pair<EdgeAccessor, VertexAccessor>> to_visit_next_; utils::pmr::vector<std::pair<EdgeAccessor, VertexAccessor>> to_visit_next_;
}; };
class ExpandWeightedShortestPathCursor : public memgraph::query::plan::Cursor { class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
public: public:
ExpandWeightedShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem) ExpandWeightedShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem)
: self_(self), : self_(self),
@ -1729,7 +1729,7 @@ class ConstructNamedPathCursor : public Cursor {
} }
DMG_ASSERT(start_vertex.IsVertex(), "First named path element must be a vertex"); DMG_ASSERT(start_vertex.IsVertex(), "First named path element must be a vertex");
memgraph::query::Path path(start_vertex.ValueVertex(), pull_memory); query::Path path(start_vertex.ValueVertex(), pull_memory);
// If the last path element symbol was for an edge list, then // If the last path element symbol was for an edge list, then
// the next symbol is a vertex and it should not append to the path // the next symbol is a vertex and it should not append to the path
@ -1966,7 +1966,7 @@ bool Delete::DeleteCursor::Pull(Frame &frame, ExecutionContext &context) {
} }
context.trigger_context_collector->RegisterDeletedObject((*res)->first); context.trigger_context_collector->RegisterDeletedObject((*res)->first);
if (!context.trigger_context_collector->ShouldRegisterDeletedObject<memgraph::query::EdgeAccessor>()) { if (!context.trigger_context_collector->ShouldRegisterDeletedObject<query::EdgeAccessor>()) {
return; return;
} }
for (const auto &edge : (*res)->second) { for (const auto &edge : (*res)->second) {
@ -2149,7 +2149,7 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr
case storage::Error::DELETED_OBJECT: case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get properties from a deleted object."); throw QueryRuntimeException("Trying to get properties from a deleted object.");
case storage::Error::NONEXISTENT_OBJECT: case storage::Error::NONEXISTENT_OBJECT:
throw memgraph::query::QueryRuntimeException("Trying to get properties from an object that doesn't exist."); throw query::QueryRuntimeException("Trying to get properties from an object that doesn't exist.");
case storage::Error::SERIALIZATION_ERROR: case storage::Error::SERIALIZATION_ERROR:
case storage::Error::VERTEX_HAS_EDGES: case storage::Error::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED: case storage::Error::PROPERTIES_DISABLED:
@ -3721,7 +3721,7 @@ void CallCustomProcedure(const std::string_view &fully_qualified_procedure_name,
for (size_t i = 0; i < args.size(); ++i) { for (size_t i = 0; i < args.size(); ++i) {
auto arg = args[i]->Accept(*evaluator); auto arg = args[i]->Accept(*evaluator);
std::string_view name; std::string_view name;
const memgraph::query::procedure::CypherType *type{nullptr}; const query::procedure::CypherType *type{nullptr};
if (proc.args.size() > i) { if (proc.args.size() > i) {
name = proc.args[i].first; name = proc.args[i].first;
type = proc.args[i].second; type = proc.args[i].second;

View File

@ -76,12 +76,12 @@ class Cursor {
}; };
/// unique_ptr to Cursor managed with a custom deleter. /// unique_ptr to Cursor managed with a custom deleter.
/// This allows us to use memgraph::utils::MemoryResource for allocation. /// This allows us to use utils::MemoryResource for allocation.
using UniqueCursorPtr = std::unique_ptr<Cursor, std::function<void(Cursor *)>>; using UniqueCursorPtr = std::unique_ptr<Cursor, std::function<void(Cursor *)>>;
template <class TCursor, class... TArgs> template <class TCursor, class... TArgs>
std::unique_ptr<Cursor, std::function<void(Cursor *)>> MakeUniqueCursorPtr( std::unique_ptr<Cursor, std::function<void(Cursor *)>> MakeUniqueCursorPtr(
memgraph::utils::Allocator<TCursor> allocator, TArgs &&... args) { utils::Allocator<TCursor> allocator, TArgs &&... args) {
auto *ptr = allocator.allocate(1); auto *ptr = allocator.allocate(1);
try { try {
auto *cursor = new (ptr) TCursor(std::forward<TArgs>(args)...); auto *cursor = new (ptr) TCursor(std::forward<TArgs>(args)...);
@ -132,7 +132,7 @@ class Cartesian;
class CallProcedure; class CallProcedure;
class LoadCsv; class LoadCsv;
using LogicalOperatorCompositeVisitor = memgraph::utils::CompositeVisitor< using LogicalOperatorCompositeVisitor = utils::CompositeVisitor<
Once, CreateNode, CreateExpand, ScanAll, ScanAllByLabel, Once, CreateNode, CreateExpand, ScanAll, ScanAllByLabel,
ScanAllByLabelPropertyRange, ScanAllByLabelPropertyValue, ScanAllByLabelPropertyRange, ScanAllByLabelPropertyValue,
ScanAllByLabelProperty, ScanAllById, ScanAllByLabelProperty, ScanAllById,
@ -141,7 +141,7 @@ using LogicalOperatorCompositeVisitor = memgraph::utils::CompositeVisitor<
EdgeUniquenessFilter, Accumulate, Aggregate, Skip, Limit, OrderBy, Merge, EdgeUniquenessFilter, Accumulate, Aggregate, Skip, Limit, OrderBy, Merge,
Optional, Unwind, Distinct, Union, Cartesian, CallProcedure, LoadCsv>; Optional, Unwind, Distinct, Union, Cartesian, CallProcedure, LoadCsv>;
using LogicalOperatorLeafVisitor = memgraph::utils::LeafVisitor<Once>; using LogicalOperatorLeafVisitor = utils::LeafVisitor<Once>;
/** /**
* @brief Base class for hierarhical visitors of @c LogicalOperator class * @brief Base class for hierarhical visitors of @c LogicalOperator class
@ -158,7 +158,7 @@ class HierarchicalLogicalOperatorVisitor
}; };
cpp<# cpp<#
(lcp:define-class logical-operator ("memgraph::utils::Visitable<HierarchicalLogicalOperatorVisitor>") (lcp:define-class logical-operator ("utils::Visitable<HierarchicalLogicalOperatorVisitor>")
() ()
(:abstractp t) (:abstractp t)
(:documentation (:documentation
@ -173,10 +173,10 @@ can serve as inputs to others and thus a sequence of operations is formed.")
/** Construct a @c Cursor which is used to run this operator. /** Construct a @c Cursor which is used to run this operator.
* *
* @param memgraph::utils::MemoryResource Memory resource used for allocations during * @param utils::MemoryResource Memory resource used for allocations during
* the lifetime of the returned Cursor. * the lifetime of the returned Cursor.
*/ */
virtual UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const = 0; virtual UniqueCursorPtr MakeCursor(utils::MemoryResource *) const = 0;
/** Return @c Symbol vector where the query results will be stored. /** Return @c Symbol vector where the query results will be stored.
* *
@ -312,7 +312,7 @@ and false on every following Pull.")
#>cpp #>cpp
Once(std::vector<Symbol> symbols = {}) : symbols_{std::move(symbols)} {} Once(std::vector<Symbol> symbols = {}) : symbols_{std::move(symbols)} {}
DEFVISITABLE(HierarchicalLogicalOperatorVisitor); DEFVISITABLE(HierarchicalLogicalOperatorVisitor);
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override { std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override {
return symbols_; return symbols_;
} }
@ -445,7 +445,7 @@ a preceding `MATCH`), or multiple nodes (`MATCH ... CREATE` or
CreateNode(const std::shared_ptr<LogicalOperator> &input, CreateNode(const std::shared_ptr<LogicalOperator> &input,
const NodeCreationInfo &node_info); const NodeCreationInfo &node_info);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -458,7 +458,7 @@ a preceding `MATCH`), or multiple nodes (`MATCH ... CREATE` or
#>cpp #>cpp
class CreateNodeCursor : public Cursor { class CreateNodeCursor : public Cursor {
public: public:
CreateNodeCursor(const CreateNode &, memgraph::utils::MemoryResource *); CreateNodeCursor(const CreateNode &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -560,7 +560,7 @@ chained in cases when longer paths need creating.
const std::shared_ptr<LogicalOperator> &input, const std::shared_ptr<LogicalOperator> &input,
Symbol input_symbol, bool existing_node); Symbol input_symbol, bool existing_node);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -573,7 +573,7 @@ chained in cases when longer paths need creating.
#>cpp #>cpp
class CreateExpandCursor : public Cursor { class CreateExpandCursor : public Cursor {
public: public:
CreateExpandCursor(const CreateExpand &, memgraph::utils::MemoryResource *); CreateExpandCursor(const CreateExpand &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -624,7 +624,7 @@ with a constructor argument.
ScanAll(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol, ScanAll(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
storage::View view = storage::View::OLD); storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -652,7 +652,7 @@ given label.
Symbol output_symbol, storage::LabelId label, Symbol output_symbol, storage::LabelId label,
storage::View view = storage::View::OLD); storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#) cpp<#)
(:serialize (:slk)) (:serialize (:slk))
(:clone)) (:clone))
@ -666,10 +666,10 @@ given label.
uint8_t bound_type; uint8_t bound_type;
const auto &bound = *self.${member}; const auto &bound = *self.${member};
switch (bound.type()) { switch (bound.type()) {
case memgraph::utils::BoundType::INCLUSIVE: case utils::BoundType::INCLUSIVE:
bound_type = 0; bound_type = 0;
break; break;
case memgraph::utils::BoundType::EXCLUSIVE: case utils::BoundType::EXCLUSIVE:
bound_type = 1; bound_type = 1;
break; break;
} }
@ -687,26 +687,26 @@ given label.
} }
uint8_t bound_type_value; uint8_t bound_type_value;
slk::Load(&bound_type_value, reader); slk::Load(&bound_type_value, reader);
memgraph::utils::BoundType bound_type; utils::BoundType bound_type;
switch (bound_type_value) { switch (bound_type_value) {
case static_cast<uint8_t>(0): case static_cast<uint8_t>(0):
bound_type = memgraph::utils::BoundType::INCLUSIVE; bound_type = utils::BoundType::INCLUSIVE;
break; break;
case static_cast<uint8_t>(1): case static_cast<uint8_t>(1):
bound_type = memgraph::utils::BoundType::EXCLUSIVE; bound_type = utils::BoundType::EXCLUSIVE;
break; break;
default: default:
throw slk::SlkDecodeException("Loading unknown BoundType"); throw slk::SlkDecodeException("Loading unknown BoundType");
} }
auto *value = query::LoadAstPointer<query::Expression>( auto *value = query::LoadAstPointer<query::Expression>(
&helper->ast_storage, reader); &helper->ast_storage, reader);
self->${member}.emplace(memgraph::utils::Bound<query::Expression *>(value, bound_type)); self->${member}.emplace(utils::Bound<query::Expression *>(value, bound_type));
cpp<#) cpp<#)
(defun clone-optional-bound (source dest) (defun clone-optional-bound (source dest)
#>cpp #>cpp
if (${source}) { if (${source}) {
${dest}.emplace(memgraph::utils::Bound<Expression *>( ${dest}.emplace(utils::Bound<Expression *>(
${source}->value()->Clone(storage), ${source}->value()->Clone(storage),
${source}->type())); ${source}->type()));
} else { } else {
@ -736,7 +736,7 @@ property value which is inside a range (inclusive or exlusive).
(:public (:public
#>cpp #>cpp
/** Bound with expression which when evaluated produces the bound value. */ /** Bound with expression which when evaluated produces the bound value. */
using Bound = memgraph::utils::Bound<Expression *>; using Bound = utils::Bound<Expression *>;
ScanAllByLabelPropertyRange() {} ScanAllByLabelPropertyRange() {}
/** /**
* Constructs the operator for given label and property value in range * Constructs the operator for given label and property value in range
@ -761,7 +761,7 @@ property value which is inside a range (inclusive or exlusive).
storage::View view = storage::View::OLD); storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#) cpp<#)
(:serialize (:slk)) (:serialize (:slk))
(:clone)) (:clone))
@ -801,7 +801,7 @@ property value.
storage::View view = storage::View::OLD); storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#) cpp<#)
(:serialize (:slk)) (:serialize (:slk))
(:clone)) (:clone))
@ -830,7 +830,7 @@ given label and property.
const std::string &property_name, const std::string &property_name,
storage::View view = storage::View::OLD); storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#) cpp<#)
(:serialize (:slk)) (:serialize (:slk))
(:clone)) (:clone))
@ -851,7 +851,7 @@ given label and property.
storage::View view = storage::View::OLD); storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#) cpp<#)
(:serialize (:slk)) (:serialize (:slk))
(:clone)) (:clone))
@ -916,7 +916,7 @@ pulled.")
Expand() {} Expand() {}
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -927,7 +927,7 @@ pulled.")
class ExpandCursor : public Cursor { class ExpandCursor : public Cursor {
public: public:
ExpandCursor(const Expand &, memgraph::utils::MemoryResource *); ExpandCursor(const Expand &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1065,7 +1065,7 @@ pulled.")
std::optional<Symbol> total_weight); std::optional<Symbol> total_weight);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1103,7 +1103,7 @@ pulled.")
path_symbol_(path_symbol), path_symbol_(path_symbol),
path_elements_(path_elements) {} path_elements_(path_elements) {}
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1135,7 +1135,7 @@ a boolean value.")
Filter(const std::shared_ptr<LogicalOperator> &input_, Filter(const std::shared_ptr<LogicalOperator> &input_,
Expression *expression_); Expression *expression_);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1148,7 +1148,7 @@ a boolean value.")
#>cpp #>cpp
class FilterCursor : public Cursor { class FilterCursor : public Cursor {
public: public:
FilterCursor(const Filter &, memgraph::utils::MemoryResource *); FilterCursor(const Filter &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1185,7 +1185,7 @@ RETURN clause) the Produce's pull succeeds exactly once.")
Produce(const std::shared_ptr<LogicalOperator> &input, Produce(const std::shared_ptr<LogicalOperator> &input,
const std::vector<NamedExpression *> &named_expressions); const std::vector<NamedExpression *> &named_expressions);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -1199,7 +1199,7 @@ RETURN clause) the Produce's pull succeeds exactly once.")
#>cpp #>cpp
class ProduceCursor : public Cursor { class ProduceCursor : public Cursor {
public: public:
ProduceCursor(const Produce &, memgraph::utils::MemoryResource *); ProduceCursor(const Produce &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1233,7 +1233,7 @@ Has a flag for using DETACH DELETE when deleting vertices.")
Delete(const std::shared_ptr<LogicalOperator> &input_, Delete(const std::shared_ptr<LogicalOperator> &input_,
const std::vector<Expression *> &expressions, bool detach_); const std::vector<Expression *> &expressions, bool detach_);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1246,7 +1246,7 @@ Has a flag for using DETACH DELETE when deleting vertices.")
#>cpp #>cpp
class DeleteCursor : public Cursor { class DeleteCursor : public Cursor {
public: public:
DeleteCursor(const Delete &, memgraph::utils::MemoryResource *); DeleteCursor(const Delete &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1283,7 +1283,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).")
storage::PropertyId property, PropertyLookup *lhs, storage::PropertyId property, PropertyLookup *lhs,
Expression *rhs); Expression *rhs);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1296,7 +1296,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).")
#>cpp #>cpp
class SetPropertyCursor : public Cursor { class SetPropertyCursor : public Cursor {
public: public:
SetPropertyCursor(const SetProperty &, memgraph::utils::MemoryResource *); SetPropertyCursor(const SetProperty &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1342,7 +1342,7 @@ that the old properties are discarded and replaced with new ones.")
SetProperties(const std::shared_ptr<LogicalOperator> &input, SetProperties(const std::shared_ptr<LogicalOperator> &input,
Symbol input_symbol, Expression *rhs, Op op); Symbol input_symbol, Expression *rhs, Op op);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1355,7 +1355,7 @@ that the old properties are discarded and replaced with new ones.")
#>cpp #>cpp
class SetPropertiesCursor : public Cursor { class SetPropertiesCursor : public Cursor {
public: public:
SetPropertiesCursor(const SetProperties &, memgraph::utils::MemoryResource *); SetPropertiesCursor(const SetProperties &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1385,7 +1385,7 @@ It does NOT remove labels that are already set on that Vertex.")
SetLabels(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol, SetLabels(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
const std::vector<storage::LabelId> &labels); const std::vector<storage::LabelId> &labels);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1398,7 +1398,7 @@ It does NOT remove labels that are already set on that Vertex.")
#>cpp #>cpp
class SetLabelsCursor : public Cursor { class SetLabelsCursor : public Cursor {
public: public:
SetLabelsCursor(const SetLabels &, memgraph::utils::MemoryResource *); SetLabelsCursor(const SetLabels &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1428,7 +1428,7 @@ It does NOT remove labels that are already set on that Vertex.")
RemoveProperty(const std::shared_ptr<LogicalOperator> &input, RemoveProperty(const std::shared_ptr<LogicalOperator> &input,
storage::PropertyId property, PropertyLookup *lhs); storage::PropertyId property, PropertyLookup *lhs);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1441,7 +1441,7 @@ It does NOT remove labels that are already set on that Vertex.")
#>cpp #>cpp
class RemovePropertyCursor : public Cursor { class RemovePropertyCursor : public Cursor {
public: public:
RemovePropertyCursor(const RemoveProperty &, memgraph::utils::MemoryResource *); RemovePropertyCursor(const RemoveProperty &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1471,7 +1471,7 @@ If a label does not exist on a Vertex, nothing happens.")
RemoveLabels(const std::shared_ptr<LogicalOperator> &input, RemoveLabels(const std::shared_ptr<LogicalOperator> &input,
Symbol input_symbol, const std::vector<storage::LabelId> &labels); Symbol input_symbol, const std::vector<storage::LabelId> &labels);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1484,7 +1484,7 @@ If a label does not exist on a Vertex, nothing happens.")
#>cpp #>cpp
class RemoveLabelsCursor : public Cursor { class RemoveLabelsCursor : public Cursor {
public: public:
RemoveLabelsCursor(const RemoveLabels &, memgraph::utils::MemoryResource *); RemoveLabelsCursor(const RemoveLabels &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1525,7 +1525,7 @@ edge lists).")
Symbol expand_symbol, Symbol expand_symbol,
const std::vector<Symbol> &previous_symbols); const std::vector<Symbol> &previous_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1539,7 +1539,7 @@ edge lists).")
class EdgeUniquenessFilterCursor : public Cursor { class EdgeUniquenessFilterCursor : public Cursor {
public: public:
EdgeUniquenessFilterCursor(const EdgeUniquenessFilter &, EdgeUniquenessFilterCursor(const EdgeUniquenessFilter &,
memgraph::utils::MemoryResource *); utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1592,7 +1592,7 @@ has been cached will be reconstructed before Pull returns.
Accumulate(const std::shared_ptr<LogicalOperator> &input, Accumulate(const std::shared_ptr<LogicalOperator> &input,
const std::vector<Symbol> &symbols, bool advance_command = false); const std::vector<Symbol> &symbols, bool advance_command = false);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1670,7 +1670,7 @@ elements are in an undefined state after aggregation.")
const std::vector<Expression *> &group_by, const std::vector<Expression *> &group_by,
const std::vector<Symbol> &remember); const std::vector<Symbol> &remember);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1707,7 +1707,7 @@ operator's implementation does not expect this.")
Skip(const std::shared_ptr<LogicalOperator> &input, Expression *expression); Skip(const std::shared_ptr<LogicalOperator> &input, Expression *expression);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -1721,7 +1721,7 @@ operator's implementation does not expect this.")
#>cpp #>cpp
class SkipCursor : public Cursor { class SkipCursor : public Cursor {
public: public:
SkipCursor(const Skip &, memgraph::utils::MemoryResource *); SkipCursor(const Skip &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1766,7 +1766,7 @@ input should be performed).")
Limit(const std::shared_ptr<LogicalOperator> &input, Expression *expression); Limit(const std::shared_ptr<LogicalOperator> &input, Expression *expression);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -1780,7 +1780,7 @@ input should be performed).")
#>cpp #>cpp
class LimitCursor : public Cursor { class LimitCursor : public Cursor {
public: public:
LimitCursor(const Limit &, memgraph::utils::MemoryResource *); LimitCursor(const Limit &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1825,7 +1825,7 @@ are valid for usage after the OrderBy operator.")
const std::vector<SortItem> &order_by, const std::vector<SortItem> &order_by,
const std::vector<Symbol> &output_symbols); const std::vector<Symbol> &output_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -1868,7 +1868,7 @@ documentation.")
const std::shared_ptr<LogicalOperator> &merge_match, const std::shared_ptr<LogicalOperator> &merge_match,
const std::shared_ptr<LogicalOperator> &merge_create); const std::shared_ptr<LogicalOperator> &merge_create);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
// TODO: Consider whether we want to treat Merge as having single input. It // TODO: Consider whether we want to treat Merge as having single input. It
@ -1884,7 +1884,7 @@ documentation.")
#>cpp #>cpp
class MergeCursor : public Cursor { class MergeCursor : public Cursor {
public: public:
MergeCursor(const Merge &, memgraph::utils::MemoryResource *); MergeCursor(const Merge &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1928,7 +1928,7 @@ and returns true, once.")
const std::shared_ptr<LogicalOperator> &optional, const std::shared_ptr<LogicalOperator> &optional,
const std::vector<Symbol> &optional_symbols); const std::vector<Symbol> &optional_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { return true; } bool HasSingleInput() const override { return true; }
@ -1941,7 +1941,7 @@ and returns true, once.")
#>cpp #>cpp
class OptionalCursor : public Cursor { class OptionalCursor : public Cursor {
public: public:
OptionalCursor(const Optional &, memgraph::utils::MemoryResource *); OptionalCursor(const Optional &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -1981,7 +1981,7 @@ Input is optional (unwind can be the first clause in a query).")
Unwind(const std::shared_ptr<LogicalOperator> &input, Unwind(const std::shared_ptr<LogicalOperator> &input,
Expression *input_expression_, Symbol output_symbol); Expression *input_expression_, Symbol output_symbol);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override { bool HasSingleInput() const override {
@ -2014,7 +2014,7 @@ This implementation maintains input ordering.")
Distinct(const std::shared_ptr<LogicalOperator> &input, Distinct(const std::shared_ptr<LogicalOperator> &input,
const std::vector<Symbol> &value_symbols); const std::vector<Symbol> &value_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -2053,7 +2053,7 @@ of symbols used by each of the inputs.")
const std::vector<Symbol> &left_symbols, const std::vector<Symbol> &left_symbols,
const std::vector<Symbol> &right_symbols); const std::vector<Symbol> &right_symbols);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -2065,7 +2065,7 @@ of symbols used by each of the inputs.")
#>cpp #>cpp
class UnionCursor : public Cursor { class UnionCursor : public Cursor {
public: public:
UnionCursor(const Union &, memgraph::utils::MemoryResource *); UnionCursor(const Union &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override; bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override; void Shutdown() override;
void Reset() override; void Reset() override;
@ -2105,7 +2105,7 @@ of symbols used by each of the inputs.")
right_symbols_(right_symbols) {} right_symbols_(right_symbols) {}
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
bool HasSingleInput() const override; bool HasSingleInput() const override;
@ -2134,7 +2134,7 @@ of symbols used by each of the inputs.")
LOG_FATAL("OutputTable operator should not be visited!"); LOG_FATAL("OutputTable operator should not be visited!");
} }
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override { std::vector<Symbol> OutputSymbols(const SymbolTable &) const override {
return output_symbols_; return output_symbols_;
} }
@ -2168,7 +2168,7 @@ at once. Instead, each call of the callback should return a single row of the ta
LOG_FATAL("OutputTableStream operator should not be visited!"); LOG_FATAL("OutputTableStream operator should not be visited!");
} }
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override { std::vector<Symbol> OutputSymbols(const SymbolTable &) const override {
return output_symbols_; return output_symbols_;
} }
@ -2208,7 +2208,7 @@ at once. Instead, each call of the callback should return a single row of the ta
Expression *memory_limit, size_t memory_scale, bool is_write); Expression *memory_limit, size_t memory_scale, bool is_write);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
@ -2223,7 +2223,7 @@ at once. Instead, each call of the callback should return a single row of the ta
cpp<#) cpp<#)
(:private (:private
#>cpp #>cpp
inline static memgraph::utils::Synchronized<std::unordered_map<std::string, int64_t>, memgraph::utils::SpinLock> procedure_counters_; inline static utils::Synchronized<std::unordered_map<std::string, int64_t>, utils::SpinLock> procedure_counters_;
cpp<#) cpp<#)
(:serialize (:slk)) (:serialize (:slk))
(:clone)) (:clone))
@ -2248,7 +2248,7 @@ at once. Instead, each call of the callback should return a single row of the ta
LoadCsv(std::shared_ptr<LogicalOperator> input, Expression *file, bool with_header, bool ignore_bad, LoadCsv(std::shared_ptr<LogicalOperator> input, Expression *file, bool with_header, bool ignore_bad,
Expression* delimiter, Expression* quote, Symbol row_var); Expression* delimiter, Expression* quote, Symbol row_var);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override; UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override; std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override; std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;

View File

@ -48,7 +48,7 @@ class PostProcessor final {
template <class TVertexCounts> template <class TVertexCounts>
double EstimatePlanCost(const std::unique_ptr<LogicalOperator> &plan, TVertexCounts *vertex_counts) { double EstimatePlanCost(const std::unique_ptr<LogicalOperator> &plan, TVertexCounts *vertex_counts) {
return ::memgraph::query::plan::EstimatePlanCost(vertex_counts, parameters_, *plan); return query::plan::EstimatePlanCost(vertex_counts, parameters_, *plan);
} }
template <class TPlanningContext> template <class TPlanningContext>

View File

@ -543,12 +543,12 @@ std::vector<SingleQueryPart> CollectSingleQueryParts(SymbolTable &symbol_table,
} }
} else { } else {
query_part->remaining_clauses.push_back(clause); query_part->remaining_clauses.push_back(clause);
if (auto *merge = utils::Downcast<memgraph::query::Merge>(clause)) { if (auto *merge = utils::Downcast<query::Merge>(clause)) {
query_part->merge_matching.emplace_back(Matching{}); query_part->merge_matching.emplace_back(Matching{});
AddMatching({merge->pattern_}, nullptr, symbol_table, storage, query_part->merge_matching.back()); AddMatching({merge->pattern_}, nullptr, symbol_table, storage, query_part->merge_matching.back());
} else if (utils::IsSubtype(*clause, With::kType) || utils::IsSubtype(*clause, memgraph::query::Unwind::kType) || } else if (utils::IsSubtype(*clause, With::kType) || utils::IsSubtype(*clause, query::Unwind::kType) ||
utils::IsSubtype(*clause, memgraph::query::CallProcedure::kType) || utils::IsSubtype(*clause, query::CallProcedure::kType) ||
utils::IsSubtype(*clause, memgraph::query::LoadCsv::kType)) { utils::IsSubtype(*clause, query::LoadCsv::kType)) {
// This query part is done, continue with a new one. // This query part is done, continue with a new one.
query_parts.emplace_back(SingleQueryPart{}); query_parts.emplace_back(SingleQueryPart{});
query_part = &query_parts.back(); query_part = &query_parts.back();

View File

@ -31,9 +31,9 @@ PRE_VISIT(CreateNode);
bool PlanPrinter::PreVisit(CreateExpand &op) { bool PlanPrinter::PreVisit(CreateExpand &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
out << "* CreateExpand (" << op.input_symbol_.name() << ")" out << "* CreateExpand (" << op.input_symbol_.name() << ")"
<< (op.edge_info_.direction == memgraph::query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" << (op.edge_info_.direction == query::EdgeAtom::Direction::IN ? "<-" : "-") << "["
<< op.edge_info_.symbol.name() << ":" << dba_->EdgeTypeToName(op.edge_info_.edge_type) << "]" << op.edge_info_.symbol.name() << ":" << dba_->EdgeTypeToName(op.edge_info_.edge_type) << "]"
<< (op.edge_info_.direction == memgraph::query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" << (op.edge_info_.direction == query::EdgeAtom::Direction::OUT ? "->" : "-") << "("
<< op.node_info_.symbol.name() << ")"; << op.node_info_.symbol.name() << ")";
}); });
return true; return true;
@ -41,7 +41,7 @@ bool PlanPrinter::PreVisit(CreateExpand &op) {
PRE_VISIT(Delete); PRE_VISIT(Delete);
bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAll &op) { bool PlanPrinter::PreVisit(query::plan::ScanAll &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
out << "* ScanAll" out << "* ScanAll"
<< " (" << op.output_symbol_.name() << ")"; << " (" << op.output_symbol_.name() << ")";
@ -49,7 +49,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAll &op) {
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabel &op) { bool PlanPrinter::PreVisit(query::plan::ScanAllByLabel &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
out << "* ScanAllByLabel" out << "* ScanAllByLabel"
<< " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << ")"; << " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << ")";
@ -57,7 +57,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabel &op) {
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabelPropertyValue &op) { bool PlanPrinter::PreVisit(query::plan::ScanAllByLabelPropertyValue &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
out << "* ScanAllByLabelPropertyValue" out << "* ScanAllByLabelPropertyValue"
<< " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {" << " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {"
@ -66,7 +66,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabelPropertyValue &o
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabelPropertyRange &op) { bool PlanPrinter::PreVisit(query::plan::ScanAllByLabelPropertyRange &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
out << "* ScanAllByLabelPropertyRange" out << "* ScanAllByLabelPropertyRange"
<< " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {" << " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {"
@ -75,7 +75,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabelPropertyRange &o
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::ScanAllByLabelProperty &op) { bool PlanPrinter::PreVisit(query::plan::ScanAllByLabelProperty &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
out << "* ScanAllByLabelProperty" out << "* ScanAllByLabelProperty"
<< " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {" << " (" << op.output_symbol_.name() << " :" << dba_->LabelToName(op.label_) << " {"
@ -92,22 +92,22 @@ bool PlanPrinter::PreVisit(ScanAllById &op) {
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::Expand &op) { bool PlanPrinter::PreVisit(query::plan::Expand &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
*out_ << "* Expand (" << op.input_symbol_.name() << ")" *out_ << "* Expand (" << op.input_symbol_.name() << ")"
<< (op.common_.direction == memgraph::query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" << (op.common_.direction == query::EdgeAtom::Direction::IN ? "<-" : "-") << "["
<< op.common_.edge_symbol.name(); << op.common_.edge_symbol.name();
utils::PrintIterable(*out_, op.common_.edge_types, "|", [this](auto &stream, const auto &edge_type) { utils::PrintIterable(*out_, op.common_.edge_types, "|", [this](auto &stream, const auto &edge_type) {
stream << ":" << dba_->EdgeTypeToName(edge_type); stream << ":" << dba_->EdgeTypeToName(edge_type);
}); });
*out_ << "]" << (op.common_.direction == memgraph::query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" *out_ << "]" << (op.common_.direction == query::EdgeAtom::Direction::OUT ? "->" : "-") << "("
<< op.common_.node_symbol.name() << ")"; << op.common_.node_symbol.name() << ")";
}); });
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::ExpandVariable &op) { bool PlanPrinter::PreVisit(query::plan::ExpandVariable &op) {
using Type = memgraph::query::EdgeAtom::Type; using Type = query::EdgeAtom::Type;
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
*out_ << "* "; *out_ << "* ";
switch (op.type_) { switch (op.type_) {
@ -124,18 +124,18 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::ExpandVariable &op) {
LOG_FATAL("Unexpected ExpandVariable::type_"); LOG_FATAL("Unexpected ExpandVariable::type_");
} }
*out_ << " (" << op.input_symbol_.name() << ")" *out_ << " (" << op.input_symbol_.name() << ")"
<< (op.common_.direction == memgraph::query::EdgeAtom::Direction::IN ? "<-" : "-") << "[" << (op.common_.direction == query::EdgeAtom::Direction::IN ? "<-" : "-") << "["
<< op.common_.edge_symbol.name(); << op.common_.edge_symbol.name();
utils::PrintIterable(*out_, op.common_.edge_types, "|", [this](auto &stream, const auto &edge_type) { utils::PrintIterable(*out_, op.common_.edge_types, "|", [this](auto &stream, const auto &edge_type) {
stream << ":" << dba_->EdgeTypeToName(edge_type); stream << ":" << dba_->EdgeTypeToName(edge_type);
}); });
*out_ << "]" << (op.common_.direction == memgraph::query::EdgeAtom::Direction::OUT ? "->" : "-") << "(" *out_ << "]" << (op.common_.direction == query::EdgeAtom::Direction::OUT ? "->" : "-") << "("
<< op.common_.node_symbol.name() << ")"; << op.common_.node_symbol.name() << ")";
}); });
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::Produce &op) { bool PlanPrinter::PreVisit(query::plan::Produce &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
out << "* Produce {"; out << "* Produce {";
utils::PrintIterable(out, op.named_expressions_, ", ", [](auto &out, const auto &nexpr) { out << nexpr->name_; }); utils::PrintIterable(out, op.named_expressions_, ", ", [](auto &out, const auto &nexpr) { out << nexpr->name_; });
@ -154,7 +154,7 @@ PRE_VISIT(RemoveLabels);
PRE_VISIT(EdgeUniquenessFilter); PRE_VISIT(EdgeUniquenessFilter);
PRE_VISIT(Accumulate); PRE_VISIT(Accumulate);
bool PlanPrinter::PreVisit(memgraph::query::plan::Aggregate &op) { bool PlanPrinter::PreVisit(query::plan::Aggregate &op) {
WithPrintLn([&](auto &out) { WithPrintLn([&](auto &out) {
out << "* Aggregate {"; out << "* Aggregate {";
utils::PrintIterable(out, op.aggregations_, ", ", utils::PrintIterable(out, op.aggregations_, ", ",
@ -169,7 +169,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::Aggregate &op) {
PRE_VISIT(Skip); PRE_VISIT(Skip);
PRE_VISIT(Limit); PRE_VISIT(Limit);
bool PlanPrinter::PreVisit(memgraph::query::plan::OrderBy &op) { bool PlanPrinter::PreVisit(query::plan::OrderBy &op) {
WithPrintLn([&op](auto &out) { WithPrintLn([&op](auto &out) {
out << "* OrderBy {"; out << "* OrderBy {";
utils::PrintIterable(out, op.output_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); }); utils::PrintIterable(out, op.output_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); });
@ -178,7 +178,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::OrderBy &op) {
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::Merge &op) { bool PlanPrinter::PreVisit(query::plan::Merge &op) {
WithPrintLn([](auto &out) { out << "* Merge"; }); WithPrintLn([](auto &out) { out << "* Merge"; });
Branch(*op.merge_match_, "On Match"); Branch(*op.merge_match_, "On Match");
Branch(*op.merge_create_, "On Create"); Branch(*op.merge_create_, "On Create");
@ -186,7 +186,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::Merge &op) {
return false; return false;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::Optional &op) { bool PlanPrinter::PreVisit(query::plan::Optional &op) {
WithPrintLn([](auto &out) { out << "* Optional"; }); WithPrintLn([](auto &out) { out << "* Optional"; });
Branch(*op.optional_); Branch(*op.optional_);
op.input_->Accept(*this); op.input_->Accept(*this);
@ -196,7 +196,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::Optional &op) {
PRE_VISIT(Unwind); PRE_VISIT(Unwind);
PRE_VISIT(Distinct); PRE_VISIT(Distinct);
bool PlanPrinter::PreVisit(memgraph::query::plan::Union &op) { bool PlanPrinter::PreVisit(query::plan::Union &op) {
WithPrintLn([&op](auto &out) { WithPrintLn([&op](auto &out) {
out << "* Union {"; out << "* Union {";
utils::PrintIterable(out, op.left_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); }); utils::PrintIterable(out, op.left_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); });
@ -209,7 +209,7 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::Union &op) {
return false; return false;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::CallProcedure &op) { bool PlanPrinter::PreVisit(query::plan::CallProcedure &op) {
WithPrintLn([&op](auto &out) { WithPrintLn([&op](auto &out) {
out << "* CallProcedure<" << op.procedure_name_ << "> {"; out << "* CallProcedure<" << op.procedure_name_ << "> {";
utils::PrintIterable(out, op.result_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); }); utils::PrintIterable(out, op.result_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); });
@ -218,17 +218,17 @@ bool PlanPrinter::PreVisit(memgraph::query::plan::CallProcedure &op) {
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::LoadCsv &op) { bool PlanPrinter::PreVisit(query::plan::LoadCsv &op) {
WithPrintLn([&op](auto &out) { out << "* LoadCsv {" << op.row_var_.name() << "}"; }); WithPrintLn([&op](auto &out) { out << "* LoadCsv {" << op.row_var_.name() << "}"; });
return true; return true;
} }
bool PlanPrinter::Visit(memgraph::query::plan::Once & /*op*/) { bool PlanPrinter::Visit(query::plan::Once & /*op*/) {
WithPrintLn([](auto &out) { out << "* Once"; }); WithPrintLn([](auto &out) { out << "* Once"; });
return true; return true;
} }
bool PlanPrinter::PreVisit(memgraph::query::plan::Cartesian &op) { bool PlanPrinter::PreVisit(query::plan::Cartesian &op) {
WithPrintLn([&op](auto &out) { WithPrintLn([&op](auto &out) {
out << "* Cartesian {"; out << "* Cartesian {";
utils::PrintIterable(out, op.left_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); }); utils::PrintIterable(out, op.left_symbols_, ", ", [](auto &out, const auto &sym) { out << sym.name(); });
@ -248,7 +248,7 @@ bool PlanPrinter::DefaultPreVisit() {
return true; return true;
} }
void PlanPrinter::Branch(memgraph::query::plan::LogicalOperator &op, const std::string &branch_name) { void PlanPrinter::Branch(query::plan::LogicalOperator &op, const std::string &branch_name) {
WithPrintLn([&](auto &out) { out << "|\\ " << branch_name; }); WithPrintLn([&](auto &out) { out << "|\\ " << branch_name; });
++depth_; ++depth_;
op.Accept(*this); op.Accept(*this);
@ -807,7 +807,7 @@ bool PlanToJsonVisitor::PreVisit(Unwind &op) {
return false; return false;
} }
bool PlanToJsonVisitor::PreVisit(memgraph::query::plan::CallProcedure &op) { bool PlanToJsonVisitor::PreVisit(query::plan::CallProcedure &op) {
json self; json self;
self["name"] = "CallProcedure"; self["name"] = "CallProcedure";
self["procedure_name"] = op.procedure_name_; self["procedure_name"] = op.procedure_name_;
@ -822,7 +822,7 @@ bool PlanToJsonVisitor::PreVisit(memgraph::query::plan::CallProcedure &op) {
return false; return false;
} }
bool PlanToJsonVisitor::PreVisit(memgraph::query::plan::LoadCsv &op) { bool PlanToJsonVisitor::PreVisit(query::plan::LoadCsv &op) {
json self; json self;
self["name"] = "LoadCsv"; self["name"] = "LoadCsv";
self["file"] = ToJson(op.file_); self["file"] = ToJson(op.file_);

View File

@ -20,9 +20,8 @@
namespace memgraph::query { namespace memgraph::query {
class DbAccessor; class DbAccessor;
}
namespace memgraph::query::plan { namespace plan {
class LogicalOperator; class LogicalOperator;
@ -225,4 +224,5 @@ class PlanToJsonVisitor : public virtual HierarchicalLogicalOperatorVisitor {
} // namespace impl } // namespace impl
} // namespace memgraph::query::plan } // namespace plan
} // namespace memgraph::query

View File

@ -184,12 +184,12 @@ class RuleBasedPlanner {
if (auto *ret = utils::Downcast<Return>(clause)) { if (auto *ret = utils::Downcast<Return>(clause)) {
input_op = impl::GenReturn(*ret, std::move(input_op), *context.symbol_table, is_write, context.bound_symbols, input_op = impl::GenReturn(*ret, std::move(input_op), *context.symbol_table, is_write, context.bound_symbols,
*context.ast_storage); *context.ast_storage);
} else if (auto *merge = utils::Downcast<memgraph::query::Merge>(clause)) { } else if (auto *merge = utils::Downcast<query::Merge>(clause)) {
input_op = GenMerge(*merge, std::move(input_op), query_part.merge_matching[merge_id++]); input_op = GenMerge(*merge, std::move(input_op), query_part.merge_matching[merge_id++]);
// Treat MERGE clause as write, because we do not know if it will // Treat MERGE clause as write, because we do not know if it will
// create anything. // create anything.
is_write = true; is_write = true;
} else if (auto *with = utils::Downcast<memgraph::query::With>(clause)) { } else if (auto *with = utils::Downcast<query::With>(clause)) {
input_op = impl::GenWith(*with, std::move(input_op), *context.symbol_table, is_write, context.bound_symbols, input_op = impl::GenWith(*with, std::move(input_op), *context.symbol_table, is_write, context.bound_symbols,
*context.ast_storage); *context.ast_storage);
// WITH clause advances the command, so reset the flag. // WITH clause advances the command, so reset the flag.
@ -197,12 +197,12 @@ class RuleBasedPlanner {
} else if (auto op = HandleWriteClause(clause, input_op, *context.symbol_table, context.bound_symbols)) { } else if (auto op = HandleWriteClause(clause, input_op, *context.symbol_table, context.bound_symbols)) {
is_write = true; is_write = true;
input_op = std::move(op); input_op = std::move(op);
} else if (auto *unwind = utils::Downcast<memgraph::query::Unwind>(clause)) { } else if (auto *unwind = utils::Downcast<query::Unwind>(clause)) {
const auto &symbol = context.symbol_table->at(*unwind->named_expression_); const auto &symbol = context.symbol_table->at(*unwind->named_expression_);
context.bound_symbols.insert(symbol); context.bound_symbols.insert(symbol);
input_op = input_op =
std::make_unique<plan::Unwind>(std::move(input_op), unwind->named_expression_->expression_, symbol); std::make_unique<plan::Unwind>(std::move(input_op), unwind->named_expression_->expression_, symbol);
} else if (auto *call_proc = utils::Downcast<memgraph::query::CallProcedure>(clause)) { } else if (auto *call_proc = utils::Downcast<query::CallProcedure>(clause)) {
std::vector<Symbol> result_symbols; std::vector<Symbol> result_symbols;
result_symbols.reserve(call_proc->result_identifiers_.size()); result_symbols.reserve(call_proc->result_identifiers_.size());
for (const auto *ident : call_proc->result_identifiers_) { for (const auto *ident : call_proc->result_identifiers_) {
@ -216,7 +216,7 @@ class RuleBasedPlanner {
input_op = std::make_unique<plan::CallProcedure>( input_op = std::make_unique<plan::CallProcedure>(
std::move(input_op), call_proc->procedure_name_, call_proc->arguments_, call_proc->result_fields_, std::move(input_op), call_proc->procedure_name_, call_proc->arguments_, call_proc->result_fields_,
result_symbols, call_proc->memory_limit_, call_proc->memory_scale_, call_proc->is_write_); result_symbols, call_proc->memory_limit_, call_proc->memory_scale_, call_proc->is_write_);
} else if (auto *load_csv = utils::Downcast<memgraph::query::LoadCsv>(clause)) { } else if (auto *load_csv = utils::Downcast<query::LoadCsv>(clause)) {
const auto &row_sym = context.symbol_table->at(*load_csv->row_var_); const auto &row_sym = context.symbol_table->at(*load_csv->row_var_);
context.bound_symbols.insert(row_sym); context.bound_symbols.insert(row_sym);
@ -338,16 +338,16 @@ class RuleBasedPlanner {
std::unordered_set<Symbol> &bound_symbols) { std::unordered_set<Symbol> &bound_symbols) {
if (auto *create = utils::Downcast<Create>(clause)) { if (auto *create = utils::Downcast<Create>(clause)) {
return GenCreate(*create, std::move(input_op), symbol_table, bound_symbols); return GenCreate(*create, std::move(input_op), symbol_table, bound_symbols);
} else if (auto *del = utils::Downcast<memgraph::query::Delete>(clause)) { } else if (auto *del = utils::Downcast<query::Delete>(clause)) {
return std::make_unique<plan::Delete>(std::move(input_op), del->expressions_, del->detach_); return std::make_unique<plan::Delete>(std::move(input_op), del->expressions_, del->detach_);
} else if (auto *set = utils::Downcast<memgraph::query::SetProperty>(clause)) { } else if (auto *set = utils::Downcast<query::SetProperty>(clause)) {
return std::make_unique<plan::SetProperty>(std::move(input_op), GetProperty(set->property_lookup_->property_), return std::make_unique<plan::SetProperty>(std::move(input_op), GetProperty(set->property_lookup_->property_),
set->property_lookup_, set->expression_); set->property_lookup_, set->expression_);
} else if (auto *set = utils::Downcast<memgraph::query::SetProperties>(clause)) { } else if (auto *set = utils::Downcast<query::SetProperties>(clause)) {
auto op = set->update_ ? plan::SetProperties::Op::UPDATE : plan::SetProperties::Op::REPLACE; auto op = set->update_ ? plan::SetProperties::Op::UPDATE : plan::SetProperties::Op::REPLACE;
const auto &input_symbol = symbol_table.at(*set->identifier_); const auto &input_symbol = symbol_table.at(*set->identifier_);
return std::make_unique<plan::SetProperties>(std::move(input_op), input_symbol, set->expression_, op); return std::make_unique<plan::SetProperties>(std::move(input_op), input_symbol, set->expression_, op);
} else if (auto *set = utils::Downcast<memgraph::query::SetLabels>(clause)) { } else if (auto *set = utils::Downcast<query::SetLabels>(clause)) {
const auto &input_symbol = symbol_table.at(*set->identifier_); const auto &input_symbol = symbol_table.at(*set->identifier_);
std::vector<storage::LabelId> labels; std::vector<storage::LabelId> labels;
labels.reserve(set->labels_.size()); labels.reserve(set->labels_.size());
@ -355,10 +355,10 @@ class RuleBasedPlanner {
labels.push_back(GetLabel(label)); labels.push_back(GetLabel(label));
} }
return std::make_unique<plan::SetLabels>(std::move(input_op), input_symbol, labels); return std::make_unique<plan::SetLabels>(std::move(input_op), input_symbol, labels);
} else if (auto *rem = utils::Downcast<memgraph::query::RemoveProperty>(clause)) { } else if (auto *rem = utils::Downcast<query::RemoveProperty>(clause)) {
return std::make_unique<plan::RemoveProperty>(std::move(input_op), GetProperty(rem->property_lookup_->property_), return std::make_unique<plan::RemoveProperty>(std::move(input_op), GetProperty(rem->property_lookup_->property_),
rem->property_lookup_); rem->property_lookup_);
} else if (auto *rem = utils::Downcast<memgraph::query::RemoveLabels>(clause)) { } else if (auto *rem = utils::Downcast<query::RemoveLabels>(clause)) {
const auto &input_symbol = symbol_table.at(*rem->identifier_); const auto &input_symbol = symbol_table.at(*rem->identifier_);
std::vector<storage::LabelId> labels; std::vector<storage::LabelId> labels;
labels.reserve(rem->labels_.size()); labels.reserve(rem->labels_.size());
@ -505,7 +505,7 @@ class RuleBasedPlanner {
return last_op; return last_op;
} }
auto GenMerge(memgraph::query::Merge &merge, std::unique_ptr<LogicalOperator> input_op, const Matching &matching) { auto GenMerge(query::Merge &merge, std::unique_ptr<LogicalOperator> input_op, const Matching &matching) {
// Copy the bound symbol set, because we don't want to use the updated // Copy the bound symbol set, because we don't want to use the updated
// version when generating the create part. // version when generating the create part.
std::unordered_set<Symbol> bound_symbols_copy(context_->bound_symbols); std::unordered_set<Symbol> bound_symbols_copy(context_->bound_symbols);

View File

@ -18,9 +18,7 @@
#include "utils/likely.hpp" #include "utils/likely.hpp"
#include "utils/tsc.hpp" #include "utils/tsc.hpp"
namespace memgraph::query { namespace memgraph::query::plan {
namespace plan {
/** /**
* A RAII class used for profiling logical operators. Instances of this class * A RAII class used for profiling logical operators. Instances of this class
@ -30,8 +28,7 @@ namespace plan {
*/ */
class ScopedProfile { class ScopedProfile {
public: public:
ScopedProfile(uint64_t key, const char *name, memgraph::query::ExecutionContext *context) noexcept ScopedProfile(uint64_t key, const char *name, query::ExecutionContext *context) noexcept : context_(context) {
: context_(context) {
if (UNLIKELY(context_->is_profile_query)) { if (UNLIKELY(context_->is_profile_query)) {
root_ = context_->stats_root; root_ = context_->stats_root;
@ -73,11 +70,10 @@ class ScopedProfile {
} }
private: private:
memgraph::query::ExecutionContext *context_; query::ExecutionContext *context_;
ProfilingStats *root_; ProfilingStats *root_;
ProfilingStats *stats_; ProfilingStats *stats_;
unsigned long long start_time_; unsigned long long start_time_;
}; };
} // namespace plan } // namespace memgraph::query::plan
} // namespace memgraph::query

View File

@ -95,11 +95,11 @@ class VertexCountCache {
size_t operator()(const BoundsKey &key) const { size_t operator()(const BoundsKey &key) const {
const auto &maybe_lower = key.first; const auto &maybe_lower = key.first;
const auto &maybe_upper = key.second; const auto &maybe_upper = key.second;
memgraph::query::TypedValue lower; query::TypedValue lower;
memgraph::query::TypedValue upper; query::TypedValue upper;
if (maybe_lower) lower = TypedValue(maybe_lower->value()); if (maybe_lower) lower = TypedValue(maybe_lower->value());
if (maybe_upper) upper = TypedValue(maybe_upper->value()); if (maybe_upper) upper = TypedValue(maybe_upper->value());
memgraph::query::TypedValue::Hash hash; query::TypedValue::Hash hash;
return utils::HashCombine<size_t, size_t>{}(hash(lower), hash(upper)); return utils::HashCombine<size_t, size_t>{}(hash(lower), hash(upper));
} }
}; };
@ -108,11 +108,11 @@ class VertexCountCache {
bool operator()(const BoundsKey &a, const BoundsKey &b) const { bool operator()(const BoundsKey &a, const BoundsKey &b) const {
auto bound_equal = [](const auto &maybe_bound_a, const auto &maybe_bound_b) { auto bound_equal = [](const auto &maybe_bound_a, const auto &maybe_bound_b) {
if (maybe_bound_a && maybe_bound_b && maybe_bound_a->type() != maybe_bound_b->type()) return false; if (maybe_bound_a && maybe_bound_b && maybe_bound_a->type() != maybe_bound_b->type()) return false;
memgraph::query::TypedValue bound_a; query::TypedValue bound_a;
memgraph::query::TypedValue bound_b; query::TypedValue bound_b;
if (maybe_bound_a) bound_a = TypedValue(maybe_bound_a->value()); if (maybe_bound_a) bound_a = TypedValue(maybe_bound_a->value());
if (maybe_bound_b) bound_b = TypedValue(maybe_bound_b->value()); if (maybe_bound_b) bound_b = TypedValue(maybe_bound_b->value());
return memgraph::query::TypedValue::BoolEqual{}(bound_a, bound_b); return query::TypedValue::BoolEqual{}(bound_a, bound_b);
}; };
return bound_equal(a.first, b.first) && bound_equal(a.second, b.second); return bound_equal(a.first, b.first) && bound_equal(a.second, b.second);
} }
@ -122,10 +122,10 @@ class VertexCountCache {
std::optional<int64_t> vertices_count_; std::optional<int64_t> vertices_count_;
std::unordered_map<storage::LabelId, int64_t> label_vertex_count_; std::unordered_map<storage::LabelId, int64_t> label_vertex_count_;
std::unordered_map<LabelPropertyKey, int64_t, LabelPropertyHash> label_property_vertex_count_; std::unordered_map<LabelPropertyKey, int64_t, LabelPropertyHash> label_property_vertex_count_;
std::unordered_map<LabelPropertyKey, std::unordered_map<
std::unordered_map<memgraph::query::TypedValue, int64_t, memgraph::query::TypedValue::Hash, LabelPropertyKey,
memgraph::query::TypedValue::BoolEqual>, std::unordered_map<query::TypedValue, int64_t, query::TypedValue::Hash, query::TypedValue::BoolEqual>,
LabelPropertyHash> LabelPropertyHash>
property_value_vertex_count_; property_value_vertex_count_;
std::unordered_map<LabelPropertyKey, std::unordered_map<BoundsKey, int64_t, BoundsHash, BoundsEqual>, std::unordered_map<LabelPropertyKey, std::unordered_map<BoundsKey, int64_t, BoundsHash, BoundsEqual>,
LabelPropertyHash> LabelPropertyHash>

View File

@ -47,7 +47,7 @@ class CypherType {
virtual bool SatisfiesType(const mgp_value &) const = 0; virtual bool SatisfiesType(const mgp_value &) const = 0;
/// Return true if given TypedValue is of the type as described by `this`. /// Return true if given TypedValue is of the type as described by `this`.
virtual bool SatisfiesType(const memgraph::query::TypedValue &) const = 0; virtual bool SatisfiesType(const query::TypedValue &) const = 0;
// The following methods are a simple replacement for RTTI because we have // The following methods are a simple replacement for RTTI because we have
// some special cases we need to handle. // some special cases we need to handle.
@ -63,7 +63,7 @@ class AnyType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type != MGP_VALUE_TYPE_NULL; } bool SatisfiesType(const mgp_value &value) const override { return value.type != MGP_VALUE_TYPE_NULL; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return !value.IsNull(); } bool SatisfiesType(const query::TypedValue &value) const override { return !value.IsNull(); }
}; };
class BoolType : public CypherType { class BoolType : public CypherType {
@ -72,7 +72,7 @@ class BoolType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_BOOL; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_BOOL; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsBool(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsBool(); }
}; };
class StringType : public CypherType { class StringType : public CypherType {
@ -81,7 +81,7 @@ class StringType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_STRING; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_STRING; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsString(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsString(); }
}; };
class IntType : public CypherType { class IntType : public CypherType {
@ -90,7 +90,7 @@ class IntType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_INT; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_INT; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsInt(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsInt(); }
}; };
class FloatType : public CypherType { class FloatType : public CypherType {
@ -99,7 +99,7 @@ class FloatType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DOUBLE; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DOUBLE; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsDouble(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDouble(); }
}; };
class NumberType : public CypherType { class NumberType : public CypherType {
@ -110,9 +110,7 @@ class NumberType : public CypherType {
return value.type == MGP_VALUE_TYPE_INT || value.type == MGP_VALUE_TYPE_DOUBLE; return value.type == MGP_VALUE_TYPE_INT || value.type == MGP_VALUE_TYPE_DOUBLE;
} }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { bool SatisfiesType(const query::TypedValue &value) const override { return value.IsInt() || value.IsDouble(); }
return value.IsInt() || value.IsDouble();
}
}; };
class NodeType : public CypherType { class NodeType : public CypherType {
@ -121,7 +119,7 @@ class NodeType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_VERTEX; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_VERTEX; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsVertex(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsVertex(); }
}; };
class RelationshipType : public CypherType { class RelationshipType : public CypherType {
@ -130,7 +128,7 @@ class RelationshipType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_EDGE; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_EDGE; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsEdge(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsEdge(); }
}; };
class PathType : public CypherType { class PathType : public CypherType {
@ -139,7 +137,7 @@ class PathType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_PATH; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_PATH; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsPath(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsPath(); }
}; };
// You'd think that MapType would be a composite type like ListType, but nope. // You'd think that MapType would be a composite type like ListType, but nope.
@ -155,7 +153,7 @@ class MapType : public CypherType {
return value.type == MGP_VALUE_TYPE_MAP || value.type == MGP_VALUE_TYPE_VERTEX || value.type == MGP_VALUE_TYPE_EDGE; return value.type == MGP_VALUE_TYPE_MAP || value.type == MGP_VALUE_TYPE_VERTEX || value.type == MGP_VALUE_TYPE_EDGE;
} }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { bool SatisfiesType(const query::TypedValue &value) const override {
return value.IsMap() || value.IsVertex() || value.IsEdge(); return value.IsMap() || value.IsVertex() || value.IsEdge();
} }
}; };
@ -168,7 +166,7 @@ class DateType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DATE; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DATE; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsDate(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDate(); }
}; };
class LocalTimeType : public CypherType { class LocalTimeType : public CypherType {
@ -177,7 +175,7 @@ class LocalTimeType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_LOCAL_TIME; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_LOCAL_TIME; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsLocalTime(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsLocalTime(); }
}; };
class LocalDateTimeType : public CypherType { class LocalDateTimeType : public CypherType {
@ -186,7 +184,7 @@ class LocalDateTimeType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_LOCAL_DATE_TIME; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_LOCAL_DATE_TIME; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsLocalDateTime(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsLocalDateTime(); }
}; };
class DurationType : public CypherType { class DurationType : public CypherType {
@ -195,7 +193,7 @@ class DurationType : public CypherType {
bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DURATION; } bool SatisfiesType(const mgp_value &value) const override { return value.type == MGP_VALUE_TYPE_DURATION; }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { return value.IsDuration(); } bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDuration(); }
}; };
// Composite Types // Composite Types
@ -228,7 +226,7 @@ class ListType : public CypherType {
return true; return true;
} }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { bool SatisfiesType(const query::TypedValue &value) const override {
if (!value.IsList()) return false; if (!value.IsList()) return false;
for (const auto &elem : value.ValueList()) { for (const auto &elem : value.ValueList()) {
if (!element_type_->SatisfiesType(elem)) return false; if (!element_type_->SatisfiesType(elem)) return false;
@ -285,7 +283,7 @@ class NullableType : public CypherType {
return value.type == MGP_VALUE_TYPE_NULL || type_->SatisfiesType(value); return value.type == MGP_VALUE_TYPE_NULL || type_->SatisfiesType(value);
} }
bool SatisfiesType(const memgraph::query::TypedValue &value) const override { bool SatisfiesType(const query::TypedValue &value) const override {
return value.IsNull() || type_->SatisfiesType(value); return value.IsNull() || type_->SatisfiesType(value);
} }

View File

@ -57,7 +57,7 @@ mgp_value *PyObjectToMgpValue(PyObject *, mgp_memory *);
/// ///
/// The function is to be used before Py_Initialize via the following code. /// The function is to be used before Py_Initialize via the following code.
/// ///
/// PyImport_AppendInittab("_mgp", &memgraph::query::procedure::PyInitMgpModule); /// PyImport_AppendInittab("_mgp", &query::procedure::PyInitMgpModule);
PyObject *PyInitMgpModule(); PyObject *PyInitMgpModule();
/// Create an instance of _mgp.Graph class. /// Create an instance of _mgp.Graph class.

View File

@ -528,7 +528,7 @@ Streams::StreamsMap::iterator Streams::CreateConsumer(StreamsMap &map, const std
interpreter->CommitTransaction(); interpreter->CommitTransaction();
result.rows.clear(); result.rows.clear();
break; break;
} catch (const memgraph::query::TransactionSerializationException &e) { } catch (const query::TransactionSerializationException &e) {
interpreter->Abort(); interpreter->Abort();
if (i == total_retries) { if (i == total_retries) {
throw; throw;

View File

@ -154,7 +154,7 @@ Trigger::Trigger(std::string name, const std::string &query,
const std::map<std::string, storage::PropertyValue> &user_parameters, const std::map<std::string, storage::PropertyValue> &user_parameters,
const TriggerEventType event_type, utils::SkipList<QueryCacheEntry> *query_cache, const TriggerEventType event_type, utils::SkipList<QueryCacheEntry> *query_cache,
DbAccessor *db_accessor, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, DbAccessor *db_accessor, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config,
std::optional<std::string> owner, const memgraph::query::AuthChecker *auth_checker) std::optional<std::string> owner, const query::AuthChecker *auth_checker)
: name_{std::move(name)}, : name_{std::move(name)},
parsed_statements_{ParseQuery(query, user_parameters, query_cache, antlr_lock, query_config)}, parsed_statements_{ParseQuery(query, user_parameters, query_cache, antlr_lock, query_config)},
event_type_{event_type}, event_type_{event_type},
@ -167,7 +167,7 @@ Trigger::TriggerPlan::TriggerPlan(std::unique_ptr<LogicalPlan> logical_plan, std
: cached_plan(std::move(logical_plan)), identifiers(std::move(identifiers)) {} : cached_plan(std::move(logical_plan)), identifiers(std::move(identifiers)) {}
std::shared_ptr<Trigger::TriggerPlan> Trigger::GetPlan(DbAccessor *db_accessor, std::shared_ptr<Trigger::TriggerPlan> Trigger::GetPlan(DbAccessor *db_accessor,
const memgraph::query::AuthChecker *auth_checker) const { const query::AuthChecker *auth_checker) const {
std::lock_guard plan_guard{plan_lock_}; std::lock_guard plan_guard{plan_lock_};
if (!parsed_statements_.is_cacheable || !trigger_plan_ || trigger_plan_->cached_plan.IsExpired()) { if (!parsed_statements_.is_cacheable || !trigger_plan_ || trigger_plan_->cached_plan.IsExpired()) {
auto identifiers = GetPredefinedIdentifiers(event_type_); auto identifiers = GetPredefinedIdentifiers(event_type_);
@ -258,7 +258,7 @@ TriggerStore::TriggerStore(std::filesystem::path directory) : storage_{std::move
void TriggerStore::RestoreTriggers(utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor, void TriggerStore::RestoreTriggers(utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor,
utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config,
const memgraph::query::AuthChecker *auth_checker) { const query::AuthChecker *auth_checker) {
MG_ASSERT(before_commit_triggers_.size() == 0 && after_commit_triggers_.size() == 0, MG_ASSERT(before_commit_triggers_.size() == 0 && after_commit_triggers_.size() == 0,
"Cannot restore trigger when some triggers already exist!"); "Cannot restore trigger when some triggers already exist!");
spdlog::info("Loading triggers..."); spdlog::info("Loading triggers...");
@ -337,7 +337,7 @@ void TriggerStore::AddTrigger(std::string name, const std::string &query,
TriggerEventType event_type, TriggerPhase phase, TriggerEventType event_type, TriggerPhase phase,
utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor, utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor,
utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config,
std::optional<std::string> owner, const memgraph::query::AuthChecker *auth_checker) { std::optional<std::string> owner, const query::AuthChecker *auth_checker) {
std::unique_lock store_guard{store_lock_}; std::unique_lock store_guard{store_lock_};
if (storage_.Get(name)) { if (storage_.Get(name)) {
throw utils::BasicException("Trigger with the same name already exists."); throw utils::BasicException("Trigger with the same name already exists.");

View File

@ -36,7 +36,7 @@ struct Trigger {
const std::map<std::string, storage::PropertyValue> &user_parameters, TriggerEventType event_type, const std::map<std::string, storage::PropertyValue> &user_parameters, TriggerEventType event_type,
utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock, utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock,
const InterpreterConfig::Query &query_config, std::optional<std::string> owner, const InterpreterConfig::Query &query_config, std::optional<std::string> owner,
const memgraph::query::AuthChecker *auth_checker); const query::AuthChecker *auth_checker);
void Execute(DbAccessor *dba, utils::MonotonicBufferResource *execution_memory, double max_execution_time_sec, void Execute(DbAccessor *dba, utils::MonotonicBufferResource *execution_memory, double max_execution_time_sec,
std::atomic<bool> *is_shutting_down, const TriggerContext &context, std::atomic<bool> *is_shutting_down, const TriggerContext &context,
@ -63,7 +63,7 @@ struct Trigger {
CachedPlan cached_plan; CachedPlan cached_plan;
std::vector<IdentifierInfo> identifiers; std::vector<IdentifierInfo> identifiers;
}; };
std::shared_ptr<TriggerPlan> GetPlan(DbAccessor *db_accessor, const memgraph::query::AuthChecker *auth_checker) const; std::shared_ptr<TriggerPlan> GetPlan(DbAccessor *db_accessor, const query::AuthChecker *auth_checker) const;
std::string name_; std::string name_;
ParsedQuery parsed_statements_; ParsedQuery parsed_statements_;
@ -82,13 +82,13 @@ struct TriggerStore {
void RestoreTriggers(utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor, void RestoreTriggers(utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor,
utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config,
const memgraph::query::AuthChecker *auth_checker); const query::AuthChecker *auth_checker);
void AddTrigger(std::string name, const std::string &query, void AddTrigger(std::string name, const std::string &query,
const std::map<std::string, storage::PropertyValue> &user_parameters, TriggerEventType event_type, const std::map<std::string, storage::PropertyValue> &user_parameters, TriggerEventType event_type,
TriggerPhase phase, utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor, TriggerPhase phase, utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor,
utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config, utils::SpinLock *antlr_lock, const InterpreterConfig::Query &query_config,
std::optional<std::string> owner, const memgraph::query::AuthChecker *auth_checker); std::optional<std::string> owner, const query::AuthChecker *auth_checker);
void DropTrigger(const std::string &name); void DropTrigger(const std::string &name);

View File

@ -168,7 +168,7 @@ using PropertyChangesLists =
template <detail::ObjectAccessor TAccessor> template <detail::ObjectAccessor TAccessor>
[[nodiscard]] PropertyChangesLists<TAccessor> PropertyMapToList( [[nodiscard]] PropertyChangesLists<TAccessor> PropertyMapToList(
memgraph::query::TriggerContextCollector::PropertyChangesMap<TAccessor> &&map) { query::TriggerContextCollector::PropertyChangesMap<TAccessor> &&map) {
std::vector<detail::SetObjectProperty<TAccessor>> set_object_properties; std::vector<detail::SetObjectProperty<TAccessor>> set_object_properties;
std::vector<detail::RemovedObjectProperty<TAccessor>> removed_object_properties; std::vector<detail::RemovedObjectProperty<TAccessor>> removed_object_properties;
@ -198,8 +198,7 @@ template <detail::ObjectAccessor TAccessor>
} }
template <detail::ObjectAccessor TAccessor> template <detail::ObjectAccessor TAccessor>
[[nodiscard]] ChangesSummary<TAccessor> Summarize( [[nodiscard]] ChangesSummary<TAccessor> Summarize(query::TriggerContextCollector::Registry<TAccessor> &&registry) {
memgraph::query::TriggerContextCollector::Registry<TAccessor> &&registry) {
auto [set_object_properties, removed_object_properties] = PropertyMapToList(std::move(registry.property_changes)); auto [set_object_properties, removed_object_properties] = PropertyMapToList(std::move(registry.property_changes));
std::vector<detail::CreatedObject<TAccessor>> created_objects_vec; std::vector<detail::CreatedObject<TAccessor>> created_objects_vec;
created_objects_vec.reserve(registry.created_objects.size()); created_objects_vec.reserve(registry.created_objects.size());

View File

@ -38,7 +38,7 @@ class Client {
friend class Client; friend class Client;
StreamHandler(Client *self, std::unique_lock<std::mutex> &&guard, StreamHandler(Client *self, std::unique_lock<std::mutex> &&guard,
std::function<typename TRequestResponse::Response(memgraph::slk::Reader *)> res_load) std::function<typename TRequestResponse::Response(slk::Reader *)> res_load)
: self_(self), : self_(self),
guard_(std::move(guard)), guard_(std::move(guard)),
req_builder_([self](const uint8_t *data, size_t size, bool have_more) { req_builder_([self](const uint8_t *data, size_t size, bool have_more) {
@ -55,7 +55,7 @@ class Client {
~StreamHandler() {} ~StreamHandler() {}
memgraph::slk::Builder *GetBuilder() { return &req_builder_; } slk::Builder *GetBuilder() { return &req_builder_; }
typename TRequestResponse::Response AwaitResponse() { typename TRequestResponse::Response AwaitResponse() {
auto res_type = TRequestResponse::Response::kType; auto res_type = TRequestResponse::Response::kType;
@ -66,10 +66,10 @@ class Client {
// Receive the response. // Receive the response.
uint64_t response_data_size = 0; uint64_t response_data_size = 0;
while (true) { while (true) {
auto ret = memgraph::slk::CheckStreamComplete(self_->client_->GetData(), self_->client_->GetDataSize()); auto ret = slk::CheckStreamComplete(self_->client_->GetData(), self_->client_->GetDataSize());
if (ret.status == memgraph::slk::StreamStatus::INVALID) { if (ret.status == slk::StreamStatus::INVALID) {
throw RpcFailedException(self_->endpoint_); throw RpcFailedException(self_->endpoint_);
} else if (ret.status == memgraph::slk::StreamStatus::PARTIAL) { } else if (ret.status == slk::StreamStatus::PARTIAL) {
if (!self_->client_->Read(ret.stream_size - self_->client_->GetDataSize(), if (!self_->client_->Read(ret.stream_size - self_->client_->GetDataSize(),
/* exactly_len = */ false)) { /* exactly_len = */ false)) {
throw RpcFailedException(self_->endpoint_); throw RpcFailedException(self_->endpoint_);
@ -81,11 +81,11 @@ class Client {
} }
// Load the response. // Load the response.
memgraph::slk::Reader res_reader(self_->client_->GetData(), response_data_size); slk::Reader res_reader(self_->client_->GetData(), response_data_size);
utils::OnScopeExit res_cleanup([&, response_data_size] { self_->client_->ShiftData(response_data_size); }); utils::OnScopeExit res_cleanup([&, response_data_size] { self_->client_->ShiftData(response_data_size); });
uint64_t res_id = 0; uint64_t res_id = 0;
memgraph::slk::Load(&res_id, &res_reader); slk::Load(&res_id, &res_reader);
// Check the response ID. // Check the response ID.
if (res_id != res_type.id) { if (res_id != res_type.id) {
@ -102,8 +102,8 @@ class Client {
private: private:
Client *self_; Client *self_;
std::unique_lock<std::mutex> guard_; std::unique_lock<std::mutex> guard_;
memgraph::slk::Builder req_builder_; slk::Builder req_builder_;
std::function<typename TRequestResponse::Response(memgraph::slk::Reader *)> res_load_; std::function<typename TRequestResponse::Response(slk::Reader *)> res_load_;
}; };
/// Stream a previously defined and registered RPC call. This function can /// Stream a previously defined and registered RPC call. This function can
@ -132,8 +132,8 @@ class Client {
/// Same as `Stream` but the first argument is a response loading function. /// Same as `Stream` but the first argument is a response loading function.
template <class TRequestResponse, class... Args> template <class TRequestResponse, class... Args>
StreamHandler<TRequestResponse> StreamWithLoad( StreamHandler<TRequestResponse> StreamWithLoad(std::function<typename TRequestResponse::Response(slk::Reader *)> load,
std::function<typename TRequestResponse::Response(memgraph::slk::Reader *)> load, Args &&...args) { Args &&...args) {
typename TRequestResponse::Request request(std::forward<Args>(args)...); typename TRequestResponse::Request request(std::forward<Args>(args)...);
auto req_type = TRequestResponse::Request::kType; auto req_type = TRequestResponse::Request::kType;
SPDLOG_TRACE("[RpcClient] sent {}", req_type.name); SPDLOG_TRACE("[RpcClient] sent {}", req_type.name);
@ -160,7 +160,7 @@ class Client {
StreamHandler<TRequestResponse> handler(this, std::move(guard), load); StreamHandler<TRequestResponse> handler(this, std::move(guard), load);
// Build and send the request. // Build and send the request.
memgraph::slk::Save(req_type.id, handler.GetBuilder()); slk::Save(req_type.id, handler.GetBuilder());
TRequestResponse::Request::Save(request, handler.GetBuilder()); TRequestResponse::Request::Save(request, handler.GetBuilder());
// Return the handler to the user. // Return the handler to the user.
@ -185,7 +185,7 @@ class Client {
/// Same as `Call` but the first argument is a response loading function. /// Same as `Call` but the first argument is a response loading function.
template <class TRequestResponse, class... Args> template <class TRequestResponse, class... Args>
typename TRequestResponse::Response CallWithLoad( typename TRequestResponse::Response CallWithLoad(
std::function<typename TRequestResponse::Response(memgraph::slk::Reader *)> load, Args &&...args) { std::function<typename TRequestResponse::Response(slk::Reader *)> load, Args &&...args) {
auto stream = StreamWithLoad(load, std::forward<Args>(args)...); auto stream = StreamWithLoad(load, std::forward<Args>(args)...);
return stream.AwaitResponse(); return stream.AwaitResponse();
} }

View File

@ -39,7 +39,7 @@ class Server {
const io::network::Endpoint &endpoint() const; const io::network::Endpoint &endpoint() const;
template <class TRequestResponse> template <class TRequestResponse>
void Register(std::function<void(memgraph::slk::Reader *, memgraph::slk::Builder *)> callback) { void Register(std::function<void(slk::Reader *, slk::Builder *)> callback) {
std::lock_guard<std::mutex> guard(lock_); std::lock_guard<std::mutex> guard(lock_);
MG_ASSERT(!server_.IsRunning(), "You can't register RPCs when the server is running!"); MG_ASSERT(!server_.IsRunning(), "You can't register RPCs when the server is running!");
RpcCallback rpc; RpcCallback rpc;
@ -57,8 +57,7 @@ class Server {
} }
template <class TRequestResponse> template <class TRequestResponse>
void Register( void Register(std::function<void(const io::network::Endpoint &, slk::Reader *, slk::Builder *)> callback) {
std::function<void(const io::network::Endpoint &, memgraph::slk::Reader *, memgraph::slk::Builder *)> callback) {
std::lock_guard<std::mutex> guard(lock_); std::lock_guard<std::mutex> guard(lock_);
MG_ASSERT(!server_.IsRunning(), "You can't register RPCs when the server is running!"); MG_ASSERT(!server_.IsRunning(), "You can't register RPCs when the server is running!");
RpcExtendedCallback rpc; RpcExtendedCallback rpc;
@ -76,13 +75,13 @@ class Server {
struct RpcCallback { struct RpcCallback {
utils::TypeInfo req_type; utils::TypeInfo req_type;
std::function<void(memgraph::slk::Reader *, memgraph::slk::Builder *)> callback; std::function<void(slk::Reader *, slk::Builder *)> callback;
utils::TypeInfo res_type; utils::TypeInfo res_type;
}; };
struct RpcExtendedCallback { struct RpcExtendedCallback {
utils::TypeInfo req_type; utils::TypeInfo req_type;
std::function<void(const io::network::Endpoint &, memgraph::slk::Reader *, memgraph::slk::Builder *)> callback; std::function<void(const io::network::Endpoint &, slk::Reader *, slk::Builder *)> callback;
utils::TypeInfo res_type; utils::TypeInfo res_type;
}; };

View File

@ -136,19 +136,19 @@ MAKE_PRIMITIVE_LOAD(uint64_t)
#undef MAKE_PRIMITIVE_LOAD #undef MAKE_PRIMITIVE_LOAD
inline void Save(float obj, Builder *builder) { memgraph::slk::Save(utils::MemcpyCast<uint32_t>(obj), builder); } inline void Save(float obj, Builder *builder) { slk::Save(utils::MemcpyCast<uint32_t>(obj), builder); }
inline void Save(double obj, Builder *builder) { memgraph::slk::Save(utils::MemcpyCast<uint64_t>(obj), builder); } inline void Save(double obj, Builder *builder) { slk::Save(utils::MemcpyCast<uint64_t>(obj), builder); }
inline void Load(float *obj, Reader *reader) { inline void Load(float *obj, Reader *reader) {
uint32_t obj_encoded; uint32_t obj_encoded;
memgraph::slk::Load(&obj_encoded, reader); slk::Load(&obj_encoded, reader);
*obj = utils::MemcpyCast<float>(obj_encoded); *obj = utils::MemcpyCast<float>(obj_encoded);
} }
inline void Load(double *obj, Reader *reader) { inline void Load(double *obj, Reader *reader) {
uint64_t obj_encoded; uint64_t obj_encoded;
memgraph::slk::Load(&obj_encoded, reader); slk::Load(&obj_encoded, reader);
*obj = utils::MemcpyCast<double>(obj_encoded); *obj = utils::MemcpyCast<double>(obj_encoded);
} }

View File

@ -31,7 +31,7 @@ std::pair<uint64_t, durability::WalDeltaData> ReadDelta(durability::BaseDecoder
SPDLOG_INFO(" Timestamp {}", timestamp); SPDLOG_INFO(" Timestamp {}", timestamp);
auto delta = ReadWalDeltaData(decoder); auto delta = ReadWalDeltaData(decoder);
return {timestamp, delta}; return {timestamp, delta};
} catch (const memgraph::slk::SlkReaderException &) { } catch (const slk::SlkReaderException &) {
throw utils::BasicException("Missing data!"); throw utils::BasicException("Missing data!");
} catch (const durability::RecoveryFailure &) { } catch (const durability::RecoveryFailure &) {
throw utils::BasicException("Invalid data!"); throw utils::BasicException("Invalid data!");
@ -79,18 +79,16 @@ Storage::ReplicationServer::ReplicationServer(Storage *storage, io::network::End
rpc_server_->Start(); rpc_server_->Start();
} }
void Storage::ReplicationServer::HeartbeatHandler(memgraph::slk::Reader *req_reader, void Storage::ReplicationServer::HeartbeatHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
memgraph::slk::Builder *res_builder) {
replication::HeartbeatReq req; replication::HeartbeatReq req;
memgraph::slk::Load(&req, req_reader); slk::Load(&req, req_reader);
replication::HeartbeatRes res{true, storage_->last_commit_timestamp_.load(), storage_->epoch_id_}; replication::HeartbeatRes res{true, storage_->last_commit_timestamp_.load(), storage_->epoch_id_};
memgraph::slk::Save(res, res_builder); slk::Save(res, res_builder);
} }
void Storage::ReplicationServer::AppendDeltasHandler(memgraph::slk::Reader *req_reader, void Storage::ReplicationServer::AppendDeltasHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
memgraph::slk::Builder *res_builder) {
replication::AppendDeltasReq req; replication::AppendDeltasReq req;
memgraph::slk::Load(&req, req_reader); slk::Load(&req, req_reader);
replication::Decoder decoder(req_reader); replication::Decoder decoder(req_reader);
@ -125,20 +123,19 @@ void Storage::ReplicationServer::AppendDeltasHandler(memgraph::slk::Reader *req_
} }
replication::AppendDeltasRes res{false, storage_->last_commit_timestamp_.load()}; replication::AppendDeltasRes res{false, storage_->last_commit_timestamp_.load()};
memgraph::slk::Save(res, res_builder); slk::Save(res, res_builder);
return; return;
} }
ReadAndApplyDelta(&decoder); ReadAndApplyDelta(&decoder);
replication::AppendDeltasRes res{true, storage_->last_commit_timestamp_.load()}; replication::AppendDeltasRes res{true, storage_->last_commit_timestamp_.load()};
memgraph::slk::Save(res, res_builder); slk::Save(res, res_builder);
} }
void Storage::ReplicationServer::SnapshotHandler(memgraph::slk::Reader *req_reader, void Storage::ReplicationServer::SnapshotHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
memgraph::slk::Builder *res_builder) {
replication::SnapshotReq req; replication::SnapshotReq req;
memgraph::slk::Load(&req, req_reader); slk::Load(&req, req_reader);
replication::Decoder decoder(req_reader); replication::Decoder decoder(req_reader);
@ -180,7 +177,7 @@ void Storage::ReplicationServer::SnapshotHandler(memgraph::slk::Reader *req_read
storage_guard.unlock(); storage_guard.unlock();
replication::SnapshotRes res{true, storage_->last_commit_timestamp_.load()}; replication::SnapshotRes res{true, storage_->last_commit_timestamp_.load()};
memgraph::slk::Save(res, res_builder); slk::Save(res, res_builder);
// Delete other durability files // Delete other durability files
auto snapshot_files = durability::GetSnapshotFiles(storage_->snapshot_directory_, storage_->uuid_); auto snapshot_files = durability::GetSnapshotFiles(storage_->snapshot_directory_, storage_->uuid_);
@ -200,10 +197,9 @@ void Storage::ReplicationServer::SnapshotHandler(memgraph::slk::Reader *req_read
} }
} }
void Storage::ReplicationServer::WalFilesHandler(memgraph::slk::Reader *req_reader, void Storage::ReplicationServer::WalFilesHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
memgraph::slk::Builder *res_builder) {
replication::WalFilesReq req; replication::WalFilesReq req;
memgraph::slk::Load(&req, req_reader); slk::Load(&req, req_reader);
const auto wal_file_number = req.file_number; const auto wal_file_number = req.file_number;
spdlog::debug("Received WAL files: {}", wal_file_number); spdlog::debug("Received WAL files: {}", wal_file_number);
@ -217,13 +213,12 @@ void Storage::ReplicationServer::WalFilesHandler(memgraph::slk::Reader *req_read
} }
replication::WalFilesRes res{true, storage_->last_commit_timestamp_.load()}; replication::WalFilesRes res{true, storage_->last_commit_timestamp_.load()};
memgraph::slk::Save(res, res_builder); slk::Save(res, res_builder);
} }
void Storage::ReplicationServer::CurrentWalHandler(memgraph::slk::Reader *req_reader, void Storage::ReplicationServer::CurrentWalHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
memgraph::slk::Builder *res_builder) {
replication::CurrentWalReq req; replication::CurrentWalReq req;
memgraph::slk::Load(&req, req_reader); slk::Load(&req, req_reader);
replication::Decoder decoder(req_reader); replication::Decoder decoder(req_reader);
@ -232,7 +227,7 @@ void Storage::ReplicationServer::CurrentWalHandler(memgraph::slk::Reader *req_re
LoadWal(&decoder); LoadWal(&decoder);
replication::CurrentWalRes res{true, storage_->last_commit_timestamp_.load()}; replication::CurrentWalRes res{true, storage_->last_commit_timestamp_.load()};
memgraph::slk::Save(res, res_builder); slk::Save(res, res_builder);
} }
void Storage::ReplicationServer::LoadWal(replication::Decoder *decoder) { void Storage::ReplicationServer::LoadWal(replication::Decoder *decoder) {

View File

@ -28,11 +28,11 @@ class Storage::ReplicationServer {
private: private:
// RPC handlers // RPC handlers
void HeartbeatHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); void HeartbeatHandler(slk::Reader *req_reader, slk::Builder *res_builder);
void AppendDeltasHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); void AppendDeltasHandler(slk::Reader *req_reader, slk::Builder *res_builder);
void SnapshotHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); void SnapshotHandler(slk::Reader *req_reader, slk::Builder *res_builder);
void WalFilesHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); void WalFilesHandler(slk::Reader *req_reader, slk::Builder *res_builder);
void CurrentWalHandler(memgraph::slk::Reader *req_reader, memgraph::slk::Builder *res_builder); void CurrentWalHandler(slk::Reader *req_reader, slk::Builder *res_builder);
void LoadWal(replication::Decoder *decoder); void LoadWal(replication::Decoder *decoder);
uint64_t ReadAndApplyDelta(durability::BaseDecoder *decoder); uint64_t ReadAndApplyDelta(durability::BaseDecoder *decoder);

View File

@ -13,31 +13,31 @@
namespace memgraph::storage::replication { namespace memgraph::storage::replication {
////// Encoder ////// ////// Encoder //////
void Encoder::WriteMarker(durability::Marker marker) { memgraph::slk::Save(marker, builder_); } void Encoder::WriteMarker(durability::Marker marker) { slk::Save(marker, builder_); }
void Encoder::WriteBool(bool value) { void Encoder::WriteBool(bool value) {
WriteMarker(durability::Marker::TYPE_BOOL); WriteMarker(durability::Marker::TYPE_BOOL);
memgraph::slk::Save(value, builder_); slk::Save(value, builder_);
} }
void Encoder::WriteUint(uint64_t value) { void Encoder::WriteUint(uint64_t value) {
WriteMarker(durability::Marker::TYPE_INT); WriteMarker(durability::Marker::TYPE_INT);
memgraph::slk::Save(value, builder_); slk::Save(value, builder_);
} }
void Encoder::WriteDouble(double value) { void Encoder::WriteDouble(double value) {
WriteMarker(durability::Marker::TYPE_DOUBLE); WriteMarker(durability::Marker::TYPE_DOUBLE);
memgraph::slk::Save(value, builder_); slk::Save(value, builder_);
} }
void Encoder::WriteString(const std::string_view &value) { void Encoder::WriteString(const std::string_view &value) {
WriteMarker(durability::Marker::TYPE_STRING); WriteMarker(durability::Marker::TYPE_STRING);
memgraph::slk::Save(value, builder_); slk::Save(value, builder_);
} }
void Encoder::WritePropertyValue(const PropertyValue &value) { void Encoder::WritePropertyValue(const PropertyValue &value) {
WriteMarker(durability::Marker::TYPE_PROPERTY_VALUE); WriteMarker(durability::Marker::TYPE_PROPERTY_VALUE);
memgraph::slk::Save(value, builder_); slk::Save(value, builder_);
} }
void Encoder::WriteBuffer(const uint8_t *buffer, const size_t buffer_size) { builder_->Save(buffer, buffer_size); } void Encoder::WriteBuffer(const uint8_t *buffer, const size_t buffer_size) { builder_->Save(buffer, buffer_size); }
@ -68,35 +68,35 @@ void Encoder::WriteFile(const std::filesystem::path &path) {
////// Decoder ////// ////// Decoder //////
std::optional<durability::Marker> Decoder::ReadMarker() { std::optional<durability::Marker> Decoder::ReadMarker() {
durability::Marker marker; durability::Marker marker;
memgraph::slk::Load(&marker, reader_); slk::Load(&marker, reader_);
return marker; return marker;
} }
std::optional<bool> Decoder::ReadBool() { std::optional<bool> Decoder::ReadBool() {
if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_BOOL) return std::nullopt; if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_BOOL) return std::nullopt;
bool value; bool value;
memgraph::slk::Load(&value, reader_); slk::Load(&value, reader_);
return value; return value;
} }
std::optional<uint64_t> Decoder::ReadUint() { std::optional<uint64_t> Decoder::ReadUint() {
if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_INT) return std::nullopt; if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_INT) return std::nullopt;
uint64_t value; uint64_t value;
memgraph::slk::Load(&value, reader_); slk::Load(&value, reader_);
return value; return value;
} }
std::optional<double> Decoder::ReadDouble() { std::optional<double> Decoder::ReadDouble() {
if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_DOUBLE) return std::nullopt; if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_DOUBLE) return std::nullopt;
double value; double value;
memgraph::slk::Load(&value, reader_); slk::Load(&value, reader_);
return value; return value;
} }
std::optional<std::string> Decoder::ReadString() { std::optional<std::string> Decoder::ReadString() {
if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_STRING) return std::nullopt; if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_STRING) return std::nullopt;
std::string value; std::string value;
memgraph::slk::Load(&value, reader_); slk::Load(&value, reader_);
return std::move(value); return std::move(value);
} }
@ -104,21 +104,21 @@ std::optional<PropertyValue> Decoder::ReadPropertyValue() {
if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_PROPERTY_VALUE) if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_PROPERTY_VALUE)
return std::nullopt; return std::nullopt;
PropertyValue value; PropertyValue value;
memgraph::slk::Load(&value, reader_); slk::Load(&value, reader_);
return std::move(value); return std::move(value);
} }
bool Decoder::SkipString() { bool Decoder::SkipString() {
if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_STRING) return false; if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_STRING) return false;
std::string value; std::string value;
memgraph::slk::Load(&value, reader_); slk::Load(&value, reader_);
return true; return true;
} }
bool Decoder::SkipPropertyValue() { bool Decoder::SkipPropertyValue() {
if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_PROPERTY_VALUE) return false; if (const auto marker = ReadMarker(); !marker || marker != durability::Marker::TYPE_PROPERTY_VALUE) return false;
PropertyValue value; PropertyValue value;
memgraph::slk::Load(&value, reader_); slk::Load(&value, reader_);
return true; return true;
} }

View File

@ -23,7 +23,7 @@ namespace memgraph::storage::replication {
class Encoder final : public durability::BaseEncoder { class Encoder final : public durability::BaseEncoder {
public: public:
explicit Encoder(memgraph::slk::Builder *builder) : builder_(builder) {} explicit Encoder(slk::Builder *builder) : builder_(builder) {}
void WriteMarker(durability::Marker marker) override; void WriteMarker(durability::Marker marker) override;
@ -44,12 +44,12 @@ class Encoder final : public durability::BaseEncoder {
void WriteFile(const std::filesystem::path &path); void WriteFile(const std::filesystem::path &path);
private: private:
memgraph::slk::Builder *builder_; slk::Builder *builder_;
}; };
class Decoder final : public durability::BaseDecoder { class Decoder final : public durability::BaseDecoder {
public: public:
explicit Decoder(memgraph::slk::Reader *reader) : reader_(reader) {} explicit Decoder(slk::Reader *reader) : reader_(reader) {}
std::optional<durability::Marker> ReadMarker() override; std::optional<durability::Marker> ReadMarker() override;
@ -74,7 +74,7 @@ class Decoder final : public durability::BaseDecoder {
std::optional<std::filesystem::path> ReadFile(const std::filesystem::path &directory, const std::string &suffix = ""); std::optional<std::filesystem::path> ReadFile(const std::filesystem::path &directory, const std::string &suffix = "");
private: private:
memgraph::slk::Reader *reader_; slk::Reader *reader_;
}; };
} // namespace memgraph::storage::replication } // namespace memgraph::storage::replication

View File

@ -19,150 +19,148 @@
namespace memgraph::slk { namespace memgraph::slk {
void Save(const memgraph::storage::Gid &gid, memgraph::slk::Builder *builder) { void Save(const storage::Gid &gid, slk::Builder *builder) { slk::Save(gid.AsUint(), builder); }
memgraph::slk::Save(gid.AsUint(), builder);
}
void Load(memgraph::storage::Gid *gid, memgraph::slk::Reader *reader) { void Load(storage::Gid *gid, slk::Reader *reader) {
uint64_t value; uint64_t value;
memgraph::slk::Load(&value, reader); slk::Load(&value, reader);
*gid = memgraph::storage::Gid::FromUint(value); *gid = storage::Gid::FromUint(value);
} }
void Load(memgraph::storage::PropertyValue::Type *type, memgraph::slk::Reader *reader) { void Load(storage::PropertyValue::Type *type, slk::Reader *reader) {
using PVTypeUnderlyingType = std::underlying_type_t<memgraph::storage::PropertyValue::Type>; using PVTypeUnderlyingType = std::underlying_type_t<storage::PropertyValue::Type>;
PVTypeUnderlyingType value{}; PVTypeUnderlyingType value{};
memgraph::slk::Load(&value, reader); slk::Load(&value, reader);
bool valid; bool valid;
switch (value) { switch (value) {
case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Null): case utils::UnderlyingCast(storage::PropertyValue::Type::Null):
case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Bool): case utils::UnderlyingCast(storage::PropertyValue::Type::Bool):
case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Int): case utils::UnderlyingCast(storage::PropertyValue::Type::Int):
case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Double): case utils::UnderlyingCast(storage::PropertyValue::Type::Double):
case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::String): case utils::UnderlyingCast(storage::PropertyValue::Type::String):
case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::List): case utils::UnderlyingCast(storage::PropertyValue::Type::List):
case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::Map): case utils::UnderlyingCast(storage::PropertyValue::Type::Map):
case utils::UnderlyingCast(memgraph::storage::PropertyValue::Type::TemporalData): case utils::UnderlyingCast(storage::PropertyValue::Type::TemporalData):
valid = true; valid = true;
break; break;
default: default:
valid = false; valid = false;
break; break;
} }
if (!valid) throw slk::SlkDecodeException("Trying to load unknown memgraph::storage::PropertyValue!"); if (!valid) throw slk::SlkDecodeException("Trying to load unknown storage::PropertyValue!");
*type = static_cast<memgraph::storage::PropertyValue::Type>(value); *type = static_cast<storage::PropertyValue::Type>(value);
} }
void Save(const memgraph::storage::PropertyValue &value, memgraph::slk::Builder *builder) { void Save(const storage::PropertyValue &value, slk::Builder *builder) {
switch (value.type()) { switch (value.type()) {
case memgraph::storage::PropertyValue::Type::Null: case storage::PropertyValue::Type::Null:
memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Null, builder); slk::Save(storage::PropertyValue::Type::Null, builder);
return; return;
case memgraph::storage::PropertyValue::Type::Bool: case storage::PropertyValue::Type::Bool:
memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Bool, builder); slk::Save(storage::PropertyValue::Type::Bool, builder);
memgraph::slk::Save(value.ValueBool(), builder); slk::Save(value.ValueBool(), builder);
return; return;
case memgraph::storage::PropertyValue::Type::Int: case storage::PropertyValue::Type::Int:
memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Int, builder); slk::Save(storage::PropertyValue::Type::Int, builder);
memgraph::slk::Save(value.ValueInt(), builder); slk::Save(value.ValueInt(), builder);
return; return;
case memgraph::storage::PropertyValue::Type::Double: case storage::PropertyValue::Type::Double:
memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Double, builder); slk::Save(storage::PropertyValue::Type::Double, builder);
memgraph::slk::Save(value.ValueDouble(), builder); slk::Save(value.ValueDouble(), builder);
return; return;
case memgraph::storage::PropertyValue::Type::String: case storage::PropertyValue::Type::String:
memgraph::slk::Save(memgraph::storage::PropertyValue::Type::String, builder); slk::Save(storage::PropertyValue::Type::String, builder);
memgraph::slk::Save(value.ValueString(), builder); slk::Save(value.ValueString(), builder);
return; return;
case memgraph::storage::PropertyValue::Type::List: { case storage::PropertyValue::Type::List: {
memgraph::slk::Save(memgraph::storage::PropertyValue::Type::List, builder); slk::Save(storage::PropertyValue::Type::List, builder);
const auto &values = value.ValueList(); const auto &values = value.ValueList();
size_t size = values.size(); size_t size = values.size();
memgraph::slk::Save(size, builder); slk::Save(size, builder);
for (const auto &v : values) { for (const auto &v : values) {
memgraph::slk::Save(v, builder); slk::Save(v, builder);
} }
return; return;
} }
case memgraph::storage::PropertyValue::Type::Map: { case storage::PropertyValue::Type::Map: {
memgraph::slk::Save(memgraph::storage::PropertyValue::Type::Map, builder); slk::Save(storage::PropertyValue::Type::Map, builder);
const auto &map = value.ValueMap(); const auto &map = value.ValueMap();
size_t size = map.size(); size_t size = map.size();
memgraph::slk::Save(size, builder); slk::Save(size, builder);
for (const auto &kv : map) { for (const auto &kv : map) {
memgraph::slk::Save(kv, builder); slk::Save(kv, builder);
} }
return; return;
} }
case memgraph::storage::PropertyValue::Type::TemporalData: { case storage::PropertyValue::Type::TemporalData: {
memgraph::slk::Save(memgraph::storage::PropertyValue::Type::TemporalData, builder); slk::Save(storage::PropertyValue::Type::TemporalData, builder);
const auto temporal_data = value.ValueTemporalData(); const auto temporal_data = value.ValueTemporalData();
memgraph::slk::Save(temporal_data.type, builder); slk::Save(temporal_data.type, builder);
memgraph::slk::Save(temporal_data.microseconds, builder); slk::Save(temporal_data.microseconds, builder);
return; return;
} }
} }
} }
void Load(memgraph::storage::PropertyValue *value, memgraph::slk::Reader *reader) { void Load(storage::PropertyValue *value, slk::Reader *reader) {
memgraph::storage::PropertyValue::Type type{}; storage::PropertyValue::Type type{};
memgraph::slk::Load(&type, reader); slk::Load(&type, reader);
switch (type) { switch (type) {
case memgraph::storage::PropertyValue::Type::Null: case storage::PropertyValue::Type::Null:
*value = memgraph::storage::PropertyValue(); *value = storage::PropertyValue();
return; return;
case memgraph::storage::PropertyValue::Type::Bool: { case storage::PropertyValue::Type::Bool: {
bool v; bool v;
memgraph::slk::Load(&v, reader); slk::Load(&v, reader);
*value = memgraph::storage::PropertyValue(v); *value = storage::PropertyValue(v);
return; return;
} }
case memgraph::storage::PropertyValue::Type::Int: { case storage::PropertyValue::Type::Int: {
int64_t v; int64_t v;
memgraph::slk::Load(&v, reader); slk::Load(&v, reader);
*value = memgraph::storage::PropertyValue(v); *value = storage::PropertyValue(v);
return; return;
} }
case memgraph::storage::PropertyValue::Type::Double: { case storage::PropertyValue::Type::Double: {
double v; double v;
memgraph::slk::Load(&v, reader); slk::Load(&v, reader);
*value = memgraph::storage::PropertyValue(v); *value = storage::PropertyValue(v);
return; return;
} }
case memgraph::storage::PropertyValue::Type::String: { case storage::PropertyValue::Type::String: {
std::string v; std::string v;
memgraph::slk::Load(&v, reader); slk::Load(&v, reader);
*value = memgraph::storage::PropertyValue(std::move(v)); *value = storage::PropertyValue(std::move(v));
return; return;
} }
case memgraph::storage::PropertyValue::Type::List: { case storage::PropertyValue::Type::List: {
size_t size; size_t size;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
std::vector<memgraph::storage::PropertyValue> list(size); std::vector<storage::PropertyValue> list(size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&list[i], reader); slk::Load(&list[i], reader);
} }
*value = memgraph::storage::PropertyValue(std::move(list)); *value = storage::PropertyValue(std::move(list));
return; return;
} }
case memgraph::storage::PropertyValue::Type::Map: { case storage::PropertyValue::Type::Map: {
size_t size; size_t size;
memgraph::slk::Load(&size, reader); slk::Load(&size, reader);
std::map<std::string, memgraph::storage::PropertyValue> map; std::map<std::string, storage::PropertyValue> map;
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
std::pair<std::string, memgraph::storage::PropertyValue> kv; std::pair<std::string, storage::PropertyValue> kv;
memgraph::slk::Load(&kv, reader); slk::Load(&kv, reader);
map.insert(kv); map.insert(kv);
} }
*value = memgraph::storage::PropertyValue(std::move(map)); *value = storage::PropertyValue(std::move(map));
return; return;
} }
case memgraph::storage::PropertyValue::Type::TemporalData: { case storage::PropertyValue::Type::TemporalData: {
memgraph::storage::TemporalType temporal_type{}; storage::TemporalType temporal_type{};
memgraph::slk::Load(&temporal_type, reader); slk::Load(&temporal_type, reader);
int64_t microseconds{0}; int64_t microseconds{0};
memgraph::slk::Load(&microseconds, reader); slk::Load(&microseconds, reader);
*value = memgraph::storage::PropertyValue(memgraph::storage::TemporalData{temporal_type, microseconds}); *value = storage::PropertyValue(storage::TemporalData{temporal_type, microseconds});
return; return;
} }
} }

View File

@ -19,22 +19,22 @@
namespace memgraph::slk { namespace memgraph::slk {
void Save(const memgraph::storage::Gid &gid, memgraph::slk::Builder *builder); void Save(const storage::Gid &gid, slk::Builder *builder);
void Load(memgraph::storage::Gid *gid, memgraph::slk::Reader *reader); void Load(storage::Gid *gid, slk::Reader *reader);
void Save(const memgraph::storage::PropertyValue &value, memgraph::slk::Builder *builder); void Save(const storage::PropertyValue &value, slk::Builder *builder);
void Load(memgraph::storage::PropertyValue *value, memgraph::slk::Reader *reader); void Load(storage::PropertyValue *value, slk::Reader *reader);
template <utils::Enum T> template <utils::Enum T>
void Save(const T &enum_value, memgraph::slk::Builder *builder) { void Save(const T &enum_value, slk::Builder *builder) {
memgraph::slk::Save(utils::UnderlyingCast(enum_value), builder); slk::Save(utils::UnderlyingCast(enum_value), builder);
} }
template <utils::Enum T> template <utils::Enum T>
void Load(T *enum_value, memgraph::slk::Reader *reader) { void Load(T *enum_value, slk::Reader *reader) {
using UnderlyingType = std::underlying_type_t<T>; using UnderlyingType = std::underlying_type_t<T>;
UnderlyingType value; UnderlyingType value;
memgraph::slk::Load(&value, reader); slk::Load(&value, reader);
*enum_value = static_cast<T>(value); *enum_value = static_cast<T>(value);
} }

View File

@ -243,15 +243,15 @@ bool LicenseChecker::IsValidLicenseFast() const { return is_valid_.load(std::mem
std::string Encode(const License &license) { std::string Encode(const License &license) {
std::vector<uint8_t> buffer; std::vector<uint8_t> buffer;
memgraph::slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool /*have_more*/) { slk::Builder builder([&buffer](const uint8_t *data, size_t size, bool /*have_more*/) {
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
buffer.push_back(data[i]); buffer.push_back(data[i]);
} }
}); });
memgraph::slk::Save(license.organization_name, &builder); slk::Save(license.organization_name, &builder);
memgraph::slk::Save(license.valid_until, &builder); slk::Save(license.valid_until, &builder);
memgraph::slk::Save(license.memory_limit, &builder); slk::Save(license.memory_limit, &builder);
builder.Finalize(); builder.Finalize();
return std::string{license_key_prefix} + base64_encode(buffer.data(), buffer.size()); return std::string{license_key_prefix} + base64_encode(buffer.data(), buffer.size());
@ -277,15 +277,15 @@ std::optional<License> Decode(std::string_view license_key) {
} }
try { try {
memgraph::slk::Reader reader(std::bit_cast<uint8_t *>(decoded->c_str()), decoded->size()); slk::Reader reader(std::bit_cast<uint8_t *>(decoded->c_str()), decoded->size());
std::string organization_name; std::string organization_name;
memgraph::slk::Load(&organization_name, &reader); slk::Load(&organization_name, &reader);
int64_t valid_until{0}; int64_t valid_until{0};
memgraph::slk::Load(&valid_until, &reader); slk::Load(&valid_until, &reader);
int64_t memory_limit{0}; int64_t memory_limit{0};
memgraph::slk::Load(&memory_limit, &reader); slk::Load(&memory_limit, &reader);
return License{.organization_name = organization_name, .valid_until = valid_until, .memory_limit = memory_limit}; return License{.organization_name = organization_name, .valid_until = valid_until, .memory_limit = memory_limit};
} catch (const memgraph::slk::SlkReaderException &e) { } catch (const slk::SlkReaderException &e) {
return std::nullopt; return std::nullopt;
} }
} }

View File

@ -65,9 +65,6 @@ inline uint64_t NextPowerOf2(uint64_t a) {
return a + 1; return a + 1;
} }
} // namespace detail } // namespace detail
} // namespace memgraph::utils
namespace memgraph::utils {
/// This is all the non-templated stuff common to all SmallVectors. /// This is all the non-templated stuff common to all SmallVectors.
class SmallVectorBase { class SmallVectorBase {