Migrate to C++17

Reviewers: teon.banek, buda

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1974
This commit is contained in:
Matej Ferencevic 2019-04-23 11:00:49 +02:00
parent 75ffcc4ee9
commit 9291a5fc4d
222 changed files with 1388 additions and 1571 deletions

View File

@ -1,6 +1,6 @@
# MemGraph CMake configuration
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.8)
# !! IMPORTANT !! run ./project_root/init.sh before cmake command
# to download dependencies
@ -64,11 +64,9 @@ add_custom_target(clean_all
# build flags -----------------------------------------------------------------
# TODO: set here 17 once it will be available in the cmake version (3.8)
# set(CMAKE_CXX_STANDARD 17)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
# For now, explicitly set -std= flag for C++17.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall \
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall \
-Werror=switch -Werror=switch-bool -Werror=return-type")
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.

View File

@ -48,8 +48,8 @@ inline nlohmann::json PropertyValueToJson(const PropertyValue &pv) {
return ret;
}
Log::Log(const std::experimental::filesystem::path &storage_directory,
int32_t buffer_size, int32_t buffer_flush_interval_millis)
Log::Log(const std::filesystem::path &storage_directory, int32_t buffer_size,
int32_t buffer_flush_interval_millis)
: storage_directory_(storage_directory),
buffer_size_(buffer_size),
buffer_flush_interval_millis_(buffer_flush_interval_millis),

View File

@ -1,8 +1,8 @@
#pragma once
#include <atomic>
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include "data_structures/ring_buffer.hpp"
#include "storage/common/types/property_value.hpp"
@ -27,8 +27,8 @@ class Log {
};
public:
Log(const std::experimental::filesystem::path &storage_directory,
int32_t buffer_size, int32_t buffer_flush_interval_millis);
Log(const std::filesystem::path &storage_directory, int32_t buffer_size,
int32_t buffer_flush_interval_millis);
~Log();
@ -52,12 +52,12 @@ class Log {
private:
void Flush();
std::experimental::filesystem::path storage_directory_;
std::filesystem::path storage_directory_;
int32_t buffer_size_;
int32_t buffer_flush_interval_millis_;
std::atomic<bool> started_;
std::experimental::optional<RingBuffer<Item>> buffer_;
std::optional<RingBuffer<Item>> buffer_;
utils::Scheduler scheduler_;
utils::LogFile log_;

View File

@ -139,9 +139,10 @@ std::string LdapEscapeString(const std::string &src) {
/// searching all first level children of the `role_base_dn` and finding that
/// item that has a `mapping` attribute to the given `user_dn`. The found item's
/// `cn` is used as the role name.
std::experimental::optional<std::string> LdapFindRole(
LDAP *ld, const std::string &role_base_dn, const std::string &user_dn,
const std::string &username) {
std::optional<std::string> LdapFindRole(LDAP *ld,
const std::string &role_base_dn,
const std::string &user_dn,
const std::string &username) {
auto ldap_user_dn = LdapConvertString(user_dn);
char *attrs[1] = {nullptr};
@ -155,7 +156,7 @@ std::experimental::optional<std::string> LdapFindRole(
if (ret != LDAP_SUCCESS) {
LOG(WARNING) << "Couldn't find role for user '" << username
<< "' using LDAP due to error: " << ldap_err2string(ret);
return std::experimental::nullopt;
return std::nullopt;
}
if (ret == LDAP_SUCCESS && msg != nullptr) {
@ -171,17 +172,17 @@ std::experimental::optional<std::string> LdapFindRole(
LOG(WARNING) << "Couldn't find role for user '" << username
<< "' using LDAP because to the role object doesn't "
"have a unique CN attribute!";
return std::experimental::nullopt;
return std::nullopt;
}
return std::string(values[0]->bv_val, values[0]->bv_len);
} else if (ret != LDAP_COMPARE_FALSE) {
LOG(WARNING) << "Couldn't find role for user '" << username
<< "' using LDAP due to error: " << ldap_err2string(ret);
return std::experimental::nullopt;
return std::nullopt;
}
}
}
return std::experimental::nullopt;
return std::nullopt;
}
#define LDAP_EXIT_ON_ERROR(expr, username) \
@ -190,12 +191,12 @@ std::experimental::optional<std::string> LdapFindRole(
if (r != LDAP_SUCCESS) { \
LOG(WARNING) << "Couldn't authenticate user '" << username \
<< "' using LDAP due to error: " << ldap_err2string(r); \
return std::experimental::nullopt; \
return std::nullopt; \
} \
}
std::experimental::optional<User> Auth::Authenticate(
const std::string &username, const std::string &password) {
std::optional<User> Auth::Authenticate(const std::string &username,
const std::string &password) {
if (FLAGS_auth_ldap_enabled) {
LDAP *ld = nullptr;
@ -237,7 +238,7 @@ std::experimental::optional<User> Auth::Authenticate(
}
// Find role name.
std::experimental::optional<std::string> rolename;
std::optional<std::string> rolename;
if (!FLAGS_auth_ldap_role_mapping_root_dn.empty()) {
rolename = LdapFindRole(ld, FLAGS_auth_ldap_role_mapping_root_dn,
distinguished_name, username);
@ -252,12 +253,12 @@ std::experimental::optional<User> Auth::Authenticate(
LOG(WARNING)
<< "Couldn't authenticate user '" << username
<< "' using LDAP because the user already exists as a role!";
return std::experimental::nullopt;
return std::nullopt;
}
} else {
LOG(WARNING) << "Couldn't authenticate user '" << username
<< "' using LDAP because the user doesn't exist!";
return std::experimental::nullopt;
return std::nullopt;
}
} else {
user->UpdatePassword(password);
@ -271,14 +272,14 @@ std::experimental::optional<User> Auth::Authenticate(
LOG(WARNING) << "Couldn't authenticate user '" << username
<< "' using LDAP because the user's role '"
<< *rolename << "' already exists as a user!";
return std::experimental::nullopt;
return std::nullopt;
}
SaveRole(*role);
} else {
LOG(WARNING) << "Couldn't authenticate user '" << username
<< "' using LDAP because the user's role '" << *rolename
<< "' doesn't exist!";
return std::experimental::nullopt;
return std::nullopt;
}
}
user->SetRole(*role);
@ -289,17 +290,16 @@ std::experimental::optional<User> Auth::Authenticate(
return user;
} else {
auto user = GetUser(username);
if (!user) return std::experimental::nullopt;
if (!user->CheckPassword(password)) return std::experimental::nullopt;
if (!user) return std::nullopt;
if (!user->CheckPassword(password)) return std::nullopt;
return user;
}
}
std::experimental::optional<User> Auth::GetUser(
const std::string &username_orig) {
std::optional<User> Auth::GetUser(const std::string &username_orig) {
auto username = utils::ToLowerCase(username_orig);
auto existing_user = storage_.Get(kUserPrefix + username);
if (!existing_user) return std::experimental::nullopt;
if (!existing_user) return std::nullopt;
nlohmann::json data;
try {
@ -336,13 +336,12 @@ void Auth::SaveUser(const User &user) {
}
}
std::experimental::optional<User> Auth::AddUser(
const std::string &username,
const std::experimental::optional<std::string> &password) {
std::optional<User> Auth::AddUser(const std::string &username,
const std::optional<std::string> &password) {
auto existing_user = GetUser(username);
if (existing_user) return std::experimental::nullopt;
if (existing_user) return std::nullopt;
auto existing_role = GetRole(username);
if (existing_role) return std::experimental::nullopt;
if (existing_role) return std::nullopt;
auto new_user = User(username);
new_user.UpdatePassword(password);
SaveUser(new_user);
@ -378,11 +377,10 @@ bool Auth::HasUsers() {
return storage_.begin(kUserPrefix) != storage_.end(kUserPrefix);
}
std::experimental::optional<Role> Auth::GetRole(
const std::string &rolename_orig) {
std::optional<Role> Auth::GetRole(const std::string &rolename_orig) {
auto rolename = utils::ToLowerCase(rolename_orig);
auto existing_role = storage_.Get(kRolePrefix + rolename);
if (!existing_role) return std::experimental::nullopt;
if (!existing_role) return std::nullopt;
nlohmann::json data;
try {
@ -400,11 +398,11 @@ void Auth::SaveRole(const Role &role) {
}
}
std::experimental::optional<Role> Auth::AddRole(const std::string &rolename) {
std::optional<Role> Auth::AddRole(const std::string &rolename) {
auto existing_role = GetRole(rolename);
if (existing_role) return std::experimental::nullopt;
if (existing_role) return std::nullopt;
auto existing_user = GetUser(rolename);
if (existing_user) return std::experimental::nullopt;
if (existing_user) return std::nullopt;
auto new_role = Role(rolename);
SaveRole(new_role);
return new_role;

View File

@ -1,7 +1,7 @@
#pragma once
#include <experimental/optional>
#include <mutex>
#include <optional>
#include <vector>
#include "auth/exceptions.hpp"
@ -36,8 +36,8 @@ class Auth final {
*
* @return a user when the username and password match, nullopt otherwise
*/
std::experimental::optional<User> Authenticate(const std::string &username,
const std::string &password);
std::optional<User> Authenticate(const std::string &username,
const std::string &password);
/**
* Gets a user from the storage.
@ -46,7 +46,7 @@ class Auth final {
*
* @return a user when the user exists, nullopt otherwise
*/
std::experimental::optional<User> GetUser(const std::string &username);
std::optional<User> GetUser(const std::string &username);
/**
* Saves a user object to the storage.
@ -63,10 +63,9 @@ class Auth final {
*
* @return a user when the user is created, nullopt if the user exists
*/
std::experimental::optional<User> AddUser(
std::optional<User> AddUser(
const std::string &username,
const std::experimental::optional<std::string> &password =
std::experimental::nullopt);
const std::optional<std::string> &password = std::nullopt);
/**
* Removes a user from the storage.
@ -99,7 +98,7 @@ class Auth final {
*
* @return a role when the role exists, nullopt otherwise
*/
std::experimental::optional<Role> GetRole(const std::string &rolename);
std::optional<Role> GetRole(const std::string &rolename);
/**
* Saves a role object to the storage.
@ -115,7 +114,7 @@ class Auth final {
*
* @return a role when the role is created, nullopt if the role exists
*/
std::experimental::optional<Role> AddRole(const std::string &rolename);
std::optional<Role> AddRole(const std::string &rolename);
/**
* Removes a role from the storage.

View File

@ -190,8 +190,7 @@ bool User::CheckPassword(const std::string &password) {
return VerifyPassword(password, password_hash_);
}
void User::UpdatePassword(
const std::experimental::optional<std::string> &password) {
void User::UpdatePassword(const std::optional<std::string> &password) {
if (password) {
std::regex re(FLAGS_auth_password_strength_regex);
if (!std::regex_match(*password, re)) {
@ -211,7 +210,7 @@ void User::UpdatePassword(
void User::SetRole(const Role &role) { role_.emplace(role); }
void User::ClearRole() { role_ = std::experimental::nullopt; }
void User::ClearRole() { role_ = std::nullopt; }
const Permissions User::GetPermissions() const {
if (role_) {
@ -226,7 +225,7 @@ const std::string &User::username() const { return username_; }
const Permissions &User::permissions() const { return permissions_; }
Permissions &User::permissions() { return permissions_; }
std::experimental::optional<Role> User::role() const { return role_; }
std::optional<Role> User::role() const { return role_; }
nlohmann::json User::Serialize() const {
nlohmann::json data = nlohmann::json::object();

View File

@ -1,6 +1,6 @@
#pragma once
#include <experimental/optional>
#include <optional>
#include <string>
#include <json/json.hpp>
@ -108,8 +108,8 @@ class User final {
bool CheckPassword(const std::string &password);
void UpdatePassword(const std::experimental::optional<std::string> &password =
std::experimental::nullopt);
void UpdatePassword(
const std::optional<std::string> &password = std::nullopt);
void SetRole(const Role &role);
@ -122,7 +122,7 @@ class User final {
const Permissions &permissions() const;
Permissions &permissions();
std::experimental::optional<Role> role() const;
std::optional<Role> role() const;
nlohmann::json Serialize() const;
@ -134,7 +134,7 @@ class User final {
std::string username_;
std::string password_hash_;
Permissions permissions_;
std::experimental::optional<Role> role_;
std::optional<Role> role_;
};
bool operator==(const User &first, const User &second);

View File

@ -1,14 +1,14 @@
#pragma once
#include <experimental/type_traits>
#include <type_traits>
#include "communication/bolt/v1/codes.hpp"
#include "communication/bolt/v1/value.hpp"
#include "utils/bswap.hpp"
#include "utils/cast.hpp"
static_assert(std::experimental::is_same_v<std::uint8_t, char> ||
std::experimental::is_same_v<std::uint8_t, unsigned char>,
static_assert(std::is_same_v<std::uint8_t, char> ||
std::is_same_v<std::uint8_t, unsigned char>,
"communication::bolt::Encoder requires uint8_t to be "
"implemented as char or unsigned char.");

View File

@ -15,7 +15,7 @@ Client::Client(const io::network::Endpoint &endpoint) : endpoint_(endpoint) {}
// Check if the connection is broken (if we haven't used the client for a
// long time the server could have died).
if (client_ && client_->ErrorStatus()) {
client_ = std::experimental::nullopt;
client_ = std::nullopt;
}
// Connect to the remote server.
@ -23,7 +23,7 @@ Client::Client(const io::network::Endpoint &endpoint) : endpoint_(endpoint) {}
client_.emplace(&context_);
if (!client_->Connect(endpoint_)) {
DLOG(ERROR) << "Couldn't connect to remote address " << endpoint_;
client_ = std::experimental::nullopt;
client_ = std::nullopt;
throw RpcFailedException(endpoint_);
}
}
@ -40,20 +40,20 @@ Client::Client(const io::network::Endpoint &endpoint) : endpoint_(endpoint) {}
if (!client_->Write(reinterpret_cast<uint8_t *>(&request_data_size),
sizeof(MessageSize), true)) {
DLOG(ERROR) << "Couldn't send request size to " << client_->endpoint();
client_ = std::experimental::nullopt;
client_ = std::nullopt;
throw RpcFailedException(endpoint_);
}
if (!client_->Write(request_bytes.begin(), request_bytes.size())) {
DLOG(ERROR) << "Couldn't send request data to " << client_->endpoint();
client_ = std::experimental::nullopt;
client_ = std::nullopt;
throw RpcFailedException(endpoint_);
}
// Receive response data size.
if (!client_->Read(sizeof(MessageSize))) {
DLOG(ERROR) << "Couldn't get response from " << client_->endpoint();
client_ = std::experimental::nullopt;
client_ = std::nullopt;
throw RpcFailedException(endpoint_);
}
MessageSize response_data_size =
@ -63,7 +63,7 @@ Client::Client(const io::network::Endpoint &endpoint) : endpoint_(endpoint) {}
// Receive response data.
if (!client_->Read(response_data_size)) {
DLOG(ERROR) << "Couldn't get response from " << client_->endpoint();
client_ = std::experimental::nullopt;
client_ = std::nullopt;
throw RpcFailedException(endpoint_);
}
@ -84,7 +84,7 @@ void Client::Abort() {
// We need to call Shutdown on the client to abort any pending read or
// write operations.
client_->Shutdown();
client_ = std::experimental::nullopt;
client_ = std::nullopt;
}
} // namespace communication::rpc

View File

@ -1,8 +1,8 @@
#pragma once
#include <experimental/optional>
#include <memory>
#include <mutex>
#include <optional>
#include <capnp/message.h>
#include <capnp/serialize.h>
@ -69,7 +69,7 @@ class Client {
// Since message_id was checked in private Call function, this means
// something is very wrong (probably on the server side).
LOG(ERROR) << "Message response was of unexpected type";
client_ = std::experimental::nullopt;
client_ = std::nullopt;
throw RpcFailedException(endpoint_);
}
@ -90,7 +90,7 @@ class Client {
io::network::Endpoint endpoint_;
// TODO (mferencevic): currently the RPC client is hardcoded not to use SSL
communication::ClientContext context_;
std::experimental::optional<communication::Client> client_;
std::optional<communication::Client> client_;
std::mutex mutex_;
};

View File

@ -3,14 +3,14 @@
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <experimental/optional>
#include <experimental/type_traits>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
@ -23,8 +23,8 @@
namespace slk {
// Static assert for the assumption made in this library.
static_assert(std::experimental::is_same_v<std::uint8_t, char> ||
std::experimental::is_same_v<std::uint8_t, unsigned char>,
static_assert(std::is_same_v<std::uint8_t, char> ||
std::is_same_v<std::uint8_t, unsigned char>,
"The slk library requires uint8_t to be implemented as char or "
"unsigned char.");
@ -68,9 +68,9 @@ void Load(std::unique_ptr<T> *obj, Reader *reader,
const std::function<void(std::unique_ptr<T> *, Reader *)> &load);
template <typename T>
void Save(const std::experimental::optional<T> &obj, Builder *builder);
void Save(const std::optional<T> &obj, Builder *builder);
template <typename T>
void Load(std::experimental::optional<T> *obj, Reader *reader);
void Load(std::optional<T> *obj, Reader *reader);
template <typename T>
void Save(const std::shared_ptr<T> &obj, Builder *builder,
@ -278,8 +278,8 @@ inline void Load(
}
template <typename T>
inline void Save(const std::experimental::optional<T> &obj, Builder *builder) {
if (obj == std::experimental::nullopt) {
inline void Save(const std::optional<T> &obj, Builder *builder) {
if (obj == std::nullopt) {
bool exists = false;
Save(exists, builder);
} else {
@ -290,7 +290,7 @@ inline void Save(const std::experimental::optional<T> &obj, Builder *builder) {
}
template <typename T>
inline void Load(std::experimental::optional<T> *obj, Reader *reader) {
inline void Load(std::optional<T> *obj, Reader *reader) {
bool exists = false;
Load(&exists, reader);
if (exists) {
@ -298,7 +298,7 @@ inline void Load(std::experimental::optional<T> *obj, Reader *reader) {
Load(&item, reader);
obj->emplace(std::move(item));
} else {
*obj = std::experimental::nullopt;
*obj = std::nullopt;
}
}
@ -435,9 +435,9 @@ inline void Load(std::vector<T> *obj, Reader *reader,
}
template <typename T>
inline void Save(const std::experimental::optional<T> &obj, Builder *builder,
inline void Save(const std::optional<T> &obj, Builder *builder,
std::function<void(const T &, Builder *)> item_save_function) {
if (obj == std::experimental::nullopt) {
if (obj == std::nullopt) {
bool exists = false;
Save(exists, builder);
} else {
@ -448,7 +448,7 @@ inline void Save(const std::experimental::optional<T> &obj, Builder *builder,
}
template <typename T>
inline void Load(std::experimental::optional<T> *obj, Reader *reader,
inline void Load(std::optional<T> *obj, Reader *reader,
std::function<void(T *, Reader *)> item_load_function) {
bool exists = false;
Load(&exists, reader);
@ -457,7 +457,7 @@ inline void Load(std::experimental::optional<T> *obj, Reader *reader,
item_load_function(&item, reader);
obj->emplace(std::move(item));
} else {
*obj = std::experimental::nullopt;
*obj = std::nullopt;
}
}
} // namespace slk

View File

@ -1,9 +1,9 @@
#pragma once
#include <atomic>
#include <experimental/optional>
#include <iostream>
#include <memory>
#include <optional>
#include <thread>
#include <vector>

View File

@ -1,6 +1,6 @@
#pragma once
#include <experimental/filesystem>
#include <filesystem>
#include <string>
#include <vector>
@ -14,7 +14,7 @@
/// 2) ~/.memgraph/config
/// 3) env - MEMGRAPH_CONFIG
void LoadConfig() {
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
std::vector<fs::path> configs = {fs::path("/etc/memgraph/memgraph.conf")};
if (getenv("HOME") != nullptr)
configs.emplace_back(fs::path(getenv("HOME")) /
@ -53,4 +53,3 @@ void LoadConfig() {
for (int i = 0; i < custom_argc; ++i) free(custom_argv[i]);
delete[] custom_argv;
}

View File

@ -2,9 +2,9 @@
#include <malloc.h>
#include <experimental/optional>
#include <list>
#include <mutex>
#include <optional>
#include <utility>
#include <gflags/gflags.h>

View File

@ -3,9 +3,9 @@
#include <atomic>
#include <condition_variable>
#include <cstdint>
#include <experimental/optional>
#include <iostream>
#include <mutex>
#include <optional>
#include <queue>
#include <thread>
@ -49,9 +49,8 @@ class Queue {
// Block until there is an element in the queue and then pop it from the queue
// and return it. Function can return nullopt if Queue is signaled via
// Shutdown function or if there is no element to pop after timeout elapses.
std::experimental::optional<T> AwaitPop(
std::chrono::system_clock::duration timeout =
std::chrono::system_clock::duration::max()) {
std::optional<T> AwaitPop(std::chrono::system_clock::duration timeout =
std::chrono::system_clock::duration::max()) {
std::unique_lock<std::mutex> guard(mutex_);
auto now = std::chrono::system_clock::now();
auto until = std::chrono::system_clock::time_point::max() - timeout > now
@ -59,17 +58,17 @@ class Queue {
: std::chrono::system_clock::time_point::max();
cvar_.wait_until(guard, until,
[this] { return !queue_.empty() || !alive_; });
if (queue_.empty() || !alive_) return std::experimental::nullopt;
std::experimental::optional<T> x(std::move(queue_.front()));
if (queue_.empty() || !alive_) return std::nullopt;
std::optional<T> x(std::move(queue_.front()));
queue_.pop();
return x;
}
// Nonblocking version of above function.
std::experimental::optional<T> MaybePop() {
std::optional<T> MaybePop() {
std::unique_lock<std::mutex> guard(mutex_);
if (queue_.empty()) return std::experimental::nullopt;
std::experimental::optional<T> x(std::move(queue_.front()));
if (queue_.empty()) return std::nullopt;
std::optional<T> x(std::move(queue_.front()));
queue_.pop();
return x;
}

View File

@ -2,8 +2,8 @@
#include <atomic>
#include <chrono>
#include <experimental/optional>
#include <mutex>
#include <optional>
#include <thread>
#include <utility>
@ -61,12 +61,11 @@ class RingBuffer {
* Removes and returns the oldest element from the buffer. If the buffer is
* empty, nullopt is returned.
*/
std::experimental::optional<TElement> pop() {
std::optional<TElement> pop() {
std::lock_guard<utils::SpinLock> guard(lock_);
if (size_ == 0) return std::experimental::nullopt;
if (size_ == 0) return std::nullopt;
size_--;
std::experimental::optional<TElement> result(
std::move(buffer_[read_pos_++]));
std::optional<TElement> result(std::move(buffer_[read_pos_++]));
read_pos_ %= capacity_;
return result;
}

View File

@ -62,8 +62,7 @@ class MasterAccessor final : public GraphDbAccessor {
worker_id_(db->WorkerId()) {}
void PostCreateIndex(const LabelPropertyIndex::Key &key) override {
std::experimental::optional<std::vector<utils::Future<bool>>>
index_rpc_completions;
std::optional<std::vector<utils::Future<bool>>> index_rpc_completions;
// Notify all workers to create the index
index_rpc_completions.emplace(coordination_->ExecuteOnWorkers<bool>(
@ -98,8 +97,7 @@ class MasterAccessor final : public GraphDbAccessor {
const LabelPropertyIndex::Key &key) override {
// Notify all workers to start populating an index if we are the master
// since they don't have to wait anymore
std::experimental::optional<std::vector<utils::Future<bool>>>
index_rpc_completions;
std::optional<std::vector<utils::Future<bool>>> index_rpc_completions;
index_rpc_completions.emplace(coordination_->ExecuteOnWorkers<bool>(
worker_id_, [this, &key](int worker_id,
communication::rpc::ClientPool &client_pool) {
@ -412,7 +410,7 @@ void Master::Start() {
// Durability recovery.
{
// What we recover.
std::experimental::optional<durability::RecoveryInfo> recovery_info;
std::optional<durability::RecoveryInfo> recovery_info;
durability::RecoveryData recovery_data;
// Recover only if necessary.
@ -422,15 +420,15 @@ void Master::Start() {
"current version of Memgraph binary!";
recovery_info = durability::RecoverOnlySnapshot(
impl_->config_.durability_directory, this, &recovery_data,
std::experimental::nullopt, impl_->config_.worker_id);
std::nullopt, impl_->config_.worker_id);
}
// Post-recovery setup and checking.
impl_->coordination_.SetRecoveredSnapshot(
recovery_info ? std::experimental::make_optional(
recovery_info ? std::make_optional(
std::make_pair(recovery_info->durability_version,
recovery_info->snapshot_tx_id))
: std::experimental::nullopt);
: std::nullopt);
// Wait till workers report back their recoverable wal txs
if (recovery_info) {
@ -598,7 +596,7 @@ VertexAccessor InsertVertexIntoRemote(
GraphDbAccessor *dba, int worker_id,
const std::vector<storage::Label> &labels,
const std::unordered_map<storage::Property, PropertyValue> &properties,
std::experimental::optional<int64_t> cypher_id) {
std::optional<int64_t> cypher_id) {
auto *db = &dba->db();
CHECK(db);
CHECK(worker_id != db->WorkerId())
@ -788,7 +786,7 @@ void Worker::Start() {
auto snapshot_to_recover = impl_->cluster_discovery_.snapshot_to_recover();
// What we recover.
std::experimental::optional<durability::RecoveryInfo> recovery_info;
std::optional<durability::RecoveryInfo> recovery_info;
durability::RecoveryData recovery_data;
// Recover only if necessary.

View File

@ -105,8 +105,7 @@ class Worker final : public GraphDb {
VertexAccessor InsertVertexIntoRemote(
GraphDbAccessor *dba, int worker_id,
const std::vector<storage::Label> &labels,
const std::unordered_map<storage::Property, PropertyValue>
&properties,
std::experimental::optional<int64_t> cypher_id);
const std::unordered_map<storage::Property, PropertyValue> &properties,
std::optional<int64_t> cypher_id);
} // namespace database

View File

@ -75,8 +75,7 @@ bool GraphDbAccessor::should_abort() const {
durability::WriteAheadLog &GraphDbAccessor::wal() { return db_.wal(); }
VertexAccessor GraphDbAccessor::InsertVertex(
std::experimental::optional<gid::Gid> requested_gid,
std::experimental::optional<int64_t> cypher_id) {
std::optional<gid::Gid> requested_gid, std::optional<int64_t> cypher_id) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
auto gid = db_.storage().vertex_generator_.Next(requested_gid);
@ -94,11 +93,11 @@ VertexAccessor GraphDbAccessor::InsertVertex(
return va;
}
std::experimental::optional<VertexAccessor> GraphDbAccessor::FindVertexOptional(
std::optional<VertexAccessor> GraphDbAccessor::FindVertexOptional(
gid::Gid gid, bool current_state) {
auto record_accessor = FindVertexRaw(gid);
if (!record_accessor.Visible(transaction(), current_state))
return std::experimental::nullopt;
return std::nullopt;
return record_accessor;
}
@ -113,11 +112,11 @@ VertexAccessor GraphDbAccessor::FindVertex(gid::Gid gid, bool current_state) {
return *found;
}
std::experimental::optional<EdgeAccessor> GraphDbAccessor::FindEdgeOptional(
std::optional<EdgeAccessor> GraphDbAccessor::FindEdgeOptional(
gid::Gid gid, bool current_state) {
auto record_accessor = FindEdgeRaw(gid);
if (!record_accessor.Visible(transaction(), current_state))
return std::experimental::nullopt;
return std::nullopt;
return record_accessor;
}
@ -281,9 +280,8 @@ int64_t GraphDbAccessor::VerticesCount(storage::Label label,
int64_t GraphDbAccessor::VerticesCount(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
const {
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper) const {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
const LabelPropertyIndex::Key key(label, property);
DCHECK(db_.storage().label_property_index_.IndexExists(key))
@ -367,10 +365,11 @@ void GraphDbAccessor::DetachRemoveVertex(VertexAccessor &vertex_accessor) {
RemoveVertex(vertex_accessor, false);
}
EdgeAccessor GraphDbAccessor::InsertEdge(
VertexAccessor &from, VertexAccessor &to, storage::EdgeType edge_type,
std::experimental::optional<gid::Gid> requested_gid,
std::experimental::optional<int64_t> cypher_id) {
EdgeAccessor GraphDbAccessor::InsertEdge(VertexAccessor &from,
VertexAccessor &to,
storage::EdgeType edge_type,
std::optional<gid::Gid> requested_gid,
std::optional<int64_t> cypher_id) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
auto edge_address =
@ -384,8 +383,8 @@ EdgeAccessor GraphDbAccessor::InsertEdge(
storage::EdgeAddress GraphDbAccessor::InsertEdgeOnFrom(
VertexAccessor *from, VertexAccessor *to,
const storage::EdgeType &edge_type,
const std::experimental::optional<gid::Gid> &requested_gid,
const std::experimental::optional<int64_t> &cypher_id) {
const std::optional<gid::Gid> &requested_gid,
const std::optional<int64_t> &cypher_id) {
if (from->is_local()) {
auto edge_accessor = InsertOnlyEdge(from->address(), to->address(),
edge_type, requested_gid, cypher_id);
@ -458,9 +457,8 @@ void GraphDbAccessor::InsertEdgeOnTo(VertexAccessor *from, VertexAccessor *to,
EdgeAccessor GraphDbAccessor::InsertOnlyEdge(
storage::VertexAddress from, storage::VertexAddress to,
storage::EdgeType edge_type,
std::experimental::optional<gid::Gid> requested_gid,
std::experimental::optional<int64_t> cypher_id) {
storage::EdgeType edge_type, std::optional<gid::Gid> requested_gid,
std::optional<int64_t> cypher_id) {
CHECK(from.is_local())
<< "`from` address should be local when calling InsertOnlyEdge";
auto gid = db_.storage().edge_generator_.Next(requested_gid);

View File

@ -2,7 +2,7 @@
#pragma once
#include <experimental/optional>
#include <optional>
#include <string>
#include <vector>
@ -101,10 +101,9 @@ class GraphDbAccessor {
*
* @return See above.
*/
VertexAccessor InsertVertex(std::experimental::optional<gid::Gid>
requested_gid = std::experimental::nullopt,
std::experimental::optional<int64_t> cypher_id =
std::experimental::nullopt);
VertexAccessor InsertVertex(
std::optional<gid::Gid> requested_gid = std::nullopt,
std::optional<int64_t> cypher_id = std::nullopt);
/**
* Removes the vertex of the given accessor. If the vertex has any outgoing or
@ -141,8 +140,8 @@ class GraphDbAccessor {
* deletions performed in the current transaction+command are not
* ignored).
*/
std::experimental::optional<VertexAccessor> FindVertexOptional(
gid::Gid gid, bool current_state);
std::optional<VertexAccessor> FindVertexOptional(gid::Gid gid,
bool current_state);
/**
* Obtains the vertex accessor for given id without checking if the
@ -293,11 +292,10 @@ class GraphDbAccessor {
* @return iterable collection of record accessors
* satisfy the bounds and are visible to the current transaction.
*/
auto Vertices(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper,
bool current_state) {
auto Vertices(storage::Label label, storage::Property property,
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper,
bool current_state) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
DCHECK(db_.storage().label_property_index_.IndexExists(
LabelPropertyIndex::Key(label, property)))
@ -333,10 +331,8 @@ class GraphDbAccessor {
*/
EdgeAccessor InsertEdge(VertexAccessor &from, VertexAccessor &to,
storage::EdgeType type,
std::experimental::optional<gid::Gid> requested_gid =
std::experimental::nullopt,
std::experimental::optional<int64_t> cypher_id =
std::experimental::nullopt);
std::optional<gid::Gid> requested_gid = std::nullopt,
std::optional<int64_t> cypher_id = std::nullopt);
/**
* Insert edge into main storage, but don't insert it into from and to
@ -344,13 +340,11 @@ class GraphDbAccessor {
*
* @param cypher_id Take a look under mvcc::VersionList::cypher_id
*/
EdgeAccessor InsertOnlyEdge(storage::VertexAddress from,
storage::VertexAddress to,
storage::EdgeType edge_type,
std::experimental::optional<gid::Gid>
requested_gid = std::experimental::nullopt,
std::experimental::optional<int64_t> cypher_id =
std::experimental::nullopt);
EdgeAccessor InsertOnlyEdge(
storage::VertexAddress from, storage::VertexAddress to,
storage::EdgeType edge_type,
std::optional<gid::Gid> requested_gid = std::nullopt,
std::optional<int64_t> cypher_id = std::nullopt);
/**
* Removes an edge from the graph. Parameters can indicate if the edge should
@ -378,8 +372,8 @@ class GraphDbAccessor {
* deletions performed in the current transaction+command are not
* ignored).
*/
std::experimental::optional<EdgeAccessor> FindEdgeOptional(
gid::Gid gid, bool current_state);
std::optional<EdgeAccessor> FindEdgeOptional(gid::Gid gid,
bool current_state);
/**
* Obtains the edge accessor for the given id without checking if the edge
@ -445,15 +439,14 @@ class GraphDbAccessor {
* @tparam TAccessor Either VertexAccessor or EdgeAccessor
*/
template <typename TAccessor>
std::experimental::optional<TAccessor> Transfer(const TAccessor &accessor) {
if (accessor.db_accessor_ == this)
return std::experimental::make_optional(accessor);
std::optional<TAccessor> Transfer(const TAccessor &accessor) {
if (accessor.db_accessor_ == this) return std::make_optional(accessor);
TAccessor accessor_in_this(accessor.address(), *this);
if (accessor_in_this.current_)
return std::experimental::make_optional(std::move(accessor_in_this));
return std::make_optional(std::move(accessor_in_this));
else
return std::experimental::nullopt;
return std::nullopt;
}
/**
@ -561,9 +554,8 @@ class GraphDbAccessor {
*/
int64_t VerticesCount(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
const;
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper) const;
/**
* Obtains the Label for the label's name.
@ -672,8 +664,8 @@ class GraphDbAccessor {
storage::EdgeAddress InsertEdgeOnFrom(
VertexAccessor *from, VertexAccessor *to,
const storage::EdgeType &edge_type,
const std::experimental::optional<gid::Gid> &requested_gid,
const std::experimental::optional<int64_t> &cypher_id);
const std::optional<gid::Gid> &requested_gid,
const std::optional<int64_t> &cypher_id);
/**
* Set the newly created edge on `to` vertex.

View File

@ -1,6 +1,6 @@
#include "database/single_node/graph_db.hpp"
#include <experimental/optional>
#include <optional>
#include <glog/logging.h>
@ -27,12 +27,11 @@ GraphDb::GraphDb(Config config) : config_(config) {
"current version of Memgraph binary!";
// What we recover.
std::experimental::optional<durability::RecoveryInfo> recovery_info;
std::optional<durability::RecoveryInfo> recovery_info;
durability::RecoveryData recovery_data;
recovery_info = durability::RecoverOnlySnapshot(
config_.durability_directory, this, &recovery_data,
std::experimental::nullopt);
config_.durability_directory, this, &recovery_data, std::nullopt);
// Post-recovery setup and checking.
if (recovery_info) {
@ -108,7 +107,7 @@ GraphDbAccessor GraphDb::Access(tx::TransactionId tx_id) {
}
GraphDbAccessor GraphDb::AccessBlocking(
std::experimental::optional<tx::TransactionId> parent_tx) {
std::optional<tx::TransactionId> parent_tx) {
return GraphDbAccessor(this, parent_tx);
}

View File

@ -2,8 +2,8 @@
#pragma once
#include <atomic>
#include <experimental/optional>
#include <memory>
#include <optional>
#include <vector>
#include "database/single_node/counters.hpp"
@ -94,8 +94,7 @@ class GraphDb {
/// Create a new accessor by starting a new transaction.
GraphDbAccessor Access();
GraphDbAccessor AccessBlocking(
std::experimental::optional<tx::TransactionId> parent_tx =
std::experimental::nullopt);
std::optional<tx::TransactionId> parent_tx = std::nullopt);
/// Create an accessor for a running transaction.
GraphDbAccessor Access(tx::TransactionId);

View File

@ -26,8 +26,8 @@ GraphDbAccessor::GraphDbAccessor(GraphDb *db, tx::TransactionId tx_id)
transaction_(db->tx_engine().RunningTransaction(tx_id)),
transaction_starter_{false} {}
GraphDbAccessor::GraphDbAccessor(
GraphDb *db, std::experimental::optional<tx::TransactionId> parent_tx)
GraphDbAccessor::GraphDbAccessor(GraphDb *db,
std::optional<tx::TransactionId> parent_tx)
: db_(db),
transaction_(db->tx_engine().BeginBlocking(parent_tx)),
transaction_starter_{true} {}
@ -92,7 +92,7 @@ bool GraphDbAccessor::should_abort() const {
durability::WriteAheadLog &GraphDbAccessor::wal() { return db_->wal(); }
VertexAccessor GraphDbAccessor::InsertVertex(
std::experimental::optional<gid::Gid> requested_gid) {
std::optional<gid::Gid> requested_gid) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
auto gid = db_->storage().vertex_generator_.Next(requested_gid);
@ -108,12 +108,12 @@ VertexAccessor GraphDbAccessor::InsertVertex(
return va;
}
std::experimental::optional<VertexAccessor> GraphDbAccessor::FindVertexOptional(
std::optional<VertexAccessor> GraphDbAccessor::FindVertexOptional(
gid::Gid gid, bool current_state) {
VertexAccessor record_accessor(db_->storage().LocalAddress<Vertex>(gid),
*this);
if (!record_accessor.Visible(transaction(), current_state))
return std::experimental::nullopt;
return std::nullopt;
return record_accessor;
}
@ -123,11 +123,11 @@ VertexAccessor GraphDbAccessor::FindVertex(gid::Gid gid, bool current_state) {
return *found;
}
std::experimental::optional<EdgeAccessor> GraphDbAccessor::FindEdgeOptional(
std::optional<EdgeAccessor> GraphDbAccessor::FindEdgeOptional(
gid::Gid gid, bool current_state) {
EdgeAccessor record_accessor(db_->storage().LocalAddress<Edge>(gid), *this);
if (!record_accessor.Visible(transaction(), current_state))
return std::experimental::nullopt;
return std::nullopt;
return record_accessor;
}
@ -150,8 +150,7 @@ void GraphDbAccessor::BuildIndex(storage::Label label,
}
try {
auto dba =
db_->AccessBlocking(std::experimental::make_optional(transaction_->id_));
auto dba = db_->AccessBlocking(std::make_optional(transaction_->id_));
dba.PopulateIndex(key);
dba.EnableIndex(key);
@ -193,8 +192,7 @@ void GraphDbAccessor::DeleteIndex(storage::Label label,
LabelPropertyIndex::Key key(label, property);
try {
auto dba =
db_->AccessBlocking(std::experimental::make_optional(transaction_->id_));
auto dba = db_->AccessBlocking(std::make_optional(transaction_->id_));
db_->storage().label_property_index_.DeleteIndex(key);
dba.wal().Emplace(database::StateDelta::DropIndex(
@ -210,8 +208,7 @@ void GraphDbAccessor::DeleteIndex(storage::Label label,
void GraphDbAccessor::BuildUniqueConstraint(storage::Label label,
storage::Property property) {
try {
auto dba =
db_->AccessBlocking(std::experimental::make_optional(transaction().id_));
auto dba = db_->AccessBlocking(std::make_optional(transaction().id_));
if (!db_->storage().unique_label_property_constraints_.AddConstraint(
label, property, dba.transaction())) {
// Already exists
@ -250,8 +247,7 @@ void GraphDbAccessor::BuildUniqueConstraint(storage::Label label,
void GraphDbAccessor::DeleteUniqueConstraint(storage::Label label,
storage::Property property) {
try {
auto dba =
db_->AccessBlocking(std::experimental::make_optional(transaction().id_));
auto dba = db_->AccessBlocking(std::make_optional(transaction().id_));
if (!db_->storage().unique_label_property_constraints_.RemoveConstraint(
label, property)) {
@ -339,8 +335,7 @@ void GraphDbAccessor::UpdateOnRemoveProperty(
void GraphDbAccessor::BuildExistenceConstraint(
storage::Label label, const std::vector<storage::Property> &properties) {
auto dba =
db_->AccessBlocking(std::experimental::make_optional(transaction().id_));
auto dba = db_->AccessBlocking(std::make_optional(transaction().id_));
storage::constraints::ExistenceRule rule{label, properties};
for (auto v : dba.Vertices(false)) {
@ -368,8 +363,7 @@ void GraphDbAccessor::BuildExistenceConstraint(
void GraphDbAccessor::DeleteExistenceConstraint(
storage::Label label, const std::vector<storage::Property> &properties) {
auto dba =
db_->AccessBlocking(std::experimental::make_optional(transaction().id_));
auto dba = db_->AccessBlocking(std::make_optional(transaction().id_));
storage::constraints::ExistenceRule rule{label, properties};
if (!db_->storage().existence_constraints_.RemoveConstraint(rule)) {
// Nothing was deleted
@ -431,9 +425,8 @@ int64_t GraphDbAccessor::VerticesCount(storage::Label label,
int64_t GraphDbAccessor::VerticesCount(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
const {
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper) const {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
const LabelPropertyIndex::Key key(label, property);
DCHECK(db_->storage().label_property_index_.IndexExists(key))
@ -508,7 +501,7 @@ void GraphDbAccessor::DetachRemoveVertex(VertexAccessor &vertex_accessor) {
EdgeAccessor GraphDbAccessor::InsertEdge(
VertexAccessor &from, VertexAccessor &to, storage::EdgeType edge_type,
std::experimental::optional<gid::Gid> requested_gid) {
std::optional<gid::Gid> requested_gid) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
auto gid = db_->storage().edge_generator_.Next(requested_gid);
auto edge_vlist = new mvcc::VersionList<Edge>(

View File

@ -2,10 +2,10 @@
#pragma once
#include <experimental/optional>
#include <map>
#include <optional>
#include <string>
#include <vector>
#include <map>
#include <glog/logging.h>
#include <cppitertools/filter.hpp>
@ -46,8 +46,7 @@ class GraphDbAccessor {
/// Creates an accessor for a running transaction.
GraphDbAccessor(GraphDb *db, tx::TransactionId tx_id);
GraphDbAccessor(GraphDb *db,
std::experimental::optional<tx::TransactionId> parent_tx);
GraphDbAccessor(GraphDb *db, std::optional<tx::TransactionId> parent_tx);
public:
~GraphDbAccessor();
@ -74,8 +73,8 @@ class GraphDbAccessor {
*
* @return See above.
*/
VertexAccessor InsertVertex(std::experimental::optional<gid::Gid>
requested_gid = std::experimental::nullopt);
VertexAccessor InsertVertex(
std::optional<gid::Gid> requested_gid = std::nullopt);
/**
* Removes the vertex of the given accessor. If the vertex has any outgoing or
@ -111,8 +110,8 @@ class GraphDbAccessor {
* deletions performed in the current transaction+command are not
* ignored).
*/
std::experimental::optional<VertexAccessor> FindVertexOptional(
gid::Gid gid, bool current_state);
std::optional<VertexAccessor> FindVertexOptional(gid::Gid gid,
bool current_state);
/**
* Obtains the vertex for the given ID. If there is no vertex for the given
@ -257,11 +256,10 @@ class GraphDbAccessor {
* @return iterable collection of record accessors
* satisfy the bounds and are visible to the current transaction.
*/
auto Vertices(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper,
bool current_state) {
auto Vertices(storage::Label label, storage::Property property,
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper,
bool current_state) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
DCHECK(db_->storage().label_property_index_.IndexExists(
LabelPropertyIndex::Key(label, property)))
@ -296,8 +294,7 @@ class GraphDbAccessor {
*/
EdgeAccessor InsertEdge(VertexAccessor &from, VertexAccessor &to,
storage::EdgeType type,
std::experimental::optional<gid::Gid> requested_gid =
std::experimental::nullopt);
std::optional<gid::Gid> requested_gid = std::nullopt);
/**
* Removes an edge from the graph. Parameters can indicate if the edge should
@ -325,8 +322,8 @@ class GraphDbAccessor {
* deletions performed in the current transaction+command are not
* ignored).
*/
std::experimental::optional<EdgeAccessor> FindEdgeOptional(
gid::Gid gid, bool current_state);
std::optional<EdgeAccessor> FindEdgeOptional(gid::Gid gid,
bool current_state);
/**
* Obtains the edge for the given ID. If there is no edge for the given
@ -386,15 +383,14 @@ class GraphDbAccessor {
* @tparam TAccessor Either VertexAccessor or EdgeAccessor
*/
template <typename TAccessor>
std::experimental::optional<TAccessor> Transfer(const TAccessor &accessor) {
if (accessor.db_accessor_ == this)
return std::experimental::make_optional(accessor);
std::optional<TAccessor> Transfer(const TAccessor &accessor) {
if (accessor.db_accessor_ == this) return std::make_optional(accessor);
TAccessor accessor_in_this(accessor.address(), *this);
if (accessor_in_this.current_)
return std::experimental::make_optional(std::move(accessor_in_this));
return std::make_optional(std::move(accessor_in_this));
else
return std::experimental::nullopt;
return std::nullopt;
}
/**
@ -554,9 +550,8 @@ class GraphDbAccessor {
*/
int64_t VerticesCount(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
const;
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper) const;
/**
* Obtains the Label for the label's name.

View File

@ -1,6 +1,6 @@
#include "database/single_node_ha/graph_db.hpp"
#include <experimental/optional>
#include <optional>
#include <glog/logging.h>
@ -60,7 +60,7 @@ GraphDbAccessor GraphDb::Access(tx::TransactionId tx_id) {
}
GraphDbAccessor GraphDb::AccessBlocking(
std::experimental::optional<tx::TransactionId> parent_tx) {
std::optional<tx::TransactionId> parent_tx) {
return GraphDbAccessor(this, parent_tx);
}

View File

@ -2,8 +2,8 @@
#pragma once
#include <atomic>
#include <experimental/optional>
#include <memory>
#include <optional>
#include <vector>
#include "database/single_node_ha/config.hpp"
@ -77,8 +77,7 @@ class GraphDb {
/// Create a new accessor by starting a new transaction.
GraphDbAccessor Access();
GraphDbAccessor AccessBlocking(
std::experimental::optional<tx::TransactionId> parent_tx);
GraphDbAccessor AccessBlocking(std::optional<tx::TransactionId> parent_tx);
/// Create an accessor for a running transaction.
GraphDbAccessor Access(tx::TransactionId);

View File

@ -26,8 +26,8 @@ GraphDbAccessor::GraphDbAccessor(GraphDb *db, tx::TransactionId tx_id)
transaction_(db->tx_engine().RunningTransaction(tx_id)),
transaction_starter_{false} {}
GraphDbAccessor::GraphDbAccessor(
GraphDb *db, std::experimental::optional<tx::TransactionId> parent_tx)
GraphDbAccessor::GraphDbAccessor(GraphDb *db,
std::optional<tx::TransactionId> parent_tx)
: db_(db),
transaction_(db->tx_engine().BeginBlocking(parent_tx)),
transaction_starter_{true} {}
@ -92,7 +92,7 @@ bool GraphDbAccessor::should_abort() const {
raft::RaftInterface *GraphDbAccessor::raft() { return db_->raft(); }
VertexAccessor GraphDbAccessor::InsertVertex(
std::experimental::optional<gid::Gid> requested_gid) {
std::optional<gid::Gid> requested_gid) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
auto gid = db_->storage().vertex_generator_.Next(requested_gid);
@ -108,12 +108,12 @@ VertexAccessor GraphDbAccessor::InsertVertex(
return va;
}
std::experimental::optional<VertexAccessor> GraphDbAccessor::FindVertexOptional(
std::optional<VertexAccessor> GraphDbAccessor::FindVertexOptional(
gid::Gid gid, bool current_state) {
VertexAccessor record_accessor(db_->storage().LocalAddress<Vertex>(gid),
*this);
if (!record_accessor.Visible(transaction(), current_state))
return std::experimental::nullopt;
return std::nullopt;
return record_accessor;
}
@ -123,11 +123,11 @@ VertexAccessor GraphDbAccessor::FindVertex(gid::Gid gid, bool current_state) {
return *found;
}
std::experimental::optional<EdgeAccessor> GraphDbAccessor::FindEdgeOptional(
std::optional<EdgeAccessor> GraphDbAccessor::FindEdgeOptional(
gid::Gid gid, bool current_state) {
EdgeAccessor record_accessor(db_->storage().LocalAddress<Edge>(gid), *this);
if (!record_accessor.Visible(transaction(), current_state))
return std::experimental::nullopt;
return std::nullopt;
return record_accessor;
}
@ -150,8 +150,7 @@ void GraphDbAccessor::BuildIndex(storage::Label label,
}
try {
auto dba =
db_->AccessBlocking(std::experimental::make_optional(transaction_->id_));
auto dba = db_->AccessBlocking(std::make_optional(transaction_->id_));
dba.PopulateIndex(key);
dba.EnableIndex(key);
@ -192,8 +191,7 @@ void GraphDbAccessor::DeleteIndex(storage::Label label,
LabelPropertyIndex::Key key(label, property);
try {
auto dba =
db_->AccessBlocking(std::experimental::make_optional(transaction_->id_));
auto dba = db_->AccessBlocking(std::make_optional(transaction_->id_));
db_->storage().label_property_index_.DeleteIndex(key);
dba.raft()->Emplace(database::StateDelta::DropIndex(
@ -264,9 +262,8 @@ int64_t GraphDbAccessor::VerticesCount(storage::Label label,
int64_t GraphDbAccessor::VerticesCount(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
const {
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper) const {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
const LabelPropertyIndex::Key key(label, property);
DCHECK(db_->storage().label_property_index_.IndexExists(key))
@ -341,7 +338,7 @@ void GraphDbAccessor::DetachRemoveVertex(VertexAccessor &vertex_accessor) {
EdgeAccessor GraphDbAccessor::InsertEdge(
VertexAccessor &from, VertexAccessor &to, storage::EdgeType edge_type,
std::experimental::optional<gid::Gid> requested_gid) {
std::optional<gid::Gid> requested_gid) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
auto gid = db_->storage().edge_generator_.Next(requested_gid);
auto edge_vlist = new mvcc::VersionList<Edge>(

View File

@ -2,10 +2,10 @@
#pragma once
#include <experimental/optional>
#include <map>
#include <optional>
#include <string>
#include <vector>
#include <map>
#include <glog/logging.h>
#include <cppitertools/filter.hpp>
@ -68,8 +68,7 @@ class GraphDbAccessor {
/// Creates an accessor for a running transaction.
GraphDbAccessor(GraphDb *db, tx::TransactionId tx_id);
GraphDbAccessor(GraphDb *db,
std::experimental::optional<tx::TransactionId> parent_tx);
GraphDbAccessor(GraphDb *db, std::optional<tx::TransactionId> parent_tx);
public:
~GraphDbAccessor();
@ -96,8 +95,8 @@ class GraphDbAccessor {
*
* @return See above.
*/
VertexAccessor InsertVertex(std::experimental::optional<gid::Gid>
requested_gid = std::experimental::nullopt);
VertexAccessor InsertVertex(
std::optional<gid::Gid> requested_gid = std::nullopt);
/**
* Removes the vertex of the given accessor. If the vertex has any outgoing or
@ -133,8 +132,8 @@ class GraphDbAccessor {
* deletions performed in the current transaction+command are not
* ignored).
*/
std::experimental::optional<VertexAccessor> FindVertexOptional(
gid::Gid gid, bool current_state);
std::optional<VertexAccessor> FindVertexOptional(gid::Gid gid,
bool current_state);
/**
* Obtains the vertex for the given ID. If there is no vertex for the given
@ -273,11 +272,10 @@ class GraphDbAccessor {
* @return iterable collection of record accessors
* satisfy the bounds and are visible to the current transaction.
*/
auto Vertices(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper,
bool current_state) {
auto Vertices(storage::Label label, storage::Property property,
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper,
bool current_state) {
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
DCHECK(db_->storage().label_property_index_.IndexExists(
LabelPropertyIndex::Key(label, property)))
@ -310,8 +308,7 @@ class GraphDbAccessor {
*/
EdgeAccessor InsertEdge(VertexAccessor &from, VertexAccessor &to,
storage::EdgeType type,
std::experimental::optional<gid::Gid> requested_gid =
std::experimental::nullopt);
std::optional<gid::Gid> requested_gid = std::nullopt);
/**
* Removes an edge from the graph. Parameters can indicate if the edge should
@ -339,8 +336,8 @@ class GraphDbAccessor {
* deletions performed in the current transaction+command are not
* ignored).
*/
std::experimental::optional<EdgeAccessor> FindEdgeOptional(
gid::Gid gid, bool current_state);
std::optional<EdgeAccessor> FindEdgeOptional(gid::Gid gid,
bool current_state);
/**
* Obtains the edge for the given ID. If there is no edge for the given
@ -398,15 +395,14 @@ class GraphDbAccessor {
* @tparam TAccessor Either VertexAccessor or EdgeAccessor
*/
template <typename TAccessor>
std::experimental::optional<TAccessor> Transfer(const TAccessor &accessor) {
if (accessor.db_accessor_ == this)
return std::experimental::make_optional(accessor);
std::optional<TAccessor> Transfer(const TAccessor &accessor) {
if (accessor.db_accessor_ == this) return std::make_optional(accessor);
TAccessor accessor_in_this(accessor.address(), *this);
if (accessor_in_this.current_)
return std::experimental::make_optional(std::move(accessor_in_this));
return std::make_optional(std::move(accessor_in_this));
else
return std::experimental::nullopt;
return std::nullopt;
}
/**
@ -514,9 +510,8 @@ class GraphDbAccessor {
*/
int64_t VerticesCount(
storage::Label label, storage::Property property,
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
const;
const std::optional<utils::Bound<PropertyValue>> lower,
const std::optional<utils::Bound<PropertyValue>> upper) const;
/**
* Obtains the Label for the label's name.

View File

@ -68,7 +68,7 @@ void BfsRpcClients::ResetSubcursors(
}
}
std::experimental::optional<VertexAccessor> BfsRpcClients::Pull(
std::optional<VertexAccessor> BfsRpcClients::Pull(
int16_t worker_id, int64_t subcursor_id, database::GraphDbAccessor *dba) {
if (worker_id == db_->WorkerId()) {
return subcursor_storage_->Get(subcursor_id)->Pull();

View File

@ -32,14 +32,15 @@ class BfsRpcClients {
const query::SymbolTable &symbol_table,
const query::EvaluationContext &evaluation_context);
void RegisterSubcursors(
const std::unordered_map<int16_t, int64_t> &subcursor_ids);
void ResetSubcursors(
const std::unordered_map<int16_t, int64_t> &subcursor_ids);
std::experimental::optional<VertexAccessor> Pull(
int16_t worker_id, int64_t subcursor_id, database::GraphDbAccessor *dba);
std::optional<VertexAccessor> Pull(int16_t worker_id, int64_t subcursor_id,
database::GraphDbAccessor *dba);
bool ExpandLevel(const std::unordered_map<int16_t, int64_t> &subcursor_ids);

View File

@ -107,7 +107,7 @@ cpp<#
(lcp:define-rpc subcursor-pull
(:request ((member :int64_t)))
(:response
((vertex "std::experimental::optional<VertexAccessor>"
((vertex "std::optional<VertexAccessor>"
:slk-save (lambda (member)
#>cpp
slk::Save(static_cast<bool>(self.${member}), builder);
@ -161,10 +161,10 @@ cpp<#
(lcp:define-rpc reconstruct-path
(:request
((subcursor-id :int64_t)
(vertex "std::experimental::optional<storage::VertexAddress>"
(vertex "std::optional<storage::VertexAddress>"
:capnp-save (lcp:capnp-save-optional "storage::capnp::Address" "storage::VertexAddress")
:capnp-load (lcp:capnp-load-optional "storage::capnp::Address" "storage::VertexAddress"))
(edge "std::experimental::optional<storage::EdgeAddress>"
(edge "std::optional<storage::EdgeAddress>"
:capnp-save (lcp:capnp-save-optional "storage::capnp::Address" "storage::EdgeAddress")
:capnp-load (lcp:capnp-load-optional "storage::capnp::Address" "storage::EdgeAddress")))
(:public
@ -176,11 +176,11 @@ cpp<#
ReconstructPathReq(int64_t subcursor_id, storage::VertexAddress vertex)
: subcursor_id(subcursor_id),
vertex(vertex),
edge(std::experimental::nullopt) {}
edge(std::nullopt) {}
ReconstructPathReq(int64_t subcursor_id, storage::EdgeAddress edge)
: subcursor_id(subcursor_id),
vertex(std::experimental::nullopt),
vertex(std::nullopt),
edge(edge) {}
cpp<#))
(:response
@ -213,10 +213,10 @@ cpp<#
"[dba, data_manager](const auto &reader) {
return storage::LoadEdgeAccessor(reader, dba, data_manager);
}"))
(next-vertex "std::experimental::optional<storage::VertexAddress>"
(next-vertex "std::optional<storage::VertexAddress>"
:capnp-save (lcp:capnp-save-optional "storage::capnp::Address" "storage::VertexAddress")
:capnp-load (lcp:capnp-load-optional "storage::capnp::Address" "storage::VertexAddress"))
(next-edge "std::experimental::optional<storage::EdgeAddress>"
(next-edge "std::optional<storage::EdgeAddress>"
:capnp-save (lcp:capnp-save-optional "storage::capnp::Address" "storage::EdgeAddress")
:capnp-load (lcp:capnp-load-optional "storage::capnp::Address" "storage::EdgeAddress")))
(:serialize (:slk :save-args '((worker-id :int16_t))
@ -234,8 +234,8 @@ cpp<#
ReconstructPathRes(
const std::vector<EdgeAccessor> &edges,
std::experimental::optional<storage::VertexAddress> next_vertex,
std::experimental::optional<storage::EdgeAddress> next_edge)
std::optional<storage::VertexAddress> next_vertex,
std::optional<storage::EdgeAddress> next_edge)
: edges(edges), next_vertex(std::move(next_vertex)), next_edge(std::move(next_edge)) {
CHECK(!static_cast<bool>(next_vertex) || !static_cast<bool>(next_edge))
<< "At most one of `next_vertex` and `next_edge` should be set";

View File

@ -45,7 +45,7 @@ void ExpandBfsSubcursor::Reset() {
void ExpandBfsSubcursor::SetSource(storage::VertexAddress source_address) {
Reset();
auto source = VertexAccessor(source_address, *dba_);
processed_.emplace(source, std::experimental::nullopt);
processed_.emplace(source, std::nullopt);
ExpandFromVertex(source);
}
@ -69,11 +69,10 @@ bool ExpandBfsSubcursor::ExpandLevel() {
return expanded;
}
std::experimental::optional<VertexAccessor> ExpandBfsSubcursor::Pull() {
std::optional<VertexAccessor> ExpandBfsSubcursor::Pull() {
return pull_index_ < to_visit_next_.size()
? std::experimental::make_optional(
to_visit_next_[pull_index_++].second)
: std::experimental::nullopt;
? std::make_optional(to_visit_next_[pull_index_++].second)
: std::nullopt;
}
bool ExpandBfsSubcursor::ExpandToLocalVertex(storage::EdgeAddress edge,

View File

@ -26,8 +26,8 @@ class BfsRpcClients;
/// information necessary to continue path reconstruction on another worker.
struct PathSegment {
std::vector<EdgeAccessor> edges;
std::experimental::optional<storage::VertexAddress> next_vertex;
std::experimental::optional<storage::EdgeAddress> next_edge;
std::optional<storage::VertexAddress> next_vertex;
std::optional<storage::EdgeAddress> next_edge;
};
/// Class storing the worker-local state of distributed BFS traversal. For each
@ -69,7 +69,7 @@ class ExpandBfsSubcursor {
bool ExpandLevel();
/// Pulls the next vertex in the current BFS frontier, if there is one.
std::experimental::optional<VertexAccessor> Pull();
std::optional<VertexAccessor> Pull();
/// Expands to a local vertex, if it wasn't already visited. Returns true if
/// expansion was successful.
@ -133,8 +133,7 @@ class ExpandBfsSubcursor {
/// List of visited vertices and their incoming edges. Local address is stored
/// for local edges, global address for remote edges.
std::unordered_map<VertexAccessor,
std::experimental::optional<storage::EdgeAddress>>
std::unordered_map<VertexAccessor, std::optional<storage::EdgeAddress>>
processed_;
/// List of vertices at the current expansion level.

View File

@ -1,6 +1,6 @@
#include "distributed/cluster_discovery_master.hpp"
#include <experimental/filesystem>
#include <filesystem>
#include "distributed/coordination_rpc_messages.hpp"
#include "io/network/endpoint.hpp"
@ -28,7 +28,7 @@ ClusterDiscoveryMaster::ClusterDiscoveryMaster(
// Create and find out what is our durability directory.
utils::EnsureDirOrDie(durability_directory_);
auto full_durability_directory =
std::experimental::filesystem::canonical(durability_directory_);
std::filesystem::canonical(durability_directory_);
// Check whether the worker is running on the same host (detected when it
// connects to us over the loopback interface) and whether it has the same

View File

@ -1,6 +1,6 @@
#include "distributed/cluster_discovery_worker.hpp"
#include <experimental/filesystem>
#include <filesystem>
#include "distributed/coordination_rpc_messages.hpp"
#include "utils/file.hpp"
@ -24,7 +24,7 @@ void ClusterDiscoveryWorker::RegisterWorker(
// Create and find out what is our durability directory.
utils::EnsureDirOrDie(durability_directory);
auto full_durability_directory =
std::experimental::filesystem::canonical(durability_directory);
std::filesystem::canonical(durability_directory);
// Register to the master.
try {
@ -49,8 +49,7 @@ void ClusterDiscoveryWorker::RegisterWorker(
}
void ClusterDiscoveryWorker::NotifyWorkerRecovered(
const std::experimental::optional<durability::RecoveryInfo>
&recovery_info) {
const std::optional<durability::RecoveryInfo> &recovery_info) {
CHECK(worker_id_ >= 0)
<< "Workers id is not yet assigned, preform registration before "
"notifying that the recovery finished";

View File

@ -1,6 +1,6 @@
#pragma once
#include <experimental/optional>
#include <optional>
#include "communication/rpc/client_pool.hpp"
#include "communication/rpc/server.hpp"
@ -34,8 +34,7 @@ class ClusterDiscoveryWorker final {
* worker was already registered with master.
*/
void NotifyWorkerRecovered(
const std::experimental::optional<durability::RecoveryInfo>
&recovery_info);
const std::optional<durability::RecoveryInfo> &recovery_info);
/** Returns the snapshot that should be recovered on workers. Valid only after
* registration. */
@ -45,7 +44,7 @@ class ClusterDiscoveryWorker final {
int worker_id_{-1};
distributed::WorkerCoordination *coordination_;
communication::rpc::ClientPool *client_pool_;
std::experimental::optional<std::pair<int64_t, tx::TransactionId>> snapshot_to_recover_;
std::optional<std::pair<int64_t, tx::TransactionId>> snapshot_to_recover_;
};
} // namespace distributed

View File

@ -56,15 +56,15 @@ bool MasterCoordination::RegisterWorker(int desired_worker_id,
}
void MasterCoordination::WorkerRecoveredSnapshot(
int worker_id, const std::experimental::optional<durability::RecoveryInfo>
&recovery_info) {
int worker_id,
const std::optional<durability::RecoveryInfo> &recovery_info) {
CHECK(recovered_workers_.insert(std::make_pair(worker_id, recovery_info))
.second)
<< "Worker already notified about finishing recovery";
}
void MasterCoordination::SetRecoveredSnapshot(
std::experimental::optional<std::pair<int64_t, tx::TransactionId>>
std::optional<std::pair<int64_t, tx::TransactionId>>
recovered_snapshot_tx) {
std::lock_guard<std::mutex> guard(master_lock_);
recovery_done_ = true;
@ -75,7 +75,7 @@ int MasterCoordination::CountRecoveredWorkers() const {
return recovered_workers_.size();
}
std::experimental::optional<std::pair<int64_t, tx::TransactionId>>
std::optional<std::pair<int64_t, tx::TransactionId>>
MasterCoordination::RecoveredSnapshotTx() const {
std::lock_guard<std::mutex> guard(master_lock_);
CHECK(recovery_done_) << "Recovered snapshot requested before it's available";

View File

@ -1,9 +1,9 @@
#pragma once
#include <atomic>
#include <experimental/optional>
#include <functional>
#include <mutex>
#include <optional>
#include <set>
#include <unordered_map>
@ -44,16 +44,15 @@ class MasterCoordination final : public Coordination {
* recovered workers alongside with its recovery_info.
*/
void WorkerRecoveredSnapshot(
int worker_id, const std::experimental::optional<durability::RecoveryInfo>
&recovery_info);
int worker_id,
const std::optional<durability::RecoveryInfo> &recovery_info);
/// Sets the recovery info. nullopt indicates nothing was recovered.
void SetRecoveredSnapshot(
std::experimental::optional<std::pair<int64_t, tx::TransactionId>>
recovered_snapshot);
std::optional<std::pair<int64_t, tx::TransactionId>> recovered_snapshot);
std::experimental::optional<std::pair<int64_t, tx::TransactionId>>
RecoveredSnapshotTx() const;
std::optional<std::pair<int64_t, tx::TransactionId>> RecoveredSnapshotTx()
const;
int CountRecoveredWorkers() const;
@ -89,11 +88,9 @@ class MasterCoordination final : public Coordination {
// Indicates if the recovery phase is done.
bool recovery_done_{false};
// Set of workers that finished sucesfully recovering snapshot
std::map<int, std::experimental::optional<durability::RecoveryInfo>>
recovered_workers_;
std::map<int, std::optional<durability::RecoveryInfo>> recovered_workers_;
// If nullopt nothing was recovered.
std::experimental::optional<std::pair<int64_t, tx::TransactionId>>
recovered_snapshot_tx_;
std::optional<std::pair<int64_t, tx::TransactionId>> recovered_snapshot_tx_;
// Scheduler that is used to periodically ping all registered workers.
utils::Scheduler scheduler_;

View File

@ -1,7 +1,7 @@
#>cpp
#pragma once
#include <experimental/optional>
#include <optional>
#include <unordered_map>
#include "communication/rpc/messages.hpp"
@ -28,7 +28,7 @@ cpp<#
(:response
((registration-successful :bool)
(durability-error :bool)
(snapshot-to-recover "std::experimental::optional<std::pair<int64_t, tx::TransactionId>>"
(snapshot-to-recover "std::optional<std::pair<int64_t, tx::TransactionId>>"
:capnp-type "Utils.Optional(Utils.Pair(Utils.BoxUInt64, Utils.BoxUInt64))"
:capnp-save
(lambda (builder member capnp-name)
@ -92,7 +92,7 @@ cpp<#
(lcp:define-rpc notify-worker-recovered
(:request
((worker-id :int16_t)
(recovery-info "std::experimental::optional<durability::RecoveryInfo>"
(recovery-info "std::optional<durability::RecoveryInfo>"
:capnp-type "Utils.Optional(Dur.RecoveryInfo)")))
(:response ()))

View File

@ -35,7 +35,7 @@ void VertexMigrator::MigrateVertex(VertexAccessor &vertex, int destination) {
// machine owns the edge.
auto new_out_edge =
dba_->InsertEdge(relocated_vertex, to, out_edge.EdgeType(),
std::experimental::nullopt, out_edge.CypherId());
std::nullopt, out_edge.CypherId());
for (auto prop : get_props(out_edge)) {
new_out_edge.PropsSet(prop.first, prop.second);
}
@ -51,7 +51,7 @@ void VertexMigrator::MigrateVertex(VertexAccessor &vertex, int destination) {
// doesn't own the edge.
auto new_in_edge =
dba_->InsertEdge(from, relocated_vertex, in_edge.EdgeType(),
std::experimental::nullopt, in_edge.CypherId());
std::nullopt, in_edge.CypherId());
for (auto prop : get_props(in_edge)) {
new_in_edge.PropsSet(prop.first, prop.second);
}

View File

@ -36,7 +36,7 @@ CreatedVertexInfo UpdatesRpcClients::CreateVertex(
int worker_id, tx::TransactionId tx_id,
const std::vector<storage::Label> &labels,
const std::unordered_map<storage::Property, PropertyValue> &properties,
std::experimental::optional<int64_t> cypher_id) {
std::optional<int64_t> cypher_id) {
auto res = coordination_->GetClientPool(worker_id)->Call<CreateVertexRpc>(
CreateVertexReqData{tx_id, labels, properties, cypher_id});
CHECK(res.member.result == UpdateResult::DONE)
@ -44,10 +44,10 @@ CreatedVertexInfo UpdatesRpcClients::CreateVertex(
return CreatedVertexInfo(res.member.cypher_id, res.member.gid);
}
CreatedEdgeInfo UpdatesRpcClients::CreateEdge(int this_worker_id,
tx::TransactionId tx_id, VertexAccessor &from, VertexAccessor &to,
storage::EdgeType edge_type,
std::experimental::optional<int64_t> cypher_id) {
CreatedEdgeInfo UpdatesRpcClients::CreateEdge(
int this_worker_id, tx::TransactionId tx_id, VertexAccessor &from,
VertexAccessor &to, storage::EdgeType edge_type,
std::optional<int64_t> cypher_id) {
CHECK(from.address().is_remote()) << "In CreateEdge `from` must be remote";
int from_worker = from.address().worker_id();
auto res =

View File

@ -32,8 +32,7 @@ class UpdatesRpcClients {
int worker_id, tx::TransactionId tx_id,
const std::vector<storage::Label> &labels,
const std::unordered_map<storage::Property, PropertyValue> &properties,
std::experimental::optional<int64_t> cypher_id =
std::experimental::nullopt);
std::optional<int64_t> cypher_id = std::nullopt);
/// Creates an edge on the given worker and returns it's address. If the `to`
/// vertex is on the same worker as `from`, then all remote CRUD will be
@ -43,8 +42,7 @@ class UpdatesRpcClients {
CreatedEdgeInfo CreateEdge(int this_worker_id, tx::TransactionId tx_id,
VertexAccessor &from, VertexAccessor &to,
storage::EdgeType edge_type,
std::experimental::optional<int64_t> cypher_id =
std::experimental::nullopt);
std::optional<int64_t> cypher_id = std::nullopt);
// TODO (buda): Another machine in the cluster is asked to create an edge.
// cypher_id should be generated in that process. It probably doesn't make
// sense to have optional cypher id here. Maybe for the recovery purposes.

View File

@ -88,7 +88,7 @@ cpp<#
return std::make_pair(prop, value);
});
cpp<#))
(cypher-id "std::experimental::optional<int64_t>"
(cypher-id "std::optional<int64_t>"
:capnp-type "Utils.Optional(Utils.BoxInt64)"
:capnp-save
(lambda (builder member capnp-name)
@ -120,7 +120,7 @@ cpp<#
(to "storage::VertexAddress")
(edge-type "storage::EdgeType")
(tx-id "tx::TransactionId")
(cypher-id "std::experimental::optional<int64_t>"
(cypher-id "std::optional<int64_t>"
:capnp-type "Utils.Optional(Utils.BoxInt64)"
:capnp-save
(lambda (builder member capnp-name)

View File

@ -62,9 +62,8 @@ template <typename TRecordAccessor>
CreatedInfo UpdatesRpcServer::TransactionUpdates<TRecordAccessor>::CreateVertex(
const std::vector<storage::Label> &labels,
const std::unordered_map<storage::Property, PropertyValue> &properties,
std::experimental::optional<int64_t> cypher_id) {
auto result =
db_accessor_->InsertVertex(std::experimental::nullopt, cypher_id);
std::optional<int64_t> cypher_id) {
auto result = db_accessor_->InsertVertex(std::nullopt, cypher_id);
for (auto &label : labels) result.add_label(label);
for (auto &kv : properties) result.PropsSet(kv.first, kv.second);
std::lock_guard<utils::SpinLock> guard{lock_};
@ -76,13 +75,13 @@ CreatedInfo UpdatesRpcServer::TransactionUpdates<TRecordAccessor>::CreateVertex(
template <typename TRecordAccessor>
CreatedInfo UpdatesRpcServer::TransactionUpdates<TRecordAccessor>::CreateEdge(
gid::Gid from, storage::VertexAddress to, storage::EdgeType edge_type,
int worker_id, std::experimental::optional<int64_t> cypher_id) {
int worker_id, std::optional<int64_t> cypher_id) {
auto &db = db_accessor_->db();
auto from_addr = db.storage().LocalizedAddressIfPossible(
storage::VertexAddress(from, worker_id));
auto to_addr = db.storage().LocalizedAddressIfPossible(to);
auto edge = db_accessor_->InsertOnlyEdge(
from_addr, to_addr, edge_type, std::experimental::nullopt, cypher_id);
auto edge = db_accessor_->InsertOnlyEdge(from_addr, to_addr, edge_type,
std::nullopt, cypher_id);
std::lock_guard<utils::SpinLock> guard{lock_};
deltas_.emplace(edge.gid(),
std::make_pair(edge, std::vector<DeltaPair>{}));

View File

@ -58,15 +58,13 @@ class UpdatesRpcServer {
CreatedInfo CreateVertex(
const std::vector<storage::Label> &labels,
const std::unordered_map<storage::Property, PropertyValue> &properties,
std::experimental::optional<int64_t> cypher_id =
std::experimental::nullopt);
std::optional<int64_t> cypher_id = std::nullopt);
/// Creates a new edge and returns it's cypher_id and gid. Does not update
/// vertices at the end of the edge.
CreatedInfo CreateEdge(gid::Gid from, storage::VertexAddress to,
storage::EdgeType edge_type, int worker_id,
std::experimental::optional<int64_t> cypher_id =
std::experimental::nullopt);
std::optional<int64_t> cypher_id = std::nullopt);
/// Applies all the deltas on the record.
UpdateResult Apply();

View File

@ -1,7 +1,7 @@
#include "durability/distributed/paths.hpp"
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include <string>
#include "glog/logging.h"
@ -12,11 +12,11 @@
namespace durability {
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
std::experimental::optional<tx::TransactionId> TransactionIdFromWalFilename(
std::optional<tx::TransactionId> TransactionIdFromWalFilename(
const std::string &name) {
auto nullopt = std::experimental::nullopt;
auto nullopt = std::nullopt;
// Get the max_transaction_id from the file name that has format
// "XXXXX__max_transaction_<MAX_TRANS_ID>_worker_<Worker_ID>"
auto file_name_split = utils::RSplit(name, "__", 1);
@ -56,9 +56,9 @@ fs::path MakeSnapshotPath(const fs::path &durability_dir, const int worker_id,
/// Generates a file path for a write-ahead log file. If given a transaction ID
/// the file name will contain it. Otherwise the file path is for the "current"
/// WAL file for which the max tx id is still unknown.
fs::path WalFilenameForTransactionId(
const std::experimental::filesystem::path &wal_dir, int worker_id,
std::experimental::optional<tx::TransactionId> tx_id) {
fs::path WalFilenameForTransactionId(const std::filesystem::path &wal_dir,
int worker_id,
std::optional<tx::TransactionId> tx_id) {
auto file_name = utils::Timestamp::Now().ToIso8601();
if (tx_id) {
file_name += "__max_transaction_" + std::to_string(*tx_id);
@ -69,9 +69,9 @@ fs::path WalFilenameForTransactionId(
return wal_dir / file_name;
}
std::experimental::optional<tx::TransactionId>
TransactionIdFromSnapshotFilename(const std::string &name) {
auto nullopt = std::experimental::nullopt;
std::optional<tx::TransactionId> TransactionIdFromSnapshotFilename(
const std::string &name) {
auto nullopt = std::nullopt;
auto file_name_split = utils::RSplit(name, "_tx_", 1);
if (file_name_split.size() != 2) {
LOG(WARNING) << "Unable to parse snapshot file name: " << name;

View File

@ -1,7 +1,7 @@
#pragma once
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include "transactions/type.hpp"
@ -16,26 +16,25 @@ const std::string kBackupDir = ".backup";
/// is returned because that's appropriate for the recovery logic (the current
/// WAL does not yet have a maximum transaction ID and can't be discarded by
/// the recovery regardless of the snapshot from which the transaction starts).
std::experimental::optional<tx::TransactionId> TransactionIdFromWalFilename(
std::optional<tx::TransactionId> TransactionIdFromWalFilename(
const std::string &name);
/** Generates a path for a DB snapshot in the given folder in a well-defined
* sortable format with worker id and transaction from which the snapshot is
* created appended to the file name. */
std::experimental::filesystem::path MakeSnapshotPath(
const std::experimental::filesystem::path &durability_dir, int worker_id,
std::filesystem::path MakeSnapshotPath(
const std::filesystem::path &durability_dir, int worker_id,
tx::TransactionId tx_id);
/// Returns the transaction id contained in the file name. If the filename is
/// not a parseable WAL file name, nullopt is returned.
std::experimental::optional<tx::TransactionId>
TransactionIdFromSnapshotFilename(const std::string &name);
std::optional<tx::TransactionId> TransactionIdFromSnapshotFilename(
const std::string &name);
/// Generates a file path for a write-ahead log file of a specified worker. If
/// given a transaction ID the file name will contain it. Otherwise the file
/// path is for the "current" WAL file for which the max tx id is still unknown.
std::experimental::filesystem::path WalFilenameForTransactionId(
const std::experimental::filesystem::path &wal_dir, int worker_id,
std::experimental::optional<tx::TransactionId> tx_id =
std::experimental::nullopt);
std::filesystem::path WalFilenameForTransactionId(
const std::filesystem::path &wal_dir, int worker_id,
std::optional<tx::TransactionId> tx_id = std::nullopt);
} // namespace durability

View File

@ -1,6 +1,6 @@
#include "durability/distributed/recovery.hpp"
#include <experimental/filesystem>
#include <filesystem>
#include <limits>
#include <unordered_map>
@ -18,7 +18,7 @@
#include "utils/algorithm.hpp"
#include "utils/file.hpp"
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
namespace durability {
@ -372,8 +372,7 @@ std::vector<tx::TransactionId> ReadWalRecoverableTransactions(
RecoveryInfo RecoverOnlySnapshot(
const fs::path &durability_dir, database::GraphDb *db,
RecoveryData *recovery_data,
std::experimental::optional<tx::TransactionId> required_snapshot_tx_id,
int worker_id) {
std::optional<tx::TransactionId> required_snapshot_tx_id, int worker_id) {
// Attempt to recover from snapshot files in reverse order (from newest
// backwards).
const auto snapshot_dir = durability_dir / kSnapshotDir;

View File

@ -1,7 +1,7 @@
#pragma once
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include <unordered_map>
#include <vector>
@ -65,8 +65,7 @@ bool ReadSnapshotSummary(HashedFileReader &buffer, int64_t &vertex_count,
* @return - True if snapshot and WAL versions are compatible with
* ` current memgraph binary.
*/
bool VersionConsistency(
const std::experimental::filesystem::path &durability_dir);
bool VersionConsistency(const std::filesystem::path &durability_dir);
/**
* Checks whether the current memgraph binary (on a worker) is
@ -85,15 +84,14 @@ bool DistributedVersionConsistency(const int64_t master_version);
* @return - True if durability directory contains either a snapshot
* or WAL file.
*/
bool ContainsDurabilityFiles(
const std::experimental::filesystem::path &durabilty_dir);
bool ContainsDurabilityFiles(const std::filesystem::path &durabilty_dir);
/**
* Backup snapshots and WAL files to a backup folder.
*
* @param durability_dir - Path to durability directory.
*/
void MoveToBackup(const std::experimental::filesystem::path &durability_dir);
void MoveToBackup(const std::filesystem::path &durability_dir);
/**
* Recovers database from the latest possible snapshot. If recovering fails,
@ -108,10 +106,9 @@ void MoveToBackup(const std::experimental::filesystem::path &durability_dir);
* @return - recovery info
*/
RecoveryInfo RecoverOnlySnapshot(
const std::experimental::filesystem::path &durability_dir,
database::GraphDb *db, durability::RecoveryData *recovery_data,
std::experimental::optional<tx::TransactionId> required_snapshot_tx_id,
int worker_id);
const std::filesystem::path &durability_dir, database::GraphDb *db,
durability::RecoveryData *recovery_data,
std::optional<tx::TransactionId> required_snapshot_tx_id, int worker_id);
/** Interface for accessing transactions during WAL recovery. */
class RecoveryTransactions {
@ -124,9 +121,9 @@ class RecoveryTransactions {
virtual void Apply(const database::StateDelta &) = 0;
};
void RecoverWal(const std::experimental::filesystem::path &durability_dir,
database::GraphDb *db, RecoveryData *recovery_data,
RecoveryTransactions *transactions);
void RecoverWal(const std::filesystem::path &durability_dir,
database::GraphDb *db, RecoveryData *recovery_data,
RecoveryTransactions *transactions);
void RecoverIndexes(
database::GraphDb *db,

View File

@ -11,7 +11,7 @@
#include "durability/hashed_file_writer.hpp"
#include "utils/file.hpp"
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
namespace durability {

View File

@ -1,6 +1,6 @@
#pragma once
#include <experimental/filesystem>
#include <filesystem>
#include "database/distributed/graph_db.hpp"
@ -14,8 +14,7 @@ namespace durability {
* @param snapshot_max_retained - maximum number of snapshots to retain.
*/
bool MakeSnapshot(database::GraphDb &db, database::GraphDbAccessor &dba,
int worker_id,
const std::experimental::filesystem::path &durability_dir,
int worker_id, const std::filesystem::path &durability_dir,
int snapshot_max_retained);
} // namespace durability

View File

@ -1,6 +1,6 @@
#pragma once
#include <experimental/optional>
#include <optional>
#include "communication/bolt/v1/decoder/decoder.hpp"
#include "durability/distributed/snapshot_value.hpp"
@ -13,7 +13,7 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
explicit SnapshotDecoder(Buffer &buffer)
: communication::bolt::Decoder<Buffer>(buffer) {}
std::experimental::optional<SnapshotVertex> ReadSnapshotVertex() {
std::optional<SnapshotVertex> ReadSnapshotVertex() {
communication::bolt::Value dv;
SnapshotVertex vertex;
@ -21,7 +21,7 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
if (!communication::bolt::Decoder<Buffer>::ReadValue(
&dv, communication::bolt::Value::Type::Vertex)) {
DLOG(WARNING) << "Unable to read snapshot vertex";
return std::experimental::nullopt;
return std::nullopt;
}
auto &read_vertex = dv.ValueVertex();
vertex.gid = read_vertex.id.AsUint();
@ -32,7 +32,7 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
if (!communication::bolt::Decoder<Buffer>::ReadValue(
&dv, communication::bolt::Value::Type::Int)) {
DLOG(WARNING) << "Unable to read vertex cypher_id";
return std::experimental::nullopt;
return std::nullopt;
}
vertex.cypher_id = dv.ValueInt();
@ -41,11 +41,11 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
&dv, communication::bolt::Value::Type::Int)) {
DLOG(WARNING) << "[ReadSnapshotVertex] Couldn't read number of in "
"edges in vertex!";
return std::experimental::nullopt;
return std::nullopt;
}
for (int i = 0; i < dv.ValueInt(); ++i) {
auto edge = ReadSnapshotEdge();
if (!edge) return std::experimental::nullopt;
if (!edge) return std::nullopt;
vertex.in.emplace_back(*edge);
}
@ -54,11 +54,11 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
&dv, communication::bolt::Value::Type::Int)) {
DLOG(WARNING) << "[ReadSnapshotVertex] Couldn't read number of out "
"edges in vertex!";
return std::experimental::nullopt;
return std::nullopt;
}
for (int i = 0; i < dv.ValueInt(); ++i) {
auto edge = ReadSnapshotEdge();
if (!edge) return std::experimental::nullopt;
if (!edge) return std::nullopt;
vertex.out.emplace_back(*edge);
}
@ -67,7 +67,7 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
}
private:
std::experimental::optional<InlinedVertexEdge> ReadSnapshotEdge() {
std::optional<InlinedVertexEdge> ReadSnapshotEdge() {
communication::bolt::Value dv;
InlinedVertexEdge edge;
@ -77,7 +77,7 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
if (!communication::bolt::Decoder<Buffer>::ReadValue(
&dv, communication::bolt::Value::Type::Int)) {
DLOG(WARNING) << "[ReadSnapshotEdge] Couldn't read Global ID!";
return std::experimental::nullopt;
return std::nullopt;
}
edge.address = storage::EdgeAddress(static_cast<uint64_t>(dv.ValueInt()));
@ -86,7 +86,7 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
if (!communication::bolt::Decoder<Buffer>::ReadValue(
&dv, communication::bolt::Value::Type::Int)) {
DLOG(WARNING) << "[ReadSnapshotEdge] Couldn't read from/to address!";
return std::experimental::nullopt;
return std::nullopt;
}
edge.vertex = storage::VertexAddress(static_cast<uint64_t>(dv.ValueInt()));
@ -94,7 +94,7 @@ class SnapshotDecoder : public communication::bolt::Decoder<Buffer> {
if (!communication::bolt::Decoder<Buffer>::ReadValue(
&dv, communication::bolt::Value::Type::String)) {
DLOG(WARNING) << "[ReadSnapshotEdge] Couldn't read type!";
return std::experimental::nullopt;
return std::nullopt;
}
edge.type = dv.ValueString();

View File

@ -247,10 +247,10 @@ void StateDelta::Encode(
if (!decoder.ReadValue(&dv)) return nullopt; \
r_val.member = static_cast<type>(dv.value_f());
std::experimental::optional<StateDelta> StateDelta::Decode(
std::optional<StateDelta> StateDelta::Decode(
HashedFileReader &reader,
communication::bolt::Decoder<HashedFileReader> &decoder) {
using std::experimental::nullopt;
using std::nullopt;
StateDelta r_val;
// The decoded value used as a temporary while decoding.

View File

@ -110,7 +110,7 @@ omitted in the comment.")
/** Attempts to decode a StateDelta from the given decoder. Returns the
* decoded value if successful, otherwise returns nullopt. */
static std::experimental::optional<StateDelta> Decode(
static std::optional<StateDelta> Decode(
HashedFileReader &reader,
communication::bolt::Decoder<HashedFileReader> &decoder);

View File

@ -1,7 +1,7 @@
#include "durability/distributed/wal.hpp"
#include "durability/distributed/version.hpp"
#include "durability/distributed/paths.hpp"
#include "durability/distributed/version.hpp"
#include "utils/file.hpp"
#include "utils/flag_validation.hpp"
@ -19,9 +19,9 @@ DEFINE_VALIDATED_HIDDEN_int32(wal_buffer_size, 4096,
FLAG_IN_RANGE(1, 1 << 30));
namespace durability {
WriteAheadLog::WriteAheadLog(
int worker_id, const std::experimental::filesystem::path &durability_dir,
bool durability_enabled, bool synchronous_commit)
WriteAheadLog::WriteAheadLog(int worker_id,
const std::filesystem::path &durability_dir,
bool durability_enabled, bool synchronous_commit)
: deltas_{FLAGS_wal_buffer_size},
wal_file_{worker_id, durability_dir},
durability_enabled_(durability_enabled),
@ -38,8 +38,8 @@ WriteAheadLog::~WriteAheadLog() {
}
}
WriteAheadLog::WalFile::WalFile(
int worker_id, const std::experimental::filesystem::path &durability_dir)
WriteAheadLog::WalFile::WalFile(int worker_id,
const std::filesystem::path &durability_dir)
: worker_id_(worker_id), wal_dir_{durability_dir / kWalDir} {}
WriteAheadLog::WalFile::~WalFile() {
@ -49,7 +49,7 @@ WriteAheadLog::WalFile::~WalFile() {
void WriteAheadLog::WalFile::Init() {
if (!utils::EnsureDir(wal_dir_)) {
LOG(ERROR) << "Can't write to WAL directory: " << wal_dir_;
current_wal_file_ = std::experimental::filesystem::path();
current_wal_file_ = std::filesystem::path();
} else {
current_wal_file_ = WalFilenameForTransactionId(wal_dir_, worker_id_);
// TODO: Fix error handling, the encoder_ returns `true` or `false`.
@ -62,7 +62,7 @@ void WriteAheadLog::WalFile::Init() {
} catch (std::ios_base::failure &) {
LOG(ERROR) << "Failed to open write-ahead log file: "
<< current_wal_file_;
current_wal_file_ = std::experimental::filesystem::path();
current_wal_file_ = std::filesystem::path();
}
}
latest_tx_ = 0;
@ -92,7 +92,7 @@ void WriteAheadLog::WalFile::Flush(RingBuffer<database::StateDelta> &buffer) {
LOG(ERROR) << "Failed to write to write-ahead log, discarding data.";
buffer.clear();
return;
} catch (std::experimental::filesystem::filesystem_error &) {
} catch (std::filesystem::filesystem_error &) {
LOG(ERROR) << "Failed to rotate write-ahead log.";
buffer.clear();
return;
@ -102,7 +102,7 @@ void WriteAheadLog::WalFile::Flush(RingBuffer<database::StateDelta> &buffer) {
void WriteAheadLog::WalFile::RotateFile() {
writer_.Flush();
writer_.Close();
std::experimental::filesystem::rename(
std::filesystem::rename(
current_wal_file_,
WalFilenameForTransactionId(wal_dir_, worker_id_, latest_tx_));
Init();

View File

@ -2,7 +2,7 @@
#include <chrono>
#include <cstdint>
#include <experimental/filesystem>
#include <filesystem>
#include <gflags/gflags.h>
#include <glog/logging.h>
@ -26,8 +26,7 @@ namespace durability {
/// indeterminism.
class WriteAheadLog {
public:
WriteAheadLog(int worker_id,
const std::experimental::filesystem::path &durability_dir,
WriteAheadLog(int worker_id, const std::filesystem::path &durability_dir,
bool durability_enabled, bool synchronous_commit);
~WriteAheadLog();
@ -48,7 +47,7 @@ class WriteAheadLog {
/// Groups the logic of WAL file handling (flushing, naming, rotating)
class WalFile {
public:
WalFile(int worker_id, const std::experimental::filesystem::path &wal__dir);
WalFile(int worker_id, const std::filesystem::path &wal__dir);
~WalFile();
/// Initializes the WAL file. Must be called before first flush. Can be
@ -63,13 +62,13 @@ class WriteAheadLog {
/// Mutex used for flushing wal data
std::mutex flush_mutex_;
int worker_id_;
const std::experimental::filesystem::path wal_dir_;
const std::filesystem::path wal_dir_;
HashedFileWriter writer_;
communication::bolt::BaseEncoder<HashedFileWriter> encoder_{writer_};
/// The file to which the WAL flushes data. The path is fixed, the file gets
/// moved when the WAL gets rotated.
std::experimental::filesystem::path current_wal_file_;
std::filesystem::path current_wal_file_;
/// Number of deltas in the current wal file.
int current_wal_file_delta_count_{0};

View File

@ -1,7 +1,7 @@
#include "durability/single_node/paths.hpp"
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include <string>
#include "glog/logging.h"
@ -12,7 +12,7 @@
namespace durability {
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
// This is the prefix used for WAL and Snapshot filenames. It is a timestamp
// format that equals to: YYYYmmddHHMMSSffffff
@ -22,7 +22,7 @@ const std::string kTimestampFormat =
// TODO: This shouldn't be used to get the transaction ID from a WAL file,
// instead the file should be parsed and the transaction ID should be read from
// the file.
std::experimental::optional<tx::TransactionId> TransactionIdFromWalFilename(
std::optional<tx::TransactionId> TransactionIdFromWalFilename(
const std::string &name) {
if (utils::EndsWith(name, "current"))
return std::numeric_limits<tx::TransactionId>::max();
@ -31,26 +31,25 @@ std::experimental::optional<tx::TransactionId> TransactionIdFromWalFilename(
auto file_name_split = utils::RSplit(name, "_", 1);
if (file_name_split.size() != 2) {
LOG(WARNING) << "Unable to parse WAL file name: " << name;
return std::experimental::nullopt;
return std::nullopt;
}
auto &tx_id_str = file_name_split[1];
try {
return std::stoll(tx_id_str);
} catch (std::invalid_argument &) {
LOG(WARNING) << "Unable to parse WAL file name tx ID: " << tx_id_str;
return std::experimental::nullopt;
return std::nullopt;
} catch (std::out_of_range &) {
LOG(WARNING) << "WAL file name tx ID too large: " << tx_id_str;
return std::experimental::nullopt;
return std::nullopt;
}
}
/// Generates a file path for a write-ahead log file. If given a transaction ID
/// the file name will contain it. Otherwise the file path is for the "current"
/// WAL file for which the max tx id is still unknown.
fs::path WalFilenameForTransactionId(
const std::experimental::filesystem::path &wal_dir,
std::experimental::optional<tx::TransactionId> tx_id) {
fs::path WalFilenameForTransactionId(const std::filesystem::path &wal_dir,
std::optional<tx::TransactionId> tx_id) {
auto file_name = utils::Timestamp::Now().ToString(kTimestampFormat);
if (tx_id) {
file_name += "_tx_" + std::to_string(*tx_id);
@ -70,23 +69,23 @@ fs::path MakeSnapshotPath(const fs::path &durability_dir,
// TODO: This shouldn't be used to get the transaction ID from a snapshot file,
// instead the file should be parsed and the transaction ID should be read from
// the file.
std::experimental::optional<tx::TransactionId>
TransactionIdFromSnapshotFilename(const std::string &name) {
std::optional<tx::TransactionId> TransactionIdFromSnapshotFilename(
const std::string &name) {
auto file_name_split = utils::RSplit(name, "_tx_", 1);
if (file_name_split.size() != 2) {
LOG(WARNING) << "Unable to parse snapshot file name: " << name;
return std::experimental::nullopt;
return std::nullopt;
}
try {
return std::stoll(file_name_split[1]);
} catch (std::invalid_argument &) {
LOG(WARNING) << "Unable to parse snapshot file name tx ID: "
<< file_name_split[1];
return std::experimental::nullopt;
return std::nullopt;
} catch (std::out_of_range &) {
LOG(WARNING) << "Unable to parse snapshot file name tx ID: "
<< file_name_split[1];
return std::experimental::nullopt;
return std::nullopt;
}
}
} // namespace durability

View File

@ -1,7 +1,7 @@
#pragma once
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include "transactions/type.hpp"
@ -16,26 +16,24 @@ const std::string kBackupDir = ".backup";
/// is returned because that's appropriate for the recovery logic (the current
/// WAL does not yet have a maximum transaction ID and can't be discarded by
/// the recovery regardless of the snapshot from which the transaction starts).
std::experimental::optional<tx::TransactionId> TransactionIdFromWalFilename(
std::optional<tx::TransactionId> TransactionIdFromWalFilename(
const std::string &name);
/// Generates a file path for a write-ahead log file. If given a transaction ID
/// the file name will contain it. Otherwise the file path is for the "current"
/// WAL file for which the max tx id is still unknown.
std::experimental::filesystem::path WalFilenameForTransactionId(
const std::experimental::filesystem::path &wal_dir,
std::experimental::optional<tx::TransactionId> tx_id =
std::experimental::nullopt);
std::filesystem::path WalFilenameForTransactionId(
const std::filesystem::path &wal_dir,
std::optional<tx::TransactionId> tx_id = std::nullopt);
/// Generates a path for a DB snapshot in the given folder in a well-defined
/// sortable format with transaction from which the snapshot is created appended
/// to the file name.
std::experimental::filesystem::path MakeSnapshotPath(
const std::experimental::filesystem::path &durability_dir,
tx::TransactionId tx_id);
std::filesystem::path MakeSnapshotPath(
const std::filesystem::path &durability_dir, tx::TransactionId tx_id);
/// Returns the transaction id contained in the file name. If the filename is
/// not a parseable WAL file name, nullopt is returned.
std::experimental::optional<tx::TransactionId>
TransactionIdFromSnapshotFilename(const std::string &name);
std::optional<tx::TransactionId> TransactionIdFromSnapshotFilename(
const std::string &name);
} // namespace durability

View File

@ -1,8 +1,8 @@
#include "durability/single_node/recovery.hpp"
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <limits>
#include <optional>
#include <unordered_map>
#include "communication/bolt/v1/decoder/decoder.hpp"
@ -17,7 +17,7 @@
#include "utils/algorithm.hpp"
#include "utils/file.hpp"
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
namespace durability {
@ -335,7 +335,7 @@ std::vector<tx::TransactionId> ReadWalRecoverableTransactions(
RecoveryInfo RecoverOnlySnapshot(
const fs::path &durability_dir, database::GraphDb *db,
RecoveryData *recovery_data,
std::experimental::optional<tx::TransactionId> required_snapshot_tx_id) {
std::optional<tx::TransactionId> required_snapshot_tx_id) {
// Attempt to recover from snapshot files in reverse order (from newest
// backwards).
const auto snapshot_dir = durability_dir / kSnapshotDir;

View File

@ -1,7 +1,7 @@
#pragma once
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include <unordered_map>
#include <vector>
@ -91,8 +91,7 @@ bool ReadSnapshotSummary(HashedFileReader &buffer, int64_t &vertex_count,
* @return - True if snapshot and WAL versions are compatible with
* ` current memgraph binary.
*/
bool VersionConsistency(
const std::experimental::filesystem::path &durability_dir);
bool VersionConsistency(const std::filesystem::path &durability_dir);
/**
* Checks whether the current memgraph binary (on a worker) is
@ -111,15 +110,14 @@ bool DistributedVersionConsistency(const int64_t master_version);
* @return - True if durability directory contains either a snapshot
* or WAL file.
*/
bool ContainsDurabilityFiles(
const std::experimental::filesystem::path &durabilty_dir);
bool ContainsDurabilityFiles(const std::filesystem::path &durabilty_dir);
/**
* Backup snapshots and WAL files to a backup folder.
*
* @param durability_dir - Path to durability directory.
*/
void MoveToBackup(const std::experimental::filesystem::path &durability_dir);
void MoveToBackup(const std::filesystem::path &durability_dir);
/**
* Recovers database from the latest possible snapshot. If recovering fails,
@ -134,9 +132,9 @@ void MoveToBackup(const std::experimental::filesystem::path &durability_dir);
* @return - recovery info
*/
RecoveryInfo RecoverOnlySnapshot(
const std::experimental::filesystem::path &durability_dir,
database::GraphDb *db, durability::RecoveryData *recovery_data,
std::experimental::optional<tx::TransactionId> required_snapshot_tx_id);
const std::filesystem::path &durability_dir, database::GraphDb *db,
durability::RecoveryData *recovery_data,
std::optional<tx::TransactionId> required_snapshot_tx_id);
/** Interface for accessing transactions during WAL recovery. */
class RecoveryTransactions {
@ -160,7 +158,7 @@ class RecoveryTransactions {
accessors_;
};
void RecoverWal(const std::experimental::filesystem::path &durability_dir,
void RecoverWal(const std::filesystem::path &durability_dir,
database::GraphDb *db, RecoveryData *recovery_data,
RecoveryTransactions *transactions);

View File

@ -12,7 +12,7 @@
#include "glue/communication.hpp"
#include "utils/file.hpp"
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
namespace durability {

View File

@ -1,6 +1,6 @@
#pragma once
#include <experimental/filesystem>
#include <filesystem>
#include "database/single_node/graph_db.hpp"
@ -14,7 +14,7 @@ namespace durability {
* @param snapshot_max_retained - maximum number of snapshots to retain.
*/
bool MakeSnapshot(database::GraphDb &db, database::GraphDbAccessor &dba,
const std::experimental::filesystem::path &durability_dir,
const std::filesystem::path &durability_dir,
int snapshot_max_retained);
} // namespace durability

View File

@ -273,10 +273,10 @@ void StateDelta::Encode(
if (!decoder.ReadValue(&dv)) return nullopt; \
r_val.member = static_cast<type>(dv.value_f());
std::experimental::optional<StateDelta> StateDelta::Decode(
std::optional<StateDelta> StateDelta::Decode(
HashedFileReader &reader,
communication::bolt::Decoder<HashedFileReader> &decoder) {
using std::experimental::nullopt;
using std::nullopt;
StateDelta r_val;
// The decoded value used as a temporary while decoding.

View File

@ -89,7 +89,7 @@ omitted in the comment."))
/** Attempts to decode a StateDelta from the given decoder. Returns the
* decoded value if successful, otherwise returns nullopt. */
static std::experimental::optional<StateDelta> Decode(
static std::optional<StateDelta> Decode(
HashedFileReader &reader,
communication::bolt::Decoder<HashedFileReader> &decoder);

View File

@ -20,9 +20,8 @@ DEFINE_VALIDATED_HIDDEN_int32(wal_buffer_size, 4096,
namespace durability {
WriteAheadLog::WriteAheadLog(
const std::experimental::filesystem::path &durability_dir,
bool durability_enabled, bool synchronous_commit)
WriteAheadLog::WriteAheadLog(const std::filesystem::path &durability_dir,
bool durability_enabled, bool synchronous_commit)
: deltas_{FLAGS_wal_buffer_size},
wal_file_{durability_dir},
durability_enabled_(durability_enabled),
@ -39,8 +38,7 @@ WriteAheadLog::~WriteAheadLog() {
}
}
WriteAheadLog::WalFile::WalFile(
const std::experimental::filesystem::path &durability_dir)
WriteAheadLog::WalFile::WalFile(const std::filesystem::path &durability_dir)
: wal_dir_{durability_dir / kWalDir} {}
WriteAheadLog::WalFile::~WalFile() {
@ -50,7 +48,7 @@ WriteAheadLog::WalFile::~WalFile() {
void WriteAheadLog::WalFile::Init() {
if (!utils::EnsureDir(wal_dir_)) {
LOG(ERROR) << "Can't write to WAL directory: " << wal_dir_;
current_wal_file_ = std::experimental::filesystem::path();
current_wal_file_ = std::filesystem::path();
} else {
current_wal_file_ = WalFilenameForTransactionId(wal_dir_);
// TODO: Fix error handling, the encoder_ returns `true` or `false`.
@ -63,7 +61,7 @@ void WriteAheadLog::WalFile::Init() {
} catch (std::ios_base::failure &) {
LOG(ERROR) << "Failed to open write-ahead log file: "
<< current_wal_file_;
current_wal_file_ = std::experimental::filesystem::path();
current_wal_file_ = std::filesystem::path();
}
}
latest_tx_ = 0;
@ -93,7 +91,7 @@ void WriteAheadLog::WalFile::Flush(RingBuffer<database::StateDelta> &buffer) {
LOG(ERROR) << "Failed to write to write-ahead log, discarding data.";
buffer.clear();
return;
} catch (std::experimental::filesystem::filesystem_error &) {
} catch (std::filesystem::filesystem_error &) {
LOG(ERROR) << "Failed to rotate write-ahead log.";
buffer.clear();
return;
@ -103,9 +101,8 @@ void WriteAheadLog::WalFile::Flush(RingBuffer<database::StateDelta> &buffer) {
void WriteAheadLog::WalFile::RotateFile() {
writer_.Flush();
writer_.Close();
std::experimental::filesystem::rename(
current_wal_file_,
WalFilenameForTransactionId(wal_dir_, latest_tx_));
std::filesystem::rename(current_wal_file_,
WalFilenameForTransactionId(wal_dir_, latest_tx_));
Init();
}

View File

@ -2,7 +2,7 @@
#include <chrono>
#include <cstdint>
#include <experimental/filesystem>
#include <filesystem>
#include <gflags/gflags.h>
#include <glog/logging.h>
@ -26,7 +26,7 @@ namespace durability {
/// indeterminism.
class WriteAheadLog {
public:
WriteAheadLog(const std::experimental::filesystem::path &durability_dir,
WriteAheadLog(const std::filesystem::path &durability_dir,
bool durability_enabled, bool synchronous_commit);
~WriteAheadLog();
@ -47,7 +47,7 @@ class WriteAheadLog {
/// Groups the logic of WAL file handling (flushing, naming, rotating)
class WalFile {
public:
explicit WalFile(const std::experimental::filesystem::path &durability_dir);
explicit WalFile(const std::filesystem::path &durability_dir);
~WalFile();
/// Initializes the WAL file. Must be called before first flush. Can be
@ -61,13 +61,13 @@ class WriteAheadLog {
private:
/// Mutex used for flushing wal data
std::mutex flush_mutex_;
const std::experimental::filesystem::path wal_dir_;
const std::filesystem::path wal_dir_;
HashedFileWriter writer_;
communication::bolt::BaseEncoder<HashedFileWriter> encoder_{writer_};
/// The file to which the WAL flushes data. The path is fixed, the file gets
/// moved when the WAL gets rotated.
std::experimental::filesystem::path current_wal_file_;
std::filesystem::path current_wal_file_;
/// Number of deltas in the current wal file.
int current_wal_file_delta_count_{0};

View File

@ -1,7 +1,7 @@
#include "durability/single_node_ha/paths.hpp"
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include <string>
#include "glog/logging.h"
@ -12,7 +12,7 @@
namespace durability {
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
std::string GetSnapshotFilename(tx::TransactionId tx_id) {
std::string date_str =
@ -26,9 +26,9 @@ fs::path MakeSnapshotPath(const fs::path &durability_dir,
return durability_dir / kSnapshotDir / snapshot_filename;
}
std::experimental::optional<tx::TransactionId>
TransactionIdFromSnapshotFilename(const std::string &name) {
auto nullopt = std::experimental::nullopt;
std::optional<tx::TransactionId> TransactionIdFromSnapshotFilename(
const std::string &name) {
auto nullopt = std::nullopt;
auto file_name_split = utils::RSplit(name, "_tx_", 1);
if (file_name_split.size() != 2) {
LOG(WARNING) << "Unable to parse snapshot file name: " << name;

View File

@ -1,7 +1,7 @@
#pragma once
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include "transactions/type.hpp"
@ -15,12 +15,12 @@ const std::string kBackupDir = ".backup";
std::string GetSnapshotFilename(tx::TransactionId tx_id);
/// Generates a full path for a DB snapshot.
std::experimental::filesystem::path MakeSnapshotPath(
const std::experimental::filesystem::path &durability_dir,
std::filesystem::path MakeSnapshotPath(
const std::filesystem::path &durability_dir,
const std::string &snapshot_filename);
/// Returns the transaction id contained in the file name. If the filename is
/// not a parseable snapshot file name, nullopt is returned.
std::experimental::optional<tx::TransactionId>
TransactionIdFromSnapshotFilename(const std::string &name);
std::optional<tx::TransactionId> TransactionIdFromSnapshotFilename(
const std::string &name);
} // namespace durability

View File

@ -1,8 +1,8 @@
#include "durability/single_node_ha/recovery.hpp"
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <limits>
#include <optional>
#include <unordered_map>
#include "communication/bolt/v1/decoder/decoder.hpp"
@ -16,7 +16,7 @@
#include "utils/algorithm.hpp"
#include "utils/file.hpp"
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
namespace durability {

View File

@ -1,7 +1,7 @@
#pragma once
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include <unordered_map>
#include <vector>
@ -56,7 +56,7 @@ bool ReadSnapshotSummary(HashedFileReader &buffer, int64_t &vertex_count,
*/
bool RecoverSnapshot(database::GraphDb *db,
durability::RecoveryData *recovery_data,
const std::experimental::filesystem::path &durability_dir,
const std::filesystem::path &durability_dir,
const std::string &snapshot_filename);
void RecoverIndexes(database::GraphDb *db,

View File

@ -12,7 +12,7 @@
#include "glue/communication.hpp"
#include "utils/file.hpp"
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
namespace durability {

View File

@ -1,6 +1,6 @@
#pragma once
#include <experimental/filesystem>
#include <filesystem>
#include "database/single_node_ha/graph_db.hpp"
@ -13,11 +13,10 @@ namespace durability {
/// @param durability_dir - directory where durability data is stored.
/// @param snapshot_filename - filename for the snapshot.
bool MakeSnapshot(database::GraphDb &db, database::GraphDbAccessor &dba,
const std::experimental::filesystem::path &durability_dir,
const std::filesystem::path &durability_dir,
const std::string &snapshot_filename);
/// Remove all snapshots inside the snapshot durability directory.
void RemoveAllSnapshots(
const std::experimental::filesystem::path &durability_dir);
void RemoveAllSnapshots(const std::filesystem::path &durability_dir);
} // namespace durability

View File

@ -203,10 +203,10 @@ void StateDelta::Encode(
if (!decoder.ReadValue(&dv)) return nullopt; \
r_val.member = static_cast<type>(dv.value_f());
std::experimental::optional<StateDelta> StateDelta::Decode(
std::optional<StateDelta> StateDelta::Decode(
HashedFileReader &reader,
communication::bolt::Decoder<HashedFileReader> &decoder) {
using std::experimental::nullopt;
using std::nullopt;
StateDelta r_val;
// The decoded value used as a temporary while decoding.

View File

@ -104,7 +104,7 @@ omitted in the comment.")
/** Attempts to decode a StateDelta from the given decoder. Returns the
* decoded value if successful, otherwise returns nullopt. */
static std::experimental::optional<StateDelta> Decode(
static std::optional<StateDelta> Decode(
HashedFileReader &reader,
communication::bolt::Decoder<HashedFileReader> &decoder);

View File

@ -106,11 +106,10 @@ void Consumer::StopConsuming() {
if (thread_.joinable()) thread_.join();
// Set limit_batches to nullopt since it's not running anymore.
info_.limit_batches = std::experimental::nullopt;
info_.limit_batches = std::nullopt;
}
void Consumer::StartConsuming(
std::experimental::optional<int64_t> limit_batches) {
void Consumer::StartConsuming(std::optional<int64_t> limit_batches) {
info_.limit_batches = limit_batches;
is_running_.store(true);
@ -153,7 +152,7 @@ void Consumer::StartConsuming(
break;
}
if (limit_batches != std::experimental::nullopt) {
if (limit_batches != std::nullopt) {
if (limit_batches <= ++batch_count) {
is_running_.store(false);
break;
@ -209,7 +208,7 @@ std::vector<std::unique_ptr<RdKafka::Message>> Consumer::GetBatch() {
return batch;
}
void Consumer::Start(std::experimental::optional<int64_t> limit_batches) {
void Consumer::Start(std::optional<int64_t> limit_batches) {
if (!consumer_) {
throw ConsumerNotAvailableException(info_.stream_name);
}
@ -239,7 +238,7 @@ void Consumer::StartIfStopped() {
}
if (!is_running_) {
StartConsuming(std::experimental::nullopt);
StartConsuming(std::nullopt);
}
}
@ -255,7 +254,7 @@ void Consumer::StopIfRunning() {
std::vector<
std::pair<std::string, std::map<std::string, communication::bolt::Value>>>
Consumer::Test(std::experimental::optional<int64_t> limit_batches) {
Consumer::Test(std::optional<int64_t> limit_batches) {
// All exceptions thrown here are handled by the Bolt protocol.
if (!consumer_) {
throw ConsumerNotAvailableException(info_.stream_name);

View File

@ -2,9 +2,9 @@
#pragma once
#include <atomic>
#include <experimental/optional>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <thread>
#include <vector>
@ -26,10 +26,10 @@ struct StreamInfo {
std::string stream_uri;
std::string stream_topic;
std::string transform_uri;
std::experimental::optional<int64_t> batch_interval_in_ms;
std::experimental::optional<int64_t> batch_size;
std::optional<int64_t> batch_interval_in_ms;
std::optional<int64_t> batch_size;
std::experimental::optional<int64_t> limit_batches;
std::optional<int64_t> limit_batches;
bool is_running = false;
};
@ -81,7 +81,7 @@ class Consumer final : public RdKafka::EventCb {
///
/// @throws ConsumerNotAvailableException if the consumer isn't initialized
/// @throws ConsumerRunningException if the consumer is already running
void Start(std::experimental::optional<int64_t> limit_batches);
void Start(std::optional<int64_t> limit_batches);
/// Stops importing data from a stream to the db.
///
@ -108,7 +108,7 @@ class Consumer final : public RdKafka::EventCb {
/// @throws ConsumerRunningException if the consumer is alredy running.
std::vector<
std::pair<std::string, std::map<std::string, communication::bolt::Value>>>
Test(std::experimental::optional<int64_t> limit_batches);
Test(std::optional<int64_t> limit_batches);
/// Returns the current status of a stream.
StreamStatus Status();
@ -135,7 +135,7 @@ class Consumer final : public RdKafka::EventCb {
void StopConsuming();
void StartConsuming(std::experimental::optional<int64_t> limit_batches);
void StartConsuming(std::optional<int64_t> limit_batches);
std::vector<std::unique_ptr<RdKafka::Message>> GetBatch();
};

View File

@ -1,8 +1,8 @@
#include "integrations/kafka/streams.hpp"
#include <cstdio>
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <optional>
#include <json/json.hpp>
@ -12,7 +12,7 @@
namespace integrations::kafka {
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
const std::string kMetadataDir = "metadata";
const std::string kTransformDir = "transform";
@ -71,7 +71,7 @@ StreamInfo Deserialize(const nlohmann::json &data) {
if (data["batch_interval_in_ms"].is_number()) {
info.batch_interval_in_ms = data["batch_interval_in_ms"];
} else if (data["batch_interval_in_ms"].is_null()) {
info.batch_interval_in_ms = std::experimental::nullopt;
info.batch_interval_in_ms = std::nullopt;
} else {
throw StreamDeserializationException();
}
@ -79,7 +79,7 @@ StreamInfo Deserialize(const nlohmann::json &data) {
if (data["batch_size"].is_number()) {
info.batch_size = data["batch_size"];
} else if (data["batch_size"].is_null()) {
info.batch_size = std::experimental::nullopt;
info.batch_size = std::nullopt;
} else {
throw StreamDeserializationException();
}
@ -90,7 +90,7 @@ StreamInfo Deserialize(const nlohmann::json &data) {
if (data["limit_batches"].is_number()) {
info.limit_batches = data["limit_batches"];
} else if (data["limit_batches"].is_null()) {
info.limit_batches = std::experimental::nullopt;
info.limit_batches = std::nullopt;
} else {
throw StreamDeserializationException();
}
@ -185,7 +185,7 @@ void Streams::Drop(const std::string &stream_name) {
}
void Streams::Start(const std::string &stream_name,
std::experimental::optional<int64_t> limit_batches) {
std::optional<int64_t> limit_batches) {
std::lock_guard<std::mutex> g(mutex_);
auto find_it = consumers_.find(stream_name);
if (find_it == consumers_.end())
@ -254,7 +254,7 @@ std::vector<StreamStatus> Streams::Show() {
std::vector<
std::pair<std::string, std::map<std::string, communication::bolt::Value>>>
Streams::Test(const std::string &stream_name,
std::experimental::optional<int64_t> limit_batches) {
std::optional<int64_t> limit_batches) {
std::lock_guard<std::mutex> g(mutex_);
auto find_it = consumers_.find(stream_name);
if (find_it == consumers_.end())

View File

@ -1,8 +1,8 @@
/// @file
#pragma once
#include <experimental/optional>
#include <mutex>
#include <optional>
#include <unordered_map>
#include "integrations/kafka/consumer.hpp"
@ -69,8 +69,7 @@ class Streams final {
/// @throws ConsumerRunningException if the consumer is already running
/// @throws StreamMetadataCouldNotBeStored if it can't persist metadata
void Start(const std::string &stream_name,
std::experimental::optional<int64_t> batch_limit =
std::experimental::nullopt);
std::optional<int64_t> batch_limit = std::nullopt);
/// Stop consuming from a stream.
///
@ -106,8 +105,7 @@ class Streams final {
std::vector<
std::pair<std::string, std::map<std::string, communication::bolt::Value>>>
Test(const std::string &stream_name,
std::experimental::optional<int64_t> batch_limit =
std::experimental::nullopt);
std::optional<int64_t> batch_limit = std::nullopt);
private:
std::string streams_directory_;

View File

@ -39,7 +39,7 @@ namespace {
using communication::bolt::Value;
using integrations::kafka::TargetArguments;
using integrations::kafka::TransformExecutionException;
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
/////////////////////////////////////////////////////////////////////////
// Constants used for starting and communicating with the target process.

View File

@ -1,7 +1,7 @@
/// @file
#pragma once
#include <experimental/filesystem>
#include <filesystem>
#include <map>
#include <string>
@ -12,7 +12,7 @@
namespace integrations::kafka {
struct TargetArguments {
std::experimental::filesystem::path transform_script_path;
std::filesystem::path transform_script_path;
int pipe_to_python{-1};
int pipe_from_python{-1};
};

View File

@ -184,7 +184,7 @@ int Socket::ErrorStatus() const {
bool Socket::Listen(int backlog) { return listen(socket_, backlog) == 0; }
std::experimental::optional<Socket> Socket::Accept() {
std::optional<Socket> Socket::Accept() {
sockaddr_storage addr;
socklen_t addr_size = sizeof addr;
char addr_decoded[INET6_ADDRSTRLEN];
@ -192,7 +192,7 @@ std::experimental::optional<Socket> Socket::Accept() {
unsigned short port;
int sfd = accept(socket_, (struct sockaddr *)&addr, &addr_size);
if (UNLIKELY(sfd == -1)) return std::experimental::nullopt;
if (UNLIKELY(sfd == -1)) return std::nullopt;
if (addr.ss_family == AF_INET) {
addr_src = (void *)&(((sockaddr_in *)&addr)->sin_addr);

View File

@ -1,8 +1,8 @@
#pragma once
#include <experimental/optional>
#include <functional>
#include <iostream>
#include <optional>
#include "io/network/endpoint.hpp"
@ -82,7 +82,7 @@ class Socket {
*
* @return socket if accepted, nullopt otherwise.
*/
std::experimental::optional<Socket> Accept();
std::optional<Socket> Accept();
/**
* Sets the socket to non-blocking.

View File

@ -46,10 +46,10 @@ std::string ResolveHostname(std::string hostname) {
}
/// Gets hostname
std::experimental::optional<std::string> GetHostname() {
std::optional<std::string> GetHostname() {
char hostname[HOST_NAME_MAX + 1];
int result = gethostname(hostname, sizeof(hostname));
if (result) return std::experimental::nullopt;
if (result) return std::nullopt;
return std::string(hostname);
}

View File

@ -1,6 +1,6 @@
#pragma once
#include <experimental/optional>
#include <optional>
#include <string>
#include "io/network/endpoint.hpp"
@ -11,7 +11,7 @@ namespace io::network {
std::string ResolveHostname(std::string hostname);
/// Gets hostname
std::experimental::optional<std::string> GetHostname();
std::optional<std::string> GetHostname();
// Try to establish a connection to a remote host
bool CanEstablishConnection(const Endpoint &endpoint);

View File

@ -175,7 +175,7 @@ Usage example:
~A
~A.emplace(std::move(~A));
} else {
~A = std::experimental::nullopt;
~A = std::nullopt;
}"
source-name
(lcp::cpp-type-decl value-type) value-var

View File

@ -820,15 +820,15 @@
}
}"))
(subtest "optional"
(single-member-test (member "std::experimental::optional<int32_t>")
(single-member-test (member "std::optional<int32_t>")
"object.member_ = member_;")
(single-member-test (member "std::experimental::optional<Klondike>")
(single-member-test (member "std::optional<Klondike>")
"if (member_) {
Klondike value1;
value1 = (*member_).Clone();
object.member_.emplace(std::move(value1));
} else {
object.member_ = std::experimental::nullopt;
object.member_ = std::nullopt;
}"))
(subtest "unordered_map"
(single-member-test (member "std::unordered_map<int32_t, std::string>")

View File

@ -66,8 +66,7 @@ void SingleNodeMain() {
// Begin enterprise features initialization
auto durability_directory =
std::experimental::filesystem::path(FLAGS_durability_directory);
auto durability_directory = std::filesystem::path(FLAGS_durability_directory);
// Auth
auth::Init();
@ -124,7 +123,7 @@ void SingleNodeMain() {
service_name, FLAGS_num_workers);
// Setup telemetry
std::experimental::optional<telemetry::Telemetry> telemetry;
std::optional<telemetry::Telemetry> telemetry;
if (FLAGS_telemetry_enabled) {
telemetry.emplace(
"https://telemetry.memgraph.com/88b5e7e8-746a-11e8-9f85-538a9e9690cc/",

View File

@ -65,8 +65,7 @@ DECLARE_int32(worker_id);
void MasterMain() {
google::SetUsageMessage("Memgraph distributed master");
auto durability_directory =
std::experimental::filesystem::path(FLAGS_durability_directory);
auto durability_directory = std::filesystem::path(FLAGS_durability_directory);
auth::Init();
auth::Auth auth{durability_directory / "auth"};

View File

@ -37,8 +37,7 @@ void SingleNodeHAMain() {
google::SetUsageMessage(
"Memgraph high availability single-node database server");
auto durability_directory =
std::experimental::filesystem::path(FLAGS_durability_directory);
auto durability_directory = std::filesystem::path(FLAGS_durability_directory);
database::GraphDb db;
query::Interpreter interpreter;

View File

@ -2,9 +2,9 @@
#pragma once
#include <csignal>
#include <experimental/filesystem>
#include <experimental/optional>
#include <filesystem>
#include <map>
#include <optional>
#include <string>
#include <gflags/gflags.h>
@ -75,7 +75,7 @@ class BoltSession final
query::TransactionEngine transaction_engine_;
auth::Auth *auth_;
std::experimental::optional<auth::User> user_;
std::optional<auth::User> user_;
audit::Log *audit_log_;
io::network::Endpoint endpoint_;
};
@ -123,5 +123,4 @@ void InitSignalHandlers(const std::function<void()> &shutdown_fun);
/// `memgraph_main` functions which does that. You should take care to call
/// `InitSignalHandlers` with appropriate function to shutdown the server you
/// started.
int WithInit(int argc, char **argv,
const std::function<void()> &memgraph_main);
int WithInit(int argc, char **argv, const std::function<void()> &memgraph_main);

View File

@ -4,7 +4,7 @@
#include "query/frontend/semantic/symbol_generator.hpp"
#include <experimental/optional>
#include <optional>
#include <unordered_set>
#include "glog/logging.h"
@ -471,11 +471,10 @@ bool SymbolGenerator::PostVisit(EdgeAtom &) {
void SymbolGenerator::VisitWithIdentifiers(
Expression *expr, const std::vector<Identifier *> &identifiers) {
std::vector<std::pair<std::experimental::optional<Symbol>, Identifier *>>
prev_symbols;
std::vector<std::pair<std::optional<Symbol>, Identifier *>> prev_symbols;
// Collect previous symbols if they exist.
for (const auto &identifier : identifiers) {
std::experimental::optional<Symbol> prev_symbol;
std::optional<Symbol> prev_symbol;
auto prev_symbol_it = scope_.symbols.find(identifier->name_);
if (prev_symbol_it != scope_.symbols.end()) {
prev_symbol = prev_symbol_it->second;

View File

@ -113,9 +113,9 @@ Callback HandleAuthQuery(AuthQuery *auth_query, auth::Auth *auth,
std::lock_guard<std::mutex> lock(auth->WithLock());
auto user = auth->AddUser(
username, password.IsString() ? std::experimental::make_optional(
password.ValueString())
: std::experimental::nullopt);
username, password.IsString()
? std::make_optional(password.ValueString())
: std::nullopt);
if (!user) {
throw QueryRuntimeException("User or role '{}' already exists.",
username);
@ -145,10 +145,9 @@ Callback HandleAuthQuery(AuthQuery *auth_query, auth::Auth *auth,
if (!user) {
throw QueryRuntimeException("User '{}' doesn't exist.", username);
}
user->UpdatePassword(
password.IsString()
? std::experimental::make_optional(password.ValueString())
: std::experimental::nullopt);
user->UpdatePassword(password.IsString()
? std::make_optional(password.ValueString())
: std::nullopt);
auth->SaveUser(*user);
return std::vector<std::vector<TypedValue>>();
};
@ -419,14 +418,13 @@ Callback HandleStreamQuery(StreamQuery *stream_query,
info.stream_uri = stream_uri.ValueString();
info.stream_topic = stream_topic.ValueString();
info.transform_uri = transform_uri.ValueString();
info.batch_interval_in_ms = batch_interval_in_ms.IsInt()
? std::experimental::make_optional(
batch_interval_in_ms.ValueInt())
: std::experimental::nullopt;
info.batch_size =
batch_size.IsInt()
? std::experimental::make_optional(batch_size.ValueInt())
: std::experimental::nullopt;
info.batch_interval_in_ms =
batch_interval_in_ms.IsInt()
? std::make_optional(batch_interval_in_ms.ValueInt())
: std::nullopt;
info.batch_size = batch_size.IsInt()
? std::make_optional(batch_size.ValueInt())
: std::nullopt;
try {
streams->Create(info);
@ -463,10 +461,10 @@ Callback HandleStreamQuery(StreamQuery *stream_query,
CHECK(limit_batches.IsInt() || limit_batches.IsNull());
try {
streams->Start(stream_name, limit_batches.IsInt()
? std::experimental::make_optional(
limit_batches.ValueInt())
: std::experimental::nullopt);
streams->Start(stream_name,
limit_batches.IsInt()
? std::make_optional(limit_batches.ValueInt())
: std::nullopt);
} catch (integrations::kafka::KafkaStreamException &e) {
throw QueryRuntimeException(e.what());
}
@ -511,10 +509,9 @@ Callback HandleStreamQuery(StreamQuery *stream_query,
std::vector<std::vector<TypedValue>> rows;
try {
auto results = streams->Test(
stream_name,
limit_batches.IsInt()
? std::experimental::make_optional(limit_batches.ValueInt())
: std::experimental::nullopt);
stream_name, limit_batches.IsInt()
? std::make_optional(limit_batches.ValueInt())
: std::nullopt);
for (const auto &result : results) {
std::map<std::string, TypedValue> params;
for (const auto &param : result.second) {

View File

@ -205,19 +205,19 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor {
// converts an optional ScanAll range bound into a property value
// if the bound is present and is a constant expression convertible to
// a property value. otherwise returns nullopt
std::experimental::optional<utils::Bound<PropertyValue>> BoundToPropertyValue(
std::experimental::optional<ScanAllByLabelPropertyRange::Bound> bound) {
std::optional<utils::Bound<PropertyValue>> BoundToPropertyValue(
std::optional<ScanAllByLabelPropertyRange::Bound> bound) {
if (bound) {
auto property_value = ConstPropertyValue(bound->value());
if (property_value)
return utils::Bound<PropertyValue>(*property_value, bound->type());
}
return std::experimental::nullopt;
return std::nullopt;
}
// If the expression is a constant property value, it is returned. Otherwise,
// return nullopt.
std::experimental::optional<PropertyValue> ConstPropertyValue(
std::optional<PropertyValue> ConstPropertyValue(
const Expression *expression) {
if (auto *literal = utils::Downcast<const PrimitiveLiteral>(expression)) {
return literal->value_;
@ -225,7 +225,7 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor {
utils::Downcast<const ParameterLookup>(expression)) {
return parameters.AtTokenPosition(param_lookup->token_position_);
}
return std::experimental::nullopt;
return std::nullopt;
}
};

View File

@ -42,7 +42,7 @@ struct Branch {
// parent_end is pointer, because we may only change its input.
LogicalOperator *parent_end{nullptr};
// Minimum index of the branch this parent depends on.
std::experimental::optional<int64_t> depends_on;
std::optional<int64_t> depends_on;
};
// Find the subtree parent, below which no operator uses symbols found in the
@ -105,9 +105,8 @@ class IndependentSubtreeFinder : public DistributedOperatorVisitor {
bool PostVisit(ScanAllByLabelPropertyRange &scan) override {
prev_ops_.pop_back();
if (branch_.subtree) return true;
auto find_forbidden =
[this](auto maybe_bound) -> std::experimental::optional<int64_t> {
if (!maybe_bound) return std::experimental::nullopt;
auto find_forbidden = [this](auto maybe_bound) -> std::optional<int64_t> {
if (!maybe_bound) return std::nullopt;
UsedSymbolsCollector collector(*symbol_table_);
maybe_bound->value()->Accept(collector);
return this->ContainsForbidden(collector.symbols_);
@ -158,7 +157,7 @@ class IndependentSubtreeFinder : public DistributedOperatorVisitor {
// Case 1.a)
new_scan = std::make_shared<ScanAllByLabelPropertyRange>(
scan.input(), scan.output_symbol_, scan.label_, scan.property_,
scan.property_name_, std::experimental::nullopt, scan.upper_bound_,
scan.property_name_, std::nullopt, scan.upper_bound_,
scan.graph_view_);
}
}
@ -188,8 +187,8 @@ class IndependentSubtreeFinder : public DistributedOperatorVisitor {
// Case 1.a)
new_scan = std::make_shared<ScanAllByLabelPropertyRange>(
scan.input(), scan.output_symbol_, scan.label_, scan.property_,
scan.property_name_, scan.lower_bound_,
std::experimental::nullopt, scan.graph_view_);
scan.property_name_, scan.lower_bound_, std::nullopt,
scan.graph_view_);
} else {
// Case 1.b)
new_scan = std::make_shared<ScanAllByLabel>(
@ -698,25 +697,24 @@ class IndependentSubtreeFinder : public DistributedOperatorVisitor {
AstStorage *storage_;
template <class TCollection>
std::experimental::optional<int64_t> ContainsForbidden(
const TCollection &symbols) {
std::optional<int64_t> ContainsForbidden(const TCollection &symbols) {
for (int64_t i = 0; i < forbidden_symbols_.size(); ++i) {
for (const auto &symbol : symbols) {
if (utils::Contains(forbidden_symbols_[i], symbol)) {
return std::experimental::make_optional(i);
return std::make_optional(i);
}
}
}
return std::experimental::nullopt;
return std::nullopt;
}
std::experimental::optional<int64_t> FindForbidden(const Symbol &symbol) {
std::optional<int64_t> FindForbidden(const Symbol &symbol) {
for (int64_t i = 0; i < forbidden_symbols_.size(); ++i) {
if (utils::Contains(forbidden_symbols_[i], symbol)) {
return std::experimental::make_optional(i);
return std::make_optional(i);
}
}
return std::experimental::nullopt;
return std::nullopt;
}
void SetBranch(std::shared_ptr<LogicalOperator> subtree,

View File

@ -712,8 +712,8 @@ class PullRemoteOrderByCursor : public Cursor {
output.emplace_back(frame[symbol]);
}
merge_.push_back(MergeResultItem{std::experimental::nullopt, output,
evaluate_result()});
merge_.push_back(
MergeResultItem{std::nullopt, output, evaluate_result()});
}
missing_master_result_ = false;
}
@ -799,7 +799,7 @@ class PullRemoteOrderByCursor : public Cursor {
private:
struct MergeResultItem {
std::experimental::optional<int> worker_id;
std::optional<int> worker_id;
std::vector<TypedValue> remote_result;
std::vector<TypedValue> order_by;
};
@ -953,10 +953,10 @@ class DistributedExpandCursor : public query::plan::Cursor {
void Reset() override {
input_cursor_->Reset();
in_edges_ = std::experimental::nullopt;
in_edges_it_ = std::experimental::nullopt;
out_edges_ = std::experimental::nullopt;
out_edges_it_ = std::experimental::nullopt;
in_edges_ = std::nullopt;
in_edges_it_ = std::nullopt;
out_edges_ = std::nullopt;
out_edges_it_ = std::nullopt;
// Explicitly get all of the requested RPC futures, so that we register any
// exceptions.
for (auto &future_expand : future_expands_) {
@ -1040,10 +1040,10 @@ class DistributedExpandCursor : public query::plan::Cursor {
// The iterable over edges and the current edge iterator are referenced via
// optional because they can not be initialized in the constructor of
// this class. They are initialized once for each pull from the input.
std::experimental::optional<InEdgeT> in_edges_;
std::experimental::optional<InEdgeIteratorT> in_edges_it_;
std::experimental::optional<OutEdgeT> out_edges_;
std::experimental::optional<OutEdgeIteratorT> out_edges_it_;
std::optional<InEdgeT> in_edges_;
std::optional<InEdgeIteratorT> in_edges_it_;
std::optional<OutEdgeT> out_edges_;
std::optional<OutEdgeIteratorT> out_edges_it_;
// Stores the last frame before we yield the frame for future edge. It needs
// to be restored afterward.
std::vector<TypedValue> last_frame_;
@ -1125,9 +1125,9 @@ class DistributedExpandBfsCursor : public query::plan::Cursor {
// worker queried for its path segment owned the crossing edge,
// `current_vertex_addr` will be set. Otherwise, `current_edge_addr`
// will be set.
std::experimental::optional<storage::VertexAddress>
current_vertex_addr = last_vertex.ValueVertex().GlobalAddress();
std::experimental::optional<storage::EdgeAddress> current_edge_addr;
std::optional<storage::VertexAddress> current_vertex_addr =
last_vertex.ValueVertex().GlobalAddress();
std::optional<storage::EdgeAddress> current_edge_addr;
while (true) {
DCHECK(static_cast<bool>(current_edge_addr) ^
@ -1274,9 +1274,8 @@ VertexAccessor &CreateVertexOnWorker(int worker_id,
properties.emplace(kv.first, std::move(value));
}
auto new_node =
database::InsertVertexIntoRemote(&dba, worker_id, node_info.labels,
properties, std::experimental::nullopt);
auto new_node = database::InsertVertexIntoRemote(
&dba, worker_id, node_info.labels, properties, std::nullopt);
frame[node_info.symbol] = new_node;
return frame[node_info.symbol].ValueVertex();
}

View File

@ -293,18 +293,18 @@ class ScanAllCursor : public Cursor {
void Reset() override {
input_cursor_->Reset();
vertices_ = std::experimental::nullopt;
vertices_it_ = std::experimental::nullopt;
vertices_ = std::nullopt;
vertices_it_ = std::nullopt;
}
private:
const Symbol output_symbol_;
const std::unique_ptr<Cursor> input_cursor_;
TVerticesFun get_vertices_;
std::experimental::optional<typename std::result_of<TVerticesFun(
std::optional<typename std::result_of<TVerticesFun(
Frame &, ExecutionContext &)>::type::value_type>
vertices_;
std::experimental::optional<decltype(vertices_.value().begin())> vertices_it_;
std::optional<decltype(vertices_.value().begin())> vertices_it_;
database::GraphDbAccessor &db_;
};
@ -319,8 +319,7 @@ ACCEPT_WITH_INPUT(ScanAll)
std::unique_ptr<Cursor> ScanAll::MakeCursor(
database::GraphDbAccessor &db) const {
auto vertices = [this, &db](Frame &, ExecutionContext &) {
return std::experimental::make_optional(
db.Vertices(graph_view_ == GraphView::NEW));
return std::make_optional(db.Vertices(graph_view_ == GraphView::NEW));
};
return std::make_unique<ScanAllCursor<decltype(vertices)>>(
output_symbol_, input_->MakeCursor(db), std::move(vertices), db);
@ -342,7 +341,7 @@ ACCEPT_WITH_INPUT(ScanAllByLabel)
std::unique_ptr<Cursor> ScanAllByLabel::MakeCursor(
database::GraphDbAccessor &db) const {
auto vertices = [this, &db](Frame &, ExecutionContext &) {
return std::experimental::make_optional(
return std::make_optional(
db.Vertices(label_, graph_view_ == GraphView::NEW));
};
return std::make_unique<ScanAllCursor<decltype(vertices)>>(
@ -352,9 +351,8 @@ std::unique_ptr<Cursor> ScanAllByLabel::MakeCursor(
ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange(
const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
storage::Label label, storage::Property property,
const std::string &property_name,
std::experimental::optional<Bound> lower_bound,
std::experimental::optional<Bound> upper_bound, GraphView graph_view)
const std::string &property_name, std::optional<Bound> lower_bound,
std::optional<Bound> upper_bound, GraphView graph_view)
: ScanAll(input, output_symbol, graph_view),
label_(label),
property_(property),
@ -369,18 +367,18 @@ ACCEPT_WITH_INPUT(ScanAllByLabelPropertyRange)
std::unique_ptr<Cursor> ScanAllByLabelPropertyRange::MakeCursor(
database::GraphDbAccessor &db) const {
auto vertices = [this, &db](Frame &frame, ExecutionContext &context)
-> std::experimental::optional<decltype(
db.Vertices(label_, property_, std::experimental::nullopt,
std::experimental::nullopt, false))> {
-> std::optional<decltype(
db.Vertices(label_, property_, std::nullopt, std::nullopt, false))> {
ExpressionEvaluator evaluator(&frame, context.symbol_table,
context.evaluation_context,
context.db_accessor, graph_view_);
auto convert = [&evaluator](const auto &bound)
-> std::experimental::optional<utils::Bound<PropertyValue>> {
if (!bound) return std::experimental::nullopt;
auto convert =
[&evaluator](
const auto &bound) -> std::optional<utils::Bound<PropertyValue>> {
if (!bound) return std::nullopt;
auto value = bound->value()->Accept(evaluator);
try {
return std::experimental::make_optional(
return std::make_optional(
utils::Bound<PropertyValue>(PropertyValue(value), bound->type()));
} catch (const TypedValueException &) {
throw QueryRuntimeException("'{}' cannot be used as a property value.",
@ -391,13 +389,11 @@ std::unique_ptr<Cursor> ScanAllByLabelPropertyRange::MakeCursor(
auto maybe_upper = convert(upper_bound_);
// If any bound is null, then the comparison would result in nulls. This
// is treated as not satisfying the filter, so return no vertices.
if (maybe_lower && maybe_lower->value().IsNull())
return std::experimental::nullopt;
if (maybe_upper && maybe_upper->value().IsNull())
return std::experimental::nullopt;
return std::experimental::make_optional(
db.Vertices(label_, property_, maybe_lower, maybe_upper,
graph_view_ == GraphView::NEW));
if (maybe_lower && maybe_lower->value().IsNull()) return std::nullopt;
if (maybe_upper && maybe_upper->value().IsNull()) return std::nullopt;
return std::make_optional(db.Vertices(label_, property_, maybe_lower,
maybe_upper,
graph_view_ == GraphView::NEW));
};
return std::make_unique<ScanAllCursor<decltype(vertices)>>(
output_symbol_, input_->MakeCursor(db), std::move(vertices), db);
@ -421,20 +417,20 @@ ACCEPT_WITH_INPUT(ScanAllByLabelPropertyValue)
std::unique_ptr<Cursor> ScanAllByLabelPropertyValue::MakeCursor(
database::GraphDbAccessor &db) const {
auto vertices = [this, &db](Frame &frame, ExecutionContext &context)
-> std::experimental::optional<decltype(
-> std::optional<decltype(
db.Vertices(label_, property_, PropertyValue::Null, false))> {
ExpressionEvaluator evaluator(&frame, context.symbol_table,
context.evaluation_context,
context.db_accessor, graph_view_);
auto value = expression_->Accept(evaluator);
if (value.IsNull()) return std::experimental::nullopt;
if (value.IsNull()) return std::nullopt;
if (!value.IsPropertyValue()) {
throw QueryRuntimeException("'{}' cannot be used as a property value.",
value.type());
}
return std::experimental::make_optional(
db.Vertices(label_, property_, PropertyValue(value),
graph_view_ == GraphView::NEW));
return std::make_optional(db.Vertices(label_, property_,
PropertyValue(value),
graph_view_ == GraphView::NEW));
};
return std::make_unique<ScanAllCursor<decltype(vertices)>>(
output_symbol_, input_->MakeCursor(db), std::move(vertices), db);
@ -533,10 +529,10 @@ void Expand::ExpandCursor::Shutdown() { input_cursor_->Shutdown(); }
void Expand::ExpandCursor::Reset() {
input_cursor_->Reset();
in_edges_ = std::experimental::nullopt;
in_edges_it_ = std::experimental::nullopt;
out_edges_ = std::experimental::nullopt;
out_edges_it_ = std::experimental::nullopt;
in_edges_ = std::nullopt;
in_edges_it_ = std::nullopt;
out_edges_ = std::nullopt;
out_edges_it_ = std::nullopt;
}
bool Expand::ExpandCursor::InitEdges(Frame &frame, ExecutionContext &context) {
@ -596,15 +592,16 @@ bool Expand::ExpandCursor::InitEdges(Frame &frame, ExecutionContext &context) {
}
}
ExpandVariable::ExpandVariable(
const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
Symbol node_symbol, Symbol edge_symbol, EdgeAtom::Type type,
EdgeAtom::Direction direction,
const std::vector<storage::EdgeType> &edge_types, bool is_reverse,
Expression *lower_bound, Expression *upper_bound, bool existing_node,
ExpansionLambda filter_lambda,
std::experimental::optional<ExpansionLambda> weight_lambda,
std::experimental::optional<Symbol> total_weight)
ExpandVariable::ExpandVariable(const std::shared_ptr<LogicalOperator> &input,
Symbol input_symbol, Symbol node_symbol,
Symbol edge_symbol, EdgeAtom::Type type,
EdgeAtom::Direction direction,
const std::vector<storage::EdgeType> &edge_types,
bool is_reverse, Expression *lower_bound,
Expression *upper_bound, bool existing_node,
ExpansionLambda filter_lambda,
std::optional<ExpansionLambda> weight_lambda,
std::optional<Symbol> total_weight)
: input_(input ? input : std::make_shared<Once>()),
input_symbol_(input_symbol),
common_{node_symbol, edge_symbol, direction, edge_types, existing_node},
@ -975,8 +972,7 @@ class STShortestPathCursor : public query::plan::Cursor {
std::unique_ptr<query::plan::Cursor> input_cursor_;
using VertexEdgeMapT =
std::unordered_map<VertexAccessor,
std::experimental::optional<EdgeAccessor>>;
std::unordered_map<VertexAccessor, std::optional<EdgeAccessor>>;
void ReconstructPath(const VertexAccessor &midpoint,
const VertexEdgeMapT &in_edge,
@ -1048,9 +1044,9 @@ class STShortestPathCursor : public query::plan::Cursor {
size_t current_length = 0;
source_frontier.emplace_back(source);
in_edge[source] = std::experimental::nullopt;
in_edge[source] = std::nullopt;
sink_frontier.emplace_back(sink);
out_edge[sink] = std::experimental::nullopt;
out_edge[sink] = std::nullopt;
while (true) {
if (dba.should_abort()) throw HintedAbortError();
@ -1240,7 +1236,7 @@ class SingleSourceShortestPathCursor : public query::plan::Cursor {
if (upper_bound_ < 1 || lower_bound_ > upper_bound_) continue;
auto vertex = vertex_value.Value<VertexAccessor>();
processed_.emplace(vertex, std::experimental::nullopt);
processed_.emplace(vertex, std::nullopt);
expand_from_vertex(vertex);
// go back to loop start and see if we expanded anything
@ -1303,8 +1299,7 @@ class SingleSourceShortestPathCursor : public query::plan::Cursor {
// maps vertices to the edge they got expanded from. it is an optional
// edge because the root does not get expanded from anything.
// contains visited vertices as well as those scheduled to be visited.
std::unordered_map<VertexAccessor, std::experimental::optional<EdgeAccessor>>
processed_;
std::unordered_map<VertexAccessor, std::optional<EdgeAccessor>> processed_;
// edge/vertex pairs we have yet to visit, for current and next depth
std::vector<std::pair<EdgeAccessor, VertexAccessor>> to_visit_current_;
std::vector<std::pair<EdgeAccessor, VertexAccessor>> to_visit_next_;
@ -1319,9 +1314,9 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
bool Pull(Frame &frame, ExecutionContext &context) override {
SCOPED_PROFILE_OP("ExpandWeightedShortestPath");
ExpressionEvaluator evaluator(
&frame, context.symbol_table, context.evaluation_context,
context.db_accessor, GraphView::OLD);
ExpressionEvaluator evaluator(&frame, context.symbol_table,
context.evaluation_context,
context.db_accessor, GraphView::OLD);
auto create_state = [this](VertexAccessor vertex, int depth) {
return std::make_pair(vertex, upper_bound_set_ ? depth : 0);
};
@ -1416,7 +1411,7 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
total_cost_.clear();
yielded_vertices_.clear();
pq_.push({0.0, 0, vertex, std::experimental::nullopt});
pq_.push({0.0, 0, vertex, std::nullopt});
// We are adding the starting vertex to the set of yielded vertices
// because we don't want to yield paths that end with the starting
// vertex.
@ -1429,8 +1424,7 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
double current_weight = std::get<0>(current);
int current_depth = std::get<1>(current);
VertexAccessor current_vertex = std::get<2>(current);
std::experimental::optional<EdgeAccessor> current_edge =
std::get<3>(current);
std::optional<EdgeAccessor> current_edge = std::get<3>(current);
pq_.pop();
auto current_state = create_state(current_vertex, current_depth);
@ -1522,7 +1516,7 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
// Maps vertices to edges used to reach them.
std::unordered_map<std::pair<VertexAccessor, int>,
std::experimental::optional<EdgeAccessor>, WspStateHash>
std::optional<EdgeAccessor>, WspStateHash>
previous_;
// Keeps track of vertices for which we yielded a path already.
@ -1531,20 +1525,18 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor {
// Priority queue comparator. Keep lowest weight on top of the queue.
class PriorityQueueComparator {
public:
bool operator()(
const std::tuple<double, int, VertexAccessor,
std::experimental::optional<EdgeAccessor>> &lhs,
const std::tuple<double, int, VertexAccessor,
std::experimental::optional<EdgeAccessor>> &rhs) {
bool operator()(const std::tuple<double, int, VertexAccessor,
std::optional<EdgeAccessor>> &lhs,
const std::tuple<double, int, VertexAccessor,
std::optional<EdgeAccessor>> &rhs) {
return std::get<0>(lhs) > std::get<0>(rhs);
}
};
std::priority_queue<
std::tuple<double, int, VertexAccessor,
std::experimental::optional<EdgeAccessor>>,
std::vector<std::tuple<double, int, VertexAccessor,
std::experimental::optional<EdgeAccessor>>>,
std::tuple<double, int, VertexAccessor, std::optional<EdgeAccessor>>,
std::vector<
std::tuple<double, int, VertexAccessor, std::optional<EdgeAccessor>>>,
PriorityQueueComparator>
pq_;

View File

@ -3,8 +3,8 @@
#pragma once
#include <experimental/optional>
#include <memory>
#include <optional>
#include <unordered_map>
#include <unordered_set>
#include <utility>
@ -728,7 +728,7 @@ given label.
bool has_bound;
slk::Load(&has_bound, reader);
if (!has_bound) {
self->${member} = std::experimental::nullopt;
self->${member} = std::nullopt;
return;
}
uint8_t bound_type_value;
@ -786,7 +786,7 @@ given label.
${source}->value()->Clone(storage),
${source}->type()));
} else {
${dest} = std::experimental::nullopt;
${dest} = std::nullopt;
}
cpp<#)
@ -794,14 +794,14 @@ given label.
((label "storage::Label" :scope :public)
(property "storage::Property" :scope :public)
(property-name "std::string" :scope :public)
(lower-bound "std::experimental::optional<Bound>" :scope :public
(lower-bound "std::optional<Bound>" :scope :public
:slk-save #'slk-save-optional-bound
:slk-load #'slk-load-optional-bound
:capnp-save #'save-optional-bound
:capnp-load #'load-optional-bound
:capnp-type "Utils.Optional(Utils.Bound(Ast.Tree))"
:clone #'clone-optional-bound)
(upper-bound "std::experimental::optional<Bound>" :scope :public
(upper-bound "std::optional<Bound>" :scope :public
:slk-save #'slk-save-optional-bound
:slk-load #'slk-load-optional-bound
:capnp-save #'save-optional-bound
@ -838,8 +838,8 @@ property value which is inside a range (inclusive or exlusive).
Symbol output_symbol, storage::Label label,
storage::Property property,
const std::string &property_name,
std::experimental::optional<Bound> lower_bound,
std::experimental::optional<Bound> upper_bound,
std::optional<Bound> lower_bound,
std::optional<Bound> upper_bound,
GraphView graph_view = GraphView::OLD);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
@ -1003,10 +1003,10 @@ pulled.")
// The iterable over edges and the current edge iterator are referenced via
// optional because they can not be initialized in the constructor of
// this class. They are initialized once for each pull from the input.
std::experimental::optional<InEdgeT> in_edges_;
std::experimental::optional<InEdgeIteratorT> in_edges_it_;
std::experimental::optional<OutEdgeT> out_edges_;
std::experimental::optional<OutEdgeIteratorT> out_edges_it_;
std::optional<InEdgeT> in_edges_;
std::optional<InEdgeIteratorT> in_edges_it_;
std::optional<OutEdgeT> out_edges_;
std::optional<OutEdgeIteratorT> out_edges_it_;
bool InitEdges(Frame &, ExecutionContext &);
};
@ -1077,13 +1077,13 @@ pulled.")
#>cpp
Load(&${member}, ${reader}, &helper->ast_storage);
cpp<#))
(weight-lambda "std::experimental::optional<ExpansionLambda>" :scope :public
(weight-lambda "std::optional<ExpansionLambda>" :scope :public
:slk-load (lambda (member)
#>cpp
bool has_value;
slk::Load(&has_value, reader);
if (!has_value) {
self->${member} = std::experimental::nullopt;
self->${member} = std::nullopt;
return;
}
query::plan::ExpansionLambda lambda;
@ -1100,7 +1100,7 @@ pulled.")
Load(&val, reader, &helper->ast_storage);
return val;
}"))
(total-weight "std::experimental::optional<Symbol>" :scope :public
(total-weight "std::optional<Symbol>" :scope :public
:capnp-save (lcp:capnp-save-optional "::query::capnp::Symbol" "Symbol")
:capnp-load (lcp:capnp-load-optional "::query::capnp::Symbol" "Symbol")))
(:documentation
@ -1157,8 +1157,8 @@ pulled.")
bool is_reverse, Expression *lower_bound,
Expression *upper_bound, bool existing_node,
ExpansionLambda filter_lambda,
std::experimental::optional<ExpansionLambda> weight_lambda,
std::experimental::optional<Symbol> total_weight);
std::optional<ExpansionLambda> weight_lambda,
std::optional<Symbol> total_weight);
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
std::unique_ptr<Cursor> MakeCursor(

View File

@ -109,7 +109,7 @@ auto MakeLogicalPlan(TPlanningContext *context, TPlanPostProcess *post_process,
ProcessedPlan last_plan;
for (const auto &query_part : query_parts.query_parts) {
std::experimental::optional<ProcessedPlan> curr_plan;
std::optional<ProcessedPlan> curr_plan;
double min_cost = std::numeric_limits<double>::max();
if (use_variable_planner) {

View File

@ -163,8 +163,8 @@ PropertyFilter::PropertyFilter(const SymbolTable &symbol_table,
PropertyFilter::PropertyFilter(
const SymbolTable &symbol_table, const Symbol &symbol, PropertyIx property,
const std::experimental::optional<PropertyFilter::Bound> &lower_bound,
const std::experimental::optional<PropertyFilter::Bound> &upper_bound)
const std::optional<PropertyFilter::Bound> &lower_bound,
const std::optional<PropertyFilter::Bound> &upper_bound)
: symbol_(symbol),
property_(property),
type_(Type::RANGE),
@ -389,18 +389,18 @@ void Filters::AnalyzeAndStoreFilter(Expression *expr,
if (get_property_lookup(expr1, prop_lookup, ident)) {
// n.prop > value
auto filter = make_filter(FilterInfo::Type::Property);
filter.property_filter.emplace(
symbol_table, symbol_table.at(*ident), prop_lookup->property_,
Bound(expr2, bound_type), std::experimental::nullopt);
filter.property_filter.emplace(symbol_table, symbol_table.at(*ident),
prop_lookup->property_,
Bound(expr2, bound_type), std::nullopt);
all_filters_.emplace_back(filter);
is_prop_filter = true;
}
if (get_property_lookup(expr2, prop_lookup, ident)) {
// value > n.prop
auto filter = make_filter(FilterInfo::Type::Property);
filter.property_filter.emplace(
symbol_table, symbol_table.at(*ident), prop_lookup->property_,
std::experimental::nullopt, Bound(expr1, bound_type));
filter.property_filter.emplace(symbol_table, symbol_table.at(*ident),
prop_lookup->property_, std::nullopt,
Bound(expr1, bound_type));
all_filters_.emplace_back(filter);
is_prop_filter = true;
}

View File

@ -1,7 +1,7 @@
/// @file
#pragma once
#include <experimental/optional>
#include <optional>
#include <set>
#include <unordered_map>
#include <unordered_set>
@ -89,8 +89,7 @@ class PropertyFilter {
Type);
/// Construct the range based filter.
PropertyFilter(const SymbolTable &, const Symbol &, PropertyIx,
const std::experimental::optional<Bound> &,
const std::experimental::optional<Bound> &);
const std::optional<Bound> &, const std::optional<Bound> &);
/// Symbol whose property is looked up.
Symbol symbol_;
@ -102,8 +101,8 @@ class PropertyFilter {
/// equal or regex match depending on type_.
Expression *value_ = nullptr;
/// Expressions which produce lower and upper bounds for a property.
std::experimental::optional<Bound> lower_bound_{};
std::experimental::optional<Bound> upper_bound_{};
std::optional<Bound> lower_bound_{};
std::optional<Bound> upper_bound_{};
};
/// Stores additional information for a filter expression.
@ -122,7 +121,7 @@ struct FilterInfo {
/// Labels for Type::Label filtering.
std::vector<LabelIx> labels;
/// Property information for Type::Property filtering.
std::experimental::optional<PropertyFilter> property_filter;
std::optional<PropertyFilter> property_filter;
};
/// Stores information on filters used inside the @c Matching of a @c QueryPart.

Some files were not shown because too many files have changed in this diff Show More