Add memgraph namespace
This commit is contained in:
parent
b33d2c3940
commit
12b4ec1589
@ -34,10 +34,8 @@ for file in $modified_files; do
|
|||||||
echo "Running header checker..."
|
echo "Running header checker..."
|
||||||
$project_folder/tools/header-checker.py $tmpdir/$file $file --amend-year
|
$project_folder/tools/header-checker.py $tmpdir/$file $file --amend-year
|
||||||
code=$?
|
code=$?
|
||||||
|
# Do not break header checker
|
||||||
|
|
||||||
if [ $code -ne 0 ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done;
|
done;
|
||||||
|
|
||||||
return $code
|
return $code
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||||
@ -18,6 +18,7 @@
|
|||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace audit {
|
namespace audit {
|
||||||
|
|
||||||
// Helper function that converts a `storage::PropertyValue` to `nlohmann::json`.
|
// Helper function that converts a `storage::PropertyValue` to `nlohmann::json`.
|
||||||
@ -144,3 +145,4 @@ void Log::Flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace audit
|
} // namespace audit
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||||
@ -17,6 +17,7 @@
|
|||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/scheduler.hpp"
|
#include "utils/scheduler.hpp"
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace audit {
|
namespace audit {
|
||||||
|
|
||||||
const uint64_t kBufferSizeDefault = 100000;
|
const uint64_t kBufferSizeDefault = 100000;
|
||||||
@ -72,3 +73,4 @@ class Log {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace audit
|
} // namespace audit
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||||
@ -42,6 +42,7 @@ DEFINE_VALIDATED_int32(auth_module_timeout_ms, 10000,
|
|||||||
"response from the auth module.",
|
"response from the auth module.",
|
||||||
FLAG_IN_RANGE(100, 1800000));
|
FLAG_IN_RANGE(100, 1800000));
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
const std::string kUserPrefix = "user:";
|
const std::string kUserPrefix = "user:";
|
||||||
@ -317,3 +318,4 @@ std::vector<auth::User> Auth::AllUsersForRole(const std::string &rolename_orig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||||
@ -18,6 +18,7 @@
|
|||||||
#include "kvstore/kvstore.hpp"
|
#include "kvstore/kvstore.hpp"
|
||||||
#include "utils/settings.hpp"
|
#include "utils/settings.hpp"
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,3 +165,4 @@ class Auth final {
|
|||||||
auth::Module module_;
|
auth::Module module_;
|
||||||
};
|
};
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "auth/exceptions.hpp"
|
#include "auth/exceptions.hpp"
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
const std::string EncryptPassword(const std::string &password) {
|
const std::string EncryptPassword(const std::string &password) {
|
||||||
@ -41,3 +42,4 @@ bool VerifyPassword(const std::string &password, const std::string &hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
/// @throw AuthException if unable to encrypt the password.
|
/// @throw AuthException if unable to encrypt the password.
|
||||||
@ -19,3 +20,4 @@ const std::string EncryptPassword(const std::string &password);
|
|||||||
bool VerifyPassword(const std::string &password, const std::string &hash);
|
bool VerifyPassword(const std::string &password, const std::string &hash);
|
||||||
|
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,3 +25,4 @@ class AuthException : public utils::BasicException {
|
|||||||
using utils::BasicException::BasicException;
|
using utils::BasicException::BasicException;
|
||||||
};
|
};
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -28,6 +28,7 @@ DEFINE_string(auth_password_strength_regex, default_password_regex.data(),
|
|||||||
"The regular expression that should be used to match the entire "
|
"The regular expression that should be used to match the entire "
|
||||||
"entered password to ensure its strength.");
|
"entered password to ensure its strength.");
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -304,3 +305,4 @@ bool operator==(const User &first, const User &second) {
|
|||||||
first.permissions_ == second.permissions_ && first.role_ == second.role_;
|
first.permissions_ == second.permissions_ && first.role_ == second.role_;
|
||||||
}
|
}
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <json/json.hpp>
|
#include <json/json.hpp>
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
// These permissions must have values that are applicable for usage in a
|
// These permissions must have values that are applicable for usage in a
|
||||||
@ -155,3 +156,4 @@ class User final {
|
|||||||
|
|
||||||
bool operator==(const User &first, const User &second);
|
bool operator==(const User &first, const User &second);
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||||
@ -153,7 +153,7 @@ int Target(void *arg) {
|
|||||||
// process and something really bad could happen.
|
// process and something really bad could happen.
|
||||||
|
|
||||||
// Get a pointer to the passed arguments.
|
// Get a pointer to the passed arguments.
|
||||||
auto *ta = reinterpret_cast<auth::TargetArguments *>(arg);
|
auto *ta = reinterpret_cast<memgraph::auth::TargetArguments *>(arg);
|
||||||
|
|
||||||
// Redirect `stdin` to `/dev/null`.
|
// Redirect `stdin` to `/dev/null`.
|
||||||
int fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
|
int fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
|
||||||
@ -312,6 +312,7 @@ nlohmann::json GetData(int fd, int timeout_millisec) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
Module::Module(const std::filesystem::path &module_executable_path) {
|
Module::Module(const std::filesystem::path &module_executable_path) {
|
||||||
@ -448,3 +449,4 @@ void Module::Shutdown() {
|
|||||||
Module::~Module() { Shutdown(); }
|
Module::~Module() { Shutdown(); }
|
||||||
|
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <json/json.hpp>
|
#include <json/json.hpp>
|
||||||
|
|
||||||
|
namespace memgraph {
|
||||||
namespace auth {
|
namespace auth {
|
||||||
|
|
||||||
struct TargetArguments {
|
struct TargetArguments {
|
||||||
@ -71,3 +72,4 @@ class Module final {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
|
} // namespace memgraph
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -21,7 +21,7 @@
|
|||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/// This exception is thrown whenever an error occurs during query execution
|
/// This exception is thrown whenever an error occurs during query execution
|
||||||
/// that isn't fatal (eg. mistyped query or some transient error occurred).
|
/// that isn't fatal (eg. mistyped query or some transient error occurred).
|
||||||
@ -315,4 +315,4 @@ class Client final {
|
|||||||
ChunkedEncoderBuffer<communication::ClientOutputStream> encoder_buffer_{output_stream_};
|
ChunkedEncoderBuffer<communication::ClientOutputStream> encoder_buffer_{output_stream_};
|
||||||
ClientEncoder<ChunkedEncoderBuffer<communication::ClientOutputStream>> encoder_{encoder_buffer_};
|
ClientEncoder<ChunkedEncoderBuffer<communication::ClientOutputStream>> encoder_{encoder_buffer_};
|
||||||
};
|
};
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
static constexpr uint8_t kPreamble[4] = {0x60, 0x60, 0xB0, 0x17};
|
static constexpr uint8_t kPreamble[4] = {0x60, 0x60, 0xB0, 0x17};
|
||||||
static constexpr uint8_t kProtocol[4] = {0x00, 0x00, 0x00, 0x01};
|
static constexpr uint8_t kProtocol[4] = {0x00, 0x00, 0x00, 0x01};
|
||||||
@ -100,4 +100,4 @@ static constexpr Marker MarkerTiny[3] = {Marker::TinyString, Marker::TinyList, M
|
|||||||
static constexpr Marker Marker8[3] = {Marker::String8, Marker::List8, Marker::Map8};
|
static constexpr Marker Marker8[3] = {Marker::String8, Marker::List8, Marker::Map8};
|
||||||
static constexpr Marker Marker16[3] = {Marker::String16, Marker::List16, Marker::Map16};
|
static constexpr Marker Marker16[3] = {Marker::String16, Marker::List16, Marker::Map16};
|
||||||
static constexpr Marker Marker32[3] = {Marker::String32, Marker::List32, Marker::Map32};
|
static constexpr Marker Marker32[3] = {Marker::String32, Marker::List32, Marker::Map32};
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sizes related to the chunk defined in Bolt protocol.
|
* Sizes related to the chunk defined in Bolt protocol.
|
||||||
@ -32,4 +32,4 @@ static constexpr uint16_t kSupportedVersions[] = {0x0100, 0x0400, 0x0401, 0x0403
|
|||||||
|
|
||||||
static constexpr int kPullAll = -1;
|
static constexpr int kPullAll = -1;
|
||||||
static constexpr int kPullLast = -1;
|
static constexpr int kPullLast = -1;
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "communication/bolt/v1/constants.hpp"
|
#include "communication/bolt/v1/constants.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used as the return value of the GetChunk function of the
|
* This class is used as the return value of the GetChunk function of the
|
||||||
@ -136,4 +136,4 @@ class ChunkedDecoderBuffer {
|
|||||||
std::vector<uint8_t> data_;
|
std::vector<uint8_t> data_;
|
||||||
size_t pos_{0};
|
size_t pos_{0};
|
||||||
};
|
};
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
#include "utils/temporal.hpp"
|
#include "utils/temporal.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bolt Decoder.
|
* Bolt Decoder.
|
||||||
@ -591,4 +591,4 @@ class Decoder {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -22,7 +22,7 @@ static_assert(std::is_same_v<std::uint8_t, char> || std::is_same_v<std::uint8_t,
|
|||||||
"communication::bolt::Encoder requires uint8_t to be "
|
"communication::bolt::Encoder requires uint8_t to be "
|
||||||
"implemented as char or unsigned char.");
|
"implemented as char or unsigned char.");
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bolt BaseEncoder. Has public interfaces for writing Bolt encoded data.
|
* Bolt BaseEncoder. Has public interfaces for writing Bolt encoded data.
|
||||||
@ -273,4 +273,4 @@ class BaseEncoder {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "communication/bolt/v1/constants.hpp"
|
#include "communication/bolt/v1/constants.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ChunkedEncoderBuffer
|
* @brief ChunkedEncoderBuffer
|
||||||
@ -123,4 +123,4 @@ class ChunkedEncoderBuffer {
|
|||||||
// Amount of data in chunk array.
|
// Amount of data in chunk array.
|
||||||
size_t have_{0};
|
size_t have_{0};
|
||||||
};
|
};
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include "communication/bolt/v1/codes.hpp"
|
#include "communication/bolt/v1/codes.hpp"
|
||||||
#include "communication/bolt/v1/encoder/base_encoder.hpp"
|
#include "communication/bolt/v1/encoder/base_encoder.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bolt Client Encoder.
|
* Bolt Client Encoder.
|
||||||
@ -169,4 +169,4 @@ class ClientEncoder : private BaseEncoder<Buffer> {
|
|||||||
return buffer_.Flush();
|
return buffer_.Flush();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include "communication/bolt/v1/codes.hpp"
|
#include "communication/bolt/v1/codes.hpp"
|
||||||
#include "communication/bolt/v1/encoder/base_encoder.hpp"
|
#include "communication/bolt/v1/encoder/base_encoder.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bolt Encoder.
|
* Bolt Encoder.
|
||||||
@ -158,4 +158,4 @@ class Encoder : private BaseEncoder<Buffer> {
|
|||||||
return buffer_.Flush();
|
return buffer_.Flush();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to indicate something is wrong with the client but the transaction is
|
* Used to indicate something is wrong with the client but the transaction is
|
||||||
@ -83,4 +83,4 @@ class VerboseError : public utils::BasicException {
|
|||||||
std::string code_;
|
std::string code_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bolt Session Exception
|
* Bolt Session Exception
|
||||||
@ -195,4 +195,4 @@ class Session {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents states in execution of the Bolt protocol.
|
* This class represents states in execution of the Bolt protocol.
|
||||||
@ -55,4 +55,4 @@ enum class State : uint8_t {
|
|||||||
*/
|
*/
|
||||||
Close
|
Close
|
||||||
};
|
};
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#include "utils/likely.hpp"
|
#include "utils/likely.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error state run function
|
* Error state run function
|
||||||
@ -95,4 +95,4 @@ State StateErrorRun(TSession &session, State state) {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -26,7 +26,7 @@
|
|||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
#include "utils/message.hpp"
|
#include "utils/message.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
template <typename TSession>
|
template <typename TSession>
|
||||||
State RunHandlerV1(Signature signature, TSession &session, State state, Marker marker) {
|
State RunHandlerV1(Signature signature, TSession &session, State state, Marker marker) {
|
||||||
@ -118,4 +118,4 @@ State StateExecutingRun(TSession &session, State state) {
|
|||||||
return State::Close;
|
return State::Close;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -24,7 +24,7 @@
|
|||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
#include "utils/message.hpp"
|
#include "utils/message.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
// TODO: Revise these error messages
|
// TODO: Revise these error messages
|
||||||
inline std::pair<std::string, std::string> ExceptionToErrorMessage(const std::exception &e) {
|
inline std::pair<std::string, std::string> ExceptionToErrorMessage(const std::exception &e) {
|
||||||
if (const auto *verbose = dynamic_cast<const VerboseError *>(&e)) {
|
if (const auto *verbose = dynamic_cast<const VerboseError *>(&e)) {
|
||||||
@ -415,4 +415,4 @@ State HandleRoute(TSession &session) {
|
|||||||
}
|
}
|
||||||
return State::Error;
|
return State::Error;
|
||||||
}
|
}
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#include "utils/likely.hpp"
|
#include "utils/likely.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
inline bool CopyProtocolInformationIfSupported(uint16_t version, uint8_t *protocol) {
|
inline bool CopyProtocolInformationIfSupported(uint16_t version, uint8_t *protocol) {
|
||||||
const auto *supported_version = std::find(std::begin(kSupportedVersions), std::end(kSupportedVersions), version);
|
const auto *supported_version = std::find(std::begin(kSupportedVersions), std::end(kSupportedVersions), version);
|
||||||
@ -110,4 +110,4 @@ State StateHandshakeRun(TSession &session) {
|
|||||||
|
|
||||||
return State::Init;
|
return State::Init;
|
||||||
}
|
}
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -21,7 +21,7 @@
|
|||||||
#include "utils/likely.hpp"
|
#include "utils/likely.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
namespace details {
|
namespace details {
|
||||||
template <typename TSession>
|
template <typename TSession>
|
||||||
@ -212,4 +212,4 @@ State StateInitRun(TSession &session) {
|
|||||||
spdlog::trace("Unsupported bolt version:{}.{})!", session.version_.major, session.version_.minor);
|
spdlog::trace("Unsupported bolt version:{}.{})!", session.version_.major, session.version_.minor);
|
||||||
return State::Close;
|
return State::Close;
|
||||||
}
|
}
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include "utils/algorithm.hpp"
|
#include "utils/algorithm.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
#define DEF_GETTER_BY_VAL(type, value_type, field) \
|
#define DEF_GETTER_BY_VAL(type, value_type, field) \
|
||||||
value_type &Value::Value##type() { \
|
value_type &Value::Value##type() { \
|
||||||
@ -461,4 +461,4 @@ std::ostream &operator<<(std::ostream &os, const Value::Type type) {
|
|||||||
return os << "duration";
|
return os << "duration";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
#include "utils/temporal.hpp"
|
#include "utils/temporal.hpp"
|
||||||
|
|
||||||
namespace communication::bolt {
|
namespace memgraph::communication::bolt {
|
||||||
|
|
||||||
/** Forward declaration of Value class. */
|
/** Forward declaration of Value class. */
|
||||||
class Value;
|
class Value;
|
||||||
@ -282,4 +282,4 @@ std::ostream &operator<<(std::ostream &os, const UnboundedEdge &edge);
|
|||||||
std::ostream &operator<<(std::ostream &os, const Path &path);
|
std::ostream &operator<<(std::ostream &os, const Path &path);
|
||||||
std::ostream &operator<<(std::ostream &os, const Value &value);
|
std::ostream &operator<<(std::ostream &os, const Value &value);
|
||||||
std::ostream &operator<<(std::ostream &os, const Value::Type type);
|
std::ostream &operator<<(std::ostream &os, const Value::Type type);
|
||||||
} // namespace communication::bolt
|
} // namespace memgraph::communication::bolt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
Buffer::Buffer() : data_(kBufferInitialSize, 0), read_end_(this), write_end_(this) {}
|
Buffer::Buffer() : data_(kBufferInitialSize, 0), read_end_(this), write_end_(this) {}
|
||||||
|
|
||||||
@ -77,4 +77,4 @@ void Buffer::Resize(size_t len) {
|
|||||||
|
|
||||||
void Buffer::Clear() { have_ = 0; }
|
void Buffer::Clear() { have_ = 0; }
|
||||||
|
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "io/network/stream_buffer.hpp"
|
#include "io/network/stream_buffer.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Buffer
|
* @brief Buffer
|
||||||
@ -171,4 +171,4 @@ class Buffer final {
|
|||||||
ReadEnd read_end_;
|
ReadEnd read_end_;
|
||||||
WriteEnd write_end_;
|
WriteEnd write_end_;
|
||||||
};
|
};
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include "communication/helpers.hpp"
|
#include "communication/helpers.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
Client::Client(ClientContext *context) : context_(context) {}
|
Client::Client(ClientContext *context) : context_(context) {}
|
||||||
|
|
||||||
@ -239,4 +239,4 @@ bool ClientOutputStream::Write(const uint8_t *data, size_t len, bool have_more)
|
|||||||
}
|
}
|
||||||
bool ClientOutputStream::Write(const std::string &str, bool have_more) { return client_.Write(str, have_more); }
|
bool ClientOutputStream::Write(const std::string &str, bool have_more) { return client_.Write(str, have_more); }
|
||||||
|
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -21,14 +21,14 @@
|
|||||||
#include "io/network/endpoint.hpp"
|
#include "io/network/endpoint.hpp"
|
||||||
#include "io/network/socket.hpp"
|
#include "io/network/socket.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements a generic network Client.
|
* This class implements a generic network Client.
|
||||||
* It uses blocking sockets and provides an API that can be used to receive/send
|
* It uses blocking sockets and provides an API that can be used to receive/send
|
||||||
* data over the network connection.
|
* data over the network connection.
|
||||||
*
|
*
|
||||||
* NOTE: If you use this client you **must** create `communication::SSLInit`
|
* NOTE: If you use this client you **must** create `memgraph::communication::SSLInit`
|
||||||
* from the `main` function before using the client!
|
* from the `main` function before using the client!
|
||||||
*/
|
*/
|
||||||
class Client final {
|
class Client final {
|
||||||
@ -167,4 +167,4 @@ class ClientOutputStream final {
|
|||||||
Client &client_;
|
Client &client_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
ClientContext::ClientContext(bool use_ssl) : use_ssl_(use_ssl), ctx_(nullptr) {
|
ClientContext::ClientContext(bool use_ssl) : use_ssl_(use_ssl), ctx_(nullptr) {
|
||||||
if (use_ssl_) {
|
if (use_ssl_) {
|
||||||
@ -140,4 +140,4 @@ boost::asio::ssl::context &ServerContext::context_clone() {
|
|||||||
|
|
||||||
bool ServerContext::use_ssl() const { return ctx_.has_value(); }
|
bool ServerContext::use_ssl() const { return ctx_.has_value(); }
|
||||||
|
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <boost/asio/ssl/context.hpp>
|
#include <boost/asio/ssl/context.hpp>
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a context that should be used with network clients. One
|
* This class represents a context that should be used with network clients. One
|
||||||
@ -104,4 +104,4 @@ class ServerContext final {
|
|||||||
std::optional<boost::asio::ssl::context> ctx_;
|
std::optional<boost::asio::ssl::context> ctx_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This exception is thrown to indicate to the communication stack that the
|
* This exception is thrown to indicate to the communication stack that the
|
||||||
@ -22,4 +22,4 @@ namespace communication {
|
|||||||
class SessionClosedException : public utils::BasicException {
|
class SessionClosedException : public utils::BasicException {
|
||||||
using utils::BasicException::BasicException;
|
using utils::BasicException::BasicException;
|
||||||
};
|
};
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "communication/helpers.hpp"
|
#include "communication/helpers.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
const std::string SslGetLastError() {
|
const std::string SslGetLastError() {
|
||||||
char buff[2048];
|
char buff[2048];
|
||||||
@ -21,4 +21,4 @@ const std::string SslGetLastError() {
|
|||||||
ERR_error_string_n(err, buff, sizeof(buff));
|
ERR_error_string_n(err, buff, sizeof(buff));
|
||||||
return std::string(buff);
|
return std::string(buff);
|
||||||
}
|
}
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function reads and returns a string describing the last OpenSSL error.
|
* This function reads and returns a string describing the last OpenSSL error.
|
||||||
*/
|
*/
|
||||||
const std::string SslGetLastError();
|
const std::string SslGetLastError();
|
||||||
|
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#include "utils/signals.hpp"
|
#include "utils/signals.hpp"
|
||||||
#include "utils/spin_lock.hpp"
|
#include "utils/spin_lock.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// OpenSSL before 1.1 did not have a out-of-the-box multithreading support
|
// OpenSSL before 1.1 did not have a out-of-the-box multithreading support
|
||||||
@ -72,4 +72,4 @@ SSLInit::SSLInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SSLInit::~SSLInit() { Cleanup(); }
|
SSLInit::~SSLInit() { Cleanup(); }
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create this object in each `main` file that uses the Communication stack. It
|
* Create this object in each `main` file that uses the Communication stack. It
|
||||||
@ -36,4 +36,4 @@ struct SSLInit {
|
|||||||
~SSLInit();
|
~SSLInit();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -28,7 +28,7 @@
|
|||||||
#include "utils/spin_lock.hpp"
|
#include "utils/spin_lock.hpp"
|
||||||
#include "utils/thread.hpp"
|
#include "utils/thread.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class listens to events on an epoll object and processes them.
|
* This class listens to events on an epoll object and processes them.
|
||||||
@ -273,4 +273,4 @@ class Listener final {
|
|||||||
const std::string service_name_;
|
const std::string service_name_;
|
||||||
const size_t workers_count_;
|
const size_t workers_count_;
|
||||||
};
|
};
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -29,7 +29,7 @@
|
|||||||
*/
|
*/
|
||||||
class ResultStreamFaker {
|
class ResultStreamFaker {
|
||||||
public:
|
public:
|
||||||
explicit ResultStreamFaker(storage::Storage *store) : store_(store) {}
|
explicit ResultStreamFaker(memgraph::storage::Storage *store) : store_(store) {}
|
||||||
|
|
||||||
ResultStreamFaker(const ResultStreamFaker &) = delete;
|
ResultStreamFaker(const ResultStreamFaker &) = delete;
|
||||||
ResultStreamFaker &operator=(const ResultStreamFaker &) = delete;
|
ResultStreamFaker &operator=(const ResultStreamFaker &) = delete;
|
||||||
@ -38,25 +38,25 @@ class ResultStreamFaker {
|
|||||||
|
|
||||||
void Header(const std::vector<std::string> &fields) { header_ = fields; }
|
void Header(const std::vector<std::string> &fields) { header_ = fields; }
|
||||||
|
|
||||||
void Result(const std::vector<communication::bolt::Value> &values) { results_.push_back(values); }
|
void Result(const std::vector<memgraph::communication::bolt::Value> &values) { results_.push_back(values); }
|
||||||
|
|
||||||
void Result(const std::vector<query::TypedValue> &values) {
|
void Result(const std::vector<memgraph::query::TypedValue> &values) {
|
||||||
std::vector<communication::bolt::Value> bvalues;
|
std::vector<memgraph::communication::bolt::Value> bvalues;
|
||||||
bvalues.reserve(values.size());
|
bvalues.reserve(values.size());
|
||||||
for (const auto &value : values) {
|
for (const auto &value : values) {
|
||||||
auto maybe_value = glue::ToBoltValue(value, *store_, storage::View::NEW);
|
auto maybe_value = memgraph::glue::ToBoltValue(value, *store_, memgraph::storage::View::NEW);
|
||||||
MG_ASSERT(maybe_value.HasValue());
|
MG_ASSERT(maybe_value.HasValue());
|
||||||
bvalues.push_back(std::move(*maybe_value));
|
bvalues.push_back(std::move(*maybe_value));
|
||||||
}
|
}
|
||||||
results_.push_back(std::move(bvalues));
|
results_.push_back(std::move(bvalues));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Summary(const std::map<std::string, communication::bolt::Value> &summary) { summary_ = summary; }
|
void Summary(const std::map<std::string, memgraph::communication::bolt::Value> &summary) { summary_ = summary; }
|
||||||
|
|
||||||
void Summary(const std::map<std::string, query::TypedValue> &summary) {
|
void Summary(const std::map<std::string, memgraph::query::TypedValue> &summary) {
|
||||||
std::map<std::string, communication::bolt::Value> bsummary;
|
std::map<std::string, memgraph::communication::bolt::Value> bsummary;
|
||||||
for (const auto &item : summary) {
|
for (const auto &item : summary) {
|
||||||
auto maybe_value = glue::ToBoltValue(item.second, *store_, storage::View::NEW);
|
auto maybe_value = memgraph::glue::ToBoltValue(item.second, *store_, memgraph::storage::View::NEW);
|
||||||
MG_ASSERT(maybe_value.HasValue());
|
MG_ASSERT(maybe_value.HasValue());
|
||||||
bsummary.insert({item.first, std::move(*maybe_value)});
|
bsummary.insert({item.first, std::move(*maybe_value)});
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ class ResultStreamFaker {
|
|||||||
|
|
||||||
// output the summary
|
// output the summary
|
||||||
os << "Query summary: {";
|
os << "Query summary: {";
|
||||||
utils::PrintIterable(os, results.GetSummary(), ", ",
|
memgraph::utils::PrintIterable(os, results.GetSummary(), ", ",
|
||||||
[&](auto &stream, const auto &kv) { stream << kv.first << ": " << kv.second; });
|
[&](auto &stream, const auto &kv) { stream << kv.first << ": " << kv.second; });
|
||||||
os << "}" << std::endl;
|
os << "}" << std::endl;
|
||||||
|
|
||||||
@ -127,9 +127,9 @@ class ResultStreamFaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
storage::Storage *store_;
|
memgraph::storage::Storage *store_;
|
||||||
// the data that the record stream can accept
|
// the data that the record stream can accept
|
||||||
std::vector<std::string> header_;
|
std::vector<std::string> header_;
|
||||||
std::vector<std::vector<communication::bolt::Value>> results_;
|
std::vector<std::vector<memgraph::communication::bolt::Value>> results_;
|
||||||
std::map<std::string, communication::bolt::Value> summary_;
|
std::map<std::string, memgraph::communication::bolt::Value> summary_;
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#include "utils/message.hpp"
|
#include "utils/message.hpp"
|
||||||
#include "utils/thread.hpp"
|
#include "utils/thread.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Communication server.
|
* Communication server.
|
||||||
@ -40,7 +40,7 @@ namespace communication {
|
|||||||
* Current Server achitecture:
|
* Current Server achitecture:
|
||||||
* incoming connection -> server -> listener -> session
|
* incoming connection -> server -> listener -> session
|
||||||
*
|
*
|
||||||
* NOTE: If you use this server you **must** create `communication::SSLInit`
|
* NOTE: If you use this server you **must** create `memgraph::communication::SSLInit`
|
||||||
* from the `main` function before using the server!
|
* from the `main` function before using the server!
|
||||||
*
|
*
|
||||||
* @tparam TSession the server can handle different Sessions, each session
|
* @tparam TSession the server can handle different Sessions, each session
|
||||||
@ -161,4 +161,4 @@ class Server final {
|
|||||||
const std::string service_name_;
|
const std::string service_name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -33,7 +33,7 @@
|
|||||||
#include "utils/on_scope_exit.hpp"
|
#include "utils/on_scope_exit.hpp"
|
||||||
#include "utils/spin_lock.hpp"
|
#include "utils/spin_lock.hpp"
|
||||||
|
|
||||||
namespace communication {
|
namespace memgraph::communication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used to provide input to user sessions. All sessions used with the
|
* This is used to provide input to user sessions. All sessions used with the
|
||||||
@ -327,4 +327,4 @@ class Session final {
|
|||||||
SSL *ssl_{nullptr};
|
SSL *ssl_{nullptr};
|
||||||
BIO *bio_{nullptr};
|
BIO *bio_{nullptr};
|
||||||
}; // namespace communication
|
}; // namespace communication
|
||||||
} // namespace communication
|
} // namespace memgraph::communication
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace communication::websocket {
|
namespace memgraph::communication::websocket {
|
||||||
|
|
||||||
bool SafeAuth::Authenticate(const std::string &username, const std::string &password) const {
|
bool SafeAuth::Authenticate(const std::string &username, const std::string &password) const {
|
||||||
return auth_->Lock()->Authenticate(username, password).has_value();
|
return auth_->Lock()->Authenticate(username, password).has_value();
|
||||||
@ -27,4 +27,4 @@ bool SafeAuth::HasUserPermission(const std::string &username, const auth::Permis
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SafeAuth::HasAnyUsers() const { return auth_->ReadLock()->HasUsers(); }
|
bool SafeAuth::HasAnyUsers() const { return auth_->ReadLock()->HasUsers(); }
|
||||||
} // namespace communication::websocket
|
} // namespace memgraph::communication::websocket
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include "utils/spin_lock.hpp"
|
#include "utils/spin_lock.hpp"
|
||||||
#include "utils/synchronized.hpp"
|
#include "utils/synchronized.hpp"
|
||||||
|
|
||||||
namespace communication::websocket {
|
namespace memgraph::communication::websocket {
|
||||||
|
|
||||||
class AuthenticationInterface {
|
class AuthenticationInterface {
|
||||||
public:
|
public:
|
||||||
@ -41,4 +41,4 @@ class SafeAuth : public AuthenticationInterface {
|
|||||||
private:
|
private:
|
||||||
utils::Synchronized<auth::Auth, utils::WritePrioritizedRWLock> *auth_;
|
utils::Synchronized<auth::Auth, utils::WritePrioritizedRWLock> *auth_;
|
||||||
};
|
};
|
||||||
} // namespace communication::websocket
|
} // namespace memgraph::communication::websocket
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "communication/websocket/listener.hpp"
|
#include "communication/websocket/listener.hpp"
|
||||||
|
|
||||||
namespace communication::websocket {
|
namespace memgraph::communication::websocket {
|
||||||
namespace {
|
namespace {
|
||||||
void LogError(boost::beast::error_code ec, const std::string_view what) {
|
void LogError(boost::beast::error_code ec, const std::string_view what) {
|
||||||
spdlog::warn("Websocket listener failed on {}: {}", what, ec.message());
|
spdlog::warn("Websocket listener failed on {}: {}", what, ec.message());
|
||||||
@ -87,4 +87,4 @@ void Listener::OnAccept(boost::beast::error_code ec, tcp::socket socket) {
|
|||||||
|
|
||||||
DoAccept();
|
DoAccept();
|
||||||
}
|
}
|
||||||
} // namespace communication::websocket
|
} // namespace memgraph::communication::websocket
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "utils/spin_lock.hpp"
|
#include "utils/spin_lock.hpp"
|
||||||
#include "utils/synchronized.hpp"
|
#include "utils/synchronized.hpp"
|
||||||
|
|
||||||
namespace communication::websocket {
|
namespace memgraph::communication::websocket {
|
||||||
class Listener : public std::enable_shared_from_this<Listener> {
|
class Listener : public std::enable_shared_from_this<Listener> {
|
||||||
using tcp = boost::asio::ip::tcp;
|
using tcp = boost::asio::ip::tcp;
|
||||||
|
|
||||||
@ -54,4 +54,4 @@ class Listener : public std::enable_shared_from_this<Listener> {
|
|||||||
utils::Synchronized<std::list<std::shared_ptr<Session>>, utils::SpinLock> sessions_;
|
utils::Synchronized<std::list<std::shared_ptr<Session>>, utils::SpinLock> sessions_;
|
||||||
AuthenticationInterface &auth_;
|
AuthenticationInterface &auth_;
|
||||||
};
|
};
|
||||||
} // namespace communication::websocket
|
} // namespace memgraph::communication::websocket
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <spdlog/pattern_formatter.h>
|
#include <spdlog/pattern_formatter.h>
|
||||||
|
|
||||||
namespace communication::websocket {
|
namespace memgraph::communication::websocket {
|
||||||
|
|
||||||
Server::~Server() {
|
Server::~Server() {
|
||||||
MG_ASSERT(!background_thread_ || (ioc_.stopped() && !background_thread_->joinable()),
|
MG_ASSERT(!background_thread_ || (ioc_.stopped() && !background_thread_->joinable()),
|
||||||
@ -81,4 +81,4 @@ std::shared_ptr<Server::LoggingSink> Server::GetLoggingSink() {
|
|||||||
return sink;
|
return sink;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace communication::websocket
|
} // namespace memgraph::communication::websocket
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "communication/websocket/listener.hpp"
|
#include "communication/websocket/listener.hpp"
|
||||||
#include "io/network/endpoint.hpp"
|
#include "io/network/endpoint.hpp"
|
||||||
|
|
||||||
namespace communication::websocket {
|
namespace memgraph::communication::websocket {
|
||||||
|
|
||||||
class Server final {
|
class Server final {
|
||||||
using tcp = boost::asio::ip::tcp;
|
using tcp = boost::asio::ip::tcp;
|
||||||
@ -65,4 +65,4 @@ class Server final {
|
|||||||
std::shared_ptr<Listener> listener_;
|
std::shared_ptr<Listener> listener_;
|
||||||
std::optional<std::thread> background_thread_;
|
std::optional<std::thread> background_thread_;
|
||||||
};
|
};
|
||||||
} // namespace communication::websocket
|
} // namespace memgraph::communication::websocket
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "communication/websocket/auth.hpp"
|
#include "communication/websocket/auth.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace communication::websocket {
|
namespace memgraph::communication::websocket {
|
||||||
namespace {
|
namespace {
|
||||||
void LogError(const boost::beast::error_code ec, const std::string_view what) {
|
void LogError(const boost::beast::error_code ec, const std::string_view what) {
|
||||||
spdlog::warn("Websocket session failed on {}: {}", what, ec.message());
|
spdlog::warn("Websocket session failed on {}: {}", what, ec.message());
|
||||||
@ -232,4 +232,4 @@ void Session::DoShutdown() {
|
|||||||
ws_);
|
ws_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace communication::websocket
|
} // namespace memgraph::communication::websocket
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "utils/synchronized.hpp"
|
#include "utils/synchronized.hpp"
|
||||||
#include "utils/variant_helpers.hpp"
|
#include "utils/variant_helpers.hpp"
|
||||||
|
|
||||||
namespace communication::websocket {
|
namespace memgraph::communication::websocket {
|
||||||
class Session : public std::enable_shared_from_this<Session> {
|
class Session : public std::enable_shared_from_this<Session> {
|
||||||
using tcp = boost::asio::ip::tcp;
|
using tcp = boost::asio::ip::tcp;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class Session : public std::enable_shared_from_this<Session> {
|
|||||||
|
|
||||||
std::variant<PlainWebSocket, SSLWebSocket> CreateWebSocket(tcp::socket &&socket, ServerContext &context);
|
std::variant<PlainWebSocket, SSLWebSocket> CreateWebSocket(tcp::socket &&socket, ServerContext &context);
|
||||||
|
|
||||||
std::optional<boost::asio::ssl::context> ssl_context_;
|
std::optional<std::reference_wrapper<boost::asio::ssl::context>> ssl_context_;
|
||||||
std::variant<PlainWebSocket, SSLWebSocket> ws_;
|
std::variant<PlainWebSocket, SSLWebSocket> ws_;
|
||||||
boost::beast::flat_buffer buffer_;
|
boost::beast::flat_buffer buffer_;
|
||||||
std::deque<std::shared_ptr<std::string>> messages_;
|
std::deque<std::shared_ptr<std::string>> messages_;
|
||||||
@ -88,4 +88,4 @@ class Session : public std::enable_shared_from_this<Session> {
|
|||||||
bool close_{false};
|
bool close_{false};
|
||||||
AuthenticationInterface &auth_;
|
AuthenticationInterface &auth_;
|
||||||
};
|
};
|
||||||
} // namespace communication::websocket
|
} // namespace memgraph::communication::websocket
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -49,7 +49,7 @@ class RingBuffer {
|
|||||||
void emplace(TArgs &&...args) {
|
void emplace(TArgs &&...args) {
|
||||||
while (true) {
|
while (true) {
|
||||||
{
|
{
|
||||||
std::lock_guard<utils::SpinLock> guard(lock_);
|
std::lock_guard<memgraph::utils::SpinLock> guard(lock_);
|
||||||
if (size_ < capacity_) {
|
if (size_ < capacity_) {
|
||||||
buffer_[write_pos_++] = TElement(std::forward<TArgs>(args)...);
|
buffer_[write_pos_++] = TElement(std::forward<TArgs>(args)...);
|
||||||
write_pos_ %= capacity_;
|
write_pos_ %= capacity_;
|
||||||
@ -70,7 +70,7 @@ class RingBuffer {
|
|||||||
* empty, nullopt is returned.
|
* empty, nullopt is returned.
|
||||||
*/
|
*/
|
||||||
std::optional<TElement> pop() {
|
std::optional<TElement> pop() {
|
||||||
std::lock_guard<utils::SpinLock> guard(lock_);
|
std::lock_guard<memgraph::utils::SpinLock> guard(lock_);
|
||||||
if (size_ == 0) return std::nullopt;
|
if (size_ == 0) return std::nullopt;
|
||||||
size_--;
|
size_--;
|
||||||
std::optional<TElement> result(std::move(buffer_[read_pos_++]));
|
std::optional<TElement> result(std::move(buffer_[read_pos_++]));
|
||||||
@ -80,7 +80,7 @@ class RingBuffer {
|
|||||||
|
|
||||||
/** Removes all elements from the buffer. */
|
/** Removes all elements from the buffer. */
|
||||||
void clear() {
|
void clear() {
|
||||||
std::lock_guard<utils::SpinLock> guard(lock_);
|
std::lock_guard<memgraph::utils::SpinLock> guard(lock_);
|
||||||
read_pos_ = 0;
|
read_pos_ = 0;
|
||||||
write_pos_ = 0;
|
write_pos_ = 0;
|
||||||
size_ = 0;
|
size_ = 0;
|
||||||
@ -89,7 +89,7 @@ class RingBuffer {
|
|||||||
private:
|
private:
|
||||||
int capacity_;
|
int capacity_;
|
||||||
std::unique_ptr<TElement[]> buffer_;
|
std::unique_ptr<TElement[]> buffer_;
|
||||||
utils::SpinLock lock_;
|
memgraph::utils::SpinLock lock_;
|
||||||
int read_pos_{0};
|
int read_pos_{0};
|
||||||
int write_pos_{0};
|
int write_pos_{0};
|
||||||
int size_{0};
|
int size_{0};
|
||||||
|
@ -11,52 +11,52 @@
|
|||||||
|
|
||||||
#include "glue/auth.hpp"
|
#include "glue/auth.hpp"
|
||||||
|
|
||||||
namespace glue {
|
namespace memgraph::glue {
|
||||||
|
|
||||||
auth::Permission PrivilegeToPermission(query::AuthQuery::Privilege privilege) {
|
auth::Permission PrivilegeToPermission(memgraph::query::AuthQuery::Privilege privilege) {
|
||||||
switch (privilege) {
|
switch (privilege) {
|
||||||
case query::AuthQuery::Privilege::MATCH:
|
case memgraph::query::AuthQuery::Privilege::MATCH:
|
||||||
return auth::Permission::MATCH;
|
return auth::Permission::MATCH;
|
||||||
case query::AuthQuery::Privilege::CREATE:
|
case memgraph::query::AuthQuery::Privilege::CREATE:
|
||||||
return auth::Permission::CREATE;
|
return auth::Permission::CREATE;
|
||||||
case query::AuthQuery::Privilege::MERGE:
|
case memgraph::query::AuthQuery::Privilege::MERGE:
|
||||||
return auth::Permission::MERGE;
|
return auth::Permission::MERGE;
|
||||||
case query::AuthQuery::Privilege::DELETE:
|
case memgraph::query::AuthQuery::Privilege::DELETE:
|
||||||
return auth::Permission::DELETE;
|
return auth::Permission::DELETE;
|
||||||
case query::AuthQuery::Privilege::SET:
|
case memgraph::query::AuthQuery::Privilege::SET:
|
||||||
return auth::Permission::SET;
|
return auth::Permission::SET;
|
||||||
case query::AuthQuery::Privilege::REMOVE:
|
case memgraph::query::AuthQuery::Privilege::REMOVE:
|
||||||
return auth::Permission::REMOVE;
|
return auth::Permission::REMOVE;
|
||||||
case query::AuthQuery::Privilege::INDEX:
|
case memgraph::query::AuthQuery::Privilege::INDEX:
|
||||||
return auth::Permission::INDEX;
|
return auth::Permission::INDEX;
|
||||||
case query::AuthQuery::Privilege::STATS:
|
case memgraph::query::AuthQuery::Privilege::STATS:
|
||||||
return auth::Permission::STATS;
|
return auth::Permission::STATS;
|
||||||
case query::AuthQuery::Privilege::CONSTRAINT:
|
case memgraph::query::AuthQuery::Privilege::CONSTRAINT:
|
||||||
return auth::Permission::CONSTRAINT;
|
return auth::Permission::CONSTRAINT;
|
||||||
case query::AuthQuery::Privilege::DUMP:
|
case memgraph::query::AuthQuery::Privilege::DUMP:
|
||||||
return auth::Permission::DUMP;
|
return auth::Permission::DUMP;
|
||||||
case query::AuthQuery::Privilege::REPLICATION:
|
case memgraph::query::AuthQuery::Privilege::REPLICATION:
|
||||||
return auth::Permission::REPLICATION;
|
return auth::Permission::REPLICATION;
|
||||||
case query::AuthQuery::Privilege::DURABILITY:
|
case memgraph::query::AuthQuery::Privilege::DURABILITY:
|
||||||
return auth::Permission::DURABILITY;
|
return auth::Permission::DURABILITY;
|
||||||
case query::AuthQuery::Privilege::READ_FILE:
|
case memgraph::query::AuthQuery::Privilege::READ_FILE:
|
||||||
return auth::Permission::READ_FILE;
|
return auth::Permission::READ_FILE;
|
||||||
case query::AuthQuery::Privilege::FREE_MEMORY:
|
case memgraph::query::AuthQuery::Privilege::FREE_MEMORY:
|
||||||
return auth::Permission::FREE_MEMORY;
|
return auth::Permission::FREE_MEMORY;
|
||||||
case query::AuthQuery::Privilege::TRIGGER:
|
case memgraph::query::AuthQuery::Privilege::TRIGGER:
|
||||||
return auth::Permission::TRIGGER;
|
return auth::Permission::TRIGGER;
|
||||||
case query::AuthQuery::Privilege::CONFIG:
|
case memgraph::query::AuthQuery::Privilege::CONFIG:
|
||||||
return auth::Permission::CONFIG;
|
return auth::Permission::CONFIG;
|
||||||
case query::AuthQuery::Privilege::AUTH:
|
case memgraph::query::AuthQuery::Privilege::AUTH:
|
||||||
return auth::Permission::AUTH;
|
return auth::Permission::AUTH;
|
||||||
case query::AuthQuery::Privilege::STREAM:
|
case memgraph::query::AuthQuery::Privilege::STREAM:
|
||||||
return auth::Permission::STREAM;
|
return auth::Permission::STREAM;
|
||||||
case query::AuthQuery::Privilege::MODULE_READ:
|
case memgraph::query::AuthQuery::Privilege::MODULE_READ:
|
||||||
return auth::Permission::MODULE_READ;
|
return auth::Permission::MODULE_READ;
|
||||||
case query::AuthQuery::Privilege::MODULE_WRITE:
|
case memgraph::query::AuthQuery::Privilege::MODULE_WRITE:
|
||||||
return auth::Permission::MODULE_WRITE;
|
return auth::Permission::MODULE_WRITE;
|
||||||
case query::AuthQuery::Privilege::WEBSOCKET:
|
case memgraph::query::AuthQuery::Privilege::WEBSOCKET:
|
||||||
return auth::Permission::WEBSOCKET;
|
return auth::Permission::WEBSOCKET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace glue
|
} // namespace memgraph::glue
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -12,12 +12,12 @@
|
|||||||
#include "auth/models.hpp"
|
#include "auth/models.hpp"
|
||||||
#include "query/frontend/ast/ast.hpp"
|
#include "query/frontend/ast/ast.hpp"
|
||||||
|
|
||||||
namespace glue {
|
namespace memgraph::glue {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function converts query::AuthQuery::Privilege to its corresponding
|
* This function converts memgraph::query::AuthQuery::Privilege to its corresponding
|
||||||
* auth::Permission.
|
* auth::Permission.
|
||||||
*/
|
*/
|
||||||
auth::Permission PrivilegeToPermission(query::AuthQuery::Privilege privilege);
|
auth::Permission PrivilegeToPermission(memgraph::query::AuthQuery::Privilege privilege);
|
||||||
|
|
||||||
} // namespace glue
|
} // namespace memgraph::glue
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -20,32 +20,32 @@
|
|||||||
#include "storage/v2/vertex_accessor.hpp"
|
#include "storage/v2/vertex_accessor.hpp"
|
||||||
#include "utils/temporal.hpp"
|
#include "utils/temporal.hpp"
|
||||||
|
|
||||||
using communication::bolt::Value;
|
using memgraph::communication::bolt::Value;
|
||||||
|
|
||||||
namespace glue {
|
namespace memgraph::glue {
|
||||||
|
|
||||||
query::TypedValue ToTypedValue(const Value &value) {
|
memgraph::query::TypedValue ToTypedValue(const Value &value) {
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
case Value::Type::Null:
|
case Value::Type::Null:
|
||||||
return query::TypedValue();
|
return memgraph::query::TypedValue();
|
||||||
case Value::Type::Bool:
|
case Value::Type::Bool:
|
||||||
return query::TypedValue(value.ValueBool());
|
return memgraph::query::TypedValue(value.ValueBool());
|
||||||
case Value::Type::Int:
|
case Value::Type::Int:
|
||||||
return query::TypedValue(value.ValueInt());
|
return memgraph::query::TypedValue(value.ValueInt());
|
||||||
case Value::Type::Double:
|
case Value::Type::Double:
|
||||||
return query::TypedValue(value.ValueDouble());
|
return memgraph::query::TypedValue(value.ValueDouble());
|
||||||
case Value::Type::String:
|
case Value::Type::String:
|
||||||
return query::TypedValue(value.ValueString());
|
return memgraph::query::TypedValue(value.ValueString());
|
||||||
case Value::Type::List: {
|
case Value::Type::List: {
|
||||||
std::vector<query::TypedValue> list;
|
std::vector<memgraph::query::TypedValue> list;
|
||||||
list.reserve(value.ValueList().size());
|
list.reserve(value.ValueList().size());
|
||||||
for (const auto &v : value.ValueList()) list.push_back(ToTypedValue(v));
|
for (const auto &v : value.ValueList()) list.push_back(ToTypedValue(v));
|
||||||
return query::TypedValue(std::move(list));
|
return memgraph::query::TypedValue(std::move(list));
|
||||||
}
|
}
|
||||||
case Value::Type::Map: {
|
case Value::Type::Map: {
|
||||||
std::map<std::string, query::TypedValue> map;
|
std::map<std::string, memgraph::query::TypedValue> map;
|
||||||
for (const auto &kv : value.ValueMap()) map.emplace(kv.first, ToTypedValue(kv.second));
|
for (const auto &kv : value.ValueMap()) map.emplace(kv.first, ToTypedValue(kv.second));
|
||||||
return query::TypedValue(std::move(map));
|
return memgraph::query::TypedValue(std::move(map));
|
||||||
}
|
}
|
||||||
case Value::Type::Vertex:
|
case Value::Type::Vertex:
|
||||||
case Value::Type::Edge:
|
case Value::Type::Edge:
|
||||||
@ -53,39 +53,40 @@ query::TypedValue ToTypedValue(const Value &value) {
|
|||||||
case Value::Type::Path:
|
case Value::Type::Path:
|
||||||
throw communication::bolt::ValueException("Unsupported conversion from Value to TypedValue");
|
throw communication::bolt::ValueException("Unsupported conversion from Value to TypedValue");
|
||||||
case Value::Type::Date:
|
case Value::Type::Date:
|
||||||
return query::TypedValue(value.ValueDate());
|
return memgraph::query::TypedValue(value.ValueDate());
|
||||||
case Value::Type::LocalTime:
|
case Value::Type::LocalTime:
|
||||||
return query::TypedValue(value.ValueLocalTime());
|
return memgraph::query::TypedValue(value.ValueLocalTime());
|
||||||
case Value::Type::LocalDateTime:
|
case Value::Type::LocalDateTime:
|
||||||
return query::TypedValue(value.ValueLocalDateTime());
|
return memgraph::query::TypedValue(value.ValueLocalDateTime());
|
||||||
case Value::Type::Duration:
|
case Value::Type::Duration:
|
||||||
return query::TypedValue(value.ValueDuration());
|
return memgraph::query::TypedValue(value.ValueDuration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
storage::Result<communication::bolt::Vertex> ToBoltVertex(const query::VertexAccessor &vertex,
|
storage::Result<communication::bolt::Vertex> ToBoltVertex(const memgraph::query::VertexAccessor &vertex,
|
||||||
const storage::Storage &db, storage::View view) {
|
const storage::Storage &db, storage::View view) {
|
||||||
return ToBoltVertex(vertex.impl_, db, view);
|
return ToBoltVertex(vertex.impl_, db, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
storage::Result<communication::bolt::Edge> ToBoltEdge(const query::EdgeAccessor &edge, const storage::Storage &db,
|
storage::Result<communication::bolt::Edge> ToBoltEdge(const memgraph::query::EdgeAccessor &edge,
|
||||||
storage::View view) {
|
const storage::Storage &db, storage::View view) {
|
||||||
return ToBoltEdge(edge.impl_, db, view);
|
return ToBoltEdge(edge.impl_, db, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
storage::Result<Value> ToBoltValue(const query::TypedValue &value, const storage::Storage &db, storage::View view) {
|
storage::Result<Value> ToBoltValue(const memgraph::query::TypedValue &value, const storage::Storage &db,
|
||||||
|
storage::View view) {
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
case query::TypedValue::Type::Null:
|
case memgraph::query::TypedValue::Type::Null:
|
||||||
return Value();
|
return Value();
|
||||||
case query::TypedValue::Type::Bool:
|
case memgraph::query::TypedValue::Type::Bool:
|
||||||
return Value(value.ValueBool());
|
return Value(value.ValueBool());
|
||||||
case query::TypedValue::Type::Int:
|
case memgraph::query::TypedValue::Type::Int:
|
||||||
return Value(value.ValueInt());
|
return Value(value.ValueInt());
|
||||||
case query::TypedValue::Type::Double:
|
case memgraph::query::TypedValue::Type::Double:
|
||||||
return Value(value.ValueDouble());
|
return Value(value.ValueDouble());
|
||||||
case query::TypedValue::Type::String:
|
case memgraph::query::TypedValue::Type::String:
|
||||||
return Value(std::string(value.ValueString()));
|
return Value(std::string(value.ValueString()));
|
||||||
case query::TypedValue::Type::List: {
|
case memgraph::query::TypedValue::Type::List: {
|
||||||
std::vector<Value> values;
|
std::vector<Value> values;
|
||||||
values.reserve(value.ValueList().size());
|
values.reserve(value.ValueList().size());
|
||||||
for (const auto &v : value.ValueList()) {
|
for (const auto &v : value.ValueList()) {
|
||||||
@ -95,7 +96,7 @@ storage::Result<Value> ToBoltValue(const query::TypedValue &value, const storage
|
|||||||
}
|
}
|
||||||
return Value(std::move(values));
|
return Value(std::move(values));
|
||||||
}
|
}
|
||||||
case query::TypedValue::Type::Map: {
|
case memgraph::query::TypedValue::Type::Map: {
|
||||||
std::map<std::string, Value> map;
|
std::map<std::string, Value> map;
|
||||||
for (const auto &kv : value.ValueMap()) {
|
for (const auto &kv : value.ValueMap()) {
|
||||||
auto maybe_value = ToBoltValue(kv.second, db, view);
|
auto maybe_value = ToBoltValue(kv.second, db, view);
|
||||||
@ -104,28 +105,28 @@ storage::Result<Value> ToBoltValue(const query::TypedValue &value, const storage
|
|||||||
}
|
}
|
||||||
return Value(std::move(map));
|
return Value(std::move(map));
|
||||||
}
|
}
|
||||||
case query::TypedValue::Type::Vertex: {
|
case memgraph::query::TypedValue::Type::Vertex: {
|
||||||
auto maybe_vertex = ToBoltVertex(value.ValueVertex(), db, view);
|
auto maybe_vertex = ToBoltVertex(value.ValueVertex(), db, view);
|
||||||
if (maybe_vertex.HasError()) return maybe_vertex.GetError();
|
if (maybe_vertex.HasError()) return maybe_vertex.GetError();
|
||||||
return Value(std::move(*maybe_vertex));
|
return Value(std::move(*maybe_vertex));
|
||||||
}
|
}
|
||||||
case query::TypedValue::Type::Edge: {
|
case memgraph::query::TypedValue::Type::Edge: {
|
||||||
auto maybe_edge = ToBoltEdge(value.ValueEdge(), db, view);
|
auto maybe_edge = ToBoltEdge(value.ValueEdge(), db, view);
|
||||||
if (maybe_edge.HasError()) return maybe_edge.GetError();
|
if (maybe_edge.HasError()) return maybe_edge.GetError();
|
||||||
return Value(std::move(*maybe_edge));
|
return Value(std::move(*maybe_edge));
|
||||||
}
|
}
|
||||||
case query::TypedValue::Type::Path: {
|
case memgraph::query::TypedValue::Type::Path: {
|
||||||
auto maybe_path = ToBoltPath(value.ValuePath(), db, view);
|
auto maybe_path = ToBoltPath(value.ValuePath(), db, view);
|
||||||
if (maybe_path.HasError()) return maybe_path.GetError();
|
if (maybe_path.HasError()) return maybe_path.GetError();
|
||||||
return Value(std::move(*maybe_path));
|
return Value(std::move(*maybe_path));
|
||||||
}
|
}
|
||||||
case query::TypedValue::Type::Date:
|
case memgraph::query::TypedValue::Type::Date:
|
||||||
return Value(value.ValueDate());
|
return Value(value.ValueDate());
|
||||||
case query::TypedValue::Type::LocalTime:
|
case memgraph::query::TypedValue::Type::LocalTime:
|
||||||
return Value(value.ValueLocalTime());
|
return Value(value.ValueLocalTime());
|
||||||
case query::TypedValue::Type::LocalDateTime:
|
case memgraph::query::TypedValue::Type::LocalDateTime:
|
||||||
return Value(value.ValueLocalDateTime());
|
return Value(value.ValueLocalDateTime());
|
||||||
case query::TypedValue::Type::Duration:
|
case memgraph::query::TypedValue::Type::Duration:
|
||||||
return Value(value.ValueDuration());
|
return Value(value.ValueDuration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,7 +165,7 @@ storage::Result<communication::bolt::Edge> ToBoltEdge(const storage::EdgeAccesso
|
|||||||
return communication::bolt::Edge{id, from, to, type, properties};
|
return communication::bolt::Edge{id, from, to, type, properties};
|
||||||
}
|
}
|
||||||
|
|
||||||
storage::Result<communication::bolt::Path> ToBoltPath(const query::Path &path, const storage::Storage &db,
|
storage::Result<communication::bolt::Path> ToBoltPath(const memgraph::query::Path &path, const storage::Storage &db,
|
||||||
storage::View view) {
|
storage::View view) {
|
||||||
std::vector<communication::bolt::Vertex> vertices;
|
std::vector<communication::bolt::Vertex> vertices;
|
||||||
vertices.reserve(path.vertices().size());
|
vertices.reserve(path.vertices().size());
|
||||||
@ -271,4 +272,4 @@ Value ToBoltValue(const storage::PropertyValue &value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glue
|
} // namespace memgraph::glue
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -18,13 +18,13 @@
|
|||||||
#include "storage/v2/result.hpp"
|
#include "storage/v2/result.hpp"
|
||||||
#include "storage/v2/view.hpp"
|
#include "storage/v2/view.hpp"
|
||||||
|
|
||||||
namespace storage {
|
namespace memgraph::storage {
|
||||||
class EdgeAccessor;
|
class EdgeAccessor;
|
||||||
class Storage;
|
class Storage;
|
||||||
class VertexAccessor;
|
class VertexAccessor;
|
||||||
} // namespace storage
|
} // namespace memgraph::storage
|
||||||
|
|
||||||
namespace glue {
|
namespace memgraph::glue {
|
||||||
|
|
||||||
/// @param storage::VertexAccessor for converting to
|
/// @param storage::VertexAccessor for converting to
|
||||||
/// communication::bolt::Vertex.
|
/// communication::bolt::Vertex.
|
||||||
@ -43,26 +43,26 @@ storage::Result<communication::bolt::Vertex> ToBoltVertex(const storage::VertexA
|
|||||||
storage::Result<communication::bolt::Edge> ToBoltEdge(const storage::EdgeAccessor &edge, const storage::Storage &db,
|
storage::Result<communication::bolt::Edge> ToBoltEdge(const storage::EdgeAccessor &edge, const storage::Storage &db,
|
||||||
storage::View view);
|
storage::View view);
|
||||||
|
|
||||||
/// @param query::Path for converting to communication::bolt::Path.
|
/// @param memgraph::query::Path for converting to communication::bolt::Path.
|
||||||
/// @param storage::Storage for ToBoltVertex and ToBoltEdge.
|
/// @param storage::Storage for ToBoltVertex and ToBoltEdge.
|
||||||
/// @param storage::View for ToBoltVertex and ToBoltEdge.
|
/// @param storage::View for ToBoltVertex and ToBoltEdge.
|
||||||
///
|
///
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
storage::Result<communication::bolt::Path> ToBoltPath(const query::Path &path, const storage::Storage &db,
|
storage::Result<communication::bolt::Path> ToBoltPath(const memgraph::query::Path &path, const storage::Storage &db,
|
||||||
storage::View view);
|
storage::View view);
|
||||||
|
|
||||||
/// @param query::TypedValue for converting to communication::bolt::Value.
|
/// @param memgraph::query::TypedValue for converting to communication::bolt::Value.
|
||||||
/// @param storage::Storage for ToBoltVertex and ToBoltEdge.
|
/// @param storage::Storage for ToBoltVertex and ToBoltEdge.
|
||||||
/// @param storage::View for ToBoltVertex and ToBoltEdge.
|
/// @param storage::View for ToBoltVertex and ToBoltEdge.
|
||||||
///
|
///
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
storage::Result<communication::bolt::Value> ToBoltValue(const query::TypedValue &value, const storage::Storage &db,
|
storage::Result<communication::bolt::Value> ToBoltValue(const memgraph::query::TypedValue &value,
|
||||||
storage::View view);
|
const storage::Storage &db, storage::View view);
|
||||||
|
|
||||||
query::TypedValue ToTypedValue(const communication::bolt::Value &value);
|
memgraph::query::TypedValue ToTypedValue(const communication::bolt::Value &value);
|
||||||
|
|
||||||
communication::bolt::Value ToBoltValue(const storage::PropertyValue &value);
|
communication::bolt::Value ToBoltValue(const storage::PropertyValue &value);
|
||||||
|
|
||||||
storage::PropertyValue ToPropertyValue(const communication::bolt::Value &value);
|
storage::PropertyValue ToPropertyValue(const communication::bolt::Value &value);
|
||||||
|
|
||||||
} // namespace glue
|
} // namespace memgraph::glue
|
||||||
|
@ -14,10 +14,12 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace integrations {
|
namespace memgraph::integrations {
|
||||||
|
|
||||||
constexpr int64_t kDefaultCheckBatchLimit{1};
|
constexpr int64_t kDefaultCheckBatchLimit{1};
|
||||||
constexpr std::chrono::milliseconds kDefaultCheckTimeout{30000};
|
constexpr std::chrono::milliseconds kDefaultCheckTimeout{30000};
|
||||||
constexpr std::chrono::milliseconds kMinimumInterval{1};
|
constexpr std::chrono::milliseconds kMinimumInterval{1};
|
||||||
constexpr int64_t kMinimumSize{1};
|
constexpr int64_t kMinimumSize{1};
|
||||||
const std::string kReducted{"<REDUCTED>"};
|
const std::string kReducted{"<REDUCTED>"};
|
||||||
} // namespace integrations
|
|
||||||
|
} // namespace memgraph::integrations
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "utils/on_scope_exit.hpp"
|
#include "utils/on_scope_exit.hpp"
|
||||||
#include "utils/thread.hpp"
|
#include "utils/thread.hpp"
|
||||||
|
|
||||||
namespace integrations::kafka {
|
namespace memgraph::integrations::kafka {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
utils::BasicResult<std::string, std::vector<Message>> GetBatch(RdKafka::KafkaConsumer &consumer,
|
utils::BasicResult<std::string, std::vector<Message>> GetBatch(RdKafka::KafkaConsumer &consumer,
|
||||||
@ -448,4 +448,4 @@ void Consumer::ConsumerRebalanceCb::rebalance_cb(RdKafka::KafkaConsumer *consume
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Consumer::ConsumerRebalanceCb::set_offset(int64_t offset) { offset_ = offset; }
|
void Consumer::ConsumerRebalanceCb::set_offset(int64_t offset) { offset_ = offset; }
|
||||||
} // namespace integrations::kafka
|
} // namespace memgraph::integrations::kafka
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <librdkafka/rdkafkacpp.h>
|
#include <librdkafka/rdkafkacpp.h>
|
||||||
#include "utils/result.hpp"
|
#include "utils/result.hpp"
|
||||||
|
|
||||||
namespace integrations::kafka {
|
namespace memgraph::integrations::kafka {
|
||||||
|
|
||||||
/// Wraps the message returned from librdkafka.
|
/// Wraps the message returned from librdkafka.
|
||||||
///
|
///
|
||||||
@ -183,4 +183,4 @@ class Consumer final : public RdKafka::EventCb {
|
|||||||
std::thread thread_;
|
std::thread thread_;
|
||||||
ConsumerRebalanceCb cb_;
|
ConsumerRebalanceCb cb_;
|
||||||
};
|
};
|
||||||
} // namespace integrations::kafka
|
} // namespace memgraph::integrations::kafka
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
|
|
||||||
namespace integrations::kafka {
|
namespace memgraph::integrations::kafka {
|
||||||
class KafkaStreamException : public utils::BasicException {
|
class KafkaStreamException : public utils::BasicException {
|
||||||
using utils::BasicException::BasicException;
|
using utils::BasicException::BasicException;
|
||||||
};
|
};
|
||||||
@ -64,4 +64,4 @@ class TopicNotFoundException : public KafkaStreamException {
|
|||||||
TopicNotFoundException(const std::string_view consumer_name, const std::string_view topic_name)
|
TopicNotFoundException(const std::string_view consumer_name, const std::string_view topic_name)
|
||||||
: KafkaStreamException("Kafka consumer {} cannot find topic {}", consumer_name, topic_name) {}
|
: KafkaStreamException("Kafka consumer {} cannot find topic {}", consumer_name, topic_name) {}
|
||||||
};
|
};
|
||||||
} // namespace integrations::kafka
|
} // namespace memgraph::integrations::kafka
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -26,7 +26,7 @@
|
|||||||
#include "utils/result.hpp"
|
#include "utils/result.hpp"
|
||||||
#include "utils/thread.hpp"
|
#include "utils/thread.hpp"
|
||||||
|
|
||||||
namespace integrations::pulsar {
|
namespace memgraph::integrations::pulsar {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -284,4 +284,4 @@ void Consumer::StopConsuming() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace integrations::pulsar
|
} // namespace memgraph::integrations::pulsar
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <pulsar/Client.h>
|
#include <pulsar/Client.h>
|
||||||
|
|
||||||
namespace integrations::pulsar {
|
namespace memgraph::integrations::pulsar {
|
||||||
|
|
||||||
namespace pulsar_client = ::pulsar;
|
namespace pulsar_client = ::pulsar;
|
||||||
|
|
||||||
@ -79,4 +79,4 @@ class Consumer final {
|
|||||||
pulsar_client::MessageId last_message_id_{pulsar_client::MessageId::earliest()};
|
pulsar_client::MessageId last_message_id_{pulsar_client::MessageId::earliest()};
|
||||||
std::thread thread_;
|
std::thread thread_;
|
||||||
};
|
};
|
||||||
} // namespace integrations::pulsar
|
} // namespace memgraph::integrations::pulsar
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
|
|
||||||
namespace integrations::pulsar {
|
namespace memgraph::integrations::pulsar {
|
||||||
class PulsarStreamException : public utils::BasicException {
|
class PulsarStreamException : public utils::BasicException {
|
||||||
using utils::BasicException::BasicException;
|
using utils::BasicException::BasicException;
|
||||||
};
|
};
|
||||||
@ -55,4 +55,4 @@ class TopicNotFoundException : public PulsarStreamException {
|
|||||||
TopicNotFoundException(const std::string &consumer_name, const std::string &topic_name)
|
TopicNotFoundException(const std::string &consumer_name, const std::string &topic_name)
|
||||||
: PulsarStreamException("Pulsar consumer {} cannot find topic {}", consumer_name, topic_name) {}
|
: PulsarStreamException("Pulsar consumer {} cannot find topic {}", consumer_name, topic_name) {}
|
||||||
};
|
};
|
||||||
} // namespace integrations::pulsar
|
} // namespace memgraph::integrations::pulsar
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "io/network/network_error.hpp"
|
#include "io/network/network_error.hpp"
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
AddrInfo::AddrInfo(struct addrinfo *info) : info(info) {}
|
AddrInfo::AddrInfo(struct addrinfo *info) : info(info) {}
|
||||||
|
|
||||||
@ -39,4 +39,4 @@ AddrInfo AddrInfo::Get(const char *addr, const char *port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddrInfo::operator struct addrinfo *() { return info; }
|
AddrInfo::operator struct addrinfo *() { return info; }
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class for getaddrinfo.
|
* Wrapper class for getaddrinfo.
|
||||||
@ -30,4 +30,4 @@ class AddrInfo {
|
|||||||
private:
|
private:
|
||||||
struct addrinfo *info;
|
struct addrinfo *info;
|
||||||
};
|
};
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -21,7 +21,7 @@
|
|||||||
#include "utils/message.hpp"
|
#include "utils/message.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
Endpoint::IpFamily Endpoint::GetIpFamily(const std::string &ip_address) {
|
Endpoint::IpFamily Endpoint::GetIpFamily(const std::string &ip_address) {
|
||||||
in_addr addr4;
|
in_addr addr4;
|
||||||
@ -110,4 +110,4 @@ std::ostream &operator<<(std::ostream &os, const Endpoint &endpoint) {
|
|||||||
return os << endpoint.address << ":" << endpoint.port;
|
return os << endpoint.address << ":" << endpoint.port;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -17,7 +17,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a network endpoint that is used in Socket.
|
* This class represents a network endpoint that is used in Socket.
|
||||||
@ -55,4 +55,4 @@ struct Endpoint {
|
|||||||
static IpFamily GetIpFamily(const std::string &ip_address);
|
static IpFamily GetIpFamily(const std::string &ip_address);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -21,7 +21,7 @@
|
|||||||
#include "utils/likely.hpp"
|
#include "utils/likely.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class for epoll.
|
* Wrapper class for epoll.
|
||||||
@ -104,4 +104,4 @@ class Epoll {
|
|||||||
private:
|
private:
|
||||||
const int epoll_fd_;
|
const int epoll_fd_;
|
||||||
};
|
};
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,10 +13,10 @@
|
|||||||
|
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
class NetworkError : public utils::StacktraceException {
|
class NetworkError : public utils::StacktraceException {
|
||||||
public:
|
public:
|
||||||
using utils::StacktraceException::StacktraceException;
|
using utils::StacktraceException::StacktraceException;
|
||||||
};
|
};
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -14,18 +14,18 @@
|
|||||||
#include "io/network/endpoint.hpp"
|
#include "io/network/endpoint.hpp"
|
||||||
#include "slk/serialization.hpp"
|
#include "slk/serialization.hpp"
|
||||||
|
|
||||||
namespace slk {
|
namespace memgraph::slk {
|
||||||
|
|
||||||
inline void Save(const io::network::Endpoint &endpoint, slk::Builder *builder) {
|
inline void Save(const io::network::Endpoint &endpoint, memgraph::slk::Builder *builder) {
|
||||||
slk::Save(endpoint.address_, builder);
|
memgraph::slk::Save(endpoint.address_, builder);
|
||||||
slk::Save(endpoint.port_, builder);
|
memgraph::slk::Save(endpoint.port_, builder);
|
||||||
slk::Save(endpoint.family_, builder);
|
memgraph::slk::Save(endpoint.family_, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Load(io::network::Endpoint *endpoint, slk::Reader *reader) {
|
inline void Load(io::network::Endpoint *endpoint, memgraph::slk::Reader *reader) {
|
||||||
slk::Load(&endpoint->address_, reader);
|
memgraph::slk::Load(&endpoint->address_, reader);
|
||||||
slk::Load(&endpoint->port_, reader);
|
memgraph::slk::Load(&endpoint->port_, reader);
|
||||||
slk::Load(&endpoint->family_, reader);
|
memgraph::slk::Load(&endpoint->family_, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace slk
|
} // namespace memgraph::slk
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -32,7 +32,7 @@
|
|||||||
#include "utils/likely.hpp"
|
#include "utils/likely.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
Socket::Socket(Socket &&other) {
|
Socket::Socket(Socket &&other) {
|
||||||
socket_ = other.socket_;
|
socket_ = other.socket_;
|
||||||
@ -268,4 +268,4 @@ bool Socket::WaitForReadyWrite() {
|
|||||||
return p.revents & POLLOUT;
|
return p.revents & POLLOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "io/network/endpoint.hpp"
|
#include "io/network/endpoint.hpp"
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class creates a network socket.
|
* This class creates a network socket.
|
||||||
@ -206,4 +206,4 @@ class Socket {
|
|||||||
int socket_ = -1;
|
int socket_ = -1;
|
||||||
Endpoint endpoint_;
|
Endpoint endpoint_;
|
||||||
};
|
};
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StreamBuffer
|
* StreamBuffer
|
||||||
@ -25,4 +25,4 @@ struct StreamBuffer {
|
|||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
size_t len;
|
size_t len;
|
||||||
};
|
};
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
/// Resolves hostname to ip, if already an ip, just returns it
|
/// Resolves hostname to ip, if already an ip, just returns it
|
||||||
std::string ResolveHostname(std::string hostname) {
|
std::string ResolveHostname(std::string hostname) {
|
||||||
@ -68,4 +68,4 @@ bool CanEstablishConnection(const io::network::Endpoint &endpoint) {
|
|||||||
return client.Connect(endpoint);
|
return client.Connect(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace io::network
|
}; // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "io/network/endpoint.hpp"
|
#include "io/network/endpoint.hpp"
|
||||||
|
|
||||||
namespace io::network {
|
namespace memgraph::io::network {
|
||||||
|
|
||||||
/// Resolves hostname to ip, if already an ip, just returns it
|
/// Resolves hostname to ip, if already an ip, just returns it
|
||||||
std::string ResolveHostname(std::string hostname);
|
std::string ResolveHostname(std::string hostname);
|
||||||
@ -27,4 +27,4 @@ std::optional<std::string> GetHostname();
|
|||||||
// Try to establish a connection to a remote host
|
// Try to establish a connection to a remote host
|
||||||
bool CanEstablishConnection(const Endpoint &endpoint);
|
bool CanEstablishConnection(const Endpoint &endpoint);
|
||||||
|
|
||||||
} // namespace io::network
|
} // namespace memgraph::io::network
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -15,7 +15,7 @@
|
|||||||
#include "kvstore/kvstore.hpp"
|
#include "kvstore/kvstore.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
namespace kvstore {
|
namespace memgraph::kvstore {
|
||||||
|
|
||||||
struct KVStore::impl {
|
struct KVStore::impl {
|
||||||
std::filesystem::path storage;
|
std::filesystem::path storage;
|
||||||
@ -169,4 +169,4 @@ bool KVStore::CompactRange(const std::string &begin_prefix, const std::string &e
|
|||||||
return s.ok();
|
return s.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace kvstore
|
} // namespace memgraph::kvstore
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
|
|
||||||
namespace kvstore {
|
namespace memgraph::kvstore {
|
||||||
|
|
||||||
class KVStoreError : public utils::BasicException {
|
class KVStoreError : public utils::BasicException {
|
||||||
public:
|
public:
|
||||||
@ -206,4 +206,4 @@ class KVStore final {
|
|||||||
std::unique_ptr<impl> pimpl_;
|
std::unique_ptr<impl> pimpl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace kvstore
|
} // namespace memgraph::kvstore
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace kvstore {
|
namespace memgraph::kvstore {
|
||||||
|
|
||||||
struct KVStore::impl {};
|
struct KVStore::impl {};
|
||||||
|
|
||||||
@ -108,4 +108,4 @@ bool KVStore::CompactRange(const std::string &begin_prefix, const std::string &e
|
|||||||
"dummy kvstore");
|
"dummy kvstore");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace kvstore
|
} // namespace memgraph::kvstore
|
||||||
|
@ -56,7 +56,7 @@ NIL, returns a string."
|
|||||||
(defun type-info-declaration-for-class (cpp-class)
|
(defun type-info-declaration-for-class (cpp-class)
|
||||||
(assert (cpp-type-simple-class-p cpp-class))
|
(assert (cpp-type-simple-class-p cpp-class))
|
||||||
(with-output-to-string (s)
|
(with-output-to-string (s)
|
||||||
(write-line "static const utils::TypeInfo kType;" s)
|
(write-line "static const memgraph::utils::TypeInfo kType;" s)
|
||||||
(let* ((type-info-basep (type-info-opts-base
|
(let* ((type-info-basep (type-info-opts-base
|
||||||
(cpp-class-type-info-opts cpp-class)))
|
(cpp-class-type-info-opts cpp-class)))
|
||||||
(virtual (if (and (or type-info-basep
|
(virtual (if (and (or type-info-basep
|
||||||
@ -68,7 +68,7 @@ NIL, returns a string."
|
|||||||
(cpp-class-super-classes cpp-class))
|
(cpp-class-super-classes cpp-class))
|
||||||
"override"
|
"override"
|
||||||
"")))
|
"")))
|
||||||
(format s "~A const utils::TypeInfo &GetTypeInfo() const ~A { return kType; }"
|
(format s "~A const memgraph::utils::TypeInfo &GetTypeInfo() const ~A { return kType; }"
|
||||||
virtual override))))
|
virtual override))))
|
||||||
|
|
||||||
(defun type-info-definition-for-class (cpp-class)
|
(defun type-info-definition-for-class (cpp-class)
|
||||||
@ -83,7 +83,7 @@ NIL, returns a string."
|
|||||||
(when (> (length super-classes) 1)
|
(when (> (length super-classes) 1)
|
||||||
(error "Unable to generate TypeInfo for class '~A' due to multiple inheritance!"
|
(error "Unable to generate TypeInfo for class '~A' due to multiple inheritance!"
|
||||||
(cpp-type-name cpp-class)))
|
(cpp-type-name cpp-class)))
|
||||||
(format s "const utils::TypeInfo ~A::kType{0x~XULL, \"~A\", ~A};~%"
|
(format s "const memgraph::utils::TypeInfo ~A::kType{0x~XULL, \"~A\", ~A};~%"
|
||||||
(if *generating-cpp-impl-p*
|
(if *generating-cpp-impl-p*
|
||||||
(cpp-type-name cpp-class)
|
(cpp-type-name cpp-class)
|
||||||
;; Use full type declaration if class definition
|
;; Use full type declaration if class definition
|
||||||
@ -344,7 +344,7 @@ LCP-FILE, HPP-FILE, CPP-FILE and SLK-SERIALIZE-P are as in PROCESS-LCP."
|
|||||||
(write-line "// SLK serialization declarations" out)
|
(write-line "// SLK serialization declarations" out)
|
||||||
(write-line "#include \"slk/serialization.hpp\"" out)
|
(write-line "#include \"slk/serialization.hpp\"" out)
|
||||||
(with-namespaced-output (out open-namespace)
|
(with-namespaced-output (out open-namespace)
|
||||||
(open-namespace '("slk"))
|
(open-namespace '("memgraph::slk"))
|
||||||
(dolist (type-for-slk types-for-slk)
|
(dolist (type-for-slk types-for-slk)
|
||||||
(ctypecase type-for-slk
|
(ctypecase type-for-slk
|
||||||
(cpp-class
|
(cpp-class
|
||||||
@ -383,7 +383,7 @@ LCP-FILE, HPP-FILE, CPP-FILE and SLK-SERIALIZE-P are as in PROCESS-LCP."
|
|||||||
(remove-if (complement #'cpp-enum-serializep) *cpp-enums*)))))
|
(remove-if (complement #'cpp-enum-serializep) *cpp-enums*)))))
|
||||||
(write-line "// Autogenerated SLK serialization code" out)
|
(write-line "// Autogenerated SLK serialization code" out)
|
||||||
(with-namespaced-output (out open-namespace)
|
(with-namespaced-output (out open-namespace)
|
||||||
(open-namespace '("slk"))
|
(open-namespace '("memgraph::slk"))
|
||||||
(dolist (cpp-type types-for-slk)
|
(dolist (cpp-type types-for-slk)
|
||||||
(ctypecase cpp-type
|
(ctypecase cpp-type
|
||||||
(cpp-class
|
(cpp-class
|
||||||
|
@ -58,7 +58,7 @@ generation expects the declarations and definitions to be in `slk` namespace."
|
|||||||
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
||||||
(lcp::cpp-type-wrap cpp-class '("const" "&"))))
|
(lcp::cpp-type-wrap cpp-class '("const" "&"))))
|
||||||
(builder-arg (list (lcp::ensure-namestring-for-variable 'builder)
|
(builder-arg (list (lcp::ensure-namestring-for-variable 'builder)
|
||||||
(lcp::ensure-cpp-type "slk::Builder *"))))
|
(lcp::ensure-cpp-type "memgraph::slk::Builder *"))))
|
||||||
(lcp::cpp-function-declaration
|
(lcp::cpp-function-declaration
|
||||||
"Save" :args (list* self-arg builder-arg (save-extra-args cpp-class))
|
"Save" :args (list* self-arg builder-arg (save-extra-args cpp-class))
|
||||||
:type-params (lcp::cpp-type-type-params cpp-class))))
|
:type-params (lcp::cpp-type-type-params cpp-class))))
|
||||||
@ -78,7 +78,7 @@ namespace."
|
|||||||
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
||||||
(lcp::cpp-type-wrap cpp-class '("std::unique_ptr" "*"))))
|
(lcp::cpp-type-wrap cpp-class '("std::unique_ptr" "*"))))
|
||||||
(reader-arg (list (lcp::ensure-namestring-for-variable 'reader)
|
(reader-arg (list (lcp::ensure-namestring-for-variable 'reader)
|
||||||
(lcp::ensure-cpp-type "slk::Reader *"))))
|
(lcp::ensure-cpp-type "memgraph::slk::Reader *"))))
|
||||||
(lcp::cpp-function-declaration
|
(lcp::cpp-function-declaration
|
||||||
"ConstructAndLoad"
|
"ConstructAndLoad"
|
||||||
:args (list* self-arg reader-arg (load-extra-args cpp-class))
|
:args (list* self-arg reader-arg (load-extra-args cpp-class))
|
||||||
@ -97,7 +97,7 @@ generation expects the declarations and definitions to be in `slk` namespace."
|
|||||||
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
||||||
(lcp::cpp-type-wrap cpp-class '("*"))))
|
(lcp::cpp-type-wrap cpp-class '("*"))))
|
||||||
(reader-arg (list (lcp::ensure-namestring-for-variable 'reader)
|
(reader-arg (list (lcp::ensure-namestring-for-variable 'reader)
|
||||||
(lcp::ensure-cpp-type "slk::Reader *"))))
|
(lcp::ensure-cpp-type "memgraph::slk::Reader *"))))
|
||||||
(lcp::cpp-function-declaration
|
(lcp::cpp-function-declaration
|
||||||
"Load" :args (list* self-arg reader-arg (load-extra-args cpp-class))
|
"Load" :args (list* self-arg reader-arg (load-extra-args cpp-class))
|
||||||
:type-params (lcp::cpp-type-type-params cpp-class))))
|
:type-params (lcp::cpp-type-type-params cpp-class))))
|
||||||
@ -125,7 +125,7 @@ serializable member has no public access."
|
|||||||
(lcp::cpp-type-name cpp-class)))
|
(lcp::cpp-type-name cpp-class)))
|
||||||
;; TODO: Extra args for cpp-class members
|
;; TODO: Extra args for cpp-class members
|
||||||
(t
|
(t
|
||||||
(format s "slk::Save(self.~A, builder);~%" member-name)))))))
|
(format s "memgraph::slk::Save(self.~A, builder);~%" member-name)))))))
|
||||||
|
|
||||||
(defun members-for-load (cpp-class)
|
(defun members-for-load (cpp-class)
|
||||||
(remove-if (lambda (m)
|
(remove-if (lambda (m)
|
||||||
@ -155,7 +155,7 @@ serializable member has no public access."
|
|||||||
(lcp::cpp-type-name cpp-class)))
|
(lcp::cpp-type-name cpp-class)))
|
||||||
;; TODO: Extra args for cpp-class members
|
;; TODO: Extra args for cpp-class members
|
||||||
(t
|
(t
|
||||||
(format s "slk::Load(&self->~A, reader);~%" member-name)))))))
|
(format s "memgraph::slk::Load(&self->~A, reader);~%" member-name)))))))
|
||||||
|
|
||||||
(defun save-parents-recursively (cpp-class)
|
(defun save-parents-recursively (cpp-class)
|
||||||
"Generate code for saving members of all parents, recursively. Raise
|
"Generate code for saving members of all parents, recursively. Raise
|
||||||
@ -220,7 +220,7 @@ CPP-CLASS. Raise `SLK-ERROR' if a derived class has template parameters."
|
|||||||
(derived-var (lcp::cpp-name-for-variable (lcp::cpp-type-name subclass)))
|
(derived-var (lcp::cpp-name-for-variable (lcp::cpp-type-name subclass)))
|
||||||
(extra-args (mapcar #'first (save-extra-args cpp-class))))
|
(extra-args (mapcar #'first (save-extra-args cpp-class))))
|
||||||
(format s "if (const auto *~A_derived = utils::Downcast<const ~A>(&self)) {
|
(format s "if (const auto *~A_derived = utils::Downcast<const ~A>(&self)) {
|
||||||
return slk::Save(*~A_derived, builder~{, ~A~}); }~%"
|
return memgraph::slk::Save(*~A_derived, builder~{, ~A~}); }~%"
|
||||||
derived-var derived-class derived-var extra-args))))))
|
derived-var derived-class derived-var extra-args))))))
|
||||||
|
|
||||||
(defun save-function-code-for-class (cpp-class)
|
(defun save-function-code-for-class (cpp-class)
|
||||||
@ -239,14 +239,14 @@ constructs, mostly related to templates."
|
|||||||
(lcp::cpp-type-name cpp-class))
|
(lcp::cpp-type-name cpp-class))
|
||||||
(progn
|
(progn
|
||||||
;; We aren't abstract, so save our data.
|
;; We aren't abstract, so save our data.
|
||||||
(format s "slk::Save(~A::kType.id, builder);~%"
|
(format s "memgraph::slk::Save(~A::kType.id, builder);~%"
|
||||||
(lcp::cpp-type-decl cpp-class))
|
(lcp::cpp-type-decl cpp-class))
|
||||||
(write-string (save-parents-recursively cpp-class) s)
|
(write-string (save-parents-recursively cpp-class) s)
|
||||||
(write-string (save-members cpp-class) s))))
|
(write-string (save-members cpp-class) s))))
|
||||||
(t
|
(t
|
||||||
(when (cpp-class-super-classes-for-slk cpp-class)
|
(when (cpp-class-super-classes-for-slk cpp-class)
|
||||||
;; Write type ID for the (final) derived classes.
|
;; Write type ID for the (final) derived classes.
|
||||||
(format s "slk::Save(~A::kType.id, builder);~%"
|
(format s "memgraph::slk::Save(~A::kType.id, builder);~%"
|
||||||
(lcp::cpp-type-decl cpp-class)))
|
(lcp::cpp-type-decl cpp-class)))
|
||||||
(write-string (save-parents-recursively cpp-class) s)
|
(write-string (save-parents-recursively cpp-class) s)
|
||||||
(write-string (save-members cpp-class) s)))))
|
(write-string (save-members cpp-class) s)))))
|
||||||
@ -268,7 +268,7 @@ constructs, mostly related to templates."
|
|||||||
(append concrete-classes (concrete-subclasses-rec subclass)))))))
|
(append concrete-classes (concrete-subclasses-rec subclass)))))))
|
||||||
(with-output-to-string (s)
|
(with-output-to-string (s)
|
||||||
(write-line "uint64_t type_id;" s)
|
(write-line "uint64_t type_id;" s)
|
||||||
(write-line "slk::Load(&type_id, reader);" s)
|
(write-line "memgraph::slk::Load(&type_id, reader);" s)
|
||||||
(let ((concrete-classes (concrete-subclasses-rec cpp-class)))
|
(let ((concrete-classes (concrete-subclasses-rec cpp-class)))
|
||||||
(unless (lcp::cpp-class-abstractp cpp-class)
|
(unless (lcp::cpp-class-abstractp cpp-class)
|
||||||
(push cpp-class concrete-classes))
|
(push cpp-class concrete-classes))
|
||||||
@ -279,9 +279,9 @@ constructs, mostly related to templates."
|
|||||||
(lcp::with-cpp-block-output
|
(lcp::with-cpp-block-output
|
||||||
(s :name (format nil "if (~A::kType.id == type_id)" type-decl))
|
(s :name (format nil "if (~A::kType.id == type_id)" type-decl))
|
||||||
(format s "auto ~A_instance = std::make_unique<~A>();~%" var-name type-decl)
|
(format s "auto ~A_instance = std::make_unique<~A>();~%" var-name type-decl)
|
||||||
(format s "slk::Load(~A_instance.get(), reader~{, ~A~});~%" var-name extra-args)
|
(format s "memgraph::slk::Load(~A_instance.get(), reader~{, ~A~});~%" var-name extra-args)
|
||||||
(format s "*self = std::move(~A_instance); return;~%" var-name))))
|
(format s "*self = std::move(~A_instance); return;~%" var-name))))
|
||||||
(write-line "throw slk::SlkDecodeException(\"Trying to load unknown derived type!\");" s)))))
|
(write-line "throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\");" s)))))
|
||||||
|
|
||||||
(defun load-function-code-for-class (cpp-class)
|
(defun load-function-code-for-class (cpp-class)
|
||||||
"Generate code for serializing CPP-CLASS. Raise `SLK-ERROR' on unsupported C++
|
"Generate code for serializing CPP-CLASS. Raise `SLK-ERROR' on unsupported C++
|
||||||
@ -296,7 +296,7 @@ constructs, mostly related to templates."
|
|||||||
;; derived ones.
|
;; derived ones.
|
||||||
(when (lcp::cpp-class-direct-subclasses cpp-class)
|
(when (lcp::cpp-class-direct-subclasses cpp-class)
|
||||||
(format s "if (self->GetTypeInfo() != ~A::kType)~%" (lcp::cpp-type-decl cpp-class))
|
(format s "if (self->GetTypeInfo() != ~A::kType)~%" (lcp::cpp-type-decl cpp-class))
|
||||||
(write-line "throw slk::SlkDecodeException(\"Trying to load incorrect derived type!\");" s))
|
(write-line "throw memgraph::slk::SlkDecodeException(\"Trying to load incorrect derived type!\");" s))
|
||||||
(write-string (load-parents-recursively cpp-class) s)
|
(write-string (load-parents-recursively cpp-class) s)
|
||||||
(write-string (load-members cpp-class) s)))
|
(write-string (load-members cpp-class) s)))
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ generation expects the declarations and definitions to be in `slk` namespace."
|
|||||||
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
||||||
(lcp::cpp-type-wrap cpp-enum '("const" "&"))))
|
(lcp::cpp-type-wrap cpp-enum '("const" "&"))))
|
||||||
(builder-arg (list (lcp::ensure-namestring-for-variable 'builder)
|
(builder-arg (list (lcp::ensure-namestring-for-variable 'builder)
|
||||||
(lcp::ensure-cpp-type "slk::Builder *"))))
|
(lcp::ensure-cpp-type "memgraph::slk::Builder *"))))
|
||||||
(lcp::cpp-function-declaration "Save" :args (list self-arg builder-arg))))
|
(lcp::cpp-function-declaration "Save" :args (list self-arg builder-arg))))
|
||||||
|
|
||||||
(defun save-function-code-for-enum (cpp-enum)
|
(defun save-function-code-for-enum (cpp-enum)
|
||||||
@ -354,7 +354,7 @@ generation expects the declarations and definitions to be in `slk` namespace."
|
|||||||
(lcp::cpp-type-decl cpp-enum)
|
(lcp::cpp-type-decl cpp-enum)
|
||||||
enum-value
|
enum-value
|
||||||
enum-ix)))
|
enum-ix)))
|
||||||
(write-line "slk::Save(enum_value, builder);" s)))
|
(write-line "memgraph::slk::Save(enum_value, builder);" s)))
|
||||||
|
|
||||||
(defun save-function-definition-for-enum (cpp-enum)
|
(defun save-function-definition-for-enum (cpp-enum)
|
||||||
"Generate SLK save function. Note that the code generation expects the
|
"Generate SLK save function. Note that the code generation expects the
|
||||||
@ -372,13 +372,13 @@ generation expects the declarations and definitions to be in `slk` namespace."
|
|||||||
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
(let ((self-arg (list (lcp::ensure-namestring-for-variable 'self)
|
||||||
(lcp::cpp-type-wrap cpp-enum '("*"))))
|
(lcp::cpp-type-wrap cpp-enum '("*"))))
|
||||||
(reader-arg (list (lcp::ensure-namestring-for-variable 'reader)
|
(reader-arg (list (lcp::ensure-namestring-for-variable 'reader)
|
||||||
(lcp::ensure-cpp-type "slk::Reader *"))))
|
(lcp::ensure-cpp-type "memgraph::slk::Reader *"))))
|
||||||
(lcp::cpp-function-declaration "Load" :args (list self-arg reader-arg))))
|
(lcp::cpp-function-declaration "Load" :args (list self-arg reader-arg))))
|
||||||
|
|
||||||
(defun load-function-code-for-enum (cpp-enum)
|
(defun load-function-code-for-enum (cpp-enum)
|
||||||
(with-output-to-string (s)
|
(with-output-to-string (s)
|
||||||
(write-line "uint8_t enum_value;" s)
|
(write-line "uint8_t enum_value;" s)
|
||||||
(write-line "slk::Load(&enum_value, reader);" s)
|
(write-line "memgraph::slk::Load(&enum_value, reader);" s)
|
||||||
(lcp::with-cpp-block-output (s :name "switch (enum_value)")
|
(lcp::with-cpp-block-output (s :name "switch (enum_value)")
|
||||||
(loop :for enum-value :in (lcp::cpp-enum-values cpp-enum)
|
(loop :for enum-value :in (lcp::cpp-enum-values cpp-enum)
|
||||||
:and enum-ix :from 0 :do
|
:and enum-ix :from 0 :do
|
||||||
@ -386,7 +386,7 @@ generation expects the declarations and definitions to be in `slk` namespace."
|
|||||||
enum-ix
|
enum-ix
|
||||||
(lcp::cpp-type-decl cpp-enum)
|
(lcp::cpp-type-decl cpp-enum)
|
||||||
enum-value))
|
enum-value))
|
||||||
(write-line "default: throw slk::SlkDecodeException(\"Trying to load unknown enum value!\");" s))))
|
(write-line "default: throw memgraph::slk::SlkDecodeException(\"Trying to load unknown enum value!\");" s))))
|
||||||
|
|
||||||
(defun load-function-definition-for-enum (cpp-enum)
|
(defun load-function-definition-for-enum (cpp-enum)
|
||||||
"Generate SLK save function. Note that the code generation expects the
|
"Generate SLK save function. Note that the code generation expects the
|
||||||
|
@ -197,25 +197,25 @@ CPP-TYPE-DECL."
|
|||||||
(let ((test-struct (lcp:define-struct test-struct ()
|
(let ((test-struct (lcp:define-struct test-struct ()
|
||||||
())))
|
())))
|
||||||
(is-generated (lcp.slk:save-function-declaration-for-class test-struct)
|
(is-generated (lcp.slk:save-function-declaration-for-class test-struct)
|
||||||
"void Save(const TestStruct &self, slk::Builder *builder)")
|
"void Save(const TestStruct &self, memgraph::slk::Builder *builder)")
|
||||||
(is-generated (lcp.slk:load-function-declaration-for-class test-struct)
|
(is-generated (lcp.slk:load-function-declaration-for-class test-struct)
|
||||||
"void Load(TestStruct *self, slk::Reader *reader)"))
|
"void Load(TestStruct *self, memgraph::slk::Reader *reader)"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
(let ((derived (lcp:define-class derived (base)
|
(let ((derived (lcp:define-class derived (base)
|
||||||
())))
|
())))
|
||||||
(is-generated (lcp.slk:save-function-declaration-for-class derived)
|
(is-generated (lcp.slk:save-function-declaration-for-class derived)
|
||||||
"void Save(const Derived &self, slk::Builder *builder)")
|
"void Save(const Derived &self, memgraph::slk::Builder *builder)")
|
||||||
(is-generated (lcp.slk:load-function-declaration-for-class derived)
|
(is-generated (lcp.slk:load-function-declaration-for-class derived)
|
||||||
"void Load(Derived *self, slk::Reader *reader)"))
|
"void Load(Derived *self, memgraph::slk::Reader *reader)"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
(let ((test-struct (lcp:define-struct test-struct ()
|
(let ((test-struct (lcp:define-struct test-struct ()
|
||||||
()
|
()
|
||||||
(:serialize (:slk :save-args '((extra-arg "SaveArgType"))
|
(:serialize (:slk :save-args '((extra-arg "SaveArgType"))
|
||||||
:load-args '((extra-arg "LoadArgType")))))))
|
:load-args '((extra-arg "LoadArgType")))))))
|
||||||
(is-generated (lcp.slk:save-function-declaration-for-class test-struct)
|
(is-generated (lcp.slk:save-function-declaration-for-class test-struct)
|
||||||
"void Save(const TestStruct &self, slk::Builder *builder, SaveArgType extra_arg)")
|
"void Save(const TestStruct &self, memgraph::slk::Builder *builder, SaveArgType extra_arg)")
|
||||||
(is-generated (lcp.slk:load-function-declaration-for-class test-struct)
|
(is-generated (lcp.slk:load-function-declaration-for-class test-struct)
|
||||||
"void Load(TestStruct *self, slk::Reader *reader, LoadArgType extra_arg)"))
|
"void Load(TestStruct *self, memgraph::slk::Reader *reader, LoadArgType extra_arg)"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
(let ((base-class (lcp:define-struct base ()
|
(let ((base-class (lcp:define-struct base ()
|
||||||
()
|
()
|
||||||
@ -225,18 +225,18 @@ CPP-TYPE-DECL."
|
|||||||
())))
|
())))
|
||||||
(declare (ignore base-class))
|
(declare (ignore base-class))
|
||||||
(is-generated (lcp.slk:save-function-declaration-for-class derived-class)
|
(is-generated (lcp.slk:save-function-declaration-for-class derived-class)
|
||||||
"void Save(const Derived &self, slk::Builder *builder, SaveArgType extra_arg)")
|
"void Save(const Derived &self, memgraph::slk::Builder *builder, SaveArgType extra_arg)")
|
||||||
(is-generated (lcp.slk:load-function-declaration-for-class derived-class)
|
(is-generated (lcp.slk:load-function-declaration-for-class derived-class)
|
||||||
"void Load(Derived *self, slk::Reader *reader, LoadArgType extra_arg)")
|
"void Load(Derived *self, memgraph::slk::Reader *reader, LoadArgType extra_arg)")
|
||||||
(is-generated (lcp.slk:construct-and-load-function-declaration-for-class derived-class)
|
(is-generated (lcp.slk:construct-and-load-function-declaration-for-class derived-class)
|
||||||
"void ConstructAndLoad(std::unique_ptr<Derived> *self, slk::Reader *reader, LoadArgType extra_arg)"))
|
"void ConstructAndLoad(std::unique_ptr<Derived> *self, memgraph::slk::Reader *reader, LoadArgType extra_arg)"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
(let ((my-enum (lcp:define-enum my-enum
|
(let ((my-enum (lcp:define-enum my-enum
|
||||||
(first-value second-value))))
|
(first-value second-value))))
|
||||||
(is-generated (lcp.slk:save-function-declaration-for-enum my-enum)
|
(is-generated (lcp.slk:save-function-declaration-for-enum my-enum)
|
||||||
"void Save(const MyEnum &self, slk::Builder *builder)")
|
"void Save(const MyEnum &self, memgraph::slk::Builder *builder)")
|
||||||
(is-generated (lcp.slk:load-function-declaration-for-enum my-enum)
|
(is-generated (lcp.slk:load-function-declaration-for-enum my-enum)
|
||||||
"void Load(MyEnum *self, slk::Reader *reader)"))
|
"void Load(MyEnum *self, memgraph::slk::Reader *reader)"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
;; Unsupported multiple inheritance
|
;; Unsupported multiple inheritance
|
||||||
(is-error (lcp.slk:save-function-declaration-for-class
|
(is-error (lcp.slk:save-function-declaration-for-class
|
||||||
@ -249,7 +249,7 @@ CPP-TYPE-DECL."
|
|||||||
(lcp:define-class derived (fst-base snd-base)
|
(lcp:define-class derived (fst-base snd-base)
|
||||||
()
|
()
|
||||||
(:serialize (:slk :ignore-other-base-classes t))))
|
(:serialize (:slk :ignore-other-base-classes t))))
|
||||||
"void Save(const Derived &self, slk::Builder *builder)")
|
"void Save(const Derived &self, memgraph::slk::Builder *builder)")
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
;; Unsupported class templates
|
;; Unsupported class templates
|
||||||
(is-error (lcp.slk:save-function-declaration-for-class
|
(is-error (lcp.slk:save-function-declaration-for-class
|
||||||
@ -268,22 +268,22 @@ CPP-TYPE-DECL."
|
|||||||
(let ((my-enum (lcp:define-enum my-enum
|
(let ((my-enum (lcp:define-enum my-enum
|
||||||
(first-value second-value))))
|
(first-value second-value))))
|
||||||
(is-generated (lcp.slk:save-function-definition-for-enum my-enum)
|
(is-generated (lcp.slk:save-function-definition-for-enum my-enum)
|
||||||
"void Save(const MyEnum &self, slk::Builder *builder) {
|
"void Save(const MyEnum &self, memgraph::slk::Builder *builder) {
|
||||||
uint8_t enum_value;
|
uint8_t enum_value;
|
||||||
switch (self) {
|
switch (self) {
|
||||||
case MyEnum::FIRST_VALUE: enum_value = 0; break;
|
case MyEnum::FIRST_VALUE: enum_value = 0; break;
|
||||||
case MyEnum::SECOND_VALUE: enum_value = 1; break;
|
case MyEnum::SECOND_VALUE: enum_value = 1; break;
|
||||||
}
|
}
|
||||||
slk::Save(enum_value, builder);
|
memgraph::slk::Save(enum_value, builder);
|
||||||
}")
|
}")
|
||||||
(is-generated (lcp.slk:load-function-definition-for-enum my-enum)
|
(is-generated (lcp.slk:load-function-definition-for-enum my-enum)
|
||||||
"void Load(MyEnum *self, slk::Reader *reader) {
|
"void Load(MyEnum *self, memgraph::slk::Reader *reader) {
|
||||||
uint8_t enum_value;
|
uint8_t enum_value;
|
||||||
slk::Load(&enum_value, reader);
|
memgraph::slk::Load(&enum_value, reader);
|
||||||
switch (enum_value) {
|
switch (enum_value) {
|
||||||
case static_cast<uint8_t>(0): *self = MyEnum::FIRST_VALUE; break;
|
case static_cast<uint8_t>(0): *self = MyEnum::FIRST_VALUE; break;
|
||||||
case static_cast<uint8_t>(1): *self = MyEnum::SECOND_VALUE; break;
|
case static_cast<uint8_t>(1): *self = MyEnum::SECOND_VALUE; break;
|
||||||
default: throw slk::SlkDecodeException(\"Trying to load unknown enum value!\");
|
default: throw memgraph::slk::SlkDecodeException(\"Trying to load unknown enum value!\");
|
||||||
}
|
}
|
||||||
}")))
|
}")))
|
||||||
|
|
||||||
@ -293,22 +293,22 @@ CPP-TYPE-DECL."
|
|||||||
((int-member :int64_t)
|
((int-member :int64_t)
|
||||||
(vec-member "std::vector<SomeType>")))))
|
(vec-member "std::vector<SomeType>")))))
|
||||||
(is-generated (lcp.slk:save-function-definition-for-class test-struct)
|
(is-generated (lcp.slk:save-function-definition-for-class test-struct)
|
||||||
"void Save(const TestStruct &self, slk::Builder *builder) {
|
"void Save(const TestStruct &self, memgraph::slk::Builder *builder) {
|
||||||
slk::Save(self.int_member, builder);
|
memgraph::slk::Save(self.int_member, builder);
|
||||||
slk::Save(self.vec_member, builder);
|
memgraph::slk::Save(self.vec_member, builder);
|
||||||
}")
|
}")
|
||||||
(is-generated (lcp.slk:load-function-definition-for-class test-struct)
|
(is-generated (lcp.slk:load-function-definition-for-class test-struct)
|
||||||
"void Load (TestStruct *self, slk::Reader *reader) {
|
"void Load (TestStruct *self, memgraph::slk::Reader *reader) {
|
||||||
slk::Load(&self->int_member, reader);
|
memgraph::slk::Load(&self->int_member, reader);
|
||||||
slk::Load(&self->vec_member, reader);
|
memgraph::slk::Load(&self->vec_member, reader);
|
||||||
}"))
|
}"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
(let ((test-struct (lcp:define-struct test-struct ()
|
(let ((test-struct (lcp:define-struct test-struct ()
|
||||||
((skip-member :int64_t :dont-save t)))))
|
((skip-member :int64_t :dont-save t)))))
|
||||||
(is-generated (lcp.slk:save-function-definition-for-class test-struct)
|
(is-generated (lcp.slk:save-function-definition-for-class test-struct)
|
||||||
"void Save(const TestStruct &self, slk::Builder *builder) {}")
|
"void Save(const TestStruct &self, memgraph::slk::Builder *builder) {}")
|
||||||
(is-generated (lcp.slk:load-function-definition-for-class test-struct)
|
(is-generated (lcp.slk:load-function-definition-for-class test-struct)
|
||||||
"void Load(TestStruct *self, slk::Reader *reader) {}"))
|
"void Load(TestStruct *self, memgraph::slk::Reader *reader) {}"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
(let ((test-struct
|
(let ((test-struct
|
||||||
(lcp:define-struct test-struct ()
|
(lcp:define-struct test-struct ()
|
||||||
@ -320,11 +320,11 @@ CPP-TYPE-DECL."
|
|||||||
(check-type member-name string)
|
(check-type member-name string)
|
||||||
(format nil "self->~A.CustomLoad(reader);" member-name)))))))
|
(format nil "self->~A.CustomLoad(reader);" member-name)))))))
|
||||||
(is-generated (lcp.slk:save-function-definition-for-class test-struct)
|
(is-generated (lcp.slk:save-function-definition-for-class test-struct)
|
||||||
"void Save(const TestStruct &self, slk::Builder *builder) {
|
"void Save(const TestStruct &self, memgraph::slk::Builder *builder) {
|
||||||
{ self.custom_member.CustomSave(builder); }
|
{ self.custom_member.CustomSave(builder); }
|
||||||
}")
|
}")
|
||||||
(is-generated (lcp.slk:load-function-definition-for-class test-struct)
|
(is-generated (lcp.slk:load-function-definition-for-class test-struct)
|
||||||
"void Load(TestStruct *self, slk::Reader *reader) {
|
"void Load(TestStruct *self, memgraph::slk::Reader *reader) {
|
||||||
{ self->custom_member.CustomLoad(reader); }
|
{ self->custom_member.CustomLoad(reader); }
|
||||||
}"))
|
}"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
@ -360,10 +360,10 @@ CPP-TYPE-DECL."
|
|||||||
:slk-load #'custom-load)))))
|
:slk-load #'custom-load)))))
|
||||||
(dolist (ptr-class (list raw-ptr-class shared-ptr-class unique-ptr-class))
|
(dolist (ptr-class (list raw-ptr-class shared-ptr-class unique-ptr-class))
|
||||||
(is-generated (lcp.slk:save-function-definition-for-class ptr-class)
|
(is-generated (lcp.slk:save-function-definition-for-class ptr-class)
|
||||||
(format nil "void Save(const ~A &self, slk::Builder *builder) { { CustomSave(); } }"
|
(format nil "void Save(const ~A &self, memgraph::slk::Builder *builder) { { CustomSave(); } }"
|
||||||
(lcp::cpp-type-decl ptr-class)))
|
(lcp::cpp-type-decl ptr-class)))
|
||||||
(is-generated (lcp.slk:load-function-definition-for-class ptr-class)
|
(is-generated (lcp.slk:load-function-definition-for-class ptr-class)
|
||||||
(format nil "void Load(~A *self, slk::Reader *reader) { { CustomLoad(); } }"
|
(format nil "void Load(~A *self, memgraph::slk::Reader *reader) { { CustomLoad(); } }"
|
||||||
(lcp::cpp-type-decl ptr-class)))))))
|
(lcp::cpp-type-decl ptr-class)))))))
|
||||||
|
|
||||||
(subtest "class inheritance serialization"
|
(subtest "class inheritance serialization"
|
||||||
@ -378,61 +378,61 @@ CPP-TYPE-DECL."
|
|||||||
;; We will test single inheritance and ignored multiple inheritance, both
|
;; We will test single inheritance and ignored multiple inheritance, both
|
||||||
;; should generate the same code that follows.
|
;; should generate the same code that follows.
|
||||||
(let ((base-save-code
|
(let ((base-save-code
|
||||||
"void Save(const Base &self, slk::Builder *builder) {
|
"void Save(const Base &self, memgraph::slk::Builder *builder) {
|
||||||
if (const auto *derived_derived = utils::Downcast<const Derived>(&self)) {
|
if (const auto *derived_derived = utils::Downcast<const Derived>(&self)) {
|
||||||
return slk::Save(*derived_derived, builder);
|
return memgraph::slk::Save(*derived_derived, builder);
|
||||||
}
|
}
|
||||||
slk::Save(Base::kType.id, builder);
|
memgraph::slk::Save(Base::kType.id, builder);
|
||||||
slk::Save(self.base_member, builder);
|
memgraph::slk::Save(self.base_member, builder);
|
||||||
}")
|
}")
|
||||||
(base-construct-code
|
(base-construct-code
|
||||||
"void ConstructAndLoad(std::unique_ptr<Base> *self, slk::Reader *reader) {
|
"void ConstructAndLoad(std::unique_ptr<Base> *self, memgraph::slk::Reader *reader) {
|
||||||
uint64_t type_id;
|
uint64_t type_id;
|
||||||
slk::Load(&type_id, reader);
|
memgraph::slk::Load(&type_id, reader);
|
||||||
if (Base::kType.id == type_id) {
|
if (Base::kType.id == type_id) {
|
||||||
auto base_instance = std::make_unique<Base>();
|
auto base_instance = std::make_unique<Base>();
|
||||||
slk::Load(base_instance.get(), reader);
|
memgraph::slk::Load(base_instance.get(), reader);
|
||||||
*self = std::move(base_instance);
|
*self = std::move(base_instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Derived::kType.id == type_id) {
|
if (Derived::kType.id == type_id) {
|
||||||
auto derived_instance = std::make_unique<Derived>();
|
auto derived_instance = std::make_unique<Derived>();
|
||||||
slk::Load(derived_instance.get(), reader);
|
memgraph::slk::Load(derived_instance.get(), reader);
|
||||||
*self = std::move(derived_instance);
|
*self = std::move(derived_instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
||||||
}")
|
}")
|
||||||
(base-load-code
|
(base-load-code
|
||||||
"void Load(Base *self, slk::Reader *reader) {
|
"void Load(Base *self, memgraph::slk::Reader *reader) {
|
||||||
if (self->GetTypeInfo() != Base::kType)
|
if (self->GetTypeInfo() != Base::kType)
|
||||||
throw slk::SlkDecodeException(\"Trying to load incorrect derived type!\");
|
throw memgraph::slk::SlkDecodeException(\"Trying to load incorrect derived type!\");
|
||||||
slk::Load(&self->base_member, reader);
|
memgraph::slk::Load(&self->base_member, reader);
|
||||||
}")
|
}")
|
||||||
(derived-save-code
|
(derived-save-code
|
||||||
"void Save(const Derived &self, slk::Builder *builder) {
|
"void Save(const Derived &self, memgraph::slk::Builder *builder) {
|
||||||
slk::Save(Derived::kType.id, builder);
|
memgraph::slk::Save(Derived::kType.id, builder);
|
||||||
// Save parent Base
|
// Save parent Base
|
||||||
{ slk::Save(self.base_member, builder); }
|
{ memgraph::slk::Save(self.base_member, builder); }
|
||||||
slk::Save(self.derived_member, builder);
|
memgraph::slk::Save(self.derived_member, builder);
|
||||||
}")
|
}")
|
||||||
(derived-construct-code
|
(derived-construct-code
|
||||||
"void ConstructAndLoad(std::unique_ptr<Derived> *self, slk::Reader *reader) {
|
"void ConstructAndLoad(std::unique_ptr<Derived> *self, memgraph::slk::Reader *reader) {
|
||||||
uint64_t type_id;
|
uint64_t type_id;
|
||||||
slk::Load(&type_id, reader);
|
memgraph::slk::Load(&type_id, reader);
|
||||||
if (Derived::kType.id == type_id) {
|
if (Derived::kType.id == type_id) {
|
||||||
auto derived_instance = std::make_unique<Derived>();
|
auto derived_instance = std::make_unique<Derived>();
|
||||||
slk::Load(derived_instance.get(), reader);
|
memgraph::slk::Load(derived_instance.get(), reader);
|
||||||
*self = std::move(derived_instance);
|
*self = std::move(derived_instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
||||||
}")
|
}")
|
||||||
(derived-load-code
|
(derived-load-code
|
||||||
"void Load(Derived *self, slk::Reader *reader) {
|
"void Load(Derived *self, memgraph::slk::Reader *reader) {
|
||||||
// Load parent Base
|
// Load parent Base
|
||||||
{ slk::Load(&self->base_member, reader); }
|
{ memgraph::slk::Load(&self->base_member, reader); }
|
||||||
slk::Load(&self->derived_member, reader);
|
memgraph::slk::Load(&self->derived_member, reader);
|
||||||
}"))
|
}"))
|
||||||
;; Single inheritance
|
;; Single inheritance
|
||||||
(let ((base-class (lcp:define-struct base ()
|
(let ((base-class (lcp:define-struct base ()
|
||||||
@ -478,48 +478,48 @@ CPP-TYPE-DECL."
|
|||||||
(derived-class (lcp:define-struct derived (abstract-base)
|
(derived-class (lcp:define-struct derived (abstract-base)
|
||||||
((derived-member :int64_t)))))
|
((derived-member :int64_t)))))
|
||||||
(is-generated (lcp.slk:save-function-definition-for-class abstract-base-class)
|
(is-generated (lcp.slk:save-function-definition-for-class abstract-base-class)
|
||||||
"void Save(const AbstractBase &self, slk::Builder *builder) {
|
"void Save(const AbstractBase &self, memgraph::slk::Builder *builder) {
|
||||||
if (const auto *derived_derived = utils::Downcast<const Derived>(&self)) {
|
if (const auto *derived_derived = utils::Downcast<const Derived>(&self)) {
|
||||||
return slk::Save(*derived_derived, builder);
|
return memgraph::slk::Save(*derived_derived, builder);
|
||||||
}
|
}
|
||||||
LOG(FATAL) << \"`AbstractBase` is marked as an abstract class!\";
|
LOG(FATAL) << \"`AbstractBase` is marked as an abstract class!\";
|
||||||
}")
|
}")
|
||||||
(is-generated (lcp.slk:construct-and-load-function-definition-for-class abstract-base-class)
|
(is-generated (lcp.slk:construct-and-load-function-definition-for-class abstract-base-class)
|
||||||
"void ConstructAndLoad(std::unique_ptr<AbstractBase> *self, slk::Reader *reader) {
|
"void ConstructAndLoad(std::unique_ptr<AbstractBase> *self, memgraph::slk::Reader *reader) {
|
||||||
uint64_t type_id;
|
uint64_t type_id;
|
||||||
slk::Load(&type_id, reader);
|
memgraph::slk::Load(&type_id, reader);
|
||||||
if (Derived::kType.id == type_id) {
|
if (Derived::kType.id == type_id) {
|
||||||
auto derived_instance = std::make_unique<Derived>();
|
auto derived_instance = std::make_unique<Derived>();
|
||||||
slk::Load(derived_instance.get(), reader);
|
memgraph::slk::Load(derived_instance.get(), reader);
|
||||||
*self = std::move(derived_instance);
|
*self = std::move(derived_instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
||||||
}")
|
}")
|
||||||
(is-generated (lcp.slk:save-function-definition-for-class derived-class)
|
(is-generated (lcp.slk:save-function-definition-for-class derived-class)
|
||||||
"void Save(const Derived &self, slk::Builder *builder) {
|
"void Save(const Derived &self, memgraph::slk::Builder *builder) {
|
||||||
slk::Save(Derived::kType.id, builder);
|
memgraph::slk::Save(Derived::kType.id, builder);
|
||||||
// Save parent AbstractBase
|
// Save parent AbstractBase
|
||||||
{ slk::Save(self.base_member, builder); }
|
{ memgraph::slk::Save(self.base_member, builder); }
|
||||||
slk::Save(self.derived_member, builder);
|
memgraph::slk::Save(self.derived_member, builder);
|
||||||
}")
|
}")
|
||||||
(is-generated (lcp.slk:construct-and-load-function-definition-for-class derived-class)
|
(is-generated (lcp.slk:construct-and-load-function-definition-for-class derived-class)
|
||||||
"void ConstructAndLoad(std::unique_ptr<Derived> *self, slk::Reader *reader) {
|
"void ConstructAndLoad(std::unique_ptr<Derived> *self, memgraph::slk::Reader *reader) {
|
||||||
uint64_t type_id;
|
uint64_t type_id;
|
||||||
slk::Load(&type_id, reader);
|
memgraph::slk::Load(&type_id, reader);
|
||||||
if (Derived::kType.id == type_id) {
|
if (Derived::kType.id == type_id) {
|
||||||
auto derived_instance = std::make_unique<Derived>();
|
auto derived_instance = std::make_unique<Derived>();
|
||||||
slk::Load(derived_instance.get(), reader);
|
memgraph::slk::Load(derived_instance.get(), reader);
|
||||||
*self = std::move(derived_instance);
|
*self = std::move(derived_instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
||||||
}")
|
}")
|
||||||
(is-generated (lcp.slk:load-function-definition-for-class derived-class)
|
(is-generated (lcp.slk:load-function-definition-for-class derived-class)
|
||||||
"void Load(Derived *self, slk::Reader *reader) {
|
"void Load(Derived *self, memgraph::slk::Reader *reader) {
|
||||||
// Load parent AbstractBase
|
// Load parent AbstractBase
|
||||||
{ slk::Load(&self->base_member, reader); }
|
{ memgraph::slk::Load(&self->base_member, reader); }
|
||||||
slk::Load(&self->derived_member, reader);
|
memgraph::slk::Load(&self->derived_member, reader);
|
||||||
}"))
|
}"))
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
(let ((base-class-template (lcp:define-struct (base t-param) ()
|
(let ((base-class-template (lcp:define-struct (base t-param) ()
|
||||||
@ -552,9 +552,9 @@ CPP-TYPE-DECL."
|
|||||||
((member :bool))
|
((member :bool))
|
||||||
(:serialize (:slk :base t)))))
|
(:serialize (:slk :base t)))))
|
||||||
(is-generated (lcp.slk:save-function-definition-for-class class)
|
(is-generated (lcp.slk:save-function-definition-for-class class)
|
||||||
"void Save(const Derived &self, slk::Builder *builder) { slk::Save(self.member, builder); }")
|
"void Save(const Derived &self, memgraph::slk::Builder *builder) { memgraph::slk::Save(self.member, builder); }")
|
||||||
(is-generated (lcp.slk:load-function-definition-for-class class)
|
(is-generated (lcp.slk:load-function-definition-for-class class)
|
||||||
"void Load(Derived *self, slk::Reader *reader) { slk::Load(&self->member, reader); }"))
|
"void Load(Derived *self, memgraph::slk::Reader *reader) { memgraph::slk::Load(&self->member, reader); }"))
|
||||||
|
|
||||||
(undefine-cpp-types)
|
(undefine-cpp-types)
|
||||||
(let ((base-class (lcp:define-struct base ()
|
(let ((base-class (lcp:define-struct base ()
|
||||||
@ -566,23 +566,23 @@ CPP-TYPE-DECL."
|
|||||||
())))
|
())))
|
||||||
(declare (ignore derived-class))
|
(declare (ignore derived-class))
|
||||||
(is-generated (lcp.slk:save-function-definition-for-class base-class)
|
(is-generated (lcp.slk:save-function-definition-for-class base-class)
|
||||||
"void Save(const Base &self, slk::Builder *builder, SaveArg extra_arg) {
|
"void Save(const Base &self, memgraph::slk::Builder *builder, SaveArg extra_arg) {
|
||||||
if (const auto *derived_derived = utils::Downcast<const Derived>(&self)) {
|
if (const auto *derived_derived = utils::Downcast<const Derived>(&self)) {
|
||||||
return slk::Save(*derived_derived, builder, extra_arg);
|
return memgraph::slk::Save(*derived_derived, builder, extra_arg);
|
||||||
}
|
}
|
||||||
LOG(FATAL) << \"`Base` is marked as an abstract class!\";
|
LOG(FATAL) << \"`Base` is marked as an abstract class!\";
|
||||||
}")
|
}")
|
||||||
(is-generated (lcp.slk:construct-and-load-function-definition-for-class base-class)
|
(is-generated (lcp.slk:construct-and-load-function-definition-for-class base-class)
|
||||||
"void ConstructAndLoad(std::unique_ptr<Base> *self, slk::Reader *reader, LoadArg extra_arg) {
|
"void ConstructAndLoad(std::unique_ptr<Base> *self, memgraph::slk::Reader *reader, LoadArg extra_arg) {
|
||||||
uint64_t type_id;
|
uint64_t type_id;
|
||||||
slk::Load(&type_id, reader);
|
memgraph::slk::Load(&type_id, reader);
|
||||||
if (Derived::kType.id == type_id) {
|
if (Derived::kType.id == type_id) {
|
||||||
auto derived_instance = std::make_unique<Derived>();
|
auto derived_instance = std::make_unique<Derived>();
|
||||||
slk::Load(derived_instance.get(), reader, extra_arg);
|
memgraph::slk::Load(derived_instance.get(), reader, extra_arg);
|
||||||
*self = std::move(derived_instance);
|
*self = std::move(derived_instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
throw memgraph::slk::SlkDecodeException(\"Trying to load unknown derived type!\");
|
||||||
}")))
|
}")))
|
||||||
|
|
||||||
(subtest "non-public members"
|
(subtest "non-public members"
|
||||||
|
@ -1416,26 +1416,26 @@ structure named by the string NAME."
|
|||||||
(unless (lcp.slk::save-extra-args class)
|
(unless (lcp.slk::save-extra-args class)
|
||||||
(push ,(progn
|
(push ,(progn
|
||||||
#>cpp
|
#>cpp
|
||||||
static void Save(const ${name} &self, slk::Builder *builder);
|
static void Save(const ${name} &self, memgraph::slk::Builder *builder);
|
||||||
cpp<#)
|
cpp<#)
|
||||||
(cpp-class-public class))
|
(cpp-class-public class))
|
||||||
(in-impl
|
(in-impl
|
||||||
,(progn
|
,(progn
|
||||||
#>cpp
|
#>cpp
|
||||||
void ${name}::Save(const ${name} &self, slk::Builder *builder) {
|
void ${name}::Save(const ${name} &self, memgraph::slk::Builder *builder) {
|
||||||
slk::Save(self, builder);
|
memgraph::slk::Save(self, builder);
|
||||||
}
|
}
|
||||||
cpp<#)))
|
cpp<#)))
|
||||||
(unless (lcp.slk::load-extra-args class)
|
(unless (lcp.slk::load-extra-args class)
|
||||||
(push ,(progn #>cpp
|
(push ,(progn #>cpp
|
||||||
static void Load(${name} *self, slk::Reader *reader);
|
static void Load(${name} *self, memgraph::slk::Reader *reader);
|
||||||
cpp<#)
|
cpp<#)
|
||||||
(cpp-class-public class))
|
(cpp-class-public class))
|
||||||
(in-impl
|
(in-impl
|
||||||
,(progn
|
,(progn
|
||||||
#>cpp
|
#>cpp
|
||||||
void ${name}::Load(${name} *self, slk::Reader *reader) {
|
void ${name}::Load(${name} *self, memgraph::slk::Reader *reader) {
|
||||||
slk::Load(self, reader);
|
memgraph::slk::Load(self, reader);
|
||||||
}
|
}
|
||||||
cpp<#)))))
|
cpp<#)))))
|
||||||
|
|
||||||
|
461
src/memgraph.cpp
461
src/memgraph.cpp
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -15,7 +15,7 @@
|
|||||||
#include <jemalloc/jemalloc.h>
|
#include <jemalloc/jemalloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace memory {
|
namespace memgraph::memory {
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||||
#define STRINGIFY_HELPER(x) #x
|
#define STRINGIFY_HELPER(x) #x
|
||||||
@ -30,4 +30,4 @@ void PurgeUnusedMemory() {
|
|||||||
|
|
||||||
#undef STRINGIFY
|
#undef STRINGIFY
|
||||||
#undef STRINGIFY_HELPER
|
#undef STRINGIFY_HELPER
|
||||||
} // namespace memory
|
} // namespace memgraph::memory
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -11,6 +11,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace memory {
|
namespace memgraph::memory {
|
||||||
void PurgeUnusedMemory();
|
void PurgeUnusedMemory();
|
||||||
} // namespace memory
|
} // namespace memgraph::memory
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -92,7 +92,7 @@ void TrackMemory(std::size_t size) {
|
|||||||
size = nallocx(size, 0);
|
size = nallocx(size, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
utils::total_memory_tracker.Alloc(size);
|
memgraph::utils::total_memory_tracker.Alloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackMemory(std::size_t size, const std::align_val_t align) {
|
void TrackMemory(std::size_t size, const std::align_val_t align) {
|
||||||
@ -101,7 +101,7 @@ void TrackMemory(std::size_t size, const std::align_val_t align) {
|
|||||||
size = nallocx(size, MALLOCX_ALIGN(align)); // NOLINT(hicpp-signed-bitwise)
|
size = nallocx(size, MALLOCX_ALIGN(align)); // NOLINT(hicpp-signed-bitwise)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
utils::total_memory_tracker.Alloc(size);
|
memgraph::utils::total_memory_tracker.Alloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrackMemoryNoExcept(const std::size_t size) {
|
bool TrackMemoryNoExcept(const std::size_t size) {
|
||||||
@ -128,14 +128,14 @@ void UntrackMemory([[maybe_unused]] void *ptr, [[maybe_unused]] std::size_t size
|
|||||||
try {
|
try {
|
||||||
#if USE_JEMALLOC
|
#if USE_JEMALLOC
|
||||||
if (ptr != nullptr) [[likely]] {
|
if (ptr != nullptr) [[likely]] {
|
||||||
utils::total_memory_tracker.Free(sallocx(ptr, 0));
|
memgraph::utils::total_memory_tracker.Free(sallocx(ptr, 0));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (size) {
|
if (size) {
|
||||||
utils::total_memory_tracker.Free(size);
|
memgraph::utils::total_memory_tracker.Free(size);
|
||||||
} else {
|
} else {
|
||||||
// Innaccurate because malloc_usable_size() result is greater or equal to allocated size.
|
// Innaccurate because malloc_usable_size() result is greater or equal to allocated size.
|
||||||
utils::total_memory_tracker.Free(malloc_usable_size(ptr));
|
memgraph::utils::total_memory_tracker.Free(malloc_usable_size(ptr));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@ -146,14 +146,14 @@ void UntrackMemory(void *ptr, const std::align_val_t align, [[maybe_unused]] std
|
|||||||
try {
|
try {
|
||||||
#if USE_JEMALLOC
|
#if USE_JEMALLOC
|
||||||
if (ptr != nullptr) [[likely]] {
|
if (ptr != nullptr) [[likely]] {
|
||||||
utils::total_memory_tracker.Free(sallocx(ptr, MALLOCX_ALIGN(align))); // NOLINT(hicpp-signed-bitwise)
|
memgraph::utils::total_memory_tracker.Free(sallocx(ptr, MALLOCX_ALIGN(align))); // NOLINT(hicpp-signed-bitwise)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (size) {
|
if (size) {
|
||||||
utils::total_memory_tracker.Free(size);
|
memgraph::utils::total_memory_tracker.Free(size);
|
||||||
} else {
|
} else {
|
||||||
// Innaccurate because malloc_usable_size() result is greater or equal to allocated size.
|
// Innaccurate because malloc_usable_size() result is greater or equal to allocated size.
|
||||||
utils::total_memory_tracker.Free(malloc_usable_size(ptr));
|
memgraph::utils::total_memory_tracker.Free(malloc_usable_size(ptr));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -41,7 +41,7 @@ bool ValidateControlCharacter(const char *flagname, const std::string &value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ValidateIdTypeOptions(const char *flagname, const std::string &value) {
|
bool ValidateIdTypeOptions(const char *flagname, const std::string &value) {
|
||||||
std::string upper = utils::ToUpperCase(utils::Trim(value));
|
std::string upper = memgraph::utils::ToUpperCase(memgraph::utils::Trim(value));
|
||||||
if (upper != "STRING" && upper != "INTEGER") {
|
if (upper != "STRING" && upper != "INTEGER") {
|
||||||
printf("Valid options for '%s' are: STRING/INTEGER\n", flagname);
|
printf("Valid options for '%s' are: STRING/INTEGER\n", flagname);
|
||||||
return false;
|
return false;
|
||||||
@ -99,9 +99,9 @@ std::vector<std::string> ParseRepeatedFlag(const std::string &flagname, int argc
|
|||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
std::string flag(argv[i]);
|
std::string flag(argv[i]);
|
||||||
int matched_flag_dashes = 0;
|
int matched_flag_dashes = 0;
|
||||||
if (utils::StartsWith(flag, "--" + flagname))
|
if (memgraph::utils::StartsWith(flag, "--" + flagname))
|
||||||
matched_flag_dashes = 2;
|
matched_flag_dashes = 2;
|
||||||
else if (utils::StartsWith(flag, "-" + flagname))
|
else if (memgraph::utils::StartsWith(flag, "-" + flagname))
|
||||||
matched_flag_dashes = 1;
|
matched_flag_dashes = 1;
|
||||||
// Get the value if we matched the flag.
|
// Get the value if we matched the flag.
|
||||||
if (matched_flag_dashes != 0) {
|
if (matched_flag_dashes != 0) {
|
||||||
@ -157,9 +157,9 @@ struct hash<NodeId> {
|
|||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
// Exception used to indicate that something went wrong during data loading.
|
// Exception used to indicate that something went wrong during data loading.
|
||||||
class LoadException : public utils::BasicException {
|
class LoadException : public memgraph::utils::BasicException {
|
||||||
public:
|
public:
|
||||||
using utils::BasicException::BasicException;
|
using memgraph::utils::BasicException::BasicException;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class CsvParserState {
|
enum class CsvParserState {
|
||||||
@ -171,7 +171,7 @@ enum class CsvParserState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool SubstringStartsWith(const std::string_view &str, size_t pos, const std::string_view &what) {
|
bool SubstringStartsWith(const std::string_view &str, size_t pos, const std::string_view &what) {
|
||||||
return utils::StartsWith(utils::Substr(str, pos), what);
|
return memgraph::utils::StartsWith(memgraph::utils::Substr(str, pos), what);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function reads a row from a CSV stream.
|
/// This function reads a row from a CSV stream.
|
||||||
@ -322,7 +322,8 @@ std::pair<std::vector<std::string>, uint64_t> ReadRow(std::istream &stream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FLAGS_trim_strings) {
|
if (FLAGS_trim_strings) {
|
||||||
std::transform(std::begin(row), std::end(row), std::begin(row), [](const auto &item) { return utils::Trim(item); });
|
std::transform(std::begin(row), std::end(row), std::begin(row),
|
||||||
|
[](const auto &item) { return memgraph::utils::Trim(item); });
|
||||||
}
|
}
|
||||||
|
|
||||||
return {std::move(row), lines_count};
|
return {std::move(row), lines_count};
|
||||||
@ -334,7 +335,7 @@ std::pair<std::vector<Field>, uint64_t> ReadHeader(std::istream &stream) {
|
|||||||
std::vector<Field> fields;
|
std::vector<Field> fields;
|
||||||
fields.reserve(row.size());
|
fields.reserve(row.size());
|
||||||
for (const auto &value : row) {
|
for (const auto &value : row) {
|
||||||
auto name_and_type = utils::Split(value, ":");
|
auto name_and_type = memgraph::utils::Split(value, ":");
|
||||||
if (name_and_type.size() != 1U && name_and_type.size() != 2U)
|
if (name_and_type.size() != 1U && name_and_type.size() != 2U)
|
||||||
throw LoadException(
|
throw LoadException(
|
||||||
"Expected a name and optionally a type, got '{}'. Did you specify a "
|
"Expected a name and optionally a type, got '{}'. Did you specify a "
|
||||||
@ -343,7 +344,7 @@ std::pair<std::vector<Field>, uint64_t> ReadHeader(std::istream &stream) {
|
|||||||
auto name = name_and_type[0];
|
auto name = name_and_type[0];
|
||||||
// When type is missing, default is string.
|
// When type is missing, default is string.
|
||||||
std::string type("string");
|
std::string type("string");
|
||||||
if (name_and_type.size() == 2U) type = utils::Trim(name_and_type[1]);
|
if (name_and_type.size() == 2U) type = memgraph::utils::Trim(name_and_type[1]);
|
||||||
fields.push_back(Field{name, type});
|
fields.push_back(Field{name, type});
|
||||||
}
|
}
|
||||||
return {std::move(fields), lines_count};
|
return {std::move(fields), lines_count};
|
||||||
@ -352,7 +353,7 @@ std::pair<std::vector<Field>, uint64_t> ReadHeader(std::istream &stream) {
|
|||||||
/// @throw LoadException
|
/// @throw LoadException
|
||||||
int64_t StringToInt(const std::string &value) {
|
int64_t StringToInt(const std::string &value) {
|
||||||
try {
|
try {
|
||||||
return utils::ParseInt(value);
|
return memgraph::utils::ParseInt(value);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw LoadException("'{}' isn't a valid integer", value);
|
throw LoadException("'{}' isn't a valid integer", value);
|
||||||
}
|
}
|
||||||
@ -361,42 +362,42 @@ int64_t StringToInt(const std::string &value) {
|
|||||||
/// @throw LoadException
|
/// @throw LoadException
|
||||||
double StringToDouble(const std::string &value) {
|
double StringToDouble(const std::string &value) {
|
||||||
try {
|
try {
|
||||||
return utils::ParseDouble(value);
|
return memgraph::utils::ParseDouble(value);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw LoadException("'{}' isn't a valid floating-point value", value);
|
throw LoadException("'{}' isn't a valid floating-point value", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @throw LoadException
|
/// @throw LoadException
|
||||||
storage::PropertyValue StringToValue(const std::string &str, const std::string &type) {
|
memgraph::storage::PropertyValue StringToValue(const std::string &str, const std::string &type) {
|
||||||
if (FLAGS_ignore_empty_strings && str.empty()) return storage::PropertyValue();
|
if (FLAGS_ignore_empty_strings && str.empty()) return memgraph::storage::PropertyValue();
|
||||||
auto convert = [](const auto &str, const auto &type) {
|
auto convert = [](const auto &str, const auto &type) {
|
||||||
if (type == "integer" || type == "int" || type == "long" || type == "byte" || type == "short") {
|
if (type == "integer" || type == "int" || type == "long" || type == "byte" || type == "short") {
|
||||||
return storage::PropertyValue(StringToInt(str));
|
return memgraph::storage::PropertyValue(StringToInt(str));
|
||||||
} else if (type == "float" || type == "double") {
|
} else if (type == "float" || type == "double") {
|
||||||
return storage::PropertyValue(StringToDouble(str));
|
return memgraph::storage::PropertyValue(StringToDouble(str));
|
||||||
} else if (type == "boolean" || type == "bool") {
|
} else if (type == "boolean" || type == "bool") {
|
||||||
if (utils::ToLowerCase(str) == "true") {
|
if (memgraph::utils::ToLowerCase(str) == "true") {
|
||||||
return storage::PropertyValue(true);
|
return memgraph::storage::PropertyValue(true);
|
||||||
} else {
|
} else {
|
||||||
return storage::PropertyValue(false);
|
return memgraph::storage::PropertyValue(false);
|
||||||
}
|
}
|
||||||
} else if (type == "char" || type == "string") {
|
} else if (type == "char" || type == "string") {
|
||||||
return storage::PropertyValue(str);
|
return memgraph::storage::PropertyValue(str);
|
||||||
}
|
}
|
||||||
throw LoadException("Unexpected type: {}", type);
|
throw LoadException("Unexpected type: {}", type);
|
||||||
};
|
};
|
||||||
// Type *not* ending with '[]', signifies regular value.
|
// Type *not* ending with '[]', signifies regular value.
|
||||||
if (!utils::EndsWith(type, "[]")) return convert(str, type);
|
if (!memgraph::utils::EndsWith(type, "[]")) return convert(str, type);
|
||||||
// Otherwise, we have an array type.
|
// Otherwise, we have an array type.
|
||||||
auto elem_type = type.substr(0, type.size() - 2);
|
auto elem_type = type.substr(0, type.size() - 2);
|
||||||
auto elems = utils::Split(str, FLAGS_array_delimiter);
|
auto elems = memgraph::utils::Split(str, FLAGS_array_delimiter);
|
||||||
std::vector<storage::PropertyValue> array;
|
std::vector<memgraph::storage::PropertyValue> array;
|
||||||
array.reserve(elems.size());
|
array.reserve(elems.size());
|
||||||
for (const auto &elem : elems) {
|
for (const auto &elem : elems) {
|
||||||
array.push_back(convert(elem, elem_type));
|
array.push_back(convert(elem, elem_type));
|
||||||
}
|
}
|
||||||
return storage::PropertyValue(std::move(array));
|
return memgraph::storage::PropertyValue(std::move(array));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @throw LoadException
|
/// @throw LoadException
|
||||||
@ -415,16 +416,16 @@ std::string GetIdSpace(const std::string &type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @throw LoadException
|
/// @throw LoadException
|
||||||
void ProcessNodeRow(storage::Storage *store, const std::vector<Field> &fields, const std::vector<std::string> &row,
|
void ProcessNodeRow(memgraph::storage::Storage *store, const std::vector<Field> &fields,
|
||||||
const std::vector<std::string> &additional_labels,
|
const std::vector<std::string> &row, const std::vector<std::string> &additional_labels,
|
||||||
std::unordered_map<NodeId, storage::Gid> *node_id_map) {
|
std::unordered_map<NodeId, memgraph::storage::Gid> *node_id_map) {
|
||||||
std::optional<NodeId> id;
|
std::optional<NodeId> id;
|
||||||
auto acc = store->Access();
|
auto acc = store->Access();
|
||||||
auto node = acc.CreateVertex();
|
auto node = acc.CreateVertex();
|
||||||
for (size_t i = 0; i < row.size(); ++i) {
|
for (size_t i = 0; i < row.size(); ++i) {
|
||||||
const auto &field = fields[i];
|
const auto &field = fields[i];
|
||||||
const auto &value = row[i];
|
const auto &value = row[i];
|
||||||
if (utils::StartsWith(field.type, "ID")) {
|
if (memgraph::utils::StartsWith(field.type, "ID")) {
|
||||||
if (id) throw LoadException("Only one node ID must be specified");
|
if (id) throw LoadException("Only one node ID must be specified");
|
||||||
if (FLAGS_id_type == "INTEGER") {
|
if (FLAGS_id_type == "INTEGER") {
|
||||||
// Call `StringToInt` to verify that the ID is a valid integer.
|
// Call `StringToInt` to verify that the ID is a valid integer.
|
||||||
@ -434,7 +435,8 @@ void ProcessNodeRow(storage::Storage *store, const std::vector<Field> &fields, c
|
|||||||
auto it = node_id_map->find(node_id);
|
auto it = node_id_map->find(node_id);
|
||||||
if (it != node_id_map->end()) {
|
if (it != node_id_map->end()) {
|
||||||
if (FLAGS_skip_duplicate_nodes) {
|
if (FLAGS_skip_duplicate_nodes) {
|
||||||
spdlog::warn(utils::MessageWithLink("Skipping duplicate node with ID '{}'.", node_id, "https://memgr.ph/csv"));
|
spdlog::warn(memgraph::utils::MessageWithLink("Skipping duplicate node with ID '{}'.", node_id,
|
||||||
|
"https://memgr.ph/csv"));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw LoadException("Node with ID '{}' already exists", node_id);
|
throw LoadException("Node with ID '{}' already exists", node_id);
|
||||||
@ -442,11 +444,11 @@ void ProcessNodeRow(storage::Storage *store, const std::vector<Field> &fields, c
|
|||||||
}
|
}
|
||||||
node_id_map->emplace(node_id, node.Gid());
|
node_id_map->emplace(node_id, node.Gid());
|
||||||
if (!field.name.empty()) {
|
if (!field.name.empty()) {
|
||||||
storage::PropertyValue pv_id;
|
memgraph::storage::PropertyValue pv_id;
|
||||||
if (FLAGS_id_type == "INTEGER") {
|
if (FLAGS_id_type == "INTEGER") {
|
||||||
pv_id = storage::PropertyValue(StringToInt(node_id.id));
|
pv_id = memgraph::storage::PropertyValue(StringToInt(node_id.id));
|
||||||
} else {
|
} else {
|
||||||
pv_id = storage::PropertyValue(node_id.id);
|
pv_id = memgraph::storage::PropertyValue(node_id.id);
|
||||||
}
|
}
|
||||||
auto old_node_property = node.SetProperty(acc.NameToProperty(field.name), pv_id);
|
auto old_node_property = node.SetProperty(acc.NameToProperty(field.name), pv_id);
|
||||||
if (!old_node_property.HasValue()) throw LoadException("Couldn't add property '{}' to the node", field.name);
|
if (!old_node_property.HasValue()) throw LoadException("Couldn't add property '{}' to the node", field.name);
|
||||||
@ -454,7 +456,7 @@ void ProcessNodeRow(storage::Storage *store, const std::vector<Field> &fields, c
|
|||||||
}
|
}
|
||||||
id = node_id;
|
id = node_id;
|
||||||
} else if (field.type == "LABEL") {
|
} else if (field.type == "LABEL") {
|
||||||
for (const auto &label : utils::Split(value, FLAGS_array_delimiter)) {
|
for (const auto &label : memgraph::utils::Split(value, FLAGS_array_delimiter)) {
|
||||||
auto node_label = node.AddLabel(acc.NameToLabel(label));
|
auto node_label = node.AddLabel(acc.NameToLabel(label));
|
||||||
if (!node_label.HasValue()) throw LoadException("Couldn't add label '{}' to the node", label);
|
if (!node_label.HasValue()) throw LoadException("Couldn't add label '{}' to the node", label);
|
||||||
if (!*node_label) throw LoadException("The label '{}' already exists", label);
|
if (!*node_label) throw LoadException("The label '{}' already exists", label);
|
||||||
@ -473,8 +475,9 @@ void ProcessNodeRow(storage::Storage *store, const std::vector<Field> &fields, c
|
|||||||
if (acc.Commit().HasError()) throw LoadException("Couldn't store the node");
|
if (acc.Commit().HasError()) throw LoadException("Couldn't store the node");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessNodes(storage::Storage *store, const std::string &nodes_path, std::optional<std::vector<Field>> *header,
|
void ProcessNodes(memgraph::storage::Storage *store, const std::string &nodes_path,
|
||||||
std::unordered_map<NodeId, storage::Gid> *node_id_map,
|
std::optional<std::vector<Field>> *header,
|
||||||
|
std::unordered_map<NodeId, memgraph::storage::Gid> *node_id_map,
|
||||||
const std::vector<std::string> &additional_labels) {
|
const std::vector<std::string> &additional_labels) {
|
||||||
std::ifstream nodes_file(nodes_path);
|
std::ifstream nodes_file(nodes_path);
|
||||||
MG_ASSERT(nodes_file, "Unable to open '{}'", nodes_path);
|
MG_ASSERT(nodes_file, "Unable to open '{}'", nodes_path);
|
||||||
@ -506,16 +509,16 @@ void ProcessNodes(storage::Storage *store, const std::string &nodes_path, std::o
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @throw LoadException
|
/// @throw LoadException
|
||||||
void ProcessRelationshipsRow(storage::Storage *store, const std::vector<Field> &fields,
|
void ProcessRelationshipsRow(memgraph::storage::Storage *store, const std::vector<Field> &fields,
|
||||||
const std::vector<std::string> &row, std::optional<std::string> relationship_type,
|
const std::vector<std::string> &row, std::optional<std::string> relationship_type,
|
||||||
const std::unordered_map<NodeId, storage::Gid> &node_id_map) {
|
const std::unordered_map<NodeId, memgraph::storage::Gid> &node_id_map) {
|
||||||
std::optional<storage::Gid> start_id;
|
std::optional<memgraph::storage::Gid> start_id;
|
||||||
std::optional<storage::Gid> end_id;
|
std::optional<memgraph::storage::Gid> end_id;
|
||||||
std::map<std::string, storage::PropertyValue> properties;
|
std::map<std::string, memgraph::storage::PropertyValue> properties;
|
||||||
for (size_t i = 0; i < row.size(); ++i) {
|
for (size_t i = 0; i < row.size(); ++i) {
|
||||||
const auto &field = fields[i];
|
const auto &field = fields[i];
|
||||||
const auto &value = row[i];
|
const auto &value = row[i];
|
||||||
if (utils::StartsWith(field.type, "START_ID")) {
|
if (memgraph::utils::StartsWith(field.type, "START_ID")) {
|
||||||
if (start_id) throw LoadException("Only one node ID must be specified");
|
if (start_id) throw LoadException("Only one node ID must be specified");
|
||||||
if (FLAGS_id_type == "INTEGER") {
|
if (FLAGS_id_type == "INTEGER") {
|
||||||
// Call `StringToInt` to verify that the START_ID is a valid integer.
|
// Call `StringToInt` to verify that the START_ID is a valid integer.
|
||||||
@ -525,15 +528,15 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector<Field> &
|
|||||||
auto it = node_id_map.find(node_id);
|
auto it = node_id_map.find(node_id);
|
||||||
if (it == node_id_map.end()) {
|
if (it == node_id_map.end()) {
|
||||||
if (FLAGS_skip_bad_relationships) {
|
if (FLAGS_skip_bad_relationships) {
|
||||||
spdlog::warn(
|
spdlog::warn(memgraph::utils::MessageWithLink("Skipping bad relationship with START_ID '{}'.", node_id,
|
||||||
utils::MessageWithLink("Skipping bad relationship with START_ID '{}'.", node_id, "https://memgr.ph/csv"));
|
"https://memgr.ph/csv"));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw LoadException("Node with ID '{}' does not exist", node_id);
|
throw LoadException("Node with ID '{}' does not exist", node_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start_id = it->second;
|
start_id = it->second;
|
||||||
} else if (utils::StartsWith(field.type, "END_ID")) {
|
} else if (memgraph::utils::StartsWith(field.type, "END_ID")) {
|
||||||
if (end_id) throw LoadException("Only one node ID must be specified");
|
if (end_id) throw LoadException("Only one node ID must be specified");
|
||||||
if (FLAGS_id_type == "INTEGER") {
|
if (FLAGS_id_type == "INTEGER") {
|
||||||
// Call `StringToInt` to verify that the END_ID is a valid integer.
|
// Call `StringToInt` to verify that the END_ID is a valid integer.
|
||||||
@ -543,7 +546,8 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector<Field> &
|
|||||||
auto it = node_id_map.find(node_id);
|
auto it = node_id_map.find(node_id);
|
||||||
if (it == node_id_map.end()) {
|
if (it == node_id_map.end()) {
|
||||||
if (FLAGS_skip_bad_relationships) {
|
if (FLAGS_skip_bad_relationships) {
|
||||||
spdlog::warn(utils::MessageWithLink("Skipping bad relationship with END_ID '{}'.", node_id, "https://memgr.ph/csv"));
|
spdlog::warn(memgraph::utils::MessageWithLink("Skipping bad relationship with END_ID '{}'.", node_id,
|
||||||
|
"https://memgr.ph/csv"));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw LoadException("Node with ID '{}' does not exist", node_id);
|
throw LoadException("Node with ID '{}' does not exist", node_id);
|
||||||
@ -563,9 +567,9 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector<Field> &
|
|||||||
if (!relationship_type) throw LoadException("Relationship TYPE must be set");
|
if (!relationship_type) throw LoadException("Relationship TYPE must be set");
|
||||||
|
|
||||||
auto acc = store->Access();
|
auto acc = store->Access();
|
||||||
auto from_node = acc.FindVertex(*start_id, storage::View::NEW);
|
auto from_node = acc.FindVertex(*start_id, memgraph::storage::View::NEW);
|
||||||
if (!from_node) throw LoadException("From node must be in the storage");
|
if (!from_node) throw LoadException("From node must be in the storage");
|
||||||
auto to_node = acc.FindVertex(*end_id, storage::View::NEW);
|
auto to_node = acc.FindVertex(*end_id, memgraph::storage::View::NEW);
|
||||||
if (!to_node) throw LoadException("To node must be in the storage");
|
if (!to_node) throw LoadException("To node must be in the storage");
|
||||||
|
|
||||||
auto relationship = acc.CreateEdge(&*from_node, &*to_node, acc.NameToEdgeType(*relationship_type));
|
auto relationship = acc.CreateEdge(&*from_node, &*to_node, acc.NameToEdgeType(*relationship_type));
|
||||||
@ -574,7 +578,7 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector<Field> &
|
|||||||
for (const auto &property : properties) {
|
for (const auto &property : properties) {
|
||||||
auto ret = relationship->SetProperty(acc.NameToProperty(property.first), property.second);
|
auto ret = relationship->SetProperty(acc.NameToProperty(property.first), property.second);
|
||||||
if (!ret.HasValue()) {
|
if (!ret.HasValue()) {
|
||||||
if (ret.GetError() != storage::Error::PROPERTIES_DISABLED) {
|
if (ret.GetError() != memgraph::storage::Error::PROPERTIES_DISABLED) {
|
||||||
throw LoadException("Couldn't add property '{}' to the relationship", property.first);
|
throw LoadException("Couldn't add property '{}' to the relationship", property.first);
|
||||||
} else {
|
} else {
|
||||||
throw LoadException(
|
throw LoadException(
|
||||||
@ -588,10 +592,10 @@ void ProcessRelationshipsRow(storage::Storage *store, const std::vector<Field> &
|
|||||||
if (acc.Commit().HasError()) throw LoadException("Couldn't store the relationship");
|
if (acc.Commit().HasError()) throw LoadException("Couldn't store the relationship");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessRelationships(storage::Storage *store, const std::string &relationships_path,
|
void ProcessRelationships(memgraph::storage::Storage *store, const std::string &relationships_path,
|
||||||
const std::optional<std::string> &relationship_type,
|
const std::optional<std::string> &relationship_type,
|
||||||
std::optional<std::vector<Field>> *header,
|
std::optional<std::vector<Field>> *header,
|
||||||
const std::unordered_map<NodeId, storage::Gid> &node_id_map) {
|
const std::unordered_map<NodeId, memgraph::storage::Gid> &node_id_map) {
|
||||||
std::ifstream relationships_file(relationships_path);
|
std::ifstream relationships_file(relationships_path);
|
||||||
MG_ASSERT(relationships_file, "Unable to open '{}'", relationships_path);
|
MG_ASSERT(relationships_file, "Unable to open '{}'", relationships_path);
|
||||||
uint64_t row_number = 1;
|
uint64_t row_number = 1;
|
||||||
@ -639,11 +643,11 @@ NodesArgument ParseNodesArgument(const std::string &value) {
|
|||||||
auto pos_equal = value.find('=');
|
auto pos_equal = value.find('=');
|
||||||
if (pos_equal != std::string::npos) {
|
if (pos_equal != std::string::npos) {
|
||||||
// We have additional labels.
|
// We have additional labels.
|
||||||
additional_labels = utils::Split(value.substr(0, pos_equal), ":");
|
additional_labels = memgraph::utils::Split(value.substr(0, pos_equal), ":");
|
||||||
pos_nodes = pos_equal + 1;
|
pos_nodes = pos_equal + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes = utils::Split(value.substr(pos_nodes), ",");
|
nodes = memgraph::utils::Split(value.substr(pos_nodes), ",");
|
||||||
|
|
||||||
return {std::move(nodes), std::move(additional_labels)};
|
return {std::move(nodes), std::move(additional_labels)};
|
||||||
}
|
}
|
||||||
@ -670,7 +674,7 @@ RelationshipsArgument ParseRelationshipsArgument(const std::string &value) {
|
|||||||
pos_relationships = pos_equal + 1;
|
pos_relationships = pos_equal + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
relationships = utils::Split(value.substr(pos_relationships), ",");
|
relationships = memgraph::utils::Split(value.substr(pos_relationships), ",");
|
||||||
|
|
||||||
return {std::move(relationships), std::move(type)};
|
return {std::move(relationships), std::move(type)};
|
||||||
}
|
}
|
||||||
@ -690,20 +694,20 @@ int main(int argc, char *argv[]) {
|
|||||||
MG_ASSERT(!nodes.empty(), "The --nodes flag is required!");
|
MG_ASSERT(!nodes.empty(), "The --nodes flag is required!");
|
||||||
|
|
||||||
{
|
{
|
||||||
std::string upper = utils::ToUpperCase(utils::Trim(FLAGS_id_type));
|
std::string upper = memgraph::utils::ToUpperCase(memgraph::utils::Trim(FLAGS_id_type));
|
||||||
FLAGS_id_type = upper;
|
FLAGS_id_type = upper;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<NodeId, storage::Gid> node_id_map;
|
std::unordered_map<NodeId, memgraph::storage::Gid> node_id_map;
|
||||||
storage::Storage store{{
|
memgraph::storage::Storage store{{
|
||||||
.items = {.properties_on_edges = FLAGS_storage_properties_on_edges},
|
.items = {.properties_on_edges = FLAGS_storage_properties_on_edges},
|
||||||
.durability = {.storage_directory = FLAGS_data_directory,
|
.durability = {.storage_directory = FLAGS_data_directory,
|
||||||
.recover_on_startup = false,
|
.recover_on_startup = false,
|
||||||
.snapshot_wal_mode = storage::Config::Durability::SnapshotWalMode::DISABLED,
|
.snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::DISABLED,
|
||||||
.snapshot_on_exit = true},
|
.snapshot_on_exit = true},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
utils::Timer load_timer;
|
memgraph::utils::Timer load_timer;
|
||||||
|
|
||||||
// Process all nodes files.
|
// Process all nodes files.
|
||||||
for (const auto &value : nodes) {
|
for (const auto &value : nodes) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace py {
|
namespace memgraph::py {
|
||||||
|
|
||||||
/// Ensure the current thread is ready to call Python C API.
|
/// Ensure the current thread is ready to call Python C API.
|
||||||
///
|
///
|
||||||
@ -273,4 +273,4 @@ inline void RestoreError(ExceptionInfo exc_info) {
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace py
|
} // namespace memgraph::py
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,17 +13,17 @@
|
|||||||
|
|
||||||
#include "query/frontend/ast/ast.hpp"
|
#include "query/frontend/ast/ast.hpp"
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
class AuthChecker {
|
class AuthChecker {
|
||||||
public:
|
public:
|
||||||
virtual bool IsUserAuthorized(const std::optional<std::string> &username,
|
virtual bool IsUserAuthorized(const std::optional<std::string> &username,
|
||||||
const std::vector<query::AuthQuery::Privilege> &privileges) const = 0;
|
const std::vector<memgraph::query::AuthQuery::Privilege> &privileges) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AllowEverythingAuthChecker final : public query::AuthChecker {
|
class AllowEverythingAuthChecker final : public memgraph::query::AuthChecker {
|
||||||
bool IsUserAuthorized(const std::optional<std::string> &username,
|
bool IsUserAuthorized(const std::optional<std::string> &username,
|
||||||
const std::vector<query::AuthQuery::Privilege> &privileges) const override {
|
const std::vector<memgraph::query::AuthQuery::Privilege> &privileges) const override {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "query/common.hpp"
|
#include "query/common.hpp"
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
|
|
||||||
namespace impl {
|
namespace impl {
|
||||||
|
|
||||||
@ -73,4 +73,4 @@ int64_t QueryTimestamp() {
|
|||||||
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch())
|
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch())
|
||||||
.count();
|
.count();
|
||||||
}
|
}
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#include "storage/v2/view.hpp"
|
#include "storage/v2/view.hpp"
|
||||||
#include "utils/logging.hpp"
|
#include "utils/logging.hpp"
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
|
|
||||||
namespace impl {
|
namespace impl {
|
||||||
bool TypedValueCompare(const TypedValue &a, const TypedValue &b);
|
bool TypedValueCompare(const TypedValue &a, const TypedValue &b);
|
||||||
@ -108,4 +108,4 @@ storage::PropertyValue PropsSetChecked(T *record, const storage::PropertyId &key
|
|||||||
}
|
}
|
||||||
|
|
||||||
int64_t QueryTimestamp();
|
int64_t QueryTimestamp();
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,7 +13,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
struct InterpreterConfig {
|
struct InterpreterConfig {
|
||||||
struct Query {
|
struct Query {
|
||||||
bool allow_load_csv{true};
|
bool allow_load_csv{true};
|
||||||
@ -27,4 +27,4 @@ struct InterpreterConfig {
|
|||||||
uint32_t stream_transaction_conflict_retries;
|
uint32_t stream_transaction_conflict_retries;
|
||||||
std::chrono::milliseconds stream_transaction_retry_interval;
|
std::chrono::milliseconds stream_transaction_retry_interval;
|
||||||
};
|
};
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -13,7 +13,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
constexpr uint16_t kDefaultReplicationPort = 10000;
|
constexpr uint16_t kDefaultReplicationPort = 10000;
|
||||||
constexpr auto *kDefaultReplicationServerIp = "0.0.0.0";
|
constexpr auto *kDefaultReplicationServerIp = "0.0.0.0";
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -21,7 +21,7 @@
|
|||||||
#include "query/trigger.hpp"
|
#include "query/trigger.hpp"
|
||||||
#include "utils/async_timer.hpp"
|
#include "utils/async_timer.hpp"
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
|
|
||||||
struct EvaluationContext {
|
struct EvaluationContext {
|
||||||
/// Memory for allocations during evaluation of a *single* Pull call.
|
/// Memory for allocations during evaluation of a *single* Pull call.
|
||||||
@ -86,4 +86,4 @@ inline plan::ProfilingStatsWithTotalTime GetStatsWithTotalTime(const ExecutionCo
|
|||||||
return plan::ProfilingStatsWithTotalTime{context.stats, context.profile_execution_time};
|
return plan::ProfilingStatsWithTotalTime{context.stats, context.profile_execution_time};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -17,7 +17,7 @@ DEFINE_HIDDEN_bool(query_cost_planner, true, "Use the cost-estimating query plan
|
|||||||
DEFINE_VALIDATED_int32(query_plan_cache_ttl, 60, "Time to live for cached query plans, in seconds.",
|
DEFINE_VALIDATED_int32(query_plan_cache_ttl, 60, "Time to live for cached query plans, in seconds.",
|
||||||
FLAG_IN_RANGE(0, std::numeric_limits<int32_t>::max()));
|
FLAG_IN_RANGE(0, std::numeric_limits<int32_t>::max()));
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
CachedPlan::CachedPlan(std::unique_ptr<LogicalPlan> plan) : plan_(std::move(plan)) {}
|
CachedPlan::CachedPlan(std::unique_ptr<LogicalPlan> plan) : plan_(std::move(plan)) {}
|
||||||
|
|
||||||
ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::string, storage::PropertyValue> ¶ms,
|
ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::string, storage::PropertyValue> ¶ms,
|
||||||
@ -37,7 +37,7 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::stri
|
|||||||
auto it = params.find(param_pair.second);
|
auto it = params.find(param_pair.second);
|
||||||
|
|
||||||
if (it == params.end()) {
|
if (it == params.end()) {
|
||||||
throw query::UnprovidedParameterError("Parameter ${} not provided.", param_pair.second);
|
throw memgraph::query::UnprovidedParameterError("Parameter ${} not provided.", param_pair.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters.Add(param_pair.first, it->second);
|
parameters.Add(param_pair.first, it->second);
|
||||||
@ -91,7 +91,8 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (visitor.GetQueryInfo().is_cacheable) {
|
if (visitor.GetQueryInfo().is_cacheable) {
|
||||||
CachedQuery cached_query{std::move(ast_storage), visitor.query(), query::GetRequiredPrivileges(visitor.query())};
|
CachedQuery cached_query{std::move(ast_storage), visitor.query(),
|
||||||
|
memgraph::query::GetRequiredPrivileges(visitor.query())};
|
||||||
it = accessor.insert({hash, std::move(cached_query)}).first;
|
it = accessor.insert({hash, std::move(cached_query)}).first;
|
||||||
|
|
||||||
get_information_from_cache(it->second);
|
get_information_from_cache(it->second);
|
||||||
@ -101,7 +102,7 @@ ParsedQuery ParseQuery(const std::string &query_string, const std::map<std::stri
|
|||||||
result.ast_storage.edge_types_ = ast_storage.edge_types_;
|
result.ast_storage.edge_types_ = ast_storage.edge_types_;
|
||||||
|
|
||||||
result.query = visitor.query()->Clone(&result.ast_storage);
|
result.query = visitor.query()->Clone(&result.ast_storage);
|
||||||
result.required_privileges = query::GetRequiredPrivileges(visitor.query());
|
result.required_privileges = memgraph::query::GetRequiredPrivileges(visitor.query());
|
||||||
|
|
||||||
is_cacheable = false;
|
is_cacheable = false;
|
||||||
}
|
}
|
||||||
@ -154,4 +155,4 @@ std::shared_ptr<CachedPlan> CypherQueryToPlan(uint64_t hash, AstStorage ast_stor
|
|||||||
}
|
}
|
||||||
return plan;
|
return plan;
|
||||||
}
|
}
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
||||||
|
@ -26,7 +26,7 @@ DECLARE_bool(query_cost_planner);
|
|||||||
// NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables)
|
// NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
DECLARE_int32(query_plan_cache_ttl);
|
DECLARE_int32(query_plan_cache_ttl);
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
|
|
||||||
// TODO: Maybe this should move to query/plan/planner.
|
// TODO: Maybe this should move to query/plan/planner.
|
||||||
/// Interface for accessing the root operator of a logical plan.
|
/// Interface for accessing the root operator of a logical plan.
|
||||||
@ -149,4 +149,4 @@ std::shared_ptr<CachedPlan> CypherQueryToPlan(uint64_t hash, AstStorage ast_stor
|
|||||||
DbAccessor *db_accessor,
|
DbAccessor *db_accessor,
|
||||||
const std::vector<Identifier *> &predefined_identifiers = {});
|
const std::vector<Identifier *> &predefined_identifiers = {});
|
||||||
|
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Memgraph Ltd.
|
// Copyright 2022 Memgraph Ltd.
|
||||||
//
|
//
|
||||||
// Use of this software is governed by the Business Source License
|
// Use of this software is governed by the Business Source License
|
||||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
@ -43,7 +43,7 @@
|
|||||||
#include "utils/bound.hpp"
|
#include "utils/bound.hpp"
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
|
|
||||||
namespace query {
|
namespace memgraph::query {
|
||||||
|
|
||||||
class VertexAccessor;
|
class VertexAccessor;
|
||||||
|
|
||||||
@ -358,18 +358,18 @@ class DbAccessor final {
|
|||||||
storage::ConstraintsInfo ListAllConstraints() const { return accessor_->ListAllConstraints(); }
|
storage::ConstraintsInfo ListAllConstraints() const { return accessor_->ListAllConstraints(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace query
|
} // namespace memgraph::query
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct hash<query::VertexAccessor> {
|
struct hash<memgraph::query::VertexAccessor> {
|
||||||
size_t operator()(const query::VertexAccessor &v) const { return std::hash<decltype(v.impl_)>{}(v.impl_); }
|
size_t operator()(const memgraph::query::VertexAccessor &v) const { return std::hash<decltype(v.impl_)>{}(v.impl_); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct hash<query::EdgeAccessor> {
|
struct hash<memgraph::query::EdgeAccessor> {
|
||||||
size_t operator()(const query::EdgeAccessor &e) const { return std::hash<decltype(e.impl_)>{}(e.impl_); }
|
size_t operator()(const memgraph::query::EdgeAccessor &e) const { return std::hash<decltype(e.impl_)>{}(e.impl_); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user