Fixes for clang-tidy / sonar issues (#1536)
This commit is contained in:
parent
1d90b60f56
commit
e4f94c15c6
292
include/mgp.hpp
292
include/mgp.hpp
File diff suppressed because it is too large
Load Diff
@ -111,7 +111,6 @@ void Schema::ProcessPropertiesRel(mgp::Record &record, const std::string_view &t
|
||||
void Schema::NodeTypeProperties(mgp_list * /*args*/, mgp_graph *memgraph_graph, mgp_result *result,
|
||||
mgp_memory *memory) {
|
||||
mgp::MemoryDispatcherGuard guard{memory};
|
||||
;
|
||||
const auto record_factory = mgp::RecordFactory(result);
|
||||
try {
|
||||
const mgp::Graph graph = mgp::Graph(memgraph_graph);
|
||||
@ -570,7 +569,6 @@ void Schema::Assert(mgp_list *args, mgp_graph *memgraph_graph, mgp_result *resul
|
||||
extern "C" int mgp_init_module(struct mgp_module *module, struct mgp_memory *memory) {
|
||||
try {
|
||||
mgp::MemoryDispatcherGuard guard{memory};
|
||||
;
|
||||
|
||||
AddProcedure(Schema::NodeTypeProperties, Schema::kProcedureNodeType, mgp::ProcedureType::Read, {},
|
||||
{mgp::Return(Schema::kReturnNodeType, mgp::Type::String),
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <json/json.hpp>
|
||||
#include <utility>
|
||||
|
||||
#include "storage/v2/temporal.hpp"
|
||||
#include "utils/logging.hpp"
|
||||
@ -87,8 +88,8 @@ inline nlohmann::json PropertyValueToJson(const storage::PropertyValue &pv) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Log::Log(const std::filesystem::path &storage_directory, int32_t buffer_size, int32_t buffer_flush_interval_millis)
|
||||
: storage_directory_(storage_directory),
|
||||
Log::Log(std::filesystem::path storage_directory, int32_t buffer_size, int32_t buffer_flush_interval_millis)
|
||||
: storage_directory_(std::move(storage_directory)),
|
||||
buffer_size_(buffer_size),
|
||||
buffer_flush_interval_millis_(buffer_flush_interval_millis),
|
||||
started_(false) {}
|
||||
|
@ -36,7 +36,7 @@ class Log {
|
||||
};
|
||||
|
||||
public:
|
||||
Log(const std::filesystem::path &storage_directory, int32_t buffer_size, int32_t buffer_flush_interval_millis);
|
||||
Log(std::filesystem::path storage_directory, int32_t buffer_size, int32_t buffer_flush_interval_millis);
|
||||
|
||||
~Log();
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <regex>
|
||||
#include <utility>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
@ -560,20 +561,20 @@ Databases Databases::Deserialize(const nlohmann::json &data) {
|
||||
}
|
||||
#endif
|
||||
|
||||
User::User() {}
|
||||
User::User() = default;
|
||||
|
||||
User::User(const std::string &username) : username_(utils::ToLowerCase(username)) {}
|
||||
User::User(const std::string &username, const std::string &password_hash, const Permissions &permissions)
|
||||
: username_(utils::ToLowerCase(username)), password_hash_(password_hash), permissions_(permissions) {}
|
||||
User::User(const std::string &username, std::string password_hash, const Permissions &permissions)
|
||||
: username_(utils::ToLowerCase(username)), password_hash_(std::move(password_hash)), permissions_(permissions) {}
|
||||
|
||||
#ifdef MG_ENTERPRISE
|
||||
User::User(const std::string &username, const std::string &password_hash, const Permissions &permissions,
|
||||
User::User(const std::string &username, std::string password_hash, const Permissions &permissions,
|
||||
FineGrainedAccessHandler fine_grained_access_handler, Databases db_access)
|
||||
: username_(utils::ToLowerCase(username)),
|
||||
password_hash_(password_hash),
|
||||
password_hash_(std::move(password_hash)),
|
||||
permissions_(permissions),
|
||||
fine_grained_access_handler_(std::move(fine_grained_access_handler)),
|
||||
database_access_(db_access) {}
|
||||
database_access_(std::move(db_access)) {}
|
||||
#endif
|
||||
|
||||
bool User::CheckPassword(const std::string &password) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <unordered_map>
|
||||
|
||||
#include <json/json.hpp>
|
||||
#include <utility>
|
||||
#include "dbms/constants.hpp"
|
||||
#include "utils/logging.hpp"
|
||||
|
||||
@ -301,8 +302,8 @@ class Databases final {
|
||||
bool Contains(const std::string &db) const;
|
||||
|
||||
bool GetAllowAll() const { return allow_all_; }
|
||||
const std::set<std::string> &GetGrants() const { return grants_dbs_; }
|
||||
const std::set<std::string> &GetDenies() const { return denies_dbs_; }
|
||||
const std::set<std::string, std::less<>> &GetGrants() const { return grants_dbs_; }
|
||||
const std::set<std::string, std::less<>> &GetDenies() const { return denies_dbs_; }
|
||||
const std::string &GetDefault() const;
|
||||
|
||||
nlohmann::json Serialize() const;
|
||||
@ -310,14 +311,17 @@ class Databases final {
|
||||
static Databases Deserialize(const nlohmann::json &data);
|
||||
|
||||
private:
|
||||
Databases(bool allow_all, std::set<std::string> grant, std::set<std::string> deny,
|
||||
const std::string &default_db = dbms::kDefaultDB)
|
||||
: grants_dbs_(grant), denies_dbs_(deny), allow_all_(allow_all), default_db_(default_db) {}
|
||||
Databases(bool allow_all, std::set<std::string, std::less<>> grant, std::set<std::string, std::less<>> deny,
|
||||
std::string default_db = dbms::kDefaultDB)
|
||||
: grants_dbs_(std::move(grant)),
|
||||
denies_dbs_(std::move(deny)),
|
||||
allow_all_(allow_all),
|
||||
default_db_(std::move(default_db)) {}
|
||||
|
||||
std::set<std::string> grants_dbs_; //!< set of databases with granted access
|
||||
std::set<std::string> denies_dbs_; //!< set of databases with denied access
|
||||
bool allow_all_; //!< flag to allow access to everything (denied overrides this)
|
||||
std::string default_db_; //!< user's default database
|
||||
std::set<std::string, std::less<>> grants_dbs_; //!< set of databases with granted access
|
||||
std::set<std::string, std::less<>> denies_dbs_; //!< set of databases with denied access
|
||||
bool allow_all_; //!< flag to allow access to everything (denied overrides this)
|
||||
std::string default_db_; //!< user's default database
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -327,9 +331,9 @@ class User final {
|
||||
User();
|
||||
|
||||
explicit User(const std::string &username);
|
||||
User(const std::string &username, const std::string &password_hash, const Permissions &permissions);
|
||||
User(const std::string &username, std::string password_hash, const Permissions &permissions);
|
||||
#ifdef MG_ENTERPRISE
|
||||
User(const std::string &username, const std::string &password_hash, const Permissions &permissions,
|
||||
User(const std::string &username, std::string password_hash, const Permissions &permissions,
|
||||
FineGrainedAccessHandler fine_grained_access_handler, Databases db_access = {});
|
||||
#endif
|
||||
User(const User &) = default;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "communication/bolt/v1/codes.hpp"
|
||||
@ -34,8 +35,8 @@ class FailureResponseException : public utils::BasicException {
|
||||
|
||||
explicit FailureResponseException(const std::string &message) : utils::BasicException{message} {}
|
||||
|
||||
FailureResponseException(const std::string &code, const std::string &message)
|
||||
: utils::BasicException{message}, code_{code} {}
|
||||
FailureResponseException(std::string code, const std::string &message)
|
||||
: utils::BasicException{message}, code_{std::move(code)} {}
|
||||
|
||||
const std::string &code() const { return code_; }
|
||||
SPECIALIZE_GET_EXCEPTION_NAME(FailureResponseException)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -51,7 +51,7 @@ enum class ChunkState : uint8_t {
|
||||
template <typename TBuffer>
|
||||
class ChunkedDecoderBuffer {
|
||||
public:
|
||||
ChunkedDecoderBuffer(TBuffer &buffer) : buffer_(buffer) { data_.reserve(kChunkMaxDataSize); }
|
||||
explicit ChunkedDecoderBuffer(TBuffer &buffer) : buffer_(buffer) { data_.reserve(kChunkMaxDataSize); }
|
||||
|
||||
/**
|
||||
* Reads data from the internal buffer.
|
||||
|
@ -401,11 +401,11 @@ class Decoder {
|
||||
}
|
||||
auto &labels = dv.ValueList();
|
||||
vertex.labels.reserve(labels.size());
|
||||
for (size_t i = 0; i < labels.size(); ++i) {
|
||||
if (labels[i].type() != Value::Type::String) {
|
||||
for (auto &label : labels) {
|
||||
if (label.type() != Value::Type::String) {
|
||||
return false;
|
||||
}
|
||||
vertex.labels.emplace_back(std::move(labels[i].ValueString()));
|
||||
vertex.labels.emplace_back(std::move(label.ValueString()));
|
||||
}
|
||||
|
||||
// read properties
|
||||
|
@ -111,12 +111,12 @@ class BaseEncoder {
|
||||
|
||||
void WriteList(const std::vector<Value> &value) {
|
||||
WriteTypeSize(value.size(), MarkerList);
|
||||
for (auto &x : value) WriteValue(x);
|
||||
for (const auto &x : value) WriteValue(x);
|
||||
}
|
||||
|
||||
void WriteMap(const std::map<std::string, Value> &value) {
|
||||
WriteTypeSize(value.size(), MarkerMap);
|
||||
for (auto &x : value) {
|
||||
for (const auto &x : value) {
|
||||
WriteString(x.first);
|
||||
WriteValue(x.second);
|
||||
}
|
||||
@ -205,11 +205,11 @@ class BaseEncoder {
|
||||
WriteRAW(utils::UnderlyingCast(Marker::TinyStruct) + 3);
|
||||
WriteRAW(utils::UnderlyingCast(Signature::Path));
|
||||
WriteTypeSize(path.vertices.size(), MarkerList);
|
||||
for (auto &v : path.vertices) WriteVertex(v);
|
||||
for (const auto &v : path.vertices) WriteVertex(v);
|
||||
WriteTypeSize(path.edges.size(), MarkerList);
|
||||
for (auto &e : path.edges) WriteEdge(e);
|
||||
for (const auto &e : path.edges) WriteEdge(e);
|
||||
WriteTypeSize(path.indices.size(), MarkerList);
|
||||
for (auto &i : path.indices) WriteInt(i);
|
||||
for (const auto &i : path.indices) WriteInt(i);
|
||||
}
|
||||
|
||||
void WriteDate(const utils::Date &date) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -48,7 +48,7 @@ namespace memgraph::communication::bolt {
|
||||
template <class TOutputStream>
|
||||
class ChunkedEncoderBuffer {
|
||||
public:
|
||||
ChunkedEncoderBuffer(TOutputStream &output_stream) : output_stream_(output_stream) {}
|
||||
explicit ChunkedEncoderBuffer(TOutputStream &output_stream) : output_stream_(output_stream) {}
|
||||
|
||||
/**
|
||||
* Writes n values into the buffer. If n is bigger than whole chunk size
|
||||
|
@ -39,7 +39,7 @@ class ClientEncoder : private BaseEncoder<Buffer> {
|
||||
using BaseEncoder<Buffer>::buffer_;
|
||||
|
||||
public:
|
||||
ClientEncoder(Buffer &buffer) : BaseEncoder<Buffer>(buffer) {}
|
||||
explicit ClientEncoder(Buffer &buffer) : BaseEncoder<Buffer>(buffer) {}
|
||||
|
||||
using BaseEncoder<Buffer>::UpdateVersion;
|
||||
|
||||
|
@ -32,7 +32,7 @@ class Encoder : private BaseEncoder<Buffer> {
|
||||
using BaseEncoder<Buffer>::buffer_;
|
||||
|
||||
public:
|
||||
Encoder(Buffer &buffer) : BaseEncoder<Buffer>(buffer) {}
|
||||
explicit Encoder(Buffer &buffer) : BaseEncoder<Buffer>(buffer) {}
|
||||
|
||||
using BaseEncoder<Buffer>::UpdateVersion;
|
||||
|
||||
|
@ -93,7 +93,7 @@ State HandlePullDiscard(TSession &session, std::optional<int> n, std::optional<i
|
||||
return State::Close;
|
||||
}
|
||||
|
||||
if (summary.count("has_more") && summary.at("has_more").ValueBool()) {
|
||||
if (summary.contains("has_more") && summary.at("has_more").ValueBool()) {
|
||||
return State::Result;
|
||||
}
|
||||
|
||||
@ -148,13 +148,13 @@ State HandlePullDiscardV4(TSession &session, const State state, const Marker mar
|
||||
spdlog::trace("Couldn't read extra field!");
|
||||
}
|
||||
const auto &extra_map = extra.ValueMap();
|
||||
if (extra_map.count("n")) {
|
||||
if (extra_map.contains("n")) {
|
||||
if (const auto n_value = extra_map.at("n").ValueInt(); n_value != kPullAll) {
|
||||
n = n_value;
|
||||
}
|
||||
}
|
||||
|
||||
if (extra_map.count("qid")) {
|
||||
if (extra_map.contains("qid")) {
|
||||
if (const auto qid_value = extra_map.at("qid").ValueInt(); qid_value != kPullLast) {
|
||||
qid = qid_value;
|
||||
}
|
||||
|
@ -42,11 +42,11 @@ std::optional<State> AuthenticateUser(TSession &session, Value &metadata) {
|
||||
std::string username;
|
||||
std::string password;
|
||||
if (data["scheme"].ValueString() == "basic") {
|
||||
if (!data.count("principal")) { // Special case principal = ""
|
||||
if (!data.contains("principal")) { // Special case principal = ""
|
||||
spdlog::warn("The client didn't supply the principal field! Trying with \"\"...");
|
||||
data["principal"] = "";
|
||||
}
|
||||
if (!data.count("credentials")) { // Special case credentials = ""
|
||||
if (!data.contains("credentials")) { // Special case credentials = ""
|
||||
spdlog::warn("The client didn't supply the credentials field! Trying with \"\"...");
|
||||
data["credentials"] = "";
|
||||
}
|
||||
@ -118,7 +118,7 @@ std::optional<Value> GetMetadataV4(TSession &session, const Marker marker) {
|
||||
}
|
||||
|
||||
auto &data = metadata.ValueMap();
|
||||
if (!data.count("user_agent")) {
|
||||
if (!data.contains("user_agent")) {
|
||||
spdlog::warn("The client didn't supply the user agent!");
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -142,7 +142,7 @@ std::optional<Value> GetInitDataV5(TSession &session, const Marker marker) {
|
||||
}
|
||||
|
||||
const auto &data = metadata.ValueMap();
|
||||
if (!data.count("user_agent")) {
|
||||
if (!data.contains("user_agent")) {
|
||||
spdlog::warn("The client didn't supply the user agent!");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ struct UnboundedEdge {
|
||||
* The decoder writes data into this structure.
|
||||
*/
|
||||
struct Path {
|
||||
Path() {}
|
||||
Path() = default;
|
||||
|
||||
Path(const std::vector<Vertex> &vertices, const std::vector<Edge> &edges) {
|
||||
// Helper function. Looks for the given element in the collection. If found,
|
||||
|
@ -132,7 +132,7 @@ class Client final {
|
||||
*/
|
||||
class ClientInputStream final {
|
||||
public:
|
||||
ClientInputStream(Client &client);
|
||||
explicit ClientInputStream(Client &client);
|
||||
|
||||
ClientInputStream(const ClientInputStream &) = delete;
|
||||
ClientInputStream(ClientInputStream &&) = delete;
|
||||
@ -156,7 +156,7 @@ class ClientInputStream final {
|
||||
*/
|
||||
class ClientOutputStream final {
|
||||
public:
|
||||
ClientOutputStream(Client &client);
|
||||
explicit ClientOutputStream(Client &client);
|
||||
|
||||
ClientOutputStream(const ClientOutputStream &) = delete;
|
||||
ClientOutputStream(ClientOutputStream &&) = delete;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -34,7 +34,7 @@ ClientContext::ClientContext(bool use_ssl) : use_ssl_(use_ssl), ctx_(nullptr) {
|
||||
}
|
||||
|
||||
ClientContext::ClientContext(const std::string &key_file, const std::string &cert_file) : ClientContext(true) {
|
||||
if (key_file != "" && cert_file != "") {
|
||||
if (!key_file.empty() && !cert_file.empty()) {
|
||||
MG_ASSERT(SSL_CTX_use_certificate_file(ctx_, cert_file.c_str(), SSL_FILETYPE_PEM) == 1,
|
||||
"Couldn't load client certificate from file: {}", cert_file);
|
||||
MG_ASSERT(SSL_CTX_use_PrivateKey_file(ctx_, key_file.c_str(), SSL_FILETYPE_PEM) == 1,
|
||||
@ -124,7 +124,7 @@ ServerContext &ServerContext::operator=(ServerContext &&other) noexcept {
|
||||
return *this;
|
||||
}
|
||||
|
||||
ServerContext::~ServerContext() {}
|
||||
ServerContext::~ServerContext() = default;
|
||||
|
||||
SSL_CTX *ServerContext::context() {
|
||||
MG_ASSERT(ctx_);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
namespace memgraph::communication {
|
||||
|
||||
const std::string SslGetLastError() {
|
||||
std::string SslGetLastError() {
|
||||
char buff[2048];
|
||||
auto err = ERR_get_error();
|
||||
ERR_error_string_n(err, buff, sizeof(buff));
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -18,6 +18,6 @@ namespace memgraph::communication {
|
||||
/**
|
||||
* This function reads and returns a string describing the last OpenSSL error.
|
||||
*/
|
||||
const std::string SslGetLastError();
|
||||
std::string SslGetLastError();
|
||||
|
||||
} // namespace memgraph::communication
|
||||
|
@ -38,7 +38,7 @@ class Listener final : public std::enable_shared_from_this<Listener<TRequestHand
|
||||
Listener(Listener &&) = delete;
|
||||
Listener &operator=(const Listener &) = delete;
|
||||
Listener &operator=(Listener &&) = delete;
|
||||
~Listener() {}
|
||||
~Listener() = default;
|
||||
|
||||
template <typename... Args>
|
||||
static std::shared_ptr<Listener> Create(Args &&...args) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
@ -51,13 +52,13 @@ class Listener final {
|
||||
using SessionHandler = Session<TSession, TSessionContext>;
|
||||
|
||||
public:
|
||||
Listener(TSessionContext *data, ServerContext *context, int inactivity_timeout_sec, const std::string &service_name,
|
||||
Listener(TSessionContext *data, ServerContext *context, int inactivity_timeout_sec, std::string service_name,
|
||||
size_t workers_count)
|
||||
: data_(data),
|
||||
alive_(false),
|
||||
context_(context),
|
||||
inactivity_timeout_sec_(inactivity_timeout_sec),
|
||||
service_name_(service_name),
|
||||
service_name_(std::move(service_name)),
|
||||
workers_count_(workers_count) {}
|
||||
|
||||
~Listener() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -80,7 +80,7 @@ class ResultStreamFaker {
|
||||
std::transform(header.begin(), header.end(), column_widths.begin(), [](const auto &s) { return s.size(); });
|
||||
|
||||
// convert all the results into strings, and track max column width
|
||||
auto &results_data = results.GetResults();
|
||||
const auto &results_data = results.GetResults();
|
||||
std::vector<std::vector<std::string>> result_strings(results_data.size(),
|
||||
std::vector<std::string>(column_widths.size()));
|
||||
for (int row_ind = 0; row_ind < static_cast<int>(results_data.size()); ++row_ind) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
@ -51,7 +52,8 @@ using InputStream = Buffer::ReadEnd;
|
||||
*/
|
||||
class OutputStream final {
|
||||
public:
|
||||
OutputStream(std::function<bool(const uint8_t *, size_t, bool)> write_function) : write_function_(write_function) {}
|
||||
explicit OutputStream(std::function<bool(const uint8_t *, size_t, bool)> write_function)
|
||||
: write_function_(std::move(write_function)) {}
|
||||
|
||||
OutputStream(const OutputStream &) = delete;
|
||||
OutputStream(OutputStream &&) = delete;
|
||||
|
@ -47,7 +47,7 @@ class Listener final : public std::enable_shared_from_this<Listener<TSession, TS
|
||||
Listener(Listener &&) = delete;
|
||||
Listener &operator=(const Listener &) = delete;
|
||||
Listener &operator=(Listener &&) = delete;
|
||||
~Listener() {}
|
||||
~Listener() = default;
|
||||
|
||||
template <typename... Args>
|
||||
static std::shared_ptr<Listener> Create(Args &&...args) {
|
||||
|
@ -76,7 +76,7 @@ using tcp = boost::asio::ip::tcp;
|
||||
class OutputStream final {
|
||||
public:
|
||||
explicit OutputStream(std::function<bool(const uint8_t *, size_t, bool)> write_function)
|
||||
: write_function_(write_function) {}
|
||||
: write_function_(std::move(write_function)) {}
|
||||
|
||||
OutputStream(const OutputStream &) = delete;
|
||||
OutputStream(OutputStream &&) = delete;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -16,6 +16,7 @@
|
||||
#include <spdlog/sinks/base_sink.h>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <utility>
|
||||
|
||||
#include "communication/websocket/listener.hpp"
|
||||
#include "io/network/endpoint.hpp"
|
||||
@ -45,7 +46,7 @@ class Server final {
|
||||
|
||||
class LoggingSink : public spdlog::sinks::base_sink<std::mutex> {
|
||||
public:
|
||||
explicit LoggingSink(std::weak_ptr<Listener> listener) : listener_(listener) {}
|
||||
explicit LoggingSink(std::weak_ptr<Listener> listener) : listener_(std::move(listener)) {}
|
||||
|
||||
private:
|
||||
void sink_it_(const spdlog::details::log_msg &msg) override;
|
||||
|
@ -542,7 +542,7 @@ class DbmsHandler {
|
||||
DatabaseHandler db_handler_; //!< multi-tenancy storage handler
|
||||
std::unique_ptr<kvstore::KVStore> durability_; //!< list of active dbs (pointer so we can postpone its creation)
|
||||
bool delete_on_drop_; //!< Flag defining if dropping storage also deletes its directory
|
||||
std::set<std::string> defunct_dbs_; //!< Databases that are in an unknown state due to various failures
|
||||
std::set<std::string, std::less<>> defunct_dbs_; //!< Databases that are in an unknown state due to various failures
|
||||
#else
|
||||
mutable utils::Gatekeeper<Database> db_gatekeeper_; //!< Single databases gatekeeper
|
||||
#endif
|
||||
|
@ -38,7 +38,7 @@ class Handler {
|
||||
* @brief Empty Handler constructor.
|
||||
*
|
||||
*/
|
||||
Handler() {}
|
||||
Handler() = default;
|
||||
|
||||
/**
|
||||
* @brief Generate a new context and corresponding configuration.
|
||||
|
@ -10,6 +10,7 @@
|
||||
// licenses/APL.txt.
|
||||
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
#include "gflags/gflags.h"
|
||||
|
||||
#include "audit/log.hpp"
|
||||
@ -272,7 +273,7 @@ void SessionHL::Configure(const std::map<std::string, memgraph::communication::b
|
||||
#endif
|
||||
}
|
||||
SessionHL::SessionHL(memgraph::query::InterpreterContext *interpreter_context,
|
||||
const memgraph::communication::v2::ServerEndpoint &endpoint,
|
||||
memgraph::communication::v2::ServerEndpoint endpoint,
|
||||
memgraph::communication::v2::InputStream *input_stream,
|
||||
memgraph::communication::v2::OutputStream *output_stream,
|
||||
memgraph::utils::Synchronized<memgraph::auth::Auth, memgraph::utils::WritePrioritizedRWLock> *auth
|
||||
@ -289,7 +290,7 @@ SessionHL::SessionHL(memgraph::query::InterpreterContext *interpreter_context,
|
||||
audit_log_(audit_log),
|
||||
#endif
|
||||
auth_(auth),
|
||||
endpoint_(endpoint),
|
||||
endpoint_(std::move(endpoint)),
|
||||
implicit_db_(dbms::kDefaultDB) {
|
||||
// Metrics update
|
||||
memgraph::metrics::IncrementCounter(memgraph::metrics::ActiveBoltSessions);
|
||||
|
@ -23,7 +23,7 @@ class SessionHL final : public memgraph::communication::bolt::Session<memgraph::
|
||||
memgraph::communication::v2::OutputStream> {
|
||||
public:
|
||||
SessionHL(memgraph::query::InterpreterContext *interpreter_context,
|
||||
const memgraph::communication::v2::ServerEndpoint &endpoint,
|
||||
memgraph::communication::v2::ServerEndpoint endpoint,
|
||||
memgraph::communication::v2::InputStream *input_stream,
|
||||
memgraph::communication::v2::OutputStream *output_stream,
|
||||
memgraph::utils::Synchronized<memgraph::auth::Auth, memgraph::utils::WritePrioritizedRWLock> *auth
|
||||
|
@ -202,7 +202,7 @@ storage::Result<std::map<std::string, Value>> ToBoltGraph(const query::Graph &gr
|
||||
for (const auto &v : graph.vertices()) {
|
||||
auto maybe_vertex = ToBoltVertex(v, db, view);
|
||||
if (maybe_vertex.HasError()) return maybe_vertex.GetError();
|
||||
vertices.emplace_back(Value(std::move(*maybe_vertex)));
|
||||
vertices.emplace_back(std::move(*maybe_vertex));
|
||||
}
|
||||
map.emplace("nodes", Value(vertices));
|
||||
|
||||
@ -211,7 +211,7 @@ storage::Result<std::map<std::string, Value>> ToBoltGraph(const query::Graph &gr
|
||||
for (const auto &e : graph.edges()) {
|
||||
auto maybe_edge = ToBoltEdge(e, db, view);
|
||||
if (maybe_edge.HasError()) return maybe_edge.GetError();
|
||||
edges.emplace_back(Value(std::move(*maybe_edge)));
|
||||
edges.emplace_back(std::move(*maybe_edge));
|
||||
}
|
||||
map.emplace("edges", Value(edges));
|
||||
|
||||
|
@ -31,7 +31,7 @@ inline void LoadConfig(const std::string &product_name) {
|
||||
std::vector<fs::path> configs = {fs::path("/etc/memgraph/memgraph.conf")};
|
||||
if (getenv("HOME") != nullptr) configs.emplace_back(fs::path(getenv("HOME")) / fs::path(".memgraph/config"));
|
||||
{
|
||||
auto memgraph_config = getenv("MEMGRAPH_CONFIG");
|
||||
auto *memgraph_config = getenv("MEMGRAPH_CONFIG");
|
||||
if (memgraph_config != nullptr) {
|
||||
auto path = fs::path(memgraph_config);
|
||||
MG_ASSERT(fs::exists(path), "MEMGRAPH_CONFIG environment variable set to nonexisting path: {}",
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <utils/event_counter.hpp>
|
||||
#include <utils/event_gauge.hpp>
|
||||
#include "storage/v2/storage.hpp"
|
||||
#include "utils/event_gauge.hpp"
|
||||
#include "utils/event_histogram.hpp"
|
||||
|
||||
namespace memgraph::http {
|
||||
|
@ -171,10 +171,10 @@ class Consumer final : public RdKafka::EventCb {
|
||||
|
||||
class ConsumerRebalanceCb : public RdKafka::RebalanceCb {
|
||||
public:
|
||||
ConsumerRebalanceCb(std::string consumer_name);
|
||||
explicit ConsumerRebalanceCb(std::string consumer_name);
|
||||
|
||||
void rebalance_cb(RdKafka::KafkaConsumer *consumer, RdKafka::ErrorCode err,
|
||||
std::vector<RdKafka::TopicPartition *> &partitions) override final;
|
||||
std::vector<RdKafka::TopicPartition *> &partitions) final;
|
||||
|
||||
void set_offset(int64_t offset);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -67,7 +67,7 @@ utils::BasicResult<std::string, std::vector<Message>> GetBatch(TConsumer &consum
|
||||
return std::move(batch);
|
||||
case pulsar_client::Result::ResultOk:
|
||||
if (message.getMessageId() != last_message_id) {
|
||||
batch.emplace_back(Message{std::move(message)});
|
||||
batch.emplace_back(std::move(message));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -48,8 +48,8 @@ struct Endpoint {
|
||||
uint16_t port{0};
|
||||
IpFamily family{IpFamily::NONE};
|
||||
|
||||
static std::optional<std::pair<std::string, uint16_t>> ParseSocketOrAddress(
|
||||
const std::string &address, const std::optional<uint16_t> default_port);
|
||||
static std::optional<std::pair<std::string, uint16_t>> ParseSocketOrAddress(const std::string &address,
|
||||
std::optional<uint16_t> default_port);
|
||||
|
||||
/**
|
||||
* Tries to parse the given string as either a socket address or ip address.
|
||||
@ -61,8 +61,8 @@ struct Endpoint {
|
||||
* it into an ip address and a port number; even if a default port is given,
|
||||
* it won't be used, as we expect that it is given in the address string.
|
||||
*/
|
||||
static std::optional<std::pair<std::string, uint16_t>> ParseSocketOrIpAddress(
|
||||
const std::string &address, const std::optional<uint16_t> default_port);
|
||||
static std::optional<std::pair<std::string, uint16_t>> ParseSocketOrIpAddress(const std::string &address,
|
||||
std::optional<uint16_t> default_port);
|
||||
|
||||
/**
|
||||
* Tries to parse given string as either socket address or hostname.
|
||||
@ -72,7 +72,7 @@ struct Endpoint {
|
||||
* After we parse hostname and port we try to resolve the hostname into an ip_address.
|
||||
*/
|
||||
static std::optional<std::pair<std::string, uint16_t>> ParseHostname(const std::string &address,
|
||||
const std::optional<uint16_t> default_port);
|
||||
std::optional<uint16_t> default_port);
|
||||
|
||||
static IpFamily GetIpFamily(const std::string &address);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -32,7 +32,7 @@ class Epoll {
|
||||
public:
|
||||
using Event = struct epoll_event;
|
||||
|
||||
Epoll(bool set_cloexec = false) : epoll_fd_(epoll_create1(set_cloexec ? EPOLL_CLOEXEC : 0)) {
|
||||
explicit Epoll(bool set_cloexec = false) : epoll_fd_(epoll_create1(set_cloexec ? EPOLL_CLOEXEC : 0)) {
|
||||
// epoll_create1 returns an error if there is a logical error in our code
|
||||
// (for example invalid flags) or if there is irrecoverable error. In both
|
||||
// cases it is best to terminate.
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
#include "io/network/endpoint.hpp"
|
||||
|
||||
@ -201,7 +202,7 @@ class Socket {
|
||||
bool WaitForReadyWrite();
|
||||
|
||||
private:
|
||||
Socket(int fd, const Endpoint &endpoint) : socket_(fd), endpoint_(endpoint) {}
|
||||
Socket(int fd, Endpoint endpoint) : socket_(fd), endpoint_(std::move(endpoint)) {}
|
||||
|
||||
int socket_ = -1;
|
||||
Endpoint endpoint_;
|
||||
|
@ -128,7 +128,7 @@ KVStore::iterator::iterator(const KVStore *kvstore, const std::string &prefix, b
|
||||
|
||||
KVStore::iterator::iterator(KVStore::iterator &&other) { pimpl_ = std::move(other.pimpl_); }
|
||||
|
||||
KVStore::iterator::~iterator() {}
|
||||
KVStore::iterator::~iterator() = default;
|
||||
|
||||
KVStore::iterator &KVStore::iterator::operator=(KVStore::iterator &&other) {
|
||||
pimpl_ = std::move(other.pimpl_);
|
||||
|
@ -41,7 +41,7 @@ bool TypedValueCompare(const TypedValue &a, const TypedValue &b);
|
||||
/// the define how respective elements compare.
|
||||
class TypedValueVectorCompare final {
|
||||
public:
|
||||
TypedValueVectorCompare() {}
|
||||
TypedValueVectorCompare() = default;
|
||||
explicit TypedValueVectorCompare(const std::vector<Ordering> &ordering) : ordering_(ordering) {}
|
||||
|
||||
template <class TAllocator>
|
||||
@ -147,8 +147,8 @@ concept AccessorWithUpdateProperties = requires(T accessor,
|
||||
///
|
||||
/// @throw QueryRuntimeException if value cannot be set as a property value
|
||||
template <AccessorWithUpdateProperties T>
|
||||
auto UpdatePropertiesChecked(T *record, std::map<storage::PropertyId, storage::PropertyValue> &properties) ->
|
||||
typename std::remove_reference<decltype(record->UpdateProperties(properties).GetValue())>::type {
|
||||
auto UpdatePropertiesChecked(T *record, std::map<storage::PropertyId, storage::PropertyValue> &properties)
|
||||
-> std::remove_reference_t<decltype(record->UpdateProperties(properties).GetValue())> {
|
||||
try {
|
||||
auto maybe_values = record->UpdateProperties(properties);
|
||||
if (maybe_values.HasError()) {
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "query/config.hpp"
|
||||
#include "query/frontend/semantic/required_privileges.hpp"
|
||||
#include "query/frontend/semantic/symbol_generator.hpp"
|
||||
@ -98,8 +100,8 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::stri
|
||||
class SingleNodeLogicalPlan final : public LogicalPlan {
|
||||
public:
|
||||
SingleNodeLogicalPlan(std::unique_ptr<plan::LogicalOperator> root, double cost, AstStorage storage,
|
||||
const SymbolTable &symbol_table)
|
||||
: root_(std::move(root)), cost_(cost), storage_(std::move(storage)), symbol_table_(symbol_table) {}
|
||||
SymbolTable symbol_table)
|
||||
: root_(std::move(root)), cost_(cost), storage_(std::move(storage)), symbol_table_(std::move(symbol_table)) {}
|
||||
|
||||
const plan::LogicalOperator &GetRoot() const override { return *root_; }
|
||||
double GetCost() const override { return cost_; }
|
||||
|
@ -40,7 +40,6 @@ class EdgeAccessor final {
|
||||
public:
|
||||
storage::EdgeAccessor impl_;
|
||||
|
||||
public:
|
||||
explicit EdgeAccessor(storage::EdgeAccessor impl) : impl_(std::move(impl)) {}
|
||||
|
||||
bool IsVisible(storage::View view) const { return impl_.IsVisible(view); }
|
||||
@ -108,7 +107,6 @@ class VertexAccessor final {
|
||||
|
||||
static EdgeAccessor MakeEdgeAccessor(const storage::EdgeAccessor impl) { return EdgeAccessor(impl); }
|
||||
|
||||
public:
|
||||
explicit VertexAccessor(storage::VertexAccessor impl) : impl_(impl) {}
|
||||
|
||||
bool IsVisible(storage::View view) const { return impl_.IsVisible(view); }
|
||||
|
@ -159,7 +159,7 @@ void DumpProperties(std::ostream *os, query::DbAccessor *dba,
|
||||
*os << "{";
|
||||
if (property_id) {
|
||||
*os << kInternalPropertyId << ": " << *property_id;
|
||||
if (store.size() > 0) *os << ", ";
|
||||
if (!store.empty()) *os << ", ";
|
||||
}
|
||||
utils::PrintIterable(*os, store, ", ", [&dba](auto &os, const auto &kv) {
|
||||
os << EscapeName(dba->PropertyToName(kv.first)) << ": ";
|
||||
@ -228,7 +228,7 @@ void DumpEdge(std::ostream *os, query::DbAccessor *dba, const query::EdgeAccesso
|
||||
throw query::QueryRuntimeException("Unexpected error when getting properties.");
|
||||
}
|
||||
}
|
||||
if (maybe_props->size() > 0) {
|
||||
if (!maybe_props->empty()) {
|
||||
*os << " ";
|
||||
DumpProperties(os, dba, *maybe_props);
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ struct CachedValue {
|
||||
if (!maybe_list.IsList()) {
|
||||
return false;
|
||||
}
|
||||
auto &list = maybe_list.ValueList();
|
||||
const auto &list = maybe_list.ValueList();
|
||||
TypedValue::Hash hash{};
|
||||
for (auto &element : list) {
|
||||
for (const auto &element : list) {
|
||||
const auto key = hash(element);
|
||||
auto &vector_values = cache_[key];
|
||||
if (!IsValueInVec(vector_values, element)) {
|
||||
|
@ -23,9 +23,7 @@
|
||||
#include "storage/v2/property_value.hpp"
|
||||
#include "utils/typeinfo.hpp"
|
||||
|
||||
namespace memgraph {
|
||||
|
||||
namespace query {
|
||||
namespace memgraph::query {
|
||||
|
||||
struct LabelIx {
|
||||
static const utils::TypeInfo kType;
|
||||
@ -62,8 +60,8 @@ inline bool operator!=(const PropertyIx &a, const PropertyIx &b) { return !(a ==
|
||||
inline bool operator==(const EdgeTypeIx &a, const EdgeTypeIx &b) { return a.ix == b.ix && a.name == b.name; }
|
||||
|
||||
inline bool operator!=(const EdgeTypeIx &a, const EdgeTypeIx &b) { return !(a == b); }
|
||||
} // namespace query
|
||||
} // namespace memgraph
|
||||
} // namespace memgraph::query
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
@ -83,9 +81,7 @@ struct hash<memgraph::query::EdgeTypeIx> {
|
||||
|
||||
} // namespace std
|
||||
|
||||
namespace memgraph {
|
||||
|
||||
namespace query {
|
||||
namespace memgraph::query {
|
||||
|
||||
class Tree;
|
||||
|
||||
@ -3577,5 +3573,4 @@ class ShowDatabasesQuery : public memgraph::query::Query {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace query
|
||||
} // namespace memgraph
|
||||
} // namespace memgraph::query
|
||||
|
@ -105,7 +105,7 @@ void PrintObject(std::ostream *out, const std::map<K, V> &map);
|
||||
|
||||
template <typename T>
|
||||
void PrintObject(std::ostream *out, const T &arg) {
|
||||
static_assert(!std::is_convertible<T, Expression *>::value,
|
||||
static_assert(!std::is_convertible_v<T, Expression *>,
|
||||
"This overload shouldn't be called with pointers convertible "
|
||||
"to Expression *. This means your other PrintObject overloads aren't "
|
||||
"being called for certain AST nodes when they should (or perhaps such "
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -31,7 +31,7 @@ class Parser {
|
||||
* @param query incoming query that has to be compiled into query plan
|
||||
* the first step is to generate AST
|
||||
*/
|
||||
Parser(const std::string query) : query_(std::move(query)) {
|
||||
explicit Parser(const std::string query) : query_(std::move(query)) {
|
||||
parser_.removeErrorListeners();
|
||||
parser_.addErrorListener(&error_listener_);
|
||||
tree_ = parser_.cypher();
|
||||
|
@ -12,12 +12,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "utils/typeinfo.hpp"
|
||||
|
||||
namespace memgraph {
|
||||
|
||||
namespace query {
|
||||
namespace memgraph::query {
|
||||
|
||||
class Symbol {
|
||||
public:
|
||||
@ -34,9 +33,13 @@ class Symbol {
|
||||
return enum_string[static_cast<int>(type)];
|
||||
}
|
||||
|
||||
Symbol() {}
|
||||
Symbol(const std::string &name, int position, bool user_declared, Type type = Type::ANY, int token_position = -1)
|
||||
: name_(name), position_(position), user_declared_(user_declared), type_(type), token_position_(token_position) {}
|
||||
Symbol() = default;
|
||||
Symbol(std::string name, int position, bool user_declared, Type type = Type::ANY, int token_position = -1)
|
||||
: name_(std::move(name)),
|
||||
position_(position),
|
||||
user_declared_(user_declared),
|
||||
type_(type),
|
||||
token_position_(token_position) {}
|
||||
|
||||
bool operator==(const Symbol &other) const {
|
||||
return position_ == other.position_ && name_ == other.name_ && type_ == other.type_;
|
||||
@ -57,8 +60,8 @@ class Symbol {
|
||||
int64_t token_position_{-1};
|
||||
};
|
||||
|
||||
} // namespace query
|
||||
} // namespace memgraph
|
||||
} // namespace memgraph::query
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
|
@ -183,7 +183,7 @@ class SymbolGenerator : public HierarchicalTreeVisitor {
|
||||
/// If property lookup for one symbol is visited more times, it is better to fetch all properties
|
||||
class PropertyLookupEvaluationModeVisitor : public ExpressionVisitor<void> {
|
||||
public:
|
||||
explicit PropertyLookupEvaluationModeVisitor() {}
|
||||
explicit PropertyLookupEvaluationModeVisitor() = default;
|
||||
|
||||
using ExpressionVisitor<void>::Visit;
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace memgraph::query {
|
||||
|
||||
class SymbolTable final {
|
||||
public:
|
||||
SymbolTable() {}
|
||||
SymbolTable() = default;
|
||||
const Symbol &CreateSymbol(const std::string &name, bool user_declared, Symbol::Type type = Symbol::Type::ANY,
|
||||
int32_t token_position = -1) {
|
||||
MG_ASSERT(table_.size() <= std::numeric_limits<int32_t>::max(),
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -16,6 +16,7 @@
|
||||
#include <iostream>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "query/exceptions.hpp"
|
||||
@ -32,7 +33,7 @@ namespace memgraph::query::frontend {
|
||||
|
||||
using namespace lexer_constants;
|
||||
|
||||
StrippedQuery::StrippedQuery(const std::string &query) : original_(query) {
|
||||
StrippedQuery::StrippedQuery(std::string query) : original_(std::move(query)) {
|
||||
enum class Token {
|
||||
UNMATCHED,
|
||||
KEYWORD, // Including true, false and null.
|
||||
@ -255,29 +256,29 @@ std::string GetFirstUtf8Symbol(const char *_s) {
|
||||
// According to
|
||||
// https://stackoverflow.com/questions/16260033/reinterpret-cast-between-char-and-stduint8-t-safe
|
||||
// this checks if casting from const char * to uint8_t is undefined behaviour.
|
||||
static_assert(std::is_same<std::uint8_t, unsigned char>::value,
|
||||
static_assert(std::is_same_v<std::uint8_t, unsigned char>,
|
||||
"This library requires std::uint8_t to be implemented as "
|
||||
"unsigned char.");
|
||||
const uint8_t *s = reinterpret_cast<const uint8_t *>(_s);
|
||||
if ((*s >> 7) == 0x00) return std::string(_s, _s + 1);
|
||||
if ((*s >> 5) == 0x06) {
|
||||
auto *s1 = s + 1;
|
||||
const auto *s1 = s + 1;
|
||||
if ((*s1 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
return std::string(_s, _s + 2);
|
||||
}
|
||||
if ((*s >> 4) == 0x0e) {
|
||||
auto *s1 = s + 1;
|
||||
const auto *s1 = s + 1;
|
||||
if ((*s1 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
auto *s2 = s + 2;
|
||||
const auto *s2 = s + 2;
|
||||
if ((*s2 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
return std::string(_s, _s + 3);
|
||||
}
|
||||
if ((*s >> 3) == 0x1e) {
|
||||
auto *s1 = s + 1;
|
||||
const auto *s1 = s + 1;
|
||||
if ((*s1 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
auto *s2 = s + 2;
|
||||
const auto *s2 = s + 2;
|
||||
if ((*s2 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
auto *s3 = s + 3;
|
||||
const auto *s3 = s + 3;
|
||||
if ((*s3 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
return std::string(_s, _s + 4);
|
||||
}
|
||||
@ -286,29 +287,29 @@ std::string GetFirstUtf8Symbol(const char *_s) {
|
||||
|
||||
// Return codepoint of first utf8 symbol and its encoded length.
|
||||
std::pair<int, int> GetFirstUtf8SymbolCodepoint(const char *_s) {
|
||||
static_assert(std::is_same<std::uint8_t, unsigned char>::value,
|
||||
static_assert(std::is_same_v<std::uint8_t, unsigned char>,
|
||||
"This library requires std::uint8_t to be implemented as "
|
||||
"unsigned char.");
|
||||
const uint8_t *s = reinterpret_cast<const uint8_t *>(_s);
|
||||
if ((*s >> 7) == 0x00) return {*s & 0x7f, 1};
|
||||
if ((*s >> 5) == 0x06) {
|
||||
auto *s1 = s + 1;
|
||||
const auto *s1 = s + 1;
|
||||
if ((*s1 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
return {((*s & 0x1f) << 6) | (*s1 & 0x3f), 2};
|
||||
}
|
||||
if ((*s >> 4) == 0x0e) {
|
||||
auto *s1 = s + 1;
|
||||
const auto *s1 = s + 1;
|
||||
if ((*s1 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
auto *s2 = s + 2;
|
||||
const auto *s2 = s + 2;
|
||||
if ((*s2 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
return {((*s & 0x0f) << 12) | ((*s1 & 0x3f) << 6) | (*s2 & 0x3f), 3};
|
||||
}
|
||||
if ((*s >> 3) == 0x1e) {
|
||||
auto *s1 = s + 1;
|
||||
const auto *s1 = s + 1;
|
||||
if ((*s1 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
auto *s2 = s + 2;
|
||||
const auto *s2 = s + 2;
|
||||
if ((*s2 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
auto *s3 = s + 3;
|
||||
const auto *s3 = s + 3;
|
||||
if ((*s3 >> 6) != 0x02) throw LexingException("Invalid character.");
|
||||
return {((*s & 0x07) << 18) | ((*s1 & 0x3f) << 12) | ((*s2 & 0x3f) << 6) | (*s3 & 0x3f), 4};
|
||||
}
|
||||
@ -336,7 +337,7 @@ int StrippedQuery::MatchSpecial(int start) const { return kSpecialTokens.Match(o
|
||||
int StrippedQuery::MatchString(int start) const {
|
||||
if (original_[start] != '"' && original_[start] != '\'') return 0;
|
||||
char start_char = original_[start];
|
||||
for (auto *p = original_.data() + start + 1; *p; ++p) {
|
||||
for (const auto *p = original_.data() + start + 1; *p; ++p) {
|
||||
if (*p == start_char) return p - (original_.data() + start) + 1;
|
||||
if (*p == '\\') {
|
||||
++p;
|
||||
@ -346,7 +347,7 @@ int StrippedQuery::MatchString(int start) const {
|
||||
continue;
|
||||
} else if (*p == 'U' || *p == 'u') {
|
||||
int cnt = 0;
|
||||
auto *r = p + 1;
|
||||
const auto *r = p + 1;
|
||||
while (isxdigit(*r) && cnt < 8) {
|
||||
++cnt;
|
||||
++r;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -40,7 +40,7 @@ class StrippedQuery {
|
||||
*
|
||||
* @param query Input query.
|
||||
*/
|
||||
explicit StrippedQuery(const std::string &query);
|
||||
explicit StrippedQuery(std::string query);
|
||||
|
||||
/**
|
||||
* Copy constructor is deleted because we don't want to make unnecessary
|
||||
|
@ -17,8 +17,7 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace memgraph::query {
|
||||
namespace lexer_constants {
|
||||
namespace memgraph::query::lexer_constants {
|
||||
|
||||
namespace trie {
|
||||
|
||||
@ -33,7 +32,7 @@ inline int Noop(int x) { return x; }
|
||||
|
||||
class Trie {
|
||||
public:
|
||||
Trie() {}
|
||||
Trie() = default;
|
||||
Trie(std::initializer_list<std::string> l) {
|
||||
for (const auto &s : l) {
|
||||
Insert(s);
|
||||
@ -2934,5 +2933,4 @@ const trie::Trie kSpecialTokens = {";",
|
||||
"\xEF\xB9\x98", // u8"\ufe58"
|
||||
"\xEF\xB9\xA3", // u8"\ufe63"
|
||||
"\xEF\xBC\x8D"}; // u8"\uff0d"
|
||||
} // namespace lexer_constants
|
||||
} // namespace memgraph::query
|
||||
} // namespace memgraph::query::lexer_constants
|
||||
|
@ -825,8 +825,8 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
throw QueryRuntimeException("'coalesce' requires at least one argument.");
|
||||
}
|
||||
|
||||
for (int64_t i = 0; i < exprs.size(); ++i) {
|
||||
TypedValue val(exprs[i]->Accept(*this), ctx_->memory);
|
||||
for (auto &expr : exprs) {
|
||||
TypedValue val(expr->Accept(*this), ctx_->memory);
|
||||
if (!val.IsNull()) {
|
||||
return val;
|
||||
}
|
||||
|
@ -797,34 +797,33 @@ Callback HandleReplicationQuery(ReplicationQuery *repl_query, const Parameters &
|
||||
std::vector<TypedValue> typed_replica;
|
||||
typed_replica.reserve(replica_nfields);
|
||||
|
||||
typed_replica.emplace_back(TypedValue(replica.name));
|
||||
typed_replica.emplace_back(TypedValue(replica.socket_address));
|
||||
typed_replica.emplace_back(replica.name);
|
||||
typed_replica.emplace_back(replica.socket_address);
|
||||
|
||||
switch (replica.sync_mode) {
|
||||
case ReplicationQuery::SyncMode::SYNC:
|
||||
typed_replica.emplace_back(TypedValue("sync"));
|
||||
typed_replica.emplace_back("sync");
|
||||
break;
|
||||
case ReplicationQuery::SyncMode::ASYNC:
|
||||
typed_replica.emplace_back(TypedValue("async"));
|
||||
typed_replica.emplace_back("async");
|
||||
break;
|
||||
}
|
||||
|
||||
typed_replica.emplace_back(TypedValue(static_cast<int64_t>(replica.current_timestamp_of_replica)));
|
||||
typed_replica.emplace_back(
|
||||
TypedValue(static_cast<int64_t>(replica.current_number_of_timestamp_behind_master)));
|
||||
typed_replica.emplace_back(static_cast<int64_t>(replica.current_timestamp_of_replica));
|
||||
typed_replica.emplace_back(static_cast<int64_t>(replica.current_number_of_timestamp_behind_master));
|
||||
|
||||
switch (replica.state) {
|
||||
case ReplicationQuery::ReplicaState::READY:
|
||||
typed_replica.emplace_back(TypedValue("ready"));
|
||||
typed_replica.emplace_back("ready");
|
||||
break;
|
||||
case ReplicationQuery::ReplicaState::REPLICATING:
|
||||
typed_replica.emplace_back(TypedValue("replicating"));
|
||||
typed_replica.emplace_back("replicating");
|
||||
break;
|
||||
case ReplicationQuery::ReplicaState::RECOVERY:
|
||||
typed_replica.emplace_back(TypedValue("recovery"));
|
||||
typed_replica.emplace_back("recovery");
|
||||
break;
|
||||
case ReplicationQuery::ReplicaState::INVALID:
|
||||
typed_replica.emplace_back(TypedValue("invalid"));
|
||||
typed_replica.emplace_back("invalid");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1962,11 +1961,11 @@ std::vector<std::vector<TypedValue>> AnalyzeGraphQueryHandler::AnalyzeGraphCreat
|
||||
result.reserve(kComputeStatisticsNumResults);
|
||||
|
||||
result.emplace_back(execution_db_accessor->LabelToName(stat_entry.first));
|
||||
result.emplace_back(TypedValue());
|
||||
result.emplace_back();
|
||||
result.emplace_back(static_cast<int64_t>(stat_entry.second.count));
|
||||
result.emplace_back(TypedValue());
|
||||
result.emplace_back(TypedValue());
|
||||
result.emplace_back(TypedValue());
|
||||
result.emplace_back();
|
||||
result.emplace_back();
|
||||
result.emplace_back();
|
||||
result.emplace_back(stat_entry.second.avg_degree);
|
||||
results.push_back(std::move(result));
|
||||
});
|
||||
@ -2883,7 +2882,7 @@ auto ShowTransactions(const std::unordered_set<Interpreter *> &interpreters, con
|
||||
metadata_tv.emplace(md.first, TypedValue(md.second));
|
||||
}
|
||||
}
|
||||
results.back().push_back(TypedValue(metadata_tv));
|
||||
results.back().emplace_back(metadata_tv);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
|
@ -174,7 +174,7 @@ struct CurrentDB {
|
||||
|
||||
class Interpreter final {
|
||||
public:
|
||||
Interpreter(InterpreterContext *interpreter_context);
|
||||
explicit Interpreter(InterpreterContext *interpreter_context);
|
||||
Interpreter(InterpreterContext *interpreter_context, memgraph::dbms::DatabaseAccess db);
|
||||
Interpreter(const Interpreter &) = delete;
|
||||
Interpreter &operator=(const Interpreter &) = delete;
|
||||
|
@ -207,8 +207,8 @@ void Once::OnceCursor::Shutdown() {}
|
||||
|
||||
void Once::OnceCursor::Reset() { did_pull_ = false; }
|
||||
|
||||
CreateNode::CreateNode(const std::shared_ptr<LogicalOperator> &input, const NodeCreationInfo &node_info)
|
||||
: input_(input ? input : std::make_shared<Once>()), node_info_(node_info) {}
|
||||
CreateNode::CreateNode(const std::shared_ptr<LogicalOperator> &input, NodeCreationInfo node_info)
|
||||
: input_(input ? input : std::make_shared<Once>()), node_info_(std::move(node_info)) {}
|
||||
|
||||
// Creates a vertex on this GraphDb. Returns a reference to vertex placed on the
|
||||
// frame.
|
||||
@ -298,12 +298,12 @@ void CreateNode::CreateNodeCursor::Shutdown() { input_cursor_->Shutdown(); }
|
||||
|
||||
void CreateNode::CreateNodeCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
CreateExpand::CreateExpand(const NodeCreationInfo &node_info, const EdgeCreationInfo &edge_info,
|
||||
CreateExpand::CreateExpand(NodeCreationInfo node_info, EdgeCreationInfo edge_info,
|
||||
const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol, bool existing_node)
|
||||
: node_info_(node_info),
|
||||
edge_info_(edge_info),
|
||||
: node_info_(std::move(node_info)),
|
||||
edge_info_(std::move(edge_info)),
|
||||
input_(input ? input : std::make_shared<Once>()),
|
||||
input_symbol_(input_symbol),
|
||||
input_symbol_(std::move(input_symbol)),
|
||||
existing_node_(existing_node) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(CreateExpand)
|
||||
@ -447,7 +447,7 @@ class ScanAllCursor : public Cursor {
|
||||
explicit ScanAllCursor(const ScanAll &self, Symbol output_symbol, UniqueCursorPtr input_cursor, storage::View view,
|
||||
TVerticesFun get_vertices, const char *op_name)
|
||||
: self_(self),
|
||||
output_symbol_(output_symbol),
|
||||
output_symbol_(std::move(output_symbol)),
|
||||
input_cursor_(std::move(input_cursor)),
|
||||
view_(view),
|
||||
get_vertices_(std::move(get_vertices)),
|
||||
@ -518,7 +518,7 @@ class ScanAllCursor : public Cursor {
|
||||
};
|
||||
|
||||
ScanAll::ScanAll(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol, storage::View view)
|
||||
: input_(input ? input : std::make_shared<Once>()), output_symbol_(output_symbol), view_(view) {}
|
||||
: input_(input ? input : std::make_shared<Once>()), output_symbol_(std::move(output_symbol)), view_(view) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(ScanAll)
|
||||
|
||||
@ -561,13 +561,13 @@ UniqueCursorPtr ScanAllByLabel::MakeCursor(utils::MemoryResource *mem) const {
|
||||
|
||||
ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, storage::LabelId label,
|
||||
storage::PropertyId property, const std::string &property_name,
|
||||
storage::PropertyId property, std::string property_name,
|
||||
std::optional<Bound> lower_bound,
|
||||
std::optional<Bound> upper_bound, storage::View view)
|
||||
: ScanAll(input, output_symbol, view),
|
||||
label_(label),
|
||||
property_(property),
|
||||
property_name_(property_name),
|
||||
property_name_(std::move(property_name)),
|
||||
lower_bound_(lower_bound),
|
||||
upper_bound_(upper_bound) {
|
||||
MG_ASSERT(lower_bound_ || upper_bound_, "Only one bound can be left out");
|
||||
@ -623,12 +623,12 @@ UniqueCursorPtr ScanAllByLabelPropertyRange::MakeCursor(utils::MemoryResource *m
|
||||
|
||||
ScanAllByLabelPropertyValue::ScanAllByLabelPropertyValue(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, storage::LabelId label,
|
||||
storage::PropertyId property, const std::string &property_name,
|
||||
storage::PropertyId property, std::string property_name,
|
||||
Expression *expression, storage::View view)
|
||||
: ScanAll(input, output_symbol, view),
|
||||
label_(label),
|
||||
property_(property),
|
||||
property_name_(property_name),
|
||||
property_name_(std::move(property_name)),
|
||||
expression_(expression) {
|
||||
DMG_ASSERT(expression, "Expression is not optional.");
|
||||
}
|
||||
@ -655,8 +655,11 @@ UniqueCursorPtr ScanAllByLabelPropertyValue::MakeCursor(utils::MemoryResource *m
|
||||
|
||||
ScanAllByLabelProperty::ScanAllByLabelProperty(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
|
||||
storage::LabelId label, storage::PropertyId property,
|
||||
const std::string &property_name, storage::View view)
|
||||
: ScanAll(input, output_symbol, view), label_(label), property_(property), property_name_(property_name) {}
|
||||
std::string property_name, storage::View view)
|
||||
: ScanAll(input, output_symbol, view),
|
||||
label_(label),
|
||||
property_(property),
|
||||
property_name_(std::move(property_name)) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(ScanAllByLabelProperty)
|
||||
|
||||
@ -728,7 +731,7 @@ Expand::Expand(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbo
|
||||
Symbol edge_symbol, EdgeAtom::Direction direction, const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
bool existing_node, storage::View view)
|
||||
: input_(input ? input : std::make_shared<Once>()),
|
||||
input_symbol_(input_symbol),
|
||||
input_symbol_(std::move(input_symbol)),
|
||||
common_{node_symbol, edge_symbol, direction, edge_types, existing_node},
|
||||
view_(view) {}
|
||||
|
||||
@ -962,15 +965,15 @@ ExpandVariable::ExpandVariable(const std::shared_ptr<LogicalOperator> &input, Sy
|
||||
ExpansionLambda filter_lambda, std::optional<ExpansionLambda> weight_lambda,
|
||||
std::optional<Symbol> total_weight)
|
||||
: input_(input ? input : std::make_shared<Once>()),
|
||||
input_symbol_(input_symbol),
|
||||
input_symbol_(std::move(input_symbol)),
|
||||
common_{node_symbol, edge_symbol, direction, edge_types, existing_node},
|
||||
type_(type),
|
||||
is_reverse_(is_reverse),
|
||||
lower_bound_(lower_bound),
|
||||
upper_bound_(upper_bound),
|
||||
filter_lambda_(filter_lambda),
|
||||
weight_lambda_(weight_lambda),
|
||||
total_weight_(total_weight) {
|
||||
filter_lambda_(std::move(filter_lambda)),
|
||||
weight_lambda_(std::move(weight_lambda)),
|
||||
total_weight_(std::move(total_weight)) {
|
||||
DMG_ASSERT(type_ == EdgeAtom::Type::DEPTH_FIRST || type_ == EdgeAtom::Type::BREADTH_FIRST ||
|
||||
type_ == EdgeAtom::Type::WEIGHTED_SHORTEST_PATH || type_ == EdgeAtom::Type::ALL_SHORTEST_PATHS,
|
||||
"ExpandVariable can only be used with breadth first, depth first, "
|
||||
@ -1758,7 +1761,7 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
|
||||
if (found_it != total_cost_.end() && (found_it->second.IsNull() || (found_it->second <= next_weight).ValueBool()))
|
||||
return;
|
||||
|
||||
pq_.push({next_weight, depth + 1, vertex, edge});
|
||||
pq_.emplace(next_weight, depth + 1, vertex, edge);
|
||||
};
|
||||
|
||||
// Populates the priority queue structure with expansions
|
||||
@ -1810,7 +1813,7 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
|
||||
total_cost_.clear();
|
||||
yielded_vertices_.clear();
|
||||
|
||||
pq_.push({TypedValue(), 0, vertex, std::nullopt});
|
||||
pq_.emplace(TypedValue(), 0, vertex, std::nullopt);
|
||||
// We are adding the starting vertex to the set of yielded vertices
|
||||
// because we don't want to yield paths that end with the starting
|
||||
// vertex.
|
||||
@ -2023,7 +2026,7 @@ class ExpandAllShortestPathsCursor : public query::plan::Cursor {
|
||||
}
|
||||
|
||||
DirectedEdge directed_edge = {edge, direction, next_weight};
|
||||
pq_.push({next_weight, depth + 1, next_vertex, directed_edge});
|
||||
pq_.emplace(next_weight, depth + 1, next_vertex, directed_edge);
|
||||
};
|
||||
|
||||
// Populates the priority queue structure with expansions
|
||||
@ -2314,8 +2317,8 @@ UniqueCursorPtr ExpandVariable::MakeCursor(utils::MemoryResource *mem) const {
|
||||
|
||||
class ConstructNamedPathCursor : public Cursor {
|
||||
public:
|
||||
ConstructNamedPathCursor(const ConstructNamedPath &self, utils::MemoryResource *mem)
|
||||
: self_(self), input_cursor_(self_.input()->MakeCursor(mem)) {}
|
||||
ConstructNamedPathCursor(ConstructNamedPath self, utils::MemoryResource *mem)
|
||||
: self_(std::move(self)), input_cursor_(self_.input()->MakeCursor(mem)) {}
|
||||
|
||||
bool Pull(Frame &frame, ExecutionContext &context) override {
|
||||
OOMExceptionEnabler oom_exception;
|
||||
@ -2413,11 +2416,11 @@ Filter::Filter(const std::shared_ptr<LogicalOperator> &input,
|
||||
|
||||
Filter::Filter(const std::shared_ptr<LogicalOperator> &input,
|
||||
const std::vector<std::shared_ptr<LogicalOperator>> &pattern_filters, Expression *expression,
|
||||
const Filters &all_filters)
|
||||
Filters all_filters)
|
||||
: input_(input ? input : std::make_shared<Once>()),
|
||||
pattern_filters_(pattern_filters),
|
||||
expression_(expression),
|
||||
all_filters_(all_filters) {}
|
||||
all_filters_(std::move(all_filters)) {}
|
||||
|
||||
bool Filter::Accept(HierarchicalLogicalOperatorVisitor &visitor) {
|
||||
if (visitor.PreVisit(*this)) {
|
||||
@ -2478,7 +2481,7 @@ void Filter::FilterCursor::Shutdown() { input_cursor_->Shutdown(); }
|
||||
void Filter::FilterCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
EvaluatePatternFilter::EvaluatePatternFilter(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol)
|
||||
: input_(input), output_symbol_(output_symbol) {}
|
||||
: input_(input), output_symbol_(std::move(output_symbol)) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(EvaluatePatternFilter);
|
||||
|
||||
@ -2801,7 +2804,7 @@ void SetProperty::SetPropertyCursor::Shutdown() { input_cursor_->Shutdown(); }
|
||||
void SetProperty::SetPropertyCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
SetProperties::SetProperties(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol, Expression *rhs, Op op)
|
||||
: input_(input), input_symbol_(input_symbol), rhs_(rhs), op_(op) {}
|
||||
: input_(input), input_symbol_(std::move(input_symbol)), rhs_(rhs), op_(op) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(SetProperties)
|
||||
|
||||
@ -3000,7 +3003,7 @@ void SetProperties::SetPropertiesCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
SetLabels::SetLabels(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
const std::vector<storage::LabelId> &labels)
|
||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||
: input_(input), input_symbol_(std::move(input_symbol)), labels_(labels) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(SetLabels)
|
||||
|
||||
@ -3160,7 +3163,7 @@ void RemoveProperty::RemovePropertyCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
RemoveLabels::RemoveLabels(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
const std::vector<storage::LabelId> &labels)
|
||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||
: input_(input), input_symbol_(std::move(input_symbol)), labels_(labels) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(RemoveLabels)
|
||||
|
||||
@ -3234,7 +3237,7 @@ void RemoveLabels::RemoveLabelsCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
EdgeUniquenessFilter::EdgeUniquenessFilter(const std::shared_ptr<LogicalOperator> &input, Symbol expand_symbol,
|
||||
const std::vector<Symbol> &previous_symbols)
|
||||
: input_(input), expand_symbol_(expand_symbol), previous_symbols_(previous_symbols) {}
|
||||
: input_(input), expand_symbol_(std::move(expand_symbol)), previous_symbols_(previous_symbols) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(EdgeUniquenessFilter)
|
||||
|
||||
@ -4204,7 +4207,7 @@ void Optional::OptionalCursor::Reset() {
|
||||
Unwind::Unwind(const std::shared_ptr<LogicalOperator> &input, Expression *input_expression, Symbol output_symbol)
|
||||
: input_(input ? input : std::make_shared<Once>()),
|
||||
input_expression_(input_expression),
|
||||
output_symbol_(output_symbol) {}
|
||||
output_symbol_(std::move(output_symbol)) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(Unwind)
|
||||
|
||||
@ -4535,7 +4538,7 @@ WITHOUT_SINGLE_INPUT(OutputTable);
|
||||
|
||||
class OutputTableCursor : public Cursor {
|
||||
public:
|
||||
OutputTableCursor(const OutputTable &self) : self_(self) {}
|
||||
explicit OutputTableCursor(const OutputTable &self) : self_(self) {}
|
||||
|
||||
bool Pull(Frame &frame, ExecutionContext &context) override {
|
||||
OOMExceptionEnabler oom_exception;
|
||||
@ -4626,10 +4629,10 @@ CallProcedure::CallProcedure(std::shared_ptr<LogicalOperator> input, std::string
|
||||
std::vector<std::string> fields, std::vector<Symbol> symbols, Expression *memory_limit,
|
||||
size_t memory_scale, bool is_write, int64_t procedure_id, bool void_procedure)
|
||||
: input_(input ? input : std::make_shared<Once>()),
|
||||
procedure_name_(name),
|
||||
arguments_(args),
|
||||
result_fields_(fields),
|
||||
result_symbols_(symbols),
|
||||
procedure_name_(std::move(name)),
|
||||
arguments_(std::move(args)),
|
||||
result_fields_(std::move(fields)),
|
||||
result_symbols_(std::move(symbols)),
|
||||
memory_limit_(memory_limit),
|
||||
memory_scale_(memory_scale),
|
||||
is_write_(is_write),
|
||||
@ -4983,7 +4986,7 @@ LoadCsv::LoadCsv(std::shared_ptr<LogicalOperator> input, Expression *file, bool
|
||||
delimiter_(delimiter),
|
||||
quote_(quote),
|
||||
nullif_(nullif),
|
||||
row_var_(row_var) {
|
||||
row_var_(std::move(row_var)) {
|
||||
MG_ASSERT(file_, "Something went wrong - '{}' member file_ shouldn't be a nullptr", __func__);
|
||||
}
|
||||
|
||||
@ -5197,7 +5200,7 @@ Foreach::Foreach(std::shared_ptr<LogicalOperator> input, std::shared_ptr<Logical
|
||||
: input_(input ? std::move(input) : std::make_shared<Once>()),
|
||||
update_clauses_(std::move(updates)),
|
||||
expression_(expr),
|
||||
loop_variable_symbol_(loop_variable_symbol) {}
|
||||
loop_variable_symbol_(std::move(loop_variable_symbol)) {}
|
||||
|
||||
UniqueCursorPtr Foreach::MakeCursor(utils::MemoryResource *mem) const {
|
||||
memgraph::metrics::IncrementCounter(memgraph::metrics::ForeachOperator);
|
||||
|
@ -32,9 +32,7 @@
|
||||
#include "utils/synchronized.hpp"
|
||||
#include "utils/visitor.hpp"
|
||||
|
||||
namespace memgraph {
|
||||
|
||||
namespace query {
|
||||
namespace memgraph::query {
|
||||
|
||||
struct ExecutionContext;
|
||||
class ExpressionEvaluator;
|
||||
@ -68,7 +66,7 @@ class Cursor {
|
||||
/// Perform cleanup which may throw an exception
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual ~Cursor() {}
|
||||
virtual ~Cursor() = default;
|
||||
};
|
||||
|
||||
/// unique_ptr to Cursor managed with a custom deleter.
|
||||
@ -172,7 +170,7 @@ class LogicalOperator : public utils::Visitable<HierarchicalLogicalOperatorVisit
|
||||
static const utils::TypeInfo kType;
|
||||
virtual const utils::TypeInfo &GetTypeInfo() const { return kType; }
|
||||
|
||||
virtual ~LogicalOperator() {}
|
||||
~LogicalOperator() override = default;
|
||||
|
||||
/** Construct a @c Cursor which is used to run this operator.
|
||||
*
|
||||
@ -274,7 +272,7 @@ class Once : public memgraph::query::plan::LogicalOperator {
|
||||
private:
|
||||
class OnceCursor : public Cursor {
|
||||
public:
|
||||
OnceCursor() {}
|
||||
OnceCursor() = default;
|
||||
bool Pull(Frame &, ExecutionContext &) override;
|
||||
void Shutdown() override;
|
||||
void Reset() override;
|
||||
@ -340,7 +338,7 @@ class CreateNode : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
CreateNode() {}
|
||||
CreateNode() = default;
|
||||
|
||||
/**
|
||||
* @param input Optional. If @c nullptr, then a single node will be
|
||||
@ -349,7 +347,7 @@ class CreateNode : public memgraph::query::plan::LogicalOperator {
|
||||
* successful pull from the given input.
|
||||
* @param node_info @c NodeCreationInfo
|
||||
*/
|
||||
CreateNode(const std::shared_ptr<LogicalOperator> &input, const NodeCreationInfo &node_info);
|
||||
CreateNode(const std::shared_ptr<LogicalOperator> &input, NodeCreationInfo node_info);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
||||
@ -445,7 +443,7 @@ class CreateExpand : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
CreateExpand() {}
|
||||
CreateExpand() = default;
|
||||
|
||||
/** @brief Construct @c CreateExpand.
|
||||
*
|
||||
@ -459,8 +457,8 @@ class CreateExpand : public memgraph::query::plan::LogicalOperator {
|
||||
* @param existing_node @c bool indicating whether the @c node_atom refers to
|
||||
* an existing node. If @c false, the operator will also create the node.
|
||||
*/
|
||||
CreateExpand(const NodeCreationInfo &node_info, const EdgeCreationInfo &edge_info,
|
||||
const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol, bool existing_node);
|
||||
CreateExpand(NodeCreationInfo node_info, EdgeCreationInfo edge_info, const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol, bool existing_node);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
||||
@ -529,7 +527,7 @@ class ScanAll : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
ScanAll() {}
|
||||
ScanAll() = default;
|
||||
ScanAll(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol, storage::View view = storage::View::OLD);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
@ -571,7 +569,7 @@ class ScanAllByLabel : public memgraph::query::plan::ScanAll {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
ScanAllByLabel() {}
|
||||
ScanAllByLabel() = default;
|
||||
ScanAllByLabel(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol, storage::LabelId label,
|
||||
storage::View view = storage::View::OLD);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -606,7 +604,7 @@ class ScanAllByLabelPropertyRange : public memgraph::query::plan::ScanAll {
|
||||
|
||||
/** Bound with expression which when evaluated produces the bound value. */
|
||||
using Bound = utils::Bound<Expression *>;
|
||||
ScanAllByLabelPropertyRange() {}
|
||||
ScanAllByLabelPropertyRange() = default;
|
||||
/**
|
||||
* Constructs the operator for given label and property value in range
|
||||
* (inclusive).
|
||||
@ -622,7 +620,7 @@ class ScanAllByLabelPropertyRange : public memgraph::query::plan::ScanAll {
|
||||
* @param view storage::View used when obtaining vertices.
|
||||
*/
|
||||
ScanAllByLabelPropertyRange(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
|
||||
storage::LabelId label, storage::PropertyId property, const std::string &property_name,
|
||||
storage::LabelId label, storage::PropertyId property, std::string property_name,
|
||||
std::optional<Bound> lower_bound, std::optional<Bound> upper_bound,
|
||||
storage::View view = storage::View::OLD);
|
||||
|
||||
@ -675,7 +673,7 @@ class ScanAllByLabelPropertyValue : public memgraph::query::plan::ScanAll {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
ScanAllByLabelPropertyValue() {}
|
||||
ScanAllByLabelPropertyValue() = default;
|
||||
/**
|
||||
* Constructs the operator for given label and property value.
|
||||
*
|
||||
@ -687,7 +685,7 @@ class ScanAllByLabelPropertyValue : public memgraph::query::plan::ScanAll {
|
||||
* @param view storage::View used when obtaining vertices.
|
||||
*/
|
||||
ScanAllByLabelPropertyValue(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
|
||||
storage::LabelId label, storage::PropertyId property, const std::string &property_name,
|
||||
storage::LabelId label, storage::PropertyId property, std::string property_name,
|
||||
Expression *expression, storage::View view = storage::View::OLD);
|
||||
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -727,9 +725,9 @@ class ScanAllByLabelProperty : public memgraph::query::plan::ScanAll {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
ScanAllByLabelProperty() {}
|
||||
ScanAllByLabelProperty() = default;
|
||||
ScanAllByLabelProperty(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol, storage::LabelId label,
|
||||
storage::PropertyId property, const std::string &property_name,
|
||||
storage::PropertyId property, std::string property_name,
|
||||
storage::View view = storage::View::OLD);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
@ -763,7 +761,7 @@ class ScanAllById : public memgraph::query::plan::ScanAll {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
ScanAllById() {}
|
||||
ScanAllById() = default;
|
||||
ScanAllById(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol, Expression *expression,
|
||||
storage::View view = storage::View::OLD);
|
||||
|
||||
@ -842,7 +840,7 @@ class Expand : public memgraph::query::plan::LogicalOperator {
|
||||
EdgeAtom::Direction direction, const std::vector<storage::EdgeTypeId> &edge_types, bool existing_node,
|
||||
storage::View view);
|
||||
|
||||
Expand() {}
|
||||
Expand() = default;
|
||||
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
@ -950,7 +948,7 @@ class ExpandVariable : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
ExpandVariable() {}
|
||||
ExpandVariable() = default;
|
||||
|
||||
/**
|
||||
* Creates a variable-length expansion. Most params are forwarded
|
||||
@ -1073,10 +1071,10 @@ class ConstructNamedPath : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
ConstructNamedPath() {}
|
||||
ConstructNamedPath() = default;
|
||||
ConstructNamedPath(const std::shared_ptr<LogicalOperator> &input, Symbol path_symbol,
|
||||
const std::vector<Symbol> &path_elements)
|
||||
: input_(input), path_symbol_(path_symbol), path_elements_(path_elements) {}
|
||||
: input_(input), path_symbol_(std::move(path_symbol)), path_elements_(path_elements) {}
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
||||
@ -1108,13 +1106,13 @@ class Filter : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Filter() {}
|
||||
Filter() = default;
|
||||
|
||||
Filter(const std::shared_ptr<LogicalOperator> &input,
|
||||
const std::vector<std::shared_ptr<LogicalOperator>> &pattern_filters, Expression *expression);
|
||||
Filter(const std::shared_ptr<LogicalOperator> &input,
|
||||
const std::vector<std::shared_ptr<LogicalOperator>> &pattern_filters, Expression *expression,
|
||||
const Filters &all_filters);
|
||||
Filters all_filters);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
||||
@ -1126,12 +1124,12 @@ class Filter : public memgraph::query::plan::LogicalOperator {
|
||||
std::shared_ptr<memgraph::query::plan::LogicalOperator> input_;
|
||||
std::vector<std::shared_ptr<memgraph::query::plan::LogicalOperator>> pattern_filters_;
|
||||
Expression *expression_;
|
||||
const memgraph::query::plan::Filters all_filters_;
|
||||
memgraph::query::plan::Filters all_filters_;
|
||||
|
||||
static std::string SingleFilterName(const query::plan::FilterInfo &single_filter) {
|
||||
using Type = query::plan::FilterInfo::Type;
|
||||
if (single_filter.type == Type::Generic) {
|
||||
std::set<std::string> symbol_names;
|
||||
std::set<std::string, std::less<>> symbol_names;
|
||||
for (const auto &symbol : single_filter.used_symbols) {
|
||||
symbol_names.insert(symbol.name());
|
||||
}
|
||||
@ -1144,7 +1142,7 @@ class Filter : public memgraph::query::plan::LogicalOperator {
|
||||
LOG_FATAL("Label filters not using LabelsTest are not supported for query inspection!");
|
||||
}
|
||||
auto filter_expression = static_cast<LabelsTest *>(single_filter.expression);
|
||||
std::set<std::string> label_names;
|
||||
std::set<std::string, std::less<>> label_names;
|
||||
for (const auto &label : filter_expression->labels_) {
|
||||
label_names.insert(label.name);
|
||||
}
|
||||
@ -1167,7 +1165,7 @@ class Filter : public memgraph::query::plan::LogicalOperator {
|
||||
}
|
||||
|
||||
std::string ToString() const override {
|
||||
std::set<std::string> filter_names;
|
||||
std::set<std::string, std::less<>> filter_names;
|
||||
for (const auto &filter : all_filters_) {
|
||||
filter_names.insert(Filter::SingleFilterName(filter));
|
||||
}
|
||||
@ -1214,7 +1212,7 @@ class Produce : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Produce() {}
|
||||
Produce() = default;
|
||||
|
||||
Produce(const std::shared_ptr<LogicalOperator> &input, const std::vector<NamedExpression *> &named_expressions);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -1271,7 +1269,7 @@ class Delete : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Delete() {}
|
||||
Delete() = default;
|
||||
|
||||
Delete(const std::shared_ptr<LogicalOperator> &input_, const std::vector<Expression *> &expressions, bool detach_);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -1326,7 +1324,7 @@ class SetProperty : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
SetProperty() {}
|
||||
SetProperty() = default;
|
||||
|
||||
SetProperty(const std::shared_ptr<LogicalOperator> &input, storage::PropertyId property, PropertyLookup *lhs,
|
||||
Expression *rhs);
|
||||
@ -1385,7 +1383,7 @@ class SetProperties : public memgraph::query::plan::LogicalOperator {
|
||||
/// that the old properties are discarded and replaced with new ones.
|
||||
enum class Op { UPDATE, REPLACE };
|
||||
|
||||
SetProperties() {}
|
||||
SetProperties() = default;
|
||||
|
||||
SetProperties(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol, Expression *rhs, Op op);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -1433,7 +1431,7 @@ class SetLabels : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
SetLabels() {}
|
||||
SetLabels() = default;
|
||||
|
||||
SetLabels(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
const std::vector<storage::LabelId> &labels);
|
||||
@ -1477,7 +1475,7 @@ class RemoveProperty : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
RemoveProperty() {}
|
||||
RemoveProperty() = default;
|
||||
|
||||
RemoveProperty(const std::shared_ptr<LogicalOperator> &input, storage::PropertyId property, PropertyLookup *lhs);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -1522,7 +1520,7 @@ class RemoveLabels : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
RemoveLabels() {}
|
||||
RemoveLabels() = default;
|
||||
|
||||
RemoveLabels(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
const std::vector<storage::LabelId> &labels);
|
||||
@ -1578,7 +1576,7 @@ class EdgeUniquenessFilter : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
EdgeUniquenessFilter() {}
|
||||
EdgeUniquenessFilter() = default;
|
||||
|
||||
EdgeUniquenessFilter(const std::shared_ptr<LogicalOperator> &input, Symbol expand_symbol,
|
||||
const std::vector<Symbol> &previous_symbols);
|
||||
@ -1636,7 +1634,7 @@ class EmptyResult : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
EmptyResult() {}
|
||||
EmptyResult() = default;
|
||||
|
||||
EmptyResult(const std::shared_ptr<LogicalOperator> &input);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -1688,7 +1686,7 @@ class Accumulate : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Accumulate() {}
|
||||
Accumulate() = default;
|
||||
|
||||
Accumulate(const std::shared_ptr<LogicalOperator> &input, const std::vector<Symbol> &symbols,
|
||||
bool advance_command = false);
|
||||
@ -1811,7 +1809,7 @@ class Skip : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Skip() {}
|
||||
Skip() = default;
|
||||
|
||||
Skip(const std::shared_ptr<LogicalOperator> &input, Expression *expression);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -1857,7 +1855,7 @@ class EvaluatePatternFilter : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
EvaluatePatternFilter() {}
|
||||
EvaluatePatternFilter() = default;
|
||||
|
||||
EvaluatePatternFilter(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -1911,7 +1909,7 @@ class Limit : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Limit() {}
|
||||
Limit() = default;
|
||||
|
||||
Limit(const std::shared_ptr<LogicalOperator> &input, Expression *expression);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -1966,7 +1964,7 @@ class OrderBy : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
OrderBy() {}
|
||||
OrderBy() = default;
|
||||
|
||||
OrderBy(const std::shared_ptr<LogicalOperator> &input, const std::vector<SortItem> &order_by,
|
||||
const std::vector<Symbol> &output_symbols);
|
||||
@ -2018,7 +2016,7 @@ class Merge : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Merge() {}
|
||||
Merge() = default;
|
||||
|
||||
Merge(const std::shared_ptr<LogicalOperator> &input, const std::shared_ptr<LogicalOperator> &merge_match,
|
||||
const std::shared_ptr<LogicalOperator> &merge_create);
|
||||
@ -2078,7 +2076,7 @@ class Optional : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Optional() {}
|
||||
Optional() = default;
|
||||
|
||||
Optional(const std::shared_ptr<LogicalOperator> &input, const std::shared_ptr<LogicalOperator> &optional,
|
||||
const std::vector<Symbol> &optional_symbols);
|
||||
@ -2132,7 +2130,7 @@ class Unwind : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Unwind() {}
|
||||
Unwind() = default;
|
||||
|
||||
Unwind(const std::shared_ptr<LogicalOperator> &input, Expression *input_expression_, Symbol output_symbol);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -2167,7 +2165,7 @@ class Distinct : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Distinct() {}
|
||||
Distinct() = default;
|
||||
|
||||
Distinct(const std::shared_ptr<LogicalOperator> &input, const std::vector<Symbol> &value_symbols);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -2200,7 +2198,7 @@ class Union : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Union() {}
|
||||
Union() = default;
|
||||
|
||||
Union(const std::shared_ptr<LogicalOperator> &left_op, const std::shared_ptr<LogicalOperator> &right_op,
|
||||
const std::vector<Symbol> &union_symbols, const std::vector<Symbol> &left_symbols,
|
||||
@ -2256,7 +2254,7 @@ class Cartesian : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Cartesian() {}
|
||||
Cartesian() = default;
|
||||
/** Construct the operator with left input branch and right input branch. */
|
||||
Cartesian(const std::shared_ptr<LogicalOperator> &left_op, const std::vector<Symbol> &left_symbols,
|
||||
const std::shared_ptr<LogicalOperator> &right_op, const std::vector<Symbol> &right_symbols)
|
||||
@ -2291,7 +2289,7 @@ class OutputTable : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
OutputTable() {}
|
||||
OutputTable() = default;
|
||||
OutputTable(std::vector<Symbol> output_symbols,
|
||||
std::function<std::vector<std::vector<TypedValue>>(Frame *, ExecutionContext *)> callback);
|
||||
OutputTable(std::vector<Symbol> output_symbols, std::vector<std::vector<TypedValue>> rows);
|
||||
@ -2327,7 +2325,7 @@ class OutputTableStream : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
OutputTableStream() {}
|
||||
OutputTableStream() = default;
|
||||
OutputTableStream(std::vector<Symbol> output_symbols,
|
||||
std::function<std::optional<std::vector<TypedValue>>(Frame *, ExecutionContext *)> callback);
|
||||
|
||||
@ -2498,7 +2496,7 @@ class Apply : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
Apply() {}
|
||||
Apply() = default;
|
||||
|
||||
Apply(const std::shared_ptr<LogicalOperator> input, const std::shared_ptr<LogicalOperator> subquery,
|
||||
bool subquery_has_return);
|
||||
@ -2545,7 +2543,7 @@ class IndexedJoin : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
IndexedJoin() {}
|
||||
IndexedJoin() = default;
|
||||
|
||||
IndexedJoin(std::shared_ptr<LogicalOperator> main_branch, std::shared_ptr<LogicalOperator> sub_branch);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
@ -2588,7 +2586,7 @@ class HashJoin : public memgraph::query::plan::LogicalOperator {
|
||||
static const utils::TypeInfo kType;
|
||||
const utils::TypeInfo &GetTypeInfo() const override { return kType; }
|
||||
|
||||
HashJoin() {}
|
||||
HashJoin() = default;
|
||||
/** Construct the operator with left input branch and right input branch. */
|
||||
HashJoin(const std::shared_ptr<LogicalOperator> &left_op, const std::vector<Symbol> &left_symbols,
|
||||
const std::shared_ptr<LogicalOperator> &right_op, const std::vector<Symbol> &right_symbols,
|
||||
@ -2631,5 +2629,4 @@ class HashJoin : public memgraph::query::plan::LogicalOperator {
|
||||
};
|
||||
|
||||
} // namespace plan
|
||||
} // namespace query
|
||||
} // namespace memgraph
|
||||
} // namespace memgraph::query
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "query/plan/cost_estimator.hpp"
|
||||
#include "query/plan/operator.hpp"
|
||||
#include "query/plan/preprocess.hpp"
|
||||
@ -42,11 +44,11 @@ class PostProcessor final {
|
||||
|
||||
using ProcessedPlan = std::unique_ptr<LogicalOperator>;
|
||||
|
||||
explicit PostProcessor(const Parameters ¶meters) : parameters_(parameters) {}
|
||||
explicit PostProcessor(Parameters parameters) : parameters_(std::move(parameters)) {}
|
||||
|
||||
template <class TDbAccessor>
|
||||
PostProcessor(const Parameters ¶meters, std::vector<IndexHint> index_hints, TDbAccessor *db)
|
||||
: parameters_(parameters), index_hints_(IndexHints(index_hints, db)) {}
|
||||
PostProcessor(Parameters parameters, std::vector<IndexHint> index_hints, TDbAccessor *db)
|
||||
: parameters_(std::move(parameters)), index_hints_(IndexHints(index_hints, db)) {}
|
||||
|
||||
template <class TPlanningContext>
|
||||
std::unique_ptr<LogicalOperator> Rewrite(std::unique_ptr<LogicalOperator> plan, TPlanningContext *context) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <stack>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
#include "query/exceptions.hpp"
|
||||
@ -199,7 +200,7 @@ auto SplitExpressionOnAnd(Expression *expression) {
|
||||
|
||||
PropertyFilter::PropertyFilter(const SymbolTable &symbol_table, const Symbol &symbol, PropertyIx property,
|
||||
Expression *value, Type type)
|
||||
: symbol_(symbol), property_(property), type_(type), value_(value) {
|
||||
: symbol_(symbol), property_(std::move(property)), type_(type), value_(value) {
|
||||
MG_ASSERT(type != Type::RANGE);
|
||||
UsedSymbolsCollector collector(symbol_table);
|
||||
value->Accept(collector);
|
||||
@ -209,7 +210,11 @@ PropertyFilter::PropertyFilter(const SymbolTable &symbol_table, const Symbol &sy
|
||||
PropertyFilter::PropertyFilter(const SymbolTable &symbol_table, const Symbol &symbol, PropertyIx property,
|
||||
const std::optional<PropertyFilter::Bound> &lower_bound,
|
||||
const std::optional<PropertyFilter::Bound> &upper_bound)
|
||||
: symbol_(symbol), property_(property), type_(Type::RANGE), lower_bound_(lower_bound), upper_bound_(upper_bound) {
|
||||
: symbol_(symbol),
|
||||
property_(std::move(property)),
|
||||
type_(Type::RANGE),
|
||||
lower_bound_(lower_bound),
|
||||
upper_bound_(upper_bound) {
|
||||
UsedSymbolsCollector collector(symbol_table);
|
||||
if (lower_bound) {
|
||||
lower_bound->value()->Accept(collector);
|
||||
@ -220,8 +225,8 @@ PropertyFilter::PropertyFilter(const SymbolTable &symbol_table, const Symbol &sy
|
||||
is_symbol_in_value_ = utils::Contains(collector.symbols_, symbol);
|
||||
}
|
||||
|
||||
PropertyFilter::PropertyFilter(const Symbol &symbol, PropertyIx property, Type type)
|
||||
: symbol_(symbol), property_(property), type_(type) {
|
||||
PropertyFilter::PropertyFilter(Symbol symbol, PropertyIx property, Type type)
|
||||
: symbol_(std::move(symbol)), property_(std::move(property)), type_(type) {
|
||||
// As this constructor is used for property filters where
|
||||
// we don't have to evaluate the filter expression, we set
|
||||
// the is_symbol_in_value_ to false, although the filter
|
||||
|
@ -103,29 +103,29 @@ class UsedSymbolsCollector : public HierarchicalTreeVisitor {
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define PREPROCESS_DEFINE_ID_TYPE(name) \
|
||||
class name final { \
|
||||
private: \
|
||||
explicit name(uint64_t id) : id_(id) {} \
|
||||
\
|
||||
public: \
|
||||
/* Default constructor to allow serialization or preallocation. */ \
|
||||
name() = default; \
|
||||
\
|
||||
static name FromUint(uint64_t id) { return name(id); } \
|
||||
static name FromInt(int64_t id) { return name(utils::MemcpyCast<uint64_t>(id)); } \
|
||||
uint64_t AsUint() const { return id_; } \
|
||||
int64_t AsInt() const { return utils::MemcpyCast<int64_t>(id_); } \
|
||||
\
|
||||
private: \
|
||||
uint64_t id_; \
|
||||
}; \
|
||||
static_assert(std::is_trivially_copyable<name>::value, "query::plan::" #name " must be trivially copyable!"); \
|
||||
inline bool operator==(const name &first, const name &second) { return first.AsUint() == second.AsUint(); } \
|
||||
inline bool operator!=(const name &first, const name &second) { return first.AsUint() != second.AsUint(); } \
|
||||
inline bool operator<(const name &first, const name &second) { return first.AsUint() < second.AsUint(); } \
|
||||
inline bool operator>(const name &first, const name &second) { return first.AsUint() > second.AsUint(); } \
|
||||
inline bool operator<=(const name &first, const name &second) { return first.AsUint() <= second.AsUint(); } \
|
||||
#define PREPROCESS_DEFINE_ID_TYPE(name) \
|
||||
class name final { \
|
||||
private: \
|
||||
explicit name(uint64_t id) : id_(id) {} \
|
||||
\
|
||||
public: \
|
||||
/* Default constructor to allow serialization or preallocation. */ \
|
||||
name() = default; \
|
||||
\
|
||||
static name FromUint(uint64_t id) { return name(id); } \
|
||||
static name FromInt(int64_t id) { return name(utils::MemcpyCast<uint64_t>(id)); } \
|
||||
uint64_t AsUint() const { return id_; } \
|
||||
int64_t AsInt() const { return utils::MemcpyCast<int64_t>(id_); } \
|
||||
\
|
||||
private: \
|
||||
uint64_t id_; \
|
||||
}; \
|
||||
static_assert(std::is_trivially_copyable_v<name>, "query::plan::" #name " must be trivially copyable!"); \
|
||||
inline bool operator==(const name &first, const name &second) { return first.AsUint() == second.AsUint(); } \
|
||||
inline bool operator!=(const name &first, const name &second) { return first.AsUint() != second.AsUint(); } \
|
||||
inline bool operator<(const name &first, const name &second) { return first.AsUint() < second.AsUint(); } \
|
||||
inline bool operator>(const name &first, const name &second) { return first.AsUint() > second.AsUint(); } \
|
||||
inline bool operator<=(const name &first, const name &second) { return first.AsUint() <= second.AsUint(); } \
|
||||
inline bool operator>=(const name &first, const name &second) { return first.AsUint() >= second.AsUint(); }
|
||||
|
||||
PREPROCESS_DEFINE_ID_TYPE(ExpansionGroupId);
|
||||
@ -259,7 +259,7 @@ class PropertyFilter {
|
||||
/// Used for the "PROP IS NOT NULL" filter, and can be used for any
|
||||
/// property filter that doesn't need to use an expression to produce
|
||||
/// values that should be filtered further.
|
||||
PropertyFilter(const Symbol &, PropertyIx, Type);
|
||||
PropertyFilter(Symbol, PropertyIx, Type);
|
||||
|
||||
/// Symbol whose property is looked up.
|
||||
Symbol symbol_;
|
||||
|
@ -18,9 +18,7 @@
|
||||
|
||||
#include "query/typed_value.hpp"
|
||||
|
||||
namespace memgraph::query {
|
||||
|
||||
namespace plan {
|
||||
namespace memgraph::query::plan {
|
||||
|
||||
/**
|
||||
* Stores profiling statistics for a single logical operator.
|
||||
@ -43,5 +41,4 @@ std::vector<std::vector<TypedValue>> ProfilingStatsToTable(const ProfilingStatsW
|
||||
|
||||
nlohmann::json ProfilingStatsToJson(const ProfilingStatsWithTotalTime &stats);
|
||||
|
||||
} // namespace plan
|
||||
} // namespace memgraph::query
|
||||
} // namespace memgraph::query::plan
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
@ -84,7 +85,7 @@ template <class TDbAccessor>
|
||||
class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor {
|
||||
public:
|
||||
IndexLookupRewriter(SymbolTable *symbol_table, AstStorage *ast_storage, TDbAccessor *db, IndexHints index_hints)
|
||||
: symbol_table_(symbol_table), ast_storage_(ast_storage), db_(db), index_hints_(index_hints) {}
|
||||
: symbol_table_(symbol_table), ast_storage_(ast_storage), db_(db), index_hints_(std::move(index_hints)) {}
|
||||
|
||||
using HierarchicalLogicalOperatorVisitor::PostVisit;
|
||||
using HierarchicalLogicalOperatorVisitor::PreVisit;
|
||||
@ -676,9 +677,9 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor {
|
||||
if (!db_->LabelPropertyIndexExists(GetLabel(label), GetProperty(property))) {
|
||||
continue;
|
||||
}
|
||||
candidate_indices.emplace_back(std::make_pair(
|
||||
candidate_indices.emplace_back(
|
||||
IndexHint{.index_type_ = IndexHint::IndexType::LABEL_PROPERTY, .label_ = label, .property_ = property},
|
||||
filter));
|
||||
filter);
|
||||
candidate_index_lookup.insert({std::make_pair(label, property), filter});
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <limits>
|
||||
#include <queue>
|
||||
#include <utility>
|
||||
|
||||
#include "utils/flag_validation.hpp"
|
||||
#include "utils/logging.hpp"
|
||||
@ -216,7 +217,7 @@ CartesianProduct<VaryMatchingStart> VaryMultiMatchingStarts(const std::vector<Ma
|
||||
std::vector<VaryMatchingStart> variants;
|
||||
variants.reserve(matchings.size());
|
||||
for (const auto &matching : matchings) {
|
||||
variants.emplace_back(VaryMatchingStart(matching, symbol_table));
|
||||
variants.emplace_back(matching, symbol_table);
|
||||
}
|
||||
return MakeCartesianProduct(std::move(variants));
|
||||
}
|
||||
@ -247,8 +248,7 @@ VaryQueryPartMatching::VaryQueryPartMatching(SingleQueryPart query_part, const S
|
||||
merge_matchings_(VaryMultiMatchingStarts(query_part_.merge_matching, symbol_table)),
|
||||
filter_matchings_(VaryFilterMatchingStarts(query_part_.matching, symbol_table)) {}
|
||||
|
||||
VaryQueryPartMatching::iterator::iterator(const SingleQueryPart &query_part,
|
||||
VaryMatchingStart::iterator matchings_begin,
|
||||
VaryQueryPartMatching::iterator::iterator(SingleQueryPart query_part, VaryMatchingStart::iterator matchings_begin,
|
||||
VaryMatchingStart::iterator matchings_end,
|
||||
CartesianProduct<VaryMatchingStart>::iterator optional_begin,
|
||||
CartesianProduct<VaryMatchingStart>::iterator optional_end,
|
||||
@ -256,18 +256,18 @@ VaryQueryPartMatching::iterator::iterator(const SingleQueryPart &query_part,
|
||||
CartesianProduct<VaryMatchingStart>::iterator merge_end,
|
||||
CartesianProduct<VaryMatchingStart>::iterator filter_begin,
|
||||
CartesianProduct<VaryMatchingStart>::iterator filter_end)
|
||||
: current_query_part_(query_part),
|
||||
matchings_it_(matchings_begin),
|
||||
matchings_end_(matchings_end),
|
||||
: current_query_part_(std::move(query_part)),
|
||||
matchings_it_(std::move(matchings_begin)),
|
||||
matchings_end_(std::move(matchings_end)),
|
||||
optional_it_(optional_begin),
|
||||
optional_begin_(optional_begin),
|
||||
optional_end_(optional_end),
|
||||
optional_end_(std::move(optional_end)),
|
||||
merge_it_(merge_begin),
|
||||
merge_begin_(merge_begin),
|
||||
merge_end_(merge_end),
|
||||
merge_end_(std::move(merge_end)),
|
||||
filter_it_(filter_begin),
|
||||
filter_begin_(filter_begin),
|
||||
filter_end_(filter_end) {
|
||||
filter_end_(std::move(filter_end)) {
|
||||
if (matchings_it_ != matchings_end_) {
|
||||
// Fill the query part with the first variation of matchings
|
||||
SetCurrentQueryPart();
|
||||
|
@ -49,16 +49,16 @@ class CartesianProduct {
|
||||
using TElement = typename decltype(begin_->begin())::value_type;
|
||||
|
||||
public:
|
||||
CartesianProduct(std::vector<TSet> sets)
|
||||
explicit CartesianProduct(std::vector<TSet> sets)
|
||||
: original_sets_(std::move(sets)), begin_(original_sets_.begin()), end_(original_sets_.end()) {}
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef std::vector<TElement> value_type;
|
||||
typedef long difference_type;
|
||||
typedef const std::vector<TElement> &reference;
|
||||
typedef const std::vector<TElement> *pointer;
|
||||
using iterator_category = std::input_iterator_tag;
|
||||
using value_type = std::vector<TElement>;
|
||||
using difference_type = long;
|
||||
using reference = const std::vector<TElement> &;
|
||||
using pointer = const std::vector<TElement> *;
|
||||
|
||||
explicit iterator(CartesianProduct *self, bool is_done) : self_(self), is_done_(is_done) {
|
||||
if (is_done || self->begin_ == self->end_) {
|
||||
@ -186,11 +186,11 @@ class VaryMatchingStart {
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef Matching value_type;
|
||||
typedef long difference_type;
|
||||
typedef const Matching &reference;
|
||||
typedef const Matching *pointer;
|
||||
using iterator_category = std::input_iterator_tag;
|
||||
using value_type = Matching;
|
||||
using difference_type = long;
|
||||
using reference = const Matching &;
|
||||
using pointer = const Matching *;
|
||||
|
||||
iterator(VaryMatchingStart *, bool);
|
||||
|
||||
@ -240,13 +240,13 @@ class VaryQueryPartMatching {
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef SingleQueryPart value_type;
|
||||
typedef long difference_type;
|
||||
typedef const SingleQueryPart &reference;
|
||||
typedef const SingleQueryPart *pointer;
|
||||
using iterator_category = std::input_iterator_tag;
|
||||
using value_type = SingleQueryPart;
|
||||
using difference_type = long;
|
||||
using reference = const SingleQueryPart &;
|
||||
using pointer = const SingleQueryPart *;
|
||||
|
||||
iterator(const SingleQueryPart &, VaryMatchingStart::iterator, VaryMatchingStart::iterator,
|
||||
iterator(SingleQueryPart, VaryMatchingStart::iterator, VaryMatchingStart::iterator,
|
||||
CartesianProduct<VaryMatchingStart>::iterator, CartesianProduct<VaryMatchingStart>::iterator,
|
||||
CartesianProduct<VaryMatchingStart>::iterator, CartesianProduct<VaryMatchingStart>::iterator,
|
||||
CartesianProduct<VaryMatchingStart>::iterator, CartesianProduct<VaryMatchingStart>::iterator);
|
||||
@ -383,8 +383,8 @@ class VariableStartPlanner {
|
||||
|
||||
/// @brief The result of plan generation is an iterable of roots to multiple
|
||||
/// generated operator trees.
|
||||
using PlanResult = typename std::result_of<decltype (&VariableStartPlanner<TPlanningContext>::Plan)(
|
||||
VariableStartPlanner<TPlanningContext>, QueryParts &)>::type;
|
||||
using PlanResult = std::result_of_t<decltype (&VariableStartPlanner<TPlanningContext>::Plan)(
|
||||
VariableStartPlanner<TPlanningContext>, QueryParts &)>;
|
||||
};
|
||||
|
||||
} // namespace memgraph::query::plan
|
||||
|
@ -27,7 +27,7 @@ namespace memgraph::query::plan {
|
||||
template <class TDbAccessor>
|
||||
class VertexCountCache {
|
||||
public:
|
||||
VertexCountCache(TDbAccessor *db) : db_(db) {}
|
||||
explicit VertexCountCache(TDbAccessor *db) : db_(db) {}
|
||||
|
||||
auto NameToLabel(const std::string &name) { return db_->NameToLabel(name); }
|
||||
auto NameToProperty(const std::string &name) { return db_->NameToProperty(name); }
|
||||
@ -88,7 +88,7 @@ class VertexCountCache {
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::pair<storage::LabelId, storage::PropertyId> LabelPropertyKey;
|
||||
using LabelPropertyKey = std::pair<storage::LabelId, storage::PropertyId>;
|
||||
|
||||
struct LabelPropertyHash {
|
||||
size_t operator()(const LabelPropertyKey &key) const {
|
||||
@ -96,9 +96,8 @@ class VertexCountCache {
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::pair<std::optional<utils::Bound<storage::PropertyValue>>,
|
||||
std::optional<utils::Bound<storage::PropertyValue>>>
|
||||
BoundsKey;
|
||||
using BoundsKey = std::pair<std::optional<utils::Bound<storage::PropertyValue>>,
|
||||
std::optional<utils::Bound<storage::PropertyValue>>>;
|
||||
|
||||
struct BoundsHash {
|
||||
size_t operator()(const BoundsKey &key) const {
|
||||
|
@ -34,8 +34,8 @@ struct ReplicationClientConfig {
|
||||
std::chrono::seconds replica_check_frequency{1};
|
||||
|
||||
struct SSL {
|
||||
std::string key_file = "";
|
||||
std::string cert_file = "";
|
||||
std::string key_file;
|
||||
std::string cert_file;
|
||||
|
||||
friend bool operator==(const SSL &, const SSL &) = default;
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ struct FrequentHeartbeatReq {
|
||||
|
||||
static void Load(FrequentHeartbeatReq *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const FrequentHeartbeatReq &self, memgraph::slk::Builder *builder);
|
||||
FrequentHeartbeatReq() {}
|
||||
FrequentHeartbeatReq() = default;
|
||||
};
|
||||
|
||||
struct FrequentHeartbeatRes {
|
||||
@ -32,7 +32,7 @@ struct FrequentHeartbeatRes {
|
||||
|
||||
static void Load(FrequentHeartbeatRes *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const FrequentHeartbeatRes &self, memgraph::slk::Builder *builder);
|
||||
FrequentHeartbeatRes() {}
|
||||
FrequentHeartbeatRes() = default;
|
||||
explicit FrequentHeartbeatRes(bool success) : success(success) {}
|
||||
|
||||
bool success;
|
||||
|
@ -35,7 +35,7 @@ bool RequestPostJson(const std::string &url, const nlohmann::json &data, int tim
|
||||
CURLcode res = CURLE_UNSUPPORTED_PROTOCOL;
|
||||
|
||||
long response_code = 0;
|
||||
struct curl_slist *headers = NULL;
|
||||
struct curl_slist *headers = nullptr;
|
||||
std::string payload = data.dump();
|
||||
std::string user_agent = fmt::format("memgraph/{}", gflags::VersionString());
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Client {
|
||||
StreamHandler(const StreamHandler &) = delete;
|
||||
StreamHandler &operator=(const StreamHandler &) = delete;
|
||||
|
||||
~StreamHandler() {}
|
||||
~StreamHandler() = default;
|
||||
|
||||
slk::Builder *GetBuilder() { return &req_builder_; }
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <stack>
|
||||
#include <utility>
|
||||
|
||||
#include "rpc/client.hpp"
|
||||
|
||||
@ -25,8 +26,8 @@ namespace memgraph::rpc {
|
||||
*/
|
||||
class ClientPool {
|
||||
public:
|
||||
ClientPool(const io::network::Endpoint &endpoint, communication::ClientContext *context)
|
||||
: endpoint_(endpoint), context_(context) {}
|
||||
ClientPool(io::network::Endpoint endpoint, communication::ClientContext *context)
|
||||
: endpoint_(std::move(endpoint)), context_(context) {}
|
||||
|
||||
template <class TRequestResponse, class... Args>
|
||||
typename TRequestResponse::Response Call(Args &&...args) {
|
||||
|
@ -21,7 +21,7 @@ namespace memgraph::rpc {
|
||||
/// This exception always requires explicit handling.
|
||||
class RpcFailedException : public utils::BasicException {
|
||||
public:
|
||||
RpcFailedException(std::string_view msg) : utils::BasicException(msg) {}
|
||||
explicit RpcFailedException(std::string_view msg) : utils::BasicException(msg) {}
|
||||
SPECIALIZE_GET_EXCEPTION_NAME(RpcFailedException);
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "rpc/protocol.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "rpc/messages.hpp"
|
||||
#include "rpc/server.hpp"
|
||||
#include "rpc/version.hpp"
|
||||
@ -21,9 +23,9 @@
|
||||
|
||||
namespace memgraph::rpc {
|
||||
|
||||
Session::Session(Server *server, const io::network::Endpoint &endpoint, communication::InputStream *input_stream,
|
||||
Session::Session(Server *server, io::network::Endpoint endpoint, communication::InputStream *input_stream,
|
||||
communication::OutputStream *output_stream)
|
||||
: server_(server), endpoint_(endpoint), input_stream_(input_stream), output_stream_(output_stream) {}
|
||||
: server_(server), endpoint_(std::move(endpoint)), input_stream_(input_stream), output_stream_(output_stream) {}
|
||||
|
||||
void Session::Execute() {
|
||||
auto ret = slk::CheckStreamComplete(input_stream_->data(), input_stream_->size());
|
||||
|
@ -48,7 +48,7 @@ class SessionException : public utils::BasicException {
|
||||
*/
|
||||
class Session {
|
||||
public:
|
||||
Session(Server *server, const io::network::Endpoint &endpoint, communication::InputStream *input_stream,
|
||||
Session(Server *server, io::network::Endpoint endpoint, communication::InputStream *input_stream,
|
||||
communication::OutputStream *output_stream);
|
||||
|
||||
/**
|
||||
|
@ -60,10 +60,10 @@ void Save(const std::vector<T> &obj, Builder *builder);
|
||||
template <typename T>
|
||||
void Load(std::vector<T> *obj, Reader *reader);
|
||||
|
||||
template <typename T>
|
||||
void Save(const std::set<T> &obj, Builder *builder);
|
||||
template <typename T>
|
||||
void Load(std::set<T> *obj, Reader *reader);
|
||||
template <typename T, typename Cmp>
|
||||
void Save(const std::set<T, Cmp> &obj, Builder *builder);
|
||||
template <typename T, typename Cmp>
|
||||
void Load(std::set<T, Cmp> *obj, Reader *reader);
|
||||
|
||||
template <typename K, typename V>
|
||||
void Save(const std::map<K, V> &obj, Builder *builder);
|
||||
@ -201,8 +201,8 @@ inline void Load(std::vector<T> *obj, Reader *reader) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void Save(const std::set<T> &obj, Builder *builder) {
|
||||
template <typename T, typename Cmp>
|
||||
inline void Save(const std::set<T, Cmp> &obj, Builder *builder) {
|
||||
uint64_t size = obj.size();
|
||||
Save(size, builder);
|
||||
for (const auto &item : obj) {
|
||||
@ -210,8 +210,8 @@ inline void Save(const std::set<T> &obj, Builder *builder) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void Load(std::set<T> *obj, Reader *reader) {
|
||||
template <typename T, typename Cmp>
|
||||
inline void Load(std::set<T, Cmp> *obj, Reader *reader) {
|
||||
uint64_t size = 0;
|
||||
Load(&size, reader);
|
||||
for (uint64_t i = 0; i < size; ++i) {
|
||||
@ -273,7 +273,7 @@ inline void Load(std::unique_ptr<T> *obj, Reader *reader) {
|
||||
// Prevent any loading which may potentially break class hierarchies.
|
||||
// Unfortunately, C++14 doesn't have (or I'm not aware of it) a trait for
|
||||
// checking whether some type has any derived or base classes.
|
||||
static_assert(!std::is_polymorphic<T>::value,
|
||||
static_assert(!std::is_polymorphic_v<T>,
|
||||
"Only non polymorphic types can be loaded generically from a "
|
||||
"pointer. Pass a custom load function as the 3rd argument.");
|
||||
bool exists = false;
|
||||
@ -379,7 +379,7 @@ inline void Load(std::shared_ptr<T> *obj, Reader *reader, std::vector<std::share
|
||||
// Prevent any loading which may potentially break class hierarchies.
|
||||
// Unfortunately, C++14 doesn't have (or I'm not aware of it) a trait for
|
||||
// checking whether some type has any derived or base classes.
|
||||
static_assert(!std::is_polymorphic<T>::value,
|
||||
static_assert(!std::is_polymorphic_v<T>,
|
||||
"Only non polymorphic types can be loaded generically from a "
|
||||
"pointer. Pass a custom load function as the 4th argument.");
|
||||
bool exists = false;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -12,12 +12,13 @@
|
||||
#include "slk/streams.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#include "utils/logging.hpp"
|
||||
|
||||
namespace memgraph::slk {
|
||||
|
||||
Builder::Builder(std::function<void(const uint8_t *, size_t, bool)> write_func) : write_func_(write_func) {}
|
||||
Builder::Builder(std::function<void(const uint8_t *, size_t, bool)> write_func) : write_func_(std::move(write_func)) {}
|
||||
|
||||
void Builder::Save(const uint8_t *data, uint64_t size) {
|
||||
size_t offset = 0;
|
||||
|
@ -211,8 +211,7 @@ uint64_t DiskLabelPropertyIndex::ApproximateVertexCount(
|
||||
void DiskLabelPropertyIndex::LoadIndexInfo(const std::vector<std::string> &keys) {
|
||||
for (const auto &label_property : keys) {
|
||||
std::vector<std::string> label_property_split = utils::Split(label_property, ",");
|
||||
index_.emplace(
|
||||
std::make_pair(LabelId::FromString(label_property_split[0]), PropertyId::FromString(label_property_split[1])));
|
||||
index_.emplace(LabelId::FromString(label_property_split[0]), PropertyId::FromString(label_property_split[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace memgraph::storage {
|
||||
/// Wraps RocksDB objects inside a struct. Vertex_chandle and edge_chandle are column family handles that may be
|
||||
/// nullptr. In that case client should take care about them.
|
||||
struct RocksDBStorage {
|
||||
explicit RocksDBStorage() {}
|
||||
explicit RocksDBStorage() = default;
|
||||
|
||||
RocksDBStorage(const RocksDBStorage &) = delete;
|
||||
RocksDBStorage &operator=(const RocksDBStorage &) = delete;
|
||||
|
@ -344,7 +344,7 @@ void DiskUniqueConstraints::LoadUniqueConstraints(const std::vector<std::string>
|
||||
for (int i = 1; i < key_parts.size(); i++) {
|
||||
properties.insert(PropertyId::FromString(key_parts[i]));
|
||||
}
|
||||
constraints_.emplace(std::make_pair(label, properties));
|
||||
constraints_.emplace(label, properties);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -27,7 +27,7 @@ namespace memgraph::storage::durability {
|
||||
/// (e.g. file and network).
|
||||
class BaseEncoder {
|
||||
protected:
|
||||
~BaseEncoder() {}
|
||||
~BaseEncoder() = default;
|
||||
|
||||
public:
|
||||
virtual void WriteMarker(Marker marker) = 0;
|
||||
@ -84,7 +84,7 @@ class Encoder final : public BaseEncoder {
|
||||
/// (e.g. file and network).
|
||||
class BaseDecoder {
|
||||
protected:
|
||||
~BaseDecoder() {}
|
||||
~BaseDecoder() = default;
|
||||
|
||||
public:
|
||||
virtual std::optional<Marker> ReadMarker() = 0;
|
||||
|
@ -1212,7 +1212,7 @@ RecoveredSnapshot LoadSnapshotVersion15(const std::filesystem::path &path, utils
|
||||
spdlog::info("Recover connectivity.");
|
||||
recovery_info.vertex_batches.reserve(vertex_batches.size());
|
||||
for (const auto batch : vertex_batches) {
|
||||
recovery_info.vertex_batches.emplace_back(std::make_pair(Gid::FromUint(0), batch.count));
|
||||
recovery_info.vertex_batches.emplace_back(Gid::FromUint(0), batch.count);
|
||||
}
|
||||
std::atomic<uint64_t> highest_edge_gid{0};
|
||||
|
||||
@ -1505,7 +1505,7 @@ RecoveredSnapshot LoadSnapshot(const std::filesystem::path &path, utils::SkipLis
|
||||
spdlog::info("Recover connectivity.");
|
||||
recovery_info.vertex_batches.reserve(vertex_batches.size());
|
||||
for (const auto batch : vertex_batches) {
|
||||
recovery_info.vertex_batches.emplace_back(std::make_pair(Gid::FromUint(0), batch.count));
|
||||
recovery_info.vertex_batches.emplace_back(Gid::FromUint(0), batch.count);
|
||||
}
|
||||
std::atomic<uint64_t> highest_edge_gid{0};
|
||||
|
||||
|
@ -108,7 +108,7 @@ struct WalDeltaData {
|
||||
|
||||
struct {
|
||||
std::string label;
|
||||
std::set<std::string> properties;
|
||||
std::set<std::string, std::less<>> properties;
|
||||
} operation_label_properties;
|
||||
|
||||
struct {
|
||||
|
@ -110,7 +110,7 @@ class EdgeAccessor final {
|
||||
|
||||
} // namespace memgraph::storage
|
||||
|
||||
static_assert(std::is_trivially_copyable<memgraph::storage::EdgeAccessor>::value,
|
||||
static_assert(std::is_trivially_copyable_v<memgraph::storage::EdgeAccessor>,
|
||||
"storage::EdgeAccessor must be trivially copyable!");
|
||||
|
||||
namespace std {
|
||||
|
@ -42,7 +42,7 @@ namespace memgraph::storage {
|
||||
private: \
|
||||
uint64_t id_; \
|
||||
}; \
|
||||
static_assert(std::is_trivially_copyable<name>::value, "storage::" #name " must be trivially copyable!"); \
|
||||
static_assert(std::is_trivially_copyable_v<name>, "storage::" #name " must be trivially copyable!"); \
|
||||
inline bool operator==(const name &first, const name &second) { return first.AsUint() == second.AsUint(); } \
|
||||
inline bool operator!=(const name &first, const name &second) { return first.AsUint() != second.AsUint(); } \
|
||||
inline bool operator<(const name &first, const name &second) { return first.AsUint() < second.AsUint(); } \
|
||||
|
@ -34,8 +34,7 @@ struct ModifiedEdgeInfo {
|
||||
EdgeRef edge_ref;
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<ModifiedEdgeInfo>::value,
|
||||
"storage::ModifiedEdgeInfo must be trivially copyable!");
|
||||
static_assert(std::is_trivially_copyable_v<ModifiedEdgeInfo>, "storage::ModifiedEdgeInfo must be trivially copyable!");
|
||||
|
||||
using ModifiedEdgesMap = std::unordered_map<Gid, ModifiedEdgeInfo>;
|
||||
|
||||
|
@ -179,7 +179,7 @@ class Writer {
|
||||
public:
|
||||
class MetadataHandle {
|
||||
public:
|
||||
MetadataHandle() {}
|
||||
MetadataHandle() = default;
|
||||
|
||||
explicit MetadataHandle(uint8_t *value) : value_(value) {}
|
||||
|
||||
@ -195,7 +195,7 @@ class Writer {
|
||||
uint8_t *value_{nullptr};
|
||||
};
|
||||
|
||||
Writer() {}
|
||||
Writer() = default;
|
||||
|
||||
Writer(uint8_t *data, uint64_t size) : data_(data), size_(size) {}
|
||||
|
||||
@ -1311,7 +1311,7 @@ std::vector<std::tuple<PropertyId, PropertyValue, PropertyValue>> PropertyStore:
|
||||
id_old_new_change.reserve(properties.size() + old_properties.size());
|
||||
for (const auto &[prop_id, new_value] : properties) {
|
||||
if (!old_properties.contains(prop_id)) {
|
||||
id_old_new_change.emplace_back(std::make_tuple(prop_id, PropertyValue(), new_value));
|
||||
id_old_new_change.emplace_back(prop_id, PropertyValue(), new_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1319,7 +1319,7 @@ std::vector<std::tuple<PropertyId, PropertyValue, PropertyValue>> PropertyStore:
|
||||
auto [it, inserted] = properties.emplace(old_key, old_value);
|
||||
if (!inserted) {
|
||||
auto &new_value = it->second;
|
||||
id_old_new_change.emplace_back(std::make_tuple(it->first, old_value, new_value));
|
||||
id_old_new_change.emplace_back(it->first, old_value, new_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class ReplicationClient {
|
||||
auto GetStorageId() const -> std::string;
|
||||
|
||||
void Start();
|
||||
void StartTransactionReplication(const uint64_t current_wal_seq_num);
|
||||
void StartTransactionReplication(uint64_t current_wal_seq_num);
|
||||
// Replication clients can be removed at any point
|
||||
// so to avoid any complexity of checking if the client was removed whenever
|
||||
// we want to send part of transaction and to avoid adding some GC logic this
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
namespace memgraph {
|
||||
|
||||
namespace storage {
|
||||
|
||||
namespace replication {
|
||||
namespace storage::replication {
|
||||
|
||||
void AppendDeltasReq::Save(const AppendDeltasReq &self, memgraph::slk::Builder *builder) {
|
||||
memgraph::slk::Save(self, builder);
|
||||
@ -59,8 +57,7 @@ void TimestampRes::Save(const TimestampRes &self, memgraph::slk::Builder *builde
|
||||
}
|
||||
void TimestampRes::Load(TimestampRes *self, memgraph::slk::Reader *reader) { memgraph::slk::Load(self, reader); }
|
||||
|
||||
} // namespace replication
|
||||
} // namespace storage
|
||||
} // namespace storage::replication
|
||||
|
||||
constexpr utils::TypeInfo storage::replication::AppendDeltasReq::kType{utils::TypeId::REP_APPEND_DELTAS_REQ,
|
||||
"AppendDeltasReq", nullptr};
|
||||
|
@ -14,16 +14,13 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "rpc/messages.hpp"
|
||||
#include "slk/serialization.hpp"
|
||||
#include "slk/streams.hpp"
|
||||
|
||||
namespace memgraph {
|
||||
|
||||
namespace storage {
|
||||
|
||||
namespace replication {
|
||||
namespace memgraph::storage::replication {
|
||||
|
||||
struct AppendDeltasReq {
|
||||
static const utils::TypeInfo kType;
|
||||
@ -31,7 +28,7 @@ struct AppendDeltasReq {
|
||||
|
||||
static void Load(AppendDeltasReq *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const AppendDeltasReq &self, memgraph::slk::Builder *builder);
|
||||
AppendDeltasReq() {}
|
||||
AppendDeltasReq() = default;
|
||||
AppendDeltasReq(std::string name, uint64_t previous_commit_timestamp, uint64_t seq_num)
|
||||
: db_name(std::move(name)), previous_commit_timestamp(previous_commit_timestamp), seq_num(seq_num) {}
|
||||
|
||||
@ -46,7 +43,7 @@ struct AppendDeltasRes {
|
||||
|
||||
static void Load(AppendDeltasRes *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const AppendDeltasRes &self, memgraph::slk::Builder *builder);
|
||||
AppendDeltasRes() {}
|
||||
AppendDeltasRes() = default;
|
||||
AppendDeltasRes(std::string name, bool success, uint64_t current_commit_timestamp)
|
||||
: db_name(std::move(name)), success(success), current_commit_timestamp(current_commit_timestamp) {}
|
||||
|
||||
@ -63,7 +60,7 @@ struct HeartbeatReq {
|
||||
|
||||
static void Load(HeartbeatReq *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const HeartbeatReq &self, memgraph::slk::Builder *builder);
|
||||
HeartbeatReq() {}
|
||||
HeartbeatReq() = default;
|
||||
HeartbeatReq(std::string name, uint64_t main_commit_timestamp, std::string epoch_id)
|
||||
: db_name(std::move(name)), main_commit_timestamp(main_commit_timestamp), epoch_id(std::move(epoch_id)) {}
|
||||
|
||||
@ -78,12 +75,12 @@ struct HeartbeatRes {
|
||||
|
||||
static void Load(HeartbeatRes *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const HeartbeatRes &self, memgraph::slk::Builder *builder);
|
||||
HeartbeatRes() {}
|
||||
HeartbeatRes() = default;
|
||||
HeartbeatRes(std::string name, bool success, uint64_t current_commit_timestamp, std::string epoch_id)
|
||||
: db_name(std::move(name)),
|
||||
success(success),
|
||||
current_commit_timestamp(current_commit_timestamp),
|
||||
epoch_id(epoch_id) {}
|
||||
epoch_id(std::move(epoch_id)) {}
|
||||
|
||||
std::string db_name;
|
||||
bool success;
|
||||
@ -99,7 +96,7 @@ struct SnapshotReq {
|
||||
|
||||
static void Load(SnapshotReq *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const SnapshotReq &self, memgraph::slk::Builder *builder);
|
||||
SnapshotReq() {}
|
||||
SnapshotReq() = default;
|
||||
explicit SnapshotReq(std::string name) : db_name(std::move(name)) {}
|
||||
|
||||
std::string db_name;
|
||||
@ -111,7 +108,7 @@ struct SnapshotRes {
|
||||
|
||||
static void Load(SnapshotRes *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const SnapshotRes &self, memgraph::slk::Builder *builder);
|
||||
SnapshotRes() {}
|
||||
SnapshotRes() = default;
|
||||
SnapshotRes(std::string name, bool success, uint64_t current_commit_timestamp)
|
||||
: db_name(std::move(name)), success(success), current_commit_timestamp(current_commit_timestamp) {}
|
||||
|
||||
@ -128,7 +125,7 @@ struct WalFilesReq {
|
||||
|
||||
static void Load(WalFilesReq *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const WalFilesReq &self, memgraph::slk::Builder *builder);
|
||||
WalFilesReq() {}
|
||||
WalFilesReq() = default;
|
||||
explicit WalFilesReq(std::string name, uint64_t file_number) : db_name(std::move(name)), file_number(file_number) {}
|
||||
|
||||
std::string db_name;
|
||||
@ -141,7 +138,7 @@ struct WalFilesRes {
|
||||
|
||||
static void Load(WalFilesRes *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const WalFilesRes &self, memgraph::slk::Builder *builder);
|
||||
WalFilesRes() {}
|
||||
WalFilesRes() = default;
|
||||
WalFilesRes(std::string name, bool success, uint64_t current_commit_timestamp)
|
||||
: db_name(std::move(name)), success(success), current_commit_timestamp(current_commit_timestamp) {}
|
||||
|
||||
@ -158,7 +155,7 @@ struct CurrentWalReq {
|
||||
|
||||
static void Load(CurrentWalReq *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const CurrentWalReq &self, memgraph::slk::Builder *builder);
|
||||
CurrentWalReq() {}
|
||||
CurrentWalReq() = default;
|
||||
explicit CurrentWalReq(std::string name) : db_name(std::move(name)) {}
|
||||
|
||||
std::string db_name;
|
||||
@ -170,7 +167,7 @@ struct CurrentWalRes {
|
||||
|
||||
static void Load(CurrentWalRes *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const CurrentWalRes &self, memgraph::slk::Builder *builder);
|
||||
CurrentWalRes() {}
|
||||
CurrentWalRes() = default;
|
||||
CurrentWalRes(std::string name, bool success, uint64_t current_commit_timestamp)
|
||||
: db_name(std::move(name)), success(success), current_commit_timestamp(current_commit_timestamp) {}
|
||||
|
||||
@ -187,7 +184,7 @@ struct TimestampReq {
|
||||
|
||||
static void Load(TimestampReq *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const TimestampReq &self, memgraph::slk::Builder *builder);
|
||||
TimestampReq() {}
|
||||
TimestampReq() = default;
|
||||
explicit TimestampReq(std::string name) : db_name(std::move(name)) {}
|
||||
|
||||
std::string db_name;
|
||||
@ -199,7 +196,7 @@ struct TimestampRes {
|
||||
|
||||
static void Load(TimestampRes *self, memgraph::slk::Reader *reader);
|
||||
static void Save(const TimestampRes &self, memgraph::slk::Builder *builder);
|
||||
TimestampRes() {}
|
||||
TimestampRes() = default;
|
||||
TimestampRes(std::string name, bool success, uint64_t current_commit_timestamp)
|
||||
: db_name(std::move(name)), success(success), current_commit_timestamp(current_commit_timestamp) {}
|
||||
|
||||
@ -209,12 +206,9 @@ struct TimestampRes {
|
||||
};
|
||||
|
||||
using TimestampRpc = rpc::RequestResponse<TimestampReq, TimestampRes>;
|
||||
} // namespace replication
|
||||
} // namespace storage
|
||||
} // namespace memgraph
|
||||
} // namespace memgraph::storage::replication
|
||||
|
||||
// SLK serialization declarations
|
||||
#include "slk/serialization.hpp"
|
||||
namespace memgraph::slk {
|
||||
|
||||
void Save(const memgraph::storage::replication::TimestampRes &self, memgraph::slk::Builder *builder);
|
||||
|
@ -140,7 +140,7 @@ class Storage {
|
||||
|
||||
Accessor(Accessor &&other) noexcept;
|
||||
|
||||
virtual ~Accessor() {}
|
||||
virtual ~Accessor() = default;
|
||||
|
||||
virtual VertexAccessor CreateVertex() = 0;
|
||||
|
||||
|
@ -127,7 +127,7 @@ class VertexAccessor final {
|
||||
bool for_deleted_{false};
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<memgraph::storage::VertexAccessor>::value,
|
||||
static_assert(std::is_trivially_copyable_v<memgraph::storage::VertexAccessor>,
|
||||
"storage::VertexAccessor must be trivially copyable!");
|
||||
|
||||
struct EdgesVertexAccessorResult {
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "telemetry/telemetry.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <utility>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
@ -36,8 +37,8 @@ Telemetry::Telemetry(std::string url, std::filesystem::path storage_directory, s
|
||||
bool ssl, std::filesystem::path root_directory, std::chrono::duration<int64_t> refresh_interval,
|
||||
const uint64_t send_every_n)
|
||||
: url_(std::move(url)),
|
||||
uuid_(uuid),
|
||||
machine_id_(machine_id),
|
||||
uuid_(std::move(uuid)),
|
||||
machine_id_(std::move(machine_id)),
|
||||
ssl_(ssl),
|
||||
send_every_n_(send_every_n),
|
||||
storage_(std::move(storage_directory)) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -18,8 +18,8 @@
|
||||
namespace memgraph::utils {
|
||||
|
||||
template <typename T>
|
||||
constexpr typename std::underlying_type<T>::type UnderlyingCast(T e) {
|
||||
return static_cast<typename std::underlying_type<T>::type>(e);
|
||||
constexpr std::underlying_type_t<T> UnderlyingCast(T e) {
|
||||
return static_cast<std::underlying_type_t<T>>(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,8 +36,8 @@ template <typename TDest, typename TSrc>
|
||||
TDest MemcpyCast(TSrc src) {
|
||||
TDest dest;
|
||||
static_assert(sizeof(dest) == sizeof(src), "MemcpyCast expects source and destination to be of same size");
|
||||
static_assert(std::is_arithmetic<TSrc>::value, "MemcpyCast expects source is an arithmetic type");
|
||||
static_assert(std::is_arithmetic<TDest>::value, "MemcypCast expects destination is an arithmetic type");
|
||||
static_assert(std::is_arithmetic_v<TSrc>, "MemcpyCast expects source is an arithmetic type");
|
||||
static_assert(std::is_arithmetic_v<TDest>, "MemcypCast expects destination is an arithmetic type");
|
||||
std::memcpy(&dest, &src, sizeof(src));
|
||||
return dest;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
|
||||
#include "utils/logging.hpp"
|
||||
|
||||
@ -73,7 +74,9 @@ class Histogram {
|
||||
percentiles_ = {0, 25, 50, 75, 90, 100};
|
||||
}
|
||||
|
||||
explicit Histogram(std::vector<uint8_t> percentiles) : percentiles_(percentiles) { samples_.resize(kSampleLimit, 0); }
|
||||
explicit Histogram(std::vector<uint8_t> percentiles) : percentiles_(std::move(percentiles)) {
|
||||
samples_.resize(kSampleLimit, 0);
|
||||
}
|
||||
|
||||
uint64_t Count() const { return count_.load(std::memory_order_relaxed); }
|
||||
|
||||
@ -104,7 +107,7 @@ class Histogram {
|
||||
percentile_yield.reserve(percentiles_.size());
|
||||
|
||||
for (const auto percentile : percentiles_) {
|
||||
percentile_yield.emplace_back(std::make_pair(percentile, Percentile(percentile)));
|
||||
percentile_yield.emplace_back(percentile, Percentile(percentile));
|
||||
}
|
||||
|
||||
return percentile_yield;
|
||||
|
@ -61,7 +61,7 @@ class BasicException : public std::exception {
|
||||
/**
|
||||
* @brief Virtual destructor to allow for subclassing.
|
||||
*/
|
||||
virtual ~BasicException() {}
|
||||
~BasicException() override = default;
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to the (constant) error description.
|
||||
@ -116,7 +116,7 @@ class StacktraceException : public std::exception {
|
||||
/**
|
||||
* @brief Virtual destructor to allow for subclassing.
|
||||
*/
|
||||
virtual ~StacktraceException() {}
|
||||
~StacktraceException() override = default;
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to the (constant) error description.
|
||||
|
@ -47,17 +47,21 @@ inline void AssertFailed(const char *file_name, int line_num, const char *expr,
|
||||
#define GET_MESSAGE(...) \
|
||||
BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 0), "", fmt::format(__VA_ARGS__))
|
||||
|
||||
#define MG_ASSERT(expr, ...) \
|
||||
if (expr) [[likely]] { \
|
||||
(void)0; \
|
||||
} else { \
|
||||
::memgraph::logging::AssertFailed(__FILE__, __LINE__, #expr, GET_MESSAGE(__VA_ARGS__)); \
|
||||
}
|
||||
#define MG_ASSERT(expr, ...) \
|
||||
do { \
|
||||
if (expr) [[likely]] { \
|
||||
(void)0; \
|
||||
} else { \
|
||||
::memgraph::logging::AssertFailed(__FILE__, __LINE__, #expr, GET_MESSAGE(__VA_ARGS__)); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DMG_ASSERT(expr, ...) MG_ASSERT(expr, __VA_ARGS__)
|
||||
#else
|
||||
#define DMG_ASSERT(...)
|
||||
#define DMG_ASSERT(...) \
|
||||
do { \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
template <typename... Args>
|
||||
@ -75,7 +79,9 @@ void Fatal(const char *msg, const Args &...msg_args) {
|
||||
#ifndef NDEBUG
|
||||
#define DLOG_FATAL(...) LOG_FATAL(__VA_ARGS__)
|
||||
#else
|
||||
#define DLOG_FATAL(...)
|
||||
#define DLOG_FATAL(...) \
|
||||
do { \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
inline void RedirectToStderr() { spdlog::set_default_logger(spdlog::stderr_color_mt("stderr")); }
|
||||
|
@ -24,7 +24,7 @@ namespace memgraph::utils {
|
||||
template <class TKey, class TVal>
|
||||
class LRUCache {
|
||||
public:
|
||||
LRUCache(int cache_size_) : cache_size(cache_size_){};
|
||||
explicit LRUCache(int cache_size_) : cache_size(cache_size_){};
|
||||
|
||||
void put(const TKey &key, const TVal &val) {
|
||||
auto it = item_map.find(key);
|
||||
|
@ -45,7 +45,7 @@ class BadAlloc final : public std::bad_alloc {
|
||||
std::string msg_;
|
||||
|
||||
public:
|
||||
explicit BadAlloc(const std::string &msg) : msg_(msg) {}
|
||||
explicit BadAlloc(std::string msg) : msg_(std::move(msg)) {}
|
||||
|
||||
const char *what() const noexcept override { return msg_.c_str(); }
|
||||
};
|
||||
@ -53,7 +53,7 @@ class BadAlloc final : public std::bad_alloc {
|
||||
/// Abstract class for writing custom memory management, i.e. allocators.
|
||||
class MemoryResource {
|
||||
public:
|
||||
virtual ~MemoryResource() {}
|
||||
virtual ~MemoryResource() = default;
|
||||
|
||||
/// Allocate storage with a size of at least `bytes` bytes.
|
||||
///
|
||||
|
@ -28,7 +28,7 @@ namespace memgraph::utils {
|
||||
*/
|
||||
class Scheduler {
|
||||
public:
|
||||
Scheduler() {}
|
||||
Scheduler() = default;
|
||||
/**
|
||||
* @param pause - Duration between two function executions. If function is
|
||||
* still running when it should be ran again, it will run right after it
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user