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;
return $((CODE || FAIL))
return ${FAIL}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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 "
"entered password to ensure its strength.");
namespace memgraph {
namespace auth {
namespace memgraph::auth {
namespace {
// Constant list of all available permissions.
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_ &&
first.permissions_ == second.permissions_ && first.role_ == second.role_;
}
} // namespace auth
} // namespace memgraph
} // namespace memgraph::auth

View File

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

View File

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

View File

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

View File

@ -37,10 +37,10 @@ namespace memgraph::communication {
* that has `num_workers` threads. It is started automatically on constructor,
* and stopped at destructor.
*
* Current Server achitecture:
* Current Server architecture:
* 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!
*
* @tparam TSession the server can handle different Sessions, each session

View File

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

View File

@ -15,9 +15,9 @@
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 PrivilegeToPermission(memgraph::query::AuthQuery::Privilege privilege);
auth::Permission PrivilegeToPermission(query::AuthQuery::Privilege privilege);
} // namespace memgraph::glue

View File

@ -24,28 +24,28 @@ using memgraph::communication::bolt::Value;
namespace memgraph::glue {
memgraph::query::TypedValue ToTypedValue(const Value &value) {
query::TypedValue ToTypedValue(const Value &value) {
switch (value.type()) {
case Value::Type::Null:
return {};
case Value::Type::Bool:
return memgraph::query::TypedValue(value.ValueBool());
return query::TypedValue(value.ValueBool());
case Value::Type::Int:
return memgraph::query::TypedValue(value.ValueInt());
return query::TypedValue(value.ValueInt());
case Value::Type::Double:
return memgraph::query::TypedValue(value.ValueDouble());
return query::TypedValue(value.ValueDouble());
case Value::Type::String:
return memgraph::query::TypedValue(value.ValueString());
return query::TypedValue(value.ValueString());
case Value::Type::List: {
std::vector<memgraph::query::TypedValue> list;
std::vector<query::TypedValue> list;
list.reserve(value.ValueList().size());
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: {
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));
return memgraph::query::TypedValue(std::move(map));
return query::TypedValue(std::move(map));
}
case Value::Type::Vertex:
case Value::Type::Edge:
@ -53,40 +53,39 @@ memgraph::query::TypedValue ToTypedValue(const Value &value) {
case Value::Type::Path:
throw communication::bolt::ValueException("Unsupported conversion from Value to TypedValue");
case Value::Type::Date:
return memgraph::query::TypedValue(value.ValueDate());
return query::TypedValue(value.ValueDate());
case Value::Type::LocalTime:
return memgraph::query::TypedValue(value.ValueLocalTime());
return query::TypedValue(value.ValueLocalTime());
case Value::Type::LocalDateTime:
return memgraph::query::TypedValue(value.ValueLocalDateTime());
return query::TypedValue(value.ValueLocalDateTime());
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) {
return ToBoltVertex(vertex.impl_, db, view);
}
storage::Result<communication::bolt::Edge> ToBoltEdge(const memgraph::query::EdgeAccessor &edge,
const storage::Storage &db, storage::View view) {
storage::Result<communication::bolt::Edge> ToBoltEdge(const query::EdgeAccessor &edge, const storage::Storage &db,
storage::View view) {
return ToBoltEdge(edge.impl_, db, view);
}
storage::Result<Value> ToBoltValue(const memgraph::query::TypedValue &value, const storage::Storage &db,
storage::View view) {
storage::Result<Value> ToBoltValue(const query::TypedValue &value, const storage::Storage &db, storage::View view) {
switch (value.type()) {
case memgraph::query::TypedValue::Type::Null:
case query::TypedValue::Type::Null:
return Value();
case memgraph::query::TypedValue::Type::Bool:
case query::TypedValue::Type::Bool:
return Value(value.ValueBool());
case memgraph::query::TypedValue::Type::Int:
case query::TypedValue::Type::Int:
return Value(value.ValueInt());
case memgraph::query::TypedValue::Type::Double:
case query::TypedValue::Type::Double:
return Value(value.ValueDouble());
case memgraph::query::TypedValue::Type::String:
case query::TypedValue::Type::String:
return Value(std::string(value.ValueString()));
case memgraph::query::TypedValue::Type::List: {
case query::TypedValue::Type::List: {
std::vector<Value> values;
values.reserve(value.ValueList().size());
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));
}
case memgraph::query::TypedValue::Type::Map: {
case query::TypedValue::Type::Map: {
std::map<std::string, Value> map;
for (const auto &kv : value.ValueMap()) {
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));
}
case memgraph::query::TypedValue::Type::Vertex: {
case query::TypedValue::Type::Vertex: {
auto maybe_vertex = ToBoltVertex(value.ValueVertex(), db, view);
if (maybe_vertex.HasError()) return maybe_vertex.GetError();
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);
if (maybe_edge.HasError()) return maybe_edge.GetError();
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);
if (maybe_path.HasError()) return maybe_path.GetError();
return Value(std::move(*maybe_path));
}
case memgraph::query::TypedValue::Type::Date:
case query::TypedValue::Type::Date:
return Value(value.ValueDate());
case memgraph::query::TypedValue::Type::LocalTime:
case query::TypedValue::Type::LocalTime:
return Value(value.ValueLocalTime());
case memgraph::query::TypedValue::Type::LocalDateTime:
case query::TypedValue::Type::LocalDateTime:
return Value(value.ValueLocalDateTime());
case memgraph::query::TypedValue::Type::Duration:
case query::TypedValue::Type::Duration:
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};
}
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) {
std::vector<communication::bolt::Vertex> vertices;
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::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::View for ToBoltVertex and ToBoltEdge.
///
/// @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);
/// @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::View for ToBoltVertex and ToBoltEdge.
///
/// @throw std::bad_alloc
storage::Result<communication::bolt::Value> ToBoltValue(const memgraph::query::TypedValue &value,
const storage::Storage &db, storage::View view);
storage::Result<communication::bolt::Value> ToBoltValue(const query::TypedValue &value, const storage::Storage &db,
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);

View File

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

View File

@ -5,7 +5,3 @@ find_package(ZLIB REQUIRED)
# STATIC library used to store key-value pairs
add_library(mg-kvstore STATIC kvstore.cpp)
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)
(assert (cpp-type-simple-class-p cpp-class))
(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
(cpp-class-type-info-opts cpp-class)))
(virtual (if (and (or type-info-basep
@ -68,7 +68,7 @@ NIL, returns a string."
(cpp-class-super-classes cpp-class))
"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))))
(defun type-info-definition-for-class (cpp-class)

View File

@ -17,12 +17,12 @@ namespace memgraph::query {
class AuthChecker {
public:
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,
const std::vector<memgraph::query::AuthQuery::Privilege> &privileges) const override {
const std::vector<query::AuthQuery::Privilege> &privileges) const override {
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);
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);
@ -91,8 +91,7 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::stri
}
if (visitor.GetQueryInfo().is_cacheable) {
CachedQuery cached_query{std::move(ast_storage), visitor.query(),
memgraph::query::GetRequiredPrivileges(visitor.query())};
CachedQuery cached_query{std::move(ast_storage), visitor.query(), query::GetRequiredPrivileges(visitor.query())};
it = accessor.insert({hash, std::move(cached_query)}).first;
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.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;
}

View File

@ -17,7 +17,7 @@
namespace memgraph::query {
struct DiscardValueResultStream final {
void Result(const std::vector<memgraph::query::TypedValue> & /*values*/) {
void Result(const std::vector<query::TypedValue> & /*values*/) {
// 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,
std::optional<int64_t> property_id = std::nullopt) {
*os << "{";
@ -168,20 +168,20 @@ void DumpProperties(std::ostream *os, memgraph::query::DbAccessor *dba,
*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 << ":" << kInternalVertexLabel;
auto maybe_labels = vertex.Labels(storage::View::OLD);
if (maybe_labels.HasError()) {
switch (maybe_labels.GetError()) {
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:
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::VERTEX_HAS_EDGES:
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) {
@ -192,20 +192,20 @@ void DumpVertex(std::ostream *os, memgraph::query::DbAccessor *dba, const memgra
if (maybe_props.HasError()) {
switch (maybe_props.GetError()) {
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:
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::VERTEX_HAS_EDGES:
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());
*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 << "(u:" << kInternalVertexLabel << "), ";
*os << "(v:" << kInternalVertexLabel << ")";
@ -219,13 +219,13 @@ void DumpEdge(std::ostream *os, memgraph::query::DbAccessor *dba, const memgraph
if (maybe_props.HasError()) {
switch (maybe_props.GetError()) {
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:
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::VERTEX_HAS_EDGES:
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) {
@ -235,23 +235,23 @@ void DumpEdge(std::ostream *os, memgraph::query::DbAccessor *dba, const memgraph
*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)) << ";";
}
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) {
*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) {
*os << "CREATE CONSTRAINT ON (u:" << EscapeName(dba->LabelToName(label)) << ") ASSERT EXISTS (u."
<< 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) {
*os << "CREATE CONSTRAINT ON (u:" << EscapeName(dba->LabelToName(label)) << ") ASSERT ";
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) {
PullPlanDump(dba).Pull(stream, {});
}
void DumpDatabaseToCypherQueries(query::DbAccessor *dba, AnyStream *stream) { PullPlanDump(dba).Pull(stream, {}); }
} // namespace memgraph::query

View File

@ -19,22 +19,22 @@
namespace memgraph::query {
void DumpDatabaseToCypherQueries(memgraph::query::DbAccessor *dba, AnyStream *stream);
void DumpDatabaseToCypherQueries(query::DbAccessor *dba, AnyStream *stream);
struct PullPlanDump {
explicit PullPlanDump(memgraph::query::DbAccessor *dba);
explicit PullPlanDump(query::DbAccessor *dba);
/// Pull the dump results lazily
/// @return true if all results were returned, false otherwise
bool Pull(AnyStream *stream, std::optional<int> n);
private:
memgraph::query::DbAccessor *dba_ = nullptr;
query::DbAccessor *dba_ = nullptr;
std::optional<storage::IndicesInfo> indices_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 EdgeAccessorIterable = decltype(std::declval<VertexAccessor>().OutEdges(storage::View::OLD));

View File

@ -43,7 +43,7 @@ cpp<#
(defun slk-save-ast-vector (member)
#>cpp
size_t size = self.${member}.size();
memgraph::slk::Save(size, builder);
slk::Save(size, builder);
for (const auto *val : self.${member}) {
query::SaveAstPointer(val, builder);
}
@ -53,7 +53,7 @@ cpp<#
(lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
self->${member}[i] = query::LoadAstPointer<query::${type}>(storage, reader);
@ -63,9 +63,9 @@ cpp<#
(defun slk-save-property-map (member)
#>cpp
size_t size = self.${member}.size();
memgraph::slk::Save(size, builder);
slk::Save(size, builder);
for (const auto &entry : self.${member}) {
memgraph::slk::Save(entry.first, builder);
slk::Save(entry.first, builder);
query::SaveAstPointer(entry.second, builder);
}
cpp<#)
@ -73,10 +73,10 @@ cpp<#
(defun slk-load-property-map (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
for (size_t i = 0; i < size; ++i) {
query::PropertyIx key;
memgraph::slk::Load(&key, reader, storage);
slk::Load(&key, reader, storage);
auto *value = query::LoadAstPointer<query::Expression>(storage, reader);
self->${member}.emplace(key, value);
}
@ -93,7 +93,7 @@ cpp<#
(defun slk-save-expression-map (member)
#>cpp
size_t size = self.${member}.size();
memgraph::slk::Save(size, builder);
slk::Save(size, builder);
for (const auto &entry : self.${member}) {
query::SaveAstPointer(entry.first, builder);
query::SaveAstPointer(entry.second, builder);
@ -103,7 +103,7 @@ cpp<#
(defun slk-load-expression-map (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
for (size_t i = 0; i < size; ++i) {
auto *key = query::LoadAstPointer<query::Expression>(storage, reader);
auto *value = query::LoadAstPointer<query::Expression>(storage, reader);
@ -299,9 +299,9 @@ cpp<#
;;; Expressions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(lcp:define-class expression (tree "utils::Visitable<HierarchicalTreeVisitor>"
"utils::Visitable<ExpressionVisitor<TypedValue>>"
"utils::Visitable<ExpressionVisitor<void>>")
(lcp:define-class expression (tree "::utils::Visitable<HierarchicalTreeVisitor>"
"::utils::Visitable<ExpressionVisitor<TypedValue>>"
"::utils::Visitable<ExpressionVisitor<void>>")
()
(:abstractp t)
(:public
@ -320,7 +320,7 @@ cpp<#
(:clone :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
:slk-save #'slk-save-ast-pointer
:slk-load (slk-load-ast-pointer "Expression")))
@ -744,7 +744,7 @@ cpp<#
(property "PropertyIx" :scope :public
:slk-load (lambda (member)
#>cpp
memgraph::slk::Load(&self->${member}, reader, storage);
slk::Load(&self->${member}, reader, storage);
cpp<#)
:clone (lambda (source dest)
#>cpp
@ -783,10 +783,10 @@ cpp<#
:slk-load (lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage);
slk::Load(&self->${member}[i], reader, storage);
}
cpp<#)
:clone (clone-name-ix-vector "Label")))
@ -1199,9 +1199,9 @@ cpp<#
(:serialize (:slk))
(:clone))
(lcp:define-class named-expression (tree "utils::Visitable<HierarchicalTreeVisitor>"
"utils::Visitable<ExpressionVisitor<TypedValue>>"
"utils::Visitable<ExpressionVisitor<void>>")
(lcp:define-class named-expression (tree "::utils::Visitable<HierarchicalTreeVisitor>"
"::utils::Visitable<ExpressionVisitor<TypedValue>>"
"::utils::Visitable<ExpressionVisitor<void>>")
((name "std::string" :scope :public)
(expression "Expression *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer
@ -1253,7 +1253,7 @@ cpp<#
;;; 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
:slk-save #'slk-save-ast-pointer
:slk-load (slk-load-ast-pointer "Identifier")))
@ -1294,10 +1294,10 @@ cpp<#
:slk-load (lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage);
slk::Load(&self->${member}[i], reader, storage);
}
cpp<#)
:clone (clone-name-ix-vector "Label"))
@ -1340,10 +1340,10 @@ cpp<#
:slk-load (lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage);
slk::Load(&self->${member}[i], reader, storage);
}
cpp<#)
: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."
:slk-load (lambda (member)
#>cpp
memgraph::slk::Load(&self->${member}, reader, storage);
slk::Load(&self->${member}, reader, storage);
cpp<#))
(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."
:slk-load (lambda (member)
#>cpp
memgraph::slk::Load(&self->${member}, reader, storage);
slk::Load(&self->${member}, reader, storage);
cpp<#))
(total-weight "Identifier *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer
@ -1457,7 +1457,7 @@ cpp<#
(:serialize (:slk))
(:clone))
(lcp:define-class pattern (tree "utils::Visitable<HierarchicalTreeVisitor>")
(lcp:define-class pattern (tree "::utils::Visitable<HierarchicalTreeVisitor>")
((identifier "Identifier *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer
:slk-load (slk-load-ast-pointer "Identifier"))
@ -1491,7 +1491,7 @@ cpp<#
(:clone :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)
(:public
@ -1508,7 +1508,7 @@ cpp<#
(:clone :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 *>"
:scope :public
:slk-save #'slk-save-ast-vector
@ -1536,7 +1536,7 @@ cpp<#
(:clone :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
:slk-save #'slk-save-ast-pointer
:slk-load (slk-load-ast-pointer "SingleQuery"))
@ -1573,7 +1573,7 @@ cpp<#
(:clone :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)
(:public
@ -1660,7 +1660,7 @@ cpp<#
(label "LabelIx" :scope :public
:slk-load (lambda (member)
#>cpp
memgraph::slk::Load(&self->${member}, reader, storage);
slk::Load(&self->${member}, reader, storage);
cpp<#)
:clone (lambda (source dest)
#>cpp
@ -1670,10 +1670,10 @@ cpp<#
:slk-load (lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage);
slk::Load(&self->${member}[i], reader, storage);
}
cpp<#)
:clone (clone-name-ix-vector "Property")))
@ -1844,10 +1844,10 @@ cpp<#
:slk-load (lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage);
slk::Load(&self->${member}[i], reader, storage);
}
cpp<#)
:documentation "Expressions used for ordering the results.")
@ -1867,7 +1867,7 @@ cpp<#
((body "ReturnBody" :scope :public
:slk-load (lambda (member)
#>cpp
memgraph::slk::Load(&self->${member}, reader, storage);
slk::Load(&self->${member}, reader, storage);
cpp<#)))
(:public
#>cpp
@ -1911,7 +1911,7 @@ cpp<#
((body "ReturnBody" :scope :public
:slk-load (lambda (member)
#>cpp
memgraph::slk::Load(&self->${member}, reader, storage);
slk::Load(&self->${member}, reader, storage);
cpp<#))
(where "Where *" :initval "nullptr" :scope :public
:slk-save #'slk-save-ast-pointer
@ -2056,10 +2056,10 @@ cpp<#
:slk-load (lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage);
slk::Load(&self->${member}[i], reader, storage);
}
cpp<#)
:clone (clone-name-ix-vector "Label")))
@ -2121,10 +2121,10 @@ cpp<#
:slk-load (lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage);
slk::Load(&self->${member}[i], reader, storage);
}
cpp<#)
:clone (clone-name-ix-vector "Label")))
@ -2314,7 +2314,7 @@ cpp<#
(label "LabelIx" :scope :public
:slk-load (lambda (member)
#>cpp
memgraph::slk::Load(&self->${member}, reader, storage);
slk::Load(&self->${member}, reader, storage);
cpp<#)
:clone (lambda (source dest)
#>cpp
@ -2324,10 +2324,10 @@ cpp<#
:slk-load (lambda (member)
#>cpp
size_t size = 0;
memgraph::slk::Load(&size, reader);
slk::Load(&size, reader);
self->${member}.resize(size);
for (size_t i = 0; i < size; ++i) {
memgraph::slk::Load(&self->${member}[i], reader, storage);
slk::Load(&self->${member}[i], reader, storage);
}
cpp<#)
:clone (clone-name-ix-vector "Property")))
@ -2342,7 +2342,7 @@ cpp<#
(constraint "Constraint" :scope :public
:slk-load (lambda (member)
#>cpp
memgraph::slk::Load(&self->${member}, reader, storage);
slk::Load(&self->${member}, reader, storage);
cpp<#)))
(:public
(lcp:define-enum action-type

View File

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

View File

@ -18,9 +18,7 @@
#include "query/frontend/opencypher/generated/MemgraphCypher.h"
#include "query/frontend/opencypher/generated/MemgraphCypherLexer.h"
namespace memgraph::query {
namespace frontend {
namespace opencypher {
namespace memgraph::query::frontend::opencypher {
/**
* Generates openCypher AST
@ -38,7 +36,7 @@ class Parser {
parser_.addErrorListener(&error_listener_);
tree_ = parser_.cypher();
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_};
antlr4::tree::ParseTree *tree_ = nullptr;
};
} // namespace opencypher
} // namespace frontend
} // namespace memgraph::query
} // namespace memgraph::query::frontend::opencypher

View File

@ -394,7 +394,7 @@ TypedValue Properties(const TypedValue *args, int64_t nargs, const FunctionConte
case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get properties from a deleted 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::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED:
@ -448,7 +448,7 @@ size_t UnwrapDegreeResult(storage::Result<size_t> maybe_degree) {
case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get degree of a deleted node.");
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::VERTEX_HAS_EDGES:
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:
throw QueryRuntimeException("Trying to get keys from a deleted 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::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED:
@ -632,7 +632,7 @@ TypedValue Labels(const TypedValue *args, int64_t nargs, const FunctionContext &
case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get labels from a deleted node.");
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::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED:

View File

@ -394,7 +394,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to access labels on a deleted node.");
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::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED:
@ -705,7 +705,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get a property from a deleted 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::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED:
@ -732,7 +732,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get a property from a deleted 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::VERTEX_HAS_EDGES:
case storage::Error::PROPERTIES_DISABLED:

View File

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

View File

@ -180,7 +180,7 @@ struct InterpreterContext {
std::atomic<bool> is_shutting_down{false};
AuthQueryHandler *auth{nullptr};
memgraph::query::AuthChecker *auth_checker{nullptr};
AuthChecker *auth_checker{nullptr};
utils::SkipList<QueryCacheEntry> ast_cache;
utils::SkipList<PlanCacheEntry> plan_cache;
@ -190,7 +190,7 @@ struct InterpreterContext {
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
@ -208,7 +208,7 @@ class Interpreter final {
struct PrepareResult {
std::vector<std::string> headers;
std::vector<memgraph::query::AuthQuery::Privilege> privileges;
std::vector<query::AuthQuery::Privilege> privileges;
std::optional<int> qid;
};
@ -218,7 +218,7 @@ class Interpreter final {
* Preparing a query means to preprocess the query and save it for
* 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,
const std::string *username);
@ -237,7 +237,7 @@ class Interpreter final {
* further.
*
* @throw utils::BasicException
* @throw memgraph::query::QueryException
* @throw query::QueryException
*/
template <typename TStream>
std::map<std::string, TypedValue> PullAll(TStream *result_stream) {
@ -259,7 +259,7 @@ class Interpreter final {
* otherwise the last query should be used.
*
* @throw utils::BasicException
* @throw memgraph::query::QueryException
* @throw query::QueryException
*/
template <typename TStream>
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
// exactly, otherwise we approximate
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();
else
unwind_value = MiscParam::kUnwindNoLiteral;

View File

@ -620,7 +620,7 @@ auto UnwrapEdgesResult(storage::Result<TEdges> &&result) {
case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get relationships of a deleted node.");
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::SERIALIZATION_ERROR:
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:
STShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *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:
SingleSourceShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem)
: self_(self),
@ -1427,7 +1427,7 @@ class SingleSourceShortestPathCursor : public memgraph::query::plan::Cursor {
utils::pmr::vector<std::pair<EdgeAccessor, VertexAccessor>> to_visit_next_;
};
class ExpandWeightedShortestPathCursor : public memgraph::query::plan::Cursor {
class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
public:
ExpandWeightedShortestPathCursor(const ExpandVariable &self, utils::MemoryResource *mem)
: self_(self),
@ -1729,7 +1729,7 @@ class ConstructNamedPathCursor : public Cursor {
}
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
// 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);
if (!context.trigger_context_collector->ShouldRegisterDeletedObject<memgraph::query::EdgeAccessor>()) {
if (!context.trigger_context_collector->ShouldRegisterDeletedObject<query::EdgeAccessor>()) {
return;
}
for (const auto &edge : (*res)->second) {
@ -2149,7 +2149,7 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr
case storage::Error::DELETED_OBJECT:
throw QueryRuntimeException("Trying to get properties from a deleted 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::VERTEX_HAS_EDGES:
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) {
auto arg = args[i]->Accept(*evaluator);
std::string_view name;
const memgraph::query::procedure::CypherType *type{nullptr};
const query::procedure::CypherType *type{nullptr};
if (proc.args.size() > i) {
name = proc.args[i].first;
type = proc.args[i].second;

View File

@ -76,12 +76,12 @@ class Cursor {
};
/// 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 *)>>;
template <class TCursor, class... TArgs>
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);
try {
auto *cursor = new (ptr) TCursor(std::forward<TArgs>(args)...);
@ -132,7 +132,7 @@ class Cartesian;
class CallProcedure;
class LoadCsv;
using LogicalOperatorCompositeVisitor = memgraph::utils::CompositeVisitor<
using LogicalOperatorCompositeVisitor = utils::CompositeVisitor<
Once, CreateNode, CreateExpand, ScanAll, ScanAllByLabel,
ScanAllByLabelPropertyRange, ScanAllByLabelPropertyValue,
ScanAllByLabelProperty, ScanAllById,
@ -141,7 +141,7 @@ using LogicalOperatorCompositeVisitor = memgraph::utils::CompositeVisitor<
EdgeUniquenessFilter, Accumulate, Aggregate, Skip, Limit, OrderBy, Merge,
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
@ -158,7 +158,7 @@ class HierarchicalLogicalOperatorVisitor
};
cpp<#
(lcp:define-class logical-operator ("memgraph::utils::Visitable<HierarchicalLogicalOperatorVisitor>")
(lcp:define-class logical-operator ("utils::Visitable<HierarchicalLogicalOperatorVisitor>")
()
(:abstractp t)
(: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.
*
* @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.
*/
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.
*
@ -312,7 +312,7 @@ and false on every following Pull.")
#>cpp
Once(std::vector<Symbol> symbols = {}) : symbols_{std::move(symbols)} {}
DEFVISITABLE(HierarchicalLogicalOperatorVisitor);
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override;
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override {
return symbols_;
}
@ -445,7 +445,7 @@ a preceding `MATCH`), or multiple nodes (`MATCH ... CREATE` or
CreateNode(const std::shared_ptr<LogicalOperator> &input,
const NodeCreationInfo &node_info);
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;
bool HasSingleInput() const override { return true; }
@ -458,7 +458,7 @@ a preceding `MATCH`), or multiple nodes (`MATCH ... CREATE` or
#>cpp
class CreateNodeCursor : public Cursor {
public:
CreateNodeCursor(const CreateNode &, memgraph::utils::MemoryResource *);
CreateNodeCursor(const CreateNode &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -560,7 +560,7 @@ chained in cases when longer paths need creating.
const std::shared_ptr<LogicalOperator> &input,
Symbol input_symbol, bool existing_node);
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;
bool HasSingleInput() const override { return true; }
@ -573,7 +573,7 @@ chained in cases when longer paths need creating.
#>cpp
class CreateExpandCursor : public Cursor {
public:
CreateExpandCursor(const CreateExpand &, memgraph::utils::MemoryResource *);
CreateExpandCursor(const CreateExpand &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -624,7 +624,7 @@ with a constructor argument.
ScanAll(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
storage::View view = storage::View::OLD);
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;
bool HasSingleInput() const override { return true; }
@ -652,7 +652,7 @@ given label.
Symbol output_symbol, storage::LabelId label,
storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override;
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#)
(:serialize (:slk))
(:clone))
@ -666,10 +666,10 @@ given label.
uint8_t bound_type;
const auto &bound = *self.${member};
switch (bound.type()) {
case memgraph::utils::BoundType::INCLUSIVE:
case utils::BoundType::INCLUSIVE:
bound_type = 0;
break;
case memgraph::utils::BoundType::EXCLUSIVE:
case utils::BoundType::EXCLUSIVE:
bound_type = 1;
break;
}
@ -687,26 +687,26 @@ given label.
}
uint8_t bound_type_value;
slk::Load(&bound_type_value, reader);
memgraph::utils::BoundType bound_type;
utils::BoundType bound_type;
switch (bound_type_value) {
case static_cast<uint8_t>(0):
bound_type = memgraph::utils::BoundType::INCLUSIVE;
bound_type = utils::BoundType::INCLUSIVE;
break;
case static_cast<uint8_t>(1):
bound_type = memgraph::utils::BoundType::EXCLUSIVE;
bound_type = utils::BoundType::EXCLUSIVE;
break;
default:
throw slk::SlkDecodeException("Loading unknown BoundType");
}
auto *value = query::LoadAstPointer<query::Expression>(
&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<#)
(defun clone-optional-bound (source dest)
#>cpp
if (${source}) {
${dest}.emplace(memgraph::utils::Bound<Expression *>(
${dest}.emplace(utils::Bound<Expression *>(
${source}->value()->Clone(storage),
${source}->type()));
} else {
@ -736,7 +736,7 @@ property value which is inside a range (inclusive or exlusive).
(:public
#>cpp
/** Bound with expression which when evaluated produces the bound value. */
using Bound = memgraph::utils::Bound<Expression *>;
using Bound = utils::Bound<Expression *>;
ScanAllByLabelPropertyRange() {}
/**
* 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);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override;
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#)
(:serialize (:slk))
(:clone))
@ -801,7 +801,7 @@ property value.
storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override;
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#)
(:serialize (:slk))
(:clone))
@ -830,7 +830,7 @@ given label and property.
const std::string &property_name,
storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override;
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#)
(:serialize (:slk))
(:clone))
@ -851,7 +851,7 @@ given label and property.
storage::View view = storage::View::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override;
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
cpp<#)
(:serialize (:slk))
(:clone))
@ -916,7 +916,7 @@ pulled.")
Expand() {}
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;
bool HasSingleInput() const override { return true; }
@ -927,7 +927,7 @@ pulled.")
class ExpandCursor : public Cursor {
public:
ExpandCursor(const Expand &, memgraph::utils::MemoryResource *);
ExpandCursor(const Expand &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -1065,7 +1065,7 @@ pulled.")
std::optional<Symbol> total_weight);
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;
bool HasSingleInput() const override { return true; }
@ -1103,7 +1103,7 @@ pulled.")
path_symbol_(path_symbol),
path_elements_(path_elements) {}
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;
bool HasSingleInput() const override { return true; }
@ -1135,7 +1135,7 @@ a boolean value.")
Filter(const std::shared_ptr<LogicalOperator> &input_,
Expression *expression_);
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;
bool HasSingleInput() const override { return true; }
@ -1148,7 +1148,7 @@ a boolean value.")
#>cpp
class FilterCursor : public Cursor {
public:
FilterCursor(const Filter &, memgraph::utils::MemoryResource *);
FilterCursor(const Filter &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -1185,7 +1185,7 @@ RETURN clause) the Produce's pull succeeds exactly once.")
Produce(const std::shared_ptr<LogicalOperator> &input,
const std::vector<NamedExpression *> &named_expressions);
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> ModifiedSymbols(const SymbolTable &) const override;
@ -1199,7 +1199,7 @@ RETURN clause) the Produce's pull succeeds exactly once.")
#>cpp
class ProduceCursor : public Cursor {
public:
ProduceCursor(const Produce &, memgraph::utils::MemoryResource *);
ProduceCursor(const Produce &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() 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_,
const std::vector<Expression *> &expressions, bool detach_);
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;
bool HasSingleInput() const override { return true; }
@ -1246,7 +1246,7 @@ Has a flag for using DETACH DELETE when deleting vertices.")
#>cpp
class DeleteCursor : public Cursor {
public:
DeleteCursor(const Delete &, memgraph::utils::MemoryResource *);
DeleteCursor(const Delete &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -1283,7 +1283,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).")
storage::PropertyId property, PropertyLookup *lhs,
Expression *rhs);
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;
bool HasSingleInput() const override { return true; }
@ -1296,7 +1296,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).")
#>cpp
class SetPropertyCursor : public Cursor {
public:
SetPropertyCursor(const SetProperty &, memgraph::utils::MemoryResource *);
SetPropertyCursor(const SetProperty &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() 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,
Symbol input_symbol, Expression *rhs, Op op);
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;
bool HasSingleInput() const override { return true; }
@ -1355,7 +1355,7 @@ that the old properties are discarded and replaced with new ones.")
#>cpp
class SetPropertiesCursor : public Cursor {
public:
SetPropertiesCursor(const SetProperties &, memgraph::utils::MemoryResource *);
SetPropertiesCursor(const SetProperties &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() 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,
const std::vector<storage::LabelId> &labels);
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;
bool HasSingleInput() const override { return true; }
@ -1398,7 +1398,7 @@ It does NOT remove labels that are already set on that Vertex.")
#>cpp
class SetLabelsCursor : public Cursor {
public:
SetLabelsCursor(const SetLabels &, memgraph::utils::MemoryResource *);
SetLabelsCursor(const SetLabels &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() 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,
storage::PropertyId property, PropertyLookup *lhs);
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;
bool HasSingleInput() const override { return true; }
@ -1441,7 +1441,7 @@ It does NOT remove labels that are already set on that Vertex.")
#>cpp
class RemovePropertyCursor : public Cursor {
public:
RemovePropertyCursor(const RemoveProperty &, memgraph::utils::MemoryResource *);
RemovePropertyCursor(const RemoveProperty &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() 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,
Symbol input_symbol, const std::vector<storage::LabelId> &labels);
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;
bool HasSingleInput() const override { return true; }
@ -1484,7 +1484,7 @@ If a label does not exist on a Vertex, nothing happens.")
#>cpp
class RemoveLabelsCursor : public Cursor {
public:
RemoveLabelsCursor(const RemoveLabels &, memgraph::utils::MemoryResource *);
RemoveLabelsCursor(const RemoveLabels &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -1525,7 +1525,7 @@ edge lists).")
Symbol expand_symbol,
const std::vector<Symbol> &previous_symbols);
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;
bool HasSingleInput() const override { return true; }
@ -1539,7 +1539,7 @@ edge lists).")
class EdgeUniquenessFilterCursor : public Cursor {
public:
EdgeUniquenessFilterCursor(const EdgeUniquenessFilter &,
memgraph::utils::MemoryResource *);
utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -1592,7 +1592,7 @@ has been cached will be reconstructed before Pull returns.
Accumulate(const std::shared_ptr<LogicalOperator> &input,
const std::vector<Symbol> &symbols, bool advance_command = false);
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;
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<Symbol> &remember);
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;
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);
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> ModifiedSymbols(const SymbolTable &) const override;
@ -1721,7 +1721,7 @@ operator's implementation does not expect this.")
#>cpp
class SkipCursor : public Cursor {
public:
SkipCursor(const Skip &, memgraph::utils::MemoryResource *);
SkipCursor(const Skip &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -1766,7 +1766,7 @@ input should be performed).")
Limit(const std::shared_ptr<LogicalOperator> &input, Expression *expression);
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> ModifiedSymbols(const SymbolTable &) const override;
@ -1780,7 +1780,7 @@ input should be performed).")
#>cpp
class LimitCursor : public Cursor {
public:
LimitCursor(const Limit &, memgraph::utils::MemoryResource *);
LimitCursor(const Limit &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() 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<Symbol> &output_symbols);
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> ModifiedSymbols(const SymbolTable &) const override;
@ -1868,7 +1868,7 @@ documentation.")
const std::shared_ptr<LogicalOperator> &merge_match,
const std::shared_ptr<LogicalOperator> &merge_create);
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;
// TODO: Consider whether we want to treat Merge as having single input. It
@ -1884,7 +1884,7 @@ documentation.")
#>cpp
class MergeCursor : public Cursor {
public:
MergeCursor(const Merge &, memgraph::utils::MemoryResource *);
MergeCursor(const Merge &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -1928,7 +1928,7 @@ and returns true, once.")
const std::shared_ptr<LogicalOperator> &optional,
const std::vector<Symbol> &optional_symbols);
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;
bool HasSingleInput() const override { return true; }
@ -1941,7 +1941,7 @@ and returns true, once.")
#>cpp
class OptionalCursor : public Cursor {
public:
OptionalCursor(const Optional &, memgraph::utils::MemoryResource *);
OptionalCursor(const Optional &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() 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,
Expression *input_expression_, Symbol output_symbol);
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;
bool HasSingleInput() const override {
@ -2014,7 +2014,7 @@ This implementation maintains input ordering.")
Distinct(const std::shared_ptr<LogicalOperator> &input,
const std::vector<Symbol> &value_symbols);
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> 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> &right_symbols);
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> ModifiedSymbols(const SymbolTable &) const override;
@ -2065,7 +2065,7 @@ of symbols used by each of the inputs.")
#>cpp
class UnionCursor : public Cursor {
public:
UnionCursor(const Union &, memgraph::utils::MemoryResource *);
UnionCursor(const Union &, utils::MemoryResource *);
bool Pull(Frame &, ExecutionContext &) override;
void Shutdown() override;
void Reset() override;
@ -2105,7 +2105,7 @@ of symbols used by each of the inputs.")
right_symbols_(right_symbols) {}
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;
bool HasSingleInput() const override;
@ -2134,7 +2134,7 @@ of symbols used by each of the inputs.")
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 {
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!");
}
UniqueCursorPtr MakeCursor(memgraph::utils::MemoryResource *) const override;
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override {
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);
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> 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<#)
(:private
#>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<#)
(:serialize (:slk))
(: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,
Expression* delimiter, Expression* quote, Symbol row_var);
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> ModifiedSymbols(const SymbolTable &) const override;

View File

@ -48,7 +48,7 @@ class PostProcessor final {
template <class TVertexCounts>
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>

View File

@ -543,12 +543,12 @@ std::vector<SingleQueryPart> CollectSingleQueryParts(SymbolTable &symbol_table,
}
} else {
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{});
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) ||
utils::IsSubtype(*clause, memgraph::query::CallProcedure::kType) ||
utils::IsSubtype(*clause, memgraph::query::LoadCsv::kType)) {
} else if (utils::IsSubtype(*clause, With::kType) || utils::IsSubtype(*clause, query::Unwind::kType) ||
utils::IsSubtype(*clause, query::CallProcedure::kType) ||
utils::IsSubtype(*clause, query::LoadCsv::kType)) {
// This query part is done, continue with a new one.
query_parts.emplace_back(SingleQueryPart{});
query_part = &query_parts.back();

View File

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

View File

@ -20,9 +20,8 @@
namespace memgraph::query {
class DbAccessor;
}
namespace memgraph::query::plan {
namespace plan {
class LogicalOperator;
@ -225,4 +224,5 @@ class PlanToJsonVisitor : public virtual HierarchicalLogicalOperatorVisitor {
} // 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)) {
input_op = impl::GenReturn(*ret, std::move(input_op), *context.symbol_table, is_write, context.bound_symbols,
*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++]);
// Treat MERGE clause as write, because we do not know if it will
// create anything.
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,
*context.ast_storage);
// 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)) {
is_write = true;
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_);
context.bound_symbols.insert(symbol);
input_op =
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;
result_symbols.reserve(call_proc->result_identifiers_.size());
for (const auto *ident : call_proc->result_identifiers_) {
@ -216,7 +216,7 @@ class RuleBasedPlanner {
input_op = std::make_unique<plan::CallProcedure>(
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_);
} 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_);
context.bound_symbols.insert(row_sym);
@ -338,16 +338,16 @@ class RuleBasedPlanner {
std::unordered_set<Symbol> &bound_symbols) {
if (auto *create = utils::Downcast<Create>(clause)) {
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_);
} 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_),
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;
const auto &input_symbol = symbol_table.at(*set->identifier_);
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_);
std::vector<storage::LabelId> labels;
labels.reserve(set->labels_.size());
@ -355,10 +355,10 @@ class RuleBasedPlanner {
labels.push_back(GetLabel(label));
}
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_),
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_);
std::vector<storage::LabelId> labels;
labels.reserve(rem->labels_.size());
@ -505,7 +505,7 @@ class RuleBasedPlanner {
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
// version when generating the create part.
std::unordered_set<Symbol> bound_symbols_copy(context_->bound_symbols);

View File

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

View File

@ -95,11 +95,11 @@ class VertexCountCache {
size_t operator()(const BoundsKey &key) const {
const auto &maybe_lower = key.first;
const auto &maybe_upper = key.second;
memgraph::query::TypedValue lower;
memgraph::query::TypedValue upper;
query::TypedValue lower;
query::TypedValue upper;
if (maybe_lower) lower = TypedValue(maybe_lower->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));
}
};
@ -108,11 +108,11 @@ class VertexCountCache {
bool operator()(const BoundsKey &a, const BoundsKey &b) const {
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;
memgraph::query::TypedValue bound_a;
memgraph::query::TypedValue bound_b;
query::TypedValue bound_a;
query::TypedValue bound_b;
if (maybe_bound_a) bound_a = TypedValue(maybe_bound_a->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);
}
@ -122,10 +122,10 @@ class VertexCountCache {
std::optional<int64_t> vertices_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,
std::unordered_map<memgraph::query::TypedValue, int64_t, memgraph::query::TypedValue::Hash,
memgraph::query::TypedValue::BoolEqual>,
LabelPropertyHash>
std::unordered_map<
LabelPropertyKey,
std::unordered_map<query::TypedValue, int64_t, query::TypedValue::Hash, query::TypedValue::BoolEqual>,
LabelPropertyHash>
property_value_vertex_count_;
std::unordered_map<LabelPropertyKey, std::unordered_map<BoundsKey, int64_t, BoundsHash, BoundsEqual>,
LabelPropertyHash>

View File

@ -47,7 +47,7 @@ class CypherType {
virtual bool SatisfiesType(const mgp_value &) const = 0;
/// 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
// 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 memgraph::query::TypedValue &value) const override { return !value.IsNull(); }
bool SatisfiesType(const query::TypedValue &value) const override { return !value.IsNull(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsBool(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsBool(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsString(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsString(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsInt(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsInt(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsDouble(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDouble(); }
};
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;
}
bool SatisfiesType(const memgraph::query::TypedValue &value) const override {
return value.IsInt() || value.IsDouble();
}
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsInt() || value.IsDouble(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsVertex(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsVertex(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsEdge(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsEdge(); }
};
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 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.
@ -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;
}
bool SatisfiesType(const memgraph::query::TypedValue &value) const override {
bool SatisfiesType(const query::TypedValue &value) const override {
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 memgraph::query::TypedValue &value) const override { return value.IsDate(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDate(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsLocalTime(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsLocalTime(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsLocalDateTime(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsLocalDateTime(); }
};
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 memgraph::query::TypedValue &value) const override { return value.IsDuration(); }
bool SatisfiesType(const query::TypedValue &value) const override { return value.IsDuration(); }
};
// Composite Types
@ -228,7 +226,7 @@ class ListType : public CypherType {
return true;
}
bool SatisfiesType(const memgraph::query::TypedValue &value) const override {
bool SatisfiesType(const query::TypedValue &value) const override {
if (!value.IsList()) return false;
for (const auto &elem : value.ValueList()) {
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);
}
bool SatisfiesType(const memgraph::query::TypedValue &value) const override {
bool SatisfiesType(const query::TypedValue &value) const override {
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.
///
/// PyImport_AppendInittab("_mgp", &memgraph::query::procedure::PyInitMgpModule);
/// PyImport_AppendInittab("_mgp", &query::procedure::PyInitMgpModule);
PyObject *PyInitMgpModule();
/// Create an instance of _mgp.Graph class.

View File

@ -528,7 +528,7 @@ Streams::StreamsMap::iterator Streams::CreateConsumer(StreamsMap &map, const std
interpreter->CommitTransaction();
result.rows.clear();
break;
} catch (const memgraph::query::TransactionSerializationException &e) {
} catch (const query::TransactionSerializationException &e) {
interpreter->Abort();
if (i == total_retries) {
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 TriggerEventType event_type, utils::SkipList<QueryCacheEntry> *query_cache,
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)},
parsed_statements_{ParseQuery(query, user_parameters, query_cache, antlr_lock, query_config)},
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)) {}
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_};
if (!parsed_statements_.is_cacheable || !trigger_plan_ || trigger_plan_->cached_plan.IsExpired()) {
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,
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,
"Cannot restore trigger when some triggers already exist!");
spdlog::info("Loading triggers...");
@ -337,7 +337,7 @@ void TriggerStore::AddTrigger(std::string name, const std::string &query,
TriggerEventType event_type, TriggerPhase phase,
utils::SkipList<QueryCacheEntry> *query_cache, 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) {
std::unique_lock store_guard{store_lock_};
if (storage_.Get(name)) {
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,
utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor, utils::SpinLock *antlr_lock,
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,
std::atomic<bool> *is_shutting_down, const TriggerContext &context,
@ -63,7 +63,7 @@ struct Trigger {
CachedPlan cached_plan;
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_;
ParsedQuery parsed_statements_;
@ -82,13 +82,13 @@ struct TriggerStore {
void RestoreTriggers(utils::SkipList<QueryCacheEntry> *query_cache, DbAccessor *db_accessor,
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,
const std::map<std::string, storage::PropertyValue> &user_parameters, TriggerEventType event_type,
TriggerPhase phase, utils::SkipList<QueryCacheEntry> *query_cache, 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);
void DropTrigger(const std::string &name);

View File

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

View File

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

View File

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

View File

@ -136,19 +136,19 @@ MAKE_PRIMITIVE_LOAD(uint64_t)
#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) {
uint32_t obj_encoded;
memgraph::slk::Load(&obj_encoded, reader);
slk::Load(&obj_encoded, reader);
*obj = utils::MemcpyCast<float>(obj_encoded);
}
inline void Load(double *obj, Reader *reader) {
uint64_t obj_encoded;
memgraph::slk::Load(&obj_encoded, reader);
slk::Load(&obj_encoded, reader);
*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);
auto delta = ReadWalDeltaData(decoder);
return {timestamp, delta};
} catch (const memgraph::slk::SlkReaderException &) {
} catch (const slk::SlkReaderException &) {
throw utils::BasicException("Missing data!");
} catch (const durability::RecoveryFailure &) {
throw utils::BasicException("Invalid data!");
@ -79,18 +79,16 @@ Storage::ReplicationServer::ReplicationServer(Storage *storage, io::network::End
rpc_server_->Start();
}
void Storage::ReplicationServer::HeartbeatHandler(memgraph::slk::Reader *req_reader,
memgraph::slk::Builder *res_builder) {
void Storage::ReplicationServer::HeartbeatHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
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_};
memgraph::slk::Save(res, res_builder);
slk::Save(res, res_builder);
}
void Storage::ReplicationServer::AppendDeltasHandler(memgraph::slk::Reader *req_reader,
memgraph::slk::Builder *res_builder) {
void Storage::ReplicationServer::AppendDeltasHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
replication::AppendDeltasReq req;
memgraph::slk::Load(&req, req_reader);
slk::Load(&req, 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()};
memgraph::slk::Save(res, res_builder);
slk::Save(res, res_builder);
return;
}
ReadAndApplyDelta(&decoder);
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,
memgraph::slk::Builder *res_builder) {
void Storage::ReplicationServer::SnapshotHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
replication::SnapshotReq req;
memgraph::slk::Load(&req, req_reader);
slk::Load(&req, req_reader);
replication::Decoder decoder(req_reader);
@ -180,7 +177,7 @@ void Storage::ReplicationServer::SnapshotHandler(memgraph::slk::Reader *req_read
storage_guard.unlock();
replication::SnapshotRes res{true, storage_->last_commit_timestamp_.load()};
memgraph::slk::Save(res, res_builder);
slk::Save(res, res_builder);
// Delete other durability files
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,
memgraph::slk::Builder *res_builder) {
void Storage::ReplicationServer::WalFilesHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
replication::WalFilesReq req;
memgraph::slk::Load(&req, req_reader);
slk::Load(&req, req_reader);
const auto wal_file_number = req.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()};
memgraph::slk::Save(res, res_builder);
slk::Save(res, res_builder);
}
void Storage::ReplicationServer::CurrentWalHandler(memgraph::slk::Reader *req_reader,
memgraph::slk::Builder *res_builder) {
void Storage::ReplicationServer::CurrentWalHandler(slk::Reader *req_reader, slk::Builder *res_builder) {
replication::CurrentWalReq req;
memgraph::slk::Load(&req, req_reader);
slk::Load(&req, req_reader);
replication::Decoder decoder(req_reader);
@ -232,7 +227,7 @@ void Storage::ReplicationServer::CurrentWalHandler(memgraph::slk::Reader *req_re
LoadWal(&decoder);
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) {

View File

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

View File

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

View File

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

View File

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

View File

@ -19,22 +19,22 @@
namespace memgraph::slk {
void Save(const memgraph::storage::Gid &gid, memgraph::slk::Builder *builder);
void Load(memgraph::storage::Gid *gid, memgraph::slk::Reader *reader);
void Save(const storage::Gid &gid, slk::Builder *builder);
void Load(storage::Gid *gid, slk::Reader *reader);
void Save(const memgraph::storage::PropertyValue &value, memgraph::slk::Builder *builder);
void Load(memgraph::storage::PropertyValue *value, memgraph::slk::Reader *reader);
void Save(const storage::PropertyValue &value, slk::Builder *builder);
void Load(storage::PropertyValue *value, slk::Reader *reader);
template <utils::Enum T>
void Save(const T &enum_value, memgraph::slk::Builder *builder) {
memgraph::slk::Save(utils::UnderlyingCast(enum_value), builder);
void Save(const T &enum_value, slk::Builder *builder) {
slk::Save(utils::UnderlyingCast(enum_value), builder);
}
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>;
UnderlyingType value;
memgraph::slk::Load(&value, reader);
slk::Load(&value, reader);
*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::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) {
buffer.push_back(data[i]);
}
});
memgraph::slk::Save(license.organization_name, &builder);
memgraph::slk::Save(license.valid_until, &builder);
memgraph::slk::Save(license.memory_limit, &builder);
slk::Save(license.organization_name, &builder);
slk::Save(license.valid_until, &builder);
slk::Save(license.memory_limit, &builder);
builder.Finalize();
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 {
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;
memgraph::slk::Load(&organization_name, &reader);
slk::Load(&organization_name, &reader);
int64_t valid_until{0};
memgraph::slk::Load(&valid_until, &reader);
slk::Load(&valid_until, &reader);
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};
} catch (const memgraph::slk::SlkReaderException &e) {
} catch (const slk::SlkReaderException &e) {
return std::nullopt;
}
}

View File

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