diff --git a/CMakeLists.txt b/CMakeLists.txt index 78a77aa27..a632a1682 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. diff --git a/src/audit/log.cpp b/src/audit/log.cpp index 2c9eb475c..269c5aeff 100644 --- a/src/audit/log.cpp +++ b/src/audit/log.cpp @@ -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), diff --git a/src/audit/log.hpp b/src/audit/log.hpp index 21d7044e0..b6127415a 100644 --- a/src/audit/log.hpp +++ b/src/audit/log.hpp @@ -1,8 +1,8 @@ #pragma once #include -#include -#include +#include +#include #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 started_; - std::experimental::optional> buffer_; + std::optional> buffer_; utils::Scheduler scheduler_; utils::LogFile log_; diff --git a/src/auth/auth.cpp b/src/auth/auth.cpp index 330ebbb20..62b7c234e 100644 --- a/src/auth/auth.cpp +++ b/src/auth/auth.cpp @@ -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 LdapFindRole( - LDAP *ld, const std::string &role_base_dn, const std::string &user_dn, - const std::string &username) { +std::optional 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 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 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 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 Auth::Authenticate( - const std::string &username, const std::string &password) { +std::optional 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 Auth::Authenticate( } // Find role name. - std::experimental::optional rolename; + std::optional 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 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 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 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 Auth::GetUser( - const std::string &username_orig) { +std::optional 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 Auth::AddUser( - const std::string &username, - const std::experimental::optional &password) { +std::optional Auth::AddUser(const std::string &username, + const std::optional &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 Auth::GetRole( - const std::string &rolename_orig) { +std::optional 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 Auth::AddRole(const std::string &rolename) { +std::optional 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; diff --git a/src/auth/auth.hpp b/src/auth/auth.hpp index 40b41f757..a04d410a8 100644 --- a/src/auth/auth.hpp +++ b/src/auth/auth.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include #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 Authenticate(const std::string &username, - const std::string &password); + std::optional 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 GetUser(const std::string &username); + std::optional 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 AddUser( + std::optional AddUser( const std::string &username, - const std::experimental::optional &password = - std::experimental::nullopt); + const std::optional &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 GetRole(const std::string &rolename); + std::optional 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 AddRole(const std::string &rolename); + std::optional AddRole(const std::string &rolename); /** * Removes a role from the storage. diff --git a/src/auth/models.cpp b/src/auth/models.cpp index d783fba37..7dacce891 100644 --- a/src/auth/models.cpp +++ b/src/auth/models.cpp @@ -190,8 +190,7 @@ bool User::CheckPassword(const std::string &password) { return VerifyPassword(password, password_hash_); } -void User::UpdatePassword( - const std::experimental::optional &password) { +void User::UpdatePassword(const std::optional &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 User::role() const { return role_; } +std::optional User::role() const { return role_; } nlohmann::json User::Serialize() const { nlohmann::json data = nlohmann::json::object(); diff --git a/src/auth/models.hpp b/src/auth/models.hpp index 0fe86290e..9740a94c5 100644 --- a/src/auth/models.hpp +++ b/src/auth/models.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -108,8 +108,8 @@ class User final { bool CheckPassword(const std::string &password); - void UpdatePassword(const std::experimental::optional &password = - std::experimental::nullopt); + void UpdatePassword( + const std::optional &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() const; + std::optional 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_; + std::optional role_; }; bool operator==(const User &first, const User &second); diff --git a/src/communication/bolt/v1/encoder/base_encoder.hpp b/src/communication/bolt/v1/encoder/base_encoder.hpp index eac87510a..bed2153c3 100644 --- a/src/communication/bolt/v1/encoder/base_encoder.hpp +++ b/src/communication/bolt/v1/encoder/base_encoder.hpp @@ -1,14 +1,14 @@ #pragma once -#include +#include #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::experimental::is_same_v, +static_assert(std::is_same_v || + std::is_same_v, "communication::bolt::Encoder requires uint8_t to be " "implemented as char or unsigned char."); diff --git a/src/communication/rpc/client.cpp b/src/communication/rpc/client.cpp index e7756a5b4..d6ccb0447 100644 --- a/src/communication/rpc/client.cpp +++ b/src/communication/rpc/client.cpp @@ -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(&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 diff --git a/src/communication/rpc/client.hpp b/src/communication/rpc/client.hpp index fdbdf0135..aa17c8fa2 100644 --- a/src/communication/rpc/client.hpp +++ b/src/communication/rpc/client.hpp @@ -1,8 +1,8 @@ #pragma once -#include #include #include +#include #include #include @@ -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 client_; + std::optional client_; std::mutex mutex_; }; diff --git a/src/communication/rpc/serialization.hpp b/src/communication/rpc/serialization.hpp index f8ae8d3d7..644369ac6 100644 --- a/src/communication/rpc/serialization.hpp +++ b/src/communication/rpc/serialization.hpp @@ -3,14 +3,14 @@ #include #include #include -#include -#include #include #include #include #include +#include #include #include +#include #include #include #include @@ -23,8 +23,8 @@ namespace slk { // Static assert for the assumption made in this library. -static_assert(std::experimental::is_same_v || - std::experimental::is_same_v, +static_assert(std::is_same_v || + std::is_same_v, "The slk library requires uint8_t to be implemented as char or " "unsigned char."); @@ -68,9 +68,9 @@ void Load(std::unique_ptr *obj, Reader *reader, const std::function *, Reader *)> &load); template -void Save(const std::experimental::optional &obj, Builder *builder); +void Save(const std::optional &obj, Builder *builder); template -void Load(std::experimental::optional *obj, Reader *reader); +void Load(std::optional *obj, Reader *reader); template void Save(const std::shared_ptr &obj, Builder *builder, @@ -278,8 +278,8 @@ inline void Load( } template -inline void Save(const std::experimental::optional &obj, Builder *builder) { - if (obj == std::experimental::nullopt) { +inline void Save(const std::optional &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 &obj, Builder *builder) { } template -inline void Load(std::experimental::optional *obj, Reader *reader) { +inline void Load(std::optional *obj, Reader *reader) { bool exists = false; Load(&exists, reader); if (exists) { @@ -298,7 +298,7 @@ inline void Load(std::experimental::optional *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 *obj, Reader *reader, } template -inline void Save(const std::experimental::optional &obj, Builder *builder, +inline void Save(const std::optional &obj, Builder *builder, std::function 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 &obj, Builder *builder, } template -inline void Load(std::experimental::optional *obj, Reader *reader, +inline void Load(std::optional *obj, Reader *reader, std::function item_load_function) { bool exists = false; Load(&exists, reader); @@ -457,7 +457,7 @@ inline void Load(std::experimental::optional *obj, Reader *reader, item_load_function(&item, reader); obj->emplace(std::move(item)); } else { - *obj = std::experimental::nullopt; + *obj = std::nullopt; } } } // namespace slk diff --git a/src/communication/server.hpp b/src/communication/server.hpp index c179760c9..d8305c804 100644 --- a/src/communication/server.hpp +++ b/src/communication/server.hpp @@ -1,9 +1,9 @@ #pragma once #include -#include #include #include +#include #include #include diff --git a/src/config.hpp b/src/config.hpp index 28dd229a3..7669a8398 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -14,7 +14,7 @@ /// 2) ~/.memgraph/config /// 3) env - MEMGRAPH_CONFIG void LoadConfig() { - namespace fs = std::experimental::filesystem; + namespace fs = std::filesystem; std::vector 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; } - diff --git a/src/data_structures/concurrent/skiplist_gc.hpp b/src/data_structures/concurrent/skiplist_gc.hpp index 381109b99..e1756a8a9 100644 --- a/src/data_structures/concurrent/skiplist_gc.hpp +++ b/src/data_structures/concurrent/skiplist_gc.hpp @@ -2,9 +2,9 @@ #include -#include #include #include +#include #include #include diff --git a/src/data_structures/queue.hpp b/src/data_structures/queue.hpp index 815cedddc..ffaa738db 100644 --- a/src/data_structures/queue.hpp +++ b/src/data_structures/queue.hpp @@ -3,9 +3,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -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 AwaitPop( - std::chrono::system_clock::duration timeout = - std::chrono::system_clock::duration::max()) { + std::optional AwaitPop(std::chrono::system_clock::duration timeout = + std::chrono::system_clock::duration::max()) { std::unique_lock 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 x(std::move(queue_.front())); + if (queue_.empty() || !alive_) return std::nullopt; + std::optional x(std::move(queue_.front())); queue_.pop(); return x; } // Nonblocking version of above function. - std::experimental::optional MaybePop() { + std::optional MaybePop() { std::unique_lock guard(mutex_); - if (queue_.empty()) return std::experimental::nullopt; - std::experimental::optional x(std::move(queue_.front())); + if (queue_.empty()) return std::nullopt; + std::optional x(std::move(queue_.front())); queue_.pop(); return x; } diff --git a/src/data_structures/ring_buffer.hpp b/src/data_structures/ring_buffer.hpp index 33e754f3a..07641f7b2 100644 --- a/src/data_structures/ring_buffer.hpp +++ b/src/data_structures/ring_buffer.hpp @@ -2,8 +2,8 @@ #include #include -#include #include +#include #include #include @@ -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 pop() { + std::optional pop() { std::lock_guard guard(lock_); - if (size_ == 0) return std::experimental::nullopt; + if (size_ == 0) return std::nullopt; size_--; - std::experimental::optional result( - std::move(buffer_[read_pos_++])); + std::optional result(std::move(buffer_[read_pos_++])); read_pos_ %= capacity_; return result; } diff --git a/src/database/distributed/distributed_graph_db.cpp b/src/database/distributed/distributed_graph_db.cpp index d3eddcc91..9132222d4 100644 --- a/src/database/distributed/distributed_graph_db.cpp +++ b/src/database/distributed/distributed_graph_db.cpp @@ -62,8 +62,7 @@ class MasterAccessor final : public GraphDbAccessor { worker_id_(db->WorkerId()) {} void PostCreateIndex(const LabelPropertyIndex::Key &key) override { - std::experimental::optional>> - index_rpc_completions; + std::optional>> index_rpc_completions; // Notify all workers to create the index index_rpc_completions.emplace(coordination_->ExecuteOnWorkers( @@ -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>> - index_rpc_completions; + std::optional>> index_rpc_completions; index_rpc_completions.emplace(coordination_->ExecuteOnWorkers( 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 recovery_info; + std::optional 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 &labels, const std::unordered_map &properties, - std::experimental::optional cypher_id) { + std::optional 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 recovery_info; + std::optional recovery_info; durability::RecoveryData recovery_data; // Recover only if necessary. diff --git a/src/database/distributed/distributed_graph_db.hpp b/src/database/distributed/distributed_graph_db.hpp index 2854c9779..92bab6994 100644 --- a/src/database/distributed/distributed_graph_db.hpp +++ b/src/database/distributed/distributed_graph_db.hpp @@ -105,8 +105,7 @@ class Worker final : public GraphDb { VertexAccessor InsertVertexIntoRemote( GraphDbAccessor *dba, int worker_id, const std::vector &labels, - const std::unordered_map - &properties, - std::experimental::optional cypher_id); + const std::unordered_map &properties, + std::optional cypher_id); } // namespace database diff --git a/src/database/distributed/graph_db_accessor.cpp b/src/database/distributed/graph_db_accessor.cpp index 0d34c1c04..a32eaecdc 100644 --- a/src/database/distributed/graph_db_accessor.cpp +++ b/src/database/distributed/graph_db_accessor.cpp @@ -75,8 +75,7 @@ bool GraphDbAccessor::should_abort() const { durability::WriteAheadLog &GraphDbAccessor::wal() { return db_.wal(); } VertexAccessor GraphDbAccessor::InsertVertex( - std::experimental::optional requested_gid, - std::experimental::optional cypher_id) { + std::optional requested_gid, std::optional 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 GraphDbAccessor::FindVertexOptional( +std::optional 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 GraphDbAccessor::FindEdgeOptional( +std::optional 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> lower, - const std::experimental::optional> upper) - const { + const std::optional> lower, + const std::optional> 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 requested_gid, - std::experimental::optional cypher_id) { +EdgeAccessor GraphDbAccessor::InsertEdge(VertexAccessor &from, + VertexAccessor &to, + storage::EdgeType edge_type, + std::optional requested_gid, + std::optional 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 &requested_gid, - const std::experimental::optional &cypher_id) { + const std::optional &requested_gid, + const std::optional &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 requested_gid, - std::experimental::optional cypher_id) { + storage::EdgeType edge_type, std::optional requested_gid, + std::optional cypher_id) { CHECK(from.is_local()) << "`from` address should be local when calling InsertOnlyEdge"; auto gid = db_.storage().edge_generator_.Next(requested_gid); diff --git a/src/database/distributed/graph_db_accessor.hpp b/src/database/distributed/graph_db_accessor.hpp index d304d015b..5edd0b8af 100644 --- a/src/database/distributed/graph_db_accessor.hpp +++ b/src/database/distributed/graph_db_accessor.hpp @@ -2,7 +2,7 @@ #pragma once -#include +#include #include #include @@ -101,10 +101,9 @@ class GraphDbAccessor { * * @return See above. */ - VertexAccessor InsertVertex(std::experimental::optional - requested_gid = std::experimental::nullopt, - std::experimental::optional cypher_id = - std::experimental::nullopt); + VertexAccessor InsertVertex( + std::optional requested_gid = std::nullopt, + std::optional 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 FindVertexOptional( - gid::Gid gid, bool current_state); + std::optional 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> lower, - const std::experimental::optional> upper, - bool current_state) { + auto Vertices(storage::Label label, storage::Property property, + const std::optional> lower, + const std::optional> 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 requested_gid = - std::experimental::nullopt, - std::experimental::optional cypher_id = - std::experimental::nullopt); + std::optional requested_gid = std::nullopt, + std::optional 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 - requested_gid = std::experimental::nullopt, - std::experimental::optional cypher_id = - std::experimental::nullopt); + EdgeAccessor InsertOnlyEdge( + storage::VertexAddress from, storage::VertexAddress to, + storage::EdgeType edge_type, + std::optional requested_gid = std::nullopt, + std::optional 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 FindEdgeOptional( - gid::Gid gid, bool current_state); + std::optional 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 - std::experimental::optional Transfer(const TAccessor &accessor) { - if (accessor.db_accessor_ == this) - return std::experimental::make_optional(accessor); + std::optional 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> lower, - const std::experimental::optional> upper) - const; + const std::optional> lower, + const std::optional> 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 &requested_gid, - const std::experimental::optional &cypher_id); + const std::optional &requested_gid, + const std::optional &cypher_id); /** * Set the newly created edge on `to` vertex. diff --git a/src/database/single_node/graph_db.cpp b/src/database/single_node/graph_db.cpp index 6cfe679dd..333d7a50c 100644 --- a/src/database/single_node/graph_db.cpp +++ b/src/database/single_node/graph_db.cpp @@ -1,6 +1,6 @@ #include "database/single_node/graph_db.hpp" -#include +#include #include @@ -27,12 +27,11 @@ GraphDb::GraphDb(Config config) : config_(config) { "current version of Memgraph binary!"; // What we recover. - std::experimental::optional recovery_info; + std::optional 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 parent_tx) { + std::optional parent_tx) { return GraphDbAccessor(this, parent_tx); } diff --git a/src/database/single_node/graph_db.hpp b/src/database/single_node/graph_db.hpp index 6295d7673..e5bee8086 100644 --- a/src/database/single_node/graph_db.hpp +++ b/src/database/single_node/graph_db.hpp @@ -2,8 +2,8 @@ #pragma once #include -#include #include +#include #include #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 parent_tx = - std::experimental::nullopt); + std::optional parent_tx = std::nullopt); /// Create an accessor for a running transaction. GraphDbAccessor Access(tx::TransactionId); diff --git a/src/database/single_node/graph_db_accessor.cpp b/src/database/single_node/graph_db_accessor.cpp index 165fc521a..ba101701c 100644 --- a/src/database/single_node/graph_db_accessor.cpp +++ b/src/database/single_node/graph_db_accessor.cpp @@ -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 parent_tx) +GraphDbAccessor::GraphDbAccessor(GraphDb *db, + std::optional 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 requested_gid) { + std::optional 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 GraphDbAccessor::FindVertexOptional( +std::optional GraphDbAccessor::FindVertexOptional( gid::Gid gid, bool current_state) { VertexAccessor record_accessor(db_->storage().LocalAddress(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 GraphDbAccessor::FindEdgeOptional( +std::optional GraphDbAccessor::FindEdgeOptional( gid::Gid gid, bool current_state) { EdgeAccessor record_accessor(db_->storage().LocalAddress(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 &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 &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> lower, - const std::experimental::optional> upper) - const { + const std::optional> lower, + const std::optional> 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 requested_gid) { + std::optional requested_gid) { DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted"; auto gid = db_->storage().edge_generator_.Next(requested_gid); auto edge_vlist = new mvcc::VersionList( diff --git a/src/database/single_node/graph_db_accessor.hpp b/src/database/single_node/graph_db_accessor.hpp index 2fdb58da9..c29f4113c 100644 --- a/src/database/single_node/graph_db_accessor.hpp +++ b/src/database/single_node/graph_db_accessor.hpp @@ -2,10 +2,10 @@ #pragma once -#include +#include +#include #include #include -#include #include #include @@ -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 parent_tx); + GraphDbAccessor(GraphDb *db, std::optional parent_tx); public: ~GraphDbAccessor(); @@ -74,8 +73,8 @@ class GraphDbAccessor { * * @return See above. */ - VertexAccessor InsertVertex(std::experimental::optional - requested_gid = std::experimental::nullopt); + VertexAccessor InsertVertex( + std::optional 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 FindVertexOptional( - gid::Gid gid, bool current_state); + std::optional 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> lower, - const std::experimental::optional> upper, - bool current_state) { + auto Vertices(storage::Label label, storage::Property property, + const std::optional> lower, + const std::optional> 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 requested_gid = - std::experimental::nullopt); + std::optional 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 FindEdgeOptional( - gid::Gid gid, bool current_state); + std::optional 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 - std::experimental::optional Transfer(const TAccessor &accessor) { - if (accessor.db_accessor_ == this) - return std::experimental::make_optional(accessor); + std::optional 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> lower, - const std::experimental::optional> upper) - const; + const std::optional> lower, + const std::optional> upper) const; /** * Obtains the Label for the label's name. diff --git a/src/database/single_node_ha/graph_db.cpp b/src/database/single_node_ha/graph_db.cpp index 293320c3b..505dab053 100644 --- a/src/database/single_node_ha/graph_db.cpp +++ b/src/database/single_node_ha/graph_db.cpp @@ -1,6 +1,6 @@ #include "database/single_node_ha/graph_db.hpp" -#include +#include #include @@ -60,7 +60,7 @@ GraphDbAccessor GraphDb::Access(tx::TransactionId tx_id) { } GraphDbAccessor GraphDb::AccessBlocking( - std::experimental::optional parent_tx) { + std::optional parent_tx) { return GraphDbAccessor(this, parent_tx); } diff --git a/src/database/single_node_ha/graph_db.hpp b/src/database/single_node_ha/graph_db.hpp index e67e92072..afc14c786 100644 --- a/src/database/single_node_ha/graph_db.hpp +++ b/src/database/single_node_ha/graph_db.hpp @@ -2,8 +2,8 @@ #pragma once #include -#include #include +#include #include #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 parent_tx); + GraphDbAccessor AccessBlocking(std::optional parent_tx); /// Create an accessor for a running transaction. GraphDbAccessor Access(tx::TransactionId); diff --git a/src/database/single_node_ha/graph_db_accessor.cpp b/src/database/single_node_ha/graph_db_accessor.cpp index b6da58202..a12c4a664 100644 --- a/src/database/single_node_ha/graph_db_accessor.cpp +++ b/src/database/single_node_ha/graph_db_accessor.cpp @@ -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 parent_tx) +GraphDbAccessor::GraphDbAccessor(GraphDb *db, + std::optional 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 requested_gid) { + std::optional 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 GraphDbAccessor::FindVertexOptional( +std::optional GraphDbAccessor::FindVertexOptional( gid::Gid gid, bool current_state) { VertexAccessor record_accessor(db_->storage().LocalAddress(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 GraphDbAccessor::FindEdgeOptional( +std::optional GraphDbAccessor::FindEdgeOptional( gid::Gid gid, bool current_state) { EdgeAccessor record_accessor(db_->storage().LocalAddress(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> lower, - const std::experimental::optional> upper) - const { + const std::optional> lower, + const std::optional> 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 requested_gid) { + std::optional requested_gid) { DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted"; auto gid = db_->storage().edge_generator_.Next(requested_gid); auto edge_vlist = new mvcc::VersionList( diff --git a/src/database/single_node_ha/graph_db_accessor.hpp b/src/database/single_node_ha/graph_db_accessor.hpp index f7ce54777..4e6af03cf 100644 --- a/src/database/single_node_ha/graph_db_accessor.hpp +++ b/src/database/single_node_ha/graph_db_accessor.hpp @@ -2,10 +2,10 @@ #pragma once -#include +#include +#include #include #include -#include #include #include @@ -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 parent_tx); + GraphDbAccessor(GraphDb *db, std::optional parent_tx); public: ~GraphDbAccessor(); @@ -96,8 +95,8 @@ class GraphDbAccessor { * * @return See above. */ - VertexAccessor InsertVertex(std::experimental::optional - requested_gid = std::experimental::nullopt); + VertexAccessor InsertVertex( + std::optional 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 FindVertexOptional( - gid::Gid gid, bool current_state); + std::optional 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> lower, - const std::experimental::optional> upper, - bool current_state) { + auto Vertices(storage::Label label, storage::Property property, + const std::optional> lower, + const std::optional> 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 requested_gid = - std::experimental::nullopt); + std::optional 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 FindEdgeOptional( - gid::Gid gid, bool current_state); + std::optional 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 - std::experimental::optional Transfer(const TAccessor &accessor) { - if (accessor.db_accessor_ == this) - return std::experimental::make_optional(accessor); + std::optional 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> lower, - const std::experimental::optional> upper) - const; + const std::optional> lower, + const std::optional> upper) const; /** * Obtains the Label for the label's name. diff --git a/src/distributed/bfs_rpc_clients.cpp b/src/distributed/bfs_rpc_clients.cpp index 86aa74ef6..593e15d2f 100644 --- a/src/distributed/bfs_rpc_clients.cpp +++ b/src/distributed/bfs_rpc_clients.cpp @@ -68,7 +68,7 @@ void BfsRpcClients::ResetSubcursors( } } -std::experimental::optional BfsRpcClients::Pull( +std::optional 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(); diff --git a/src/distributed/bfs_rpc_clients.hpp b/src/distributed/bfs_rpc_clients.hpp index 0d29c5df5..2fcede0a1 100644 --- a/src/distributed/bfs_rpc_clients.hpp +++ b/src/distributed/bfs_rpc_clients.hpp @@ -32,14 +32,15 @@ class BfsRpcClients { const query::SymbolTable &symbol_table, const query::EvaluationContext &evaluation_context); + void RegisterSubcursors( const std::unordered_map &subcursor_ids); void ResetSubcursors( const std::unordered_map &subcursor_ids); - std::experimental::optional Pull( - int16_t worker_id, int64_t subcursor_id, database::GraphDbAccessor *dba); + std::optional Pull(int16_t worker_id, int64_t subcursor_id, + database::GraphDbAccessor *dba); bool ExpandLevel(const std::unordered_map &subcursor_ids); diff --git a/src/distributed/bfs_rpc_messages.lcp b/src/distributed/bfs_rpc_messages.lcp index edc1fb3b7..7146d6cc6 100644 --- a/src/distributed/bfs_rpc_messages.lcp +++ b/src/distributed/bfs_rpc_messages.lcp @@ -107,7 +107,7 @@ cpp<# (lcp:define-rpc subcursor-pull (:request ((member :int64_t))) (:response - ((vertex "std::experimental::optional" + ((vertex "std::optional" :slk-save (lambda (member) #>cpp slk::Save(static_cast(self.${member}), builder); @@ -161,10 +161,10 @@ cpp<# (lcp:define-rpc reconstruct-path (:request ((subcursor-id :int64_t) - (vertex "std::experimental::optional" + (vertex "std::optional" :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" + (edge "std::optional" :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" + (next-vertex "std::optional" :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" + (next-edge "std::optional" :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 &edges, - std::experimental::optional next_vertex, - std::experimental::optional next_edge) + std::optional next_vertex, + std::optional next_edge) : edges(edges), next_vertex(std::move(next_vertex)), next_edge(std::move(next_edge)) { CHECK(!static_cast(next_vertex) || !static_cast(next_edge)) << "At most one of `next_vertex` and `next_edge` should be set"; diff --git a/src/distributed/bfs_subcursor.cpp b/src/distributed/bfs_subcursor.cpp index 028295e37..efea3d29a 100644 --- a/src/distributed/bfs_subcursor.cpp +++ b/src/distributed/bfs_subcursor.cpp @@ -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 ExpandBfsSubcursor::Pull() { +std::optional 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, diff --git a/src/distributed/bfs_subcursor.hpp b/src/distributed/bfs_subcursor.hpp index aa4ea0a24..72616c839 100644 --- a/src/distributed/bfs_subcursor.hpp +++ b/src/distributed/bfs_subcursor.hpp @@ -26,8 +26,8 @@ class BfsRpcClients; /// information necessary to continue path reconstruction on another worker. struct PathSegment { std::vector edges; - std::experimental::optional next_vertex; - std::experimental::optional next_edge; + std::optional next_vertex; + std::optional 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 Pull(); + std::optional 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> + std::unordered_map> processed_; /// List of vertices at the current expansion level. diff --git a/src/distributed/cluster_discovery_master.cpp b/src/distributed/cluster_discovery_master.cpp index 9212977de..802bbc029 100644 --- a/src/distributed/cluster_discovery_master.cpp +++ b/src/distributed/cluster_discovery_master.cpp @@ -1,6 +1,6 @@ #include "distributed/cluster_discovery_master.hpp" -#include +#include #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 diff --git a/src/distributed/cluster_discovery_worker.cpp b/src/distributed/cluster_discovery_worker.cpp index 5be51c55c..03f4c2da3 100644 --- a/src/distributed/cluster_discovery_worker.cpp +++ b/src/distributed/cluster_discovery_worker.cpp @@ -1,6 +1,6 @@ #include "distributed/cluster_discovery_worker.hpp" -#include +#include #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 - &recovery_info) { + const std::optional &recovery_info) { CHECK(worker_id_ >= 0) << "Workers id is not yet assigned, preform registration before " "notifying that the recovery finished"; diff --git a/src/distributed/cluster_discovery_worker.hpp b/src/distributed/cluster_discovery_worker.hpp index 6d38c0b65..013740f9e 100644 --- a/src/distributed/cluster_discovery_worker.hpp +++ b/src/distributed/cluster_discovery_worker.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #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 - &recovery_info); + const std::optional &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> snapshot_to_recover_; + std::optional> snapshot_to_recover_; }; } // namespace distributed diff --git a/src/distributed/coordination_master.cpp b/src/distributed/coordination_master.cpp index 10ad58fa7..c1970a914 100644 --- a/src/distributed/coordination_master.cpp +++ b/src/distributed/coordination_master.cpp @@ -56,15 +56,15 @@ bool MasterCoordination::RegisterWorker(int desired_worker_id, } void MasterCoordination::WorkerRecoveredSnapshot( - int worker_id, const std::experimental::optional - &recovery_info) { + int worker_id, + const std::optional &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::optional> recovered_snapshot_tx) { std::lock_guard guard(master_lock_); recovery_done_ = true; @@ -75,7 +75,7 @@ int MasterCoordination::CountRecoveredWorkers() const { return recovered_workers_.size(); } -std::experimental::optional> +std::optional> MasterCoordination::RecoveredSnapshotTx() const { std::lock_guard guard(master_lock_); CHECK(recovery_done_) << "Recovered snapshot requested before it's available"; diff --git a/src/distributed/coordination_master.hpp b/src/distributed/coordination_master.hpp index ac170d82d..b7711d042 100644 --- a/src/distributed/coordination_master.hpp +++ b/src/distributed/coordination_master.hpp @@ -1,9 +1,9 @@ #pragma once #include -#include #include #include +#include #include #include @@ -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 - &recovery_info); + int worker_id, + const std::optional &recovery_info); /// Sets the recovery info. nullopt indicates nothing was recovered. void SetRecoveredSnapshot( - std::experimental::optional> - recovered_snapshot); + std::optional> recovered_snapshot); - std::experimental::optional> - RecoveredSnapshotTx() const; + std::optional> 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> - recovered_workers_; + std::map> recovered_workers_; // If nullopt nothing was recovered. - std::experimental::optional> - recovered_snapshot_tx_; + std::optional> recovered_snapshot_tx_; // Scheduler that is used to periodically ping all registered workers. utils::Scheduler scheduler_; diff --git a/src/distributed/coordination_rpc_messages.lcp b/src/distributed/coordination_rpc_messages.lcp index 649e4cde0..845ad3eb6 100644 --- a/src/distributed/coordination_rpc_messages.lcp +++ b/src/distributed/coordination_rpc_messages.lcp @@ -1,7 +1,7 @@ #>cpp #pragma once -#include +#include #include #include "communication/rpc/messages.hpp" @@ -28,7 +28,7 @@ cpp<# (:response ((registration-successful :bool) (durability-error :bool) - (snapshot-to-recover "std::experimental::optional>" + (snapshot-to-recover "std::optional>" :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" + (recovery-info "std::optional" :capnp-type "Utils.Optional(Dur.RecoveryInfo)"))) (:response ())) diff --git a/src/distributed/dgp/vertex_migrator.cpp b/src/distributed/dgp/vertex_migrator.cpp index e9e710365..373e103d7 100644 --- a/src/distributed/dgp/vertex_migrator.cpp +++ b/src/distributed/dgp/vertex_migrator.cpp @@ -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); } diff --git a/src/distributed/updates_rpc_clients.cpp b/src/distributed/updates_rpc_clients.cpp index ed2d6ef9a..1a7fcf208 100644 --- a/src/distributed/updates_rpc_clients.cpp +++ b/src/distributed/updates_rpc_clients.cpp @@ -36,7 +36,7 @@ CreatedVertexInfo UpdatesRpcClients::CreateVertex( int worker_id, tx::TransactionId tx_id, const std::vector &labels, const std::unordered_map &properties, - std::experimental::optional cypher_id) { + std::optional cypher_id) { auto res = coordination_->GetClientPool(worker_id)->Call( 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 cypher_id) { +CreatedEdgeInfo UpdatesRpcClients::CreateEdge( + int this_worker_id, tx::TransactionId tx_id, VertexAccessor &from, + VertexAccessor &to, storage::EdgeType edge_type, + std::optional cypher_id) { CHECK(from.address().is_remote()) << "In CreateEdge `from` must be remote"; int from_worker = from.address().worker_id(); auto res = diff --git a/src/distributed/updates_rpc_clients.hpp b/src/distributed/updates_rpc_clients.hpp index 50a64cc80..058c22501 100644 --- a/src/distributed/updates_rpc_clients.hpp +++ b/src/distributed/updates_rpc_clients.hpp @@ -32,8 +32,7 @@ class UpdatesRpcClients { int worker_id, tx::TransactionId tx_id, const std::vector &labels, const std::unordered_map &properties, - std::experimental::optional cypher_id = - std::experimental::nullopt); + std::optional 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 cypher_id = - std::experimental::nullopt); + std::optional 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. diff --git a/src/distributed/updates_rpc_messages.lcp b/src/distributed/updates_rpc_messages.lcp index b4676266c..fb79959e7 100644 --- a/src/distributed/updates_rpc_messages.lcp +++ b/src/distributed/updates_rpc_messages.lcp @@ -88,7 +88,7 @@ cpp<# return std::make_pair(prop, value); }); cpp<#)) - (cypher-id "std::experimental::optional" + (cypher-id "std::optional" :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" + (cypher-id "std::optional" :capnp-type "Utils.Optional(Utils.BoxInt64)" :capnp-save (lambda (builder member capnp-name) diff --git a/src/distributed/updates_rpc_server.cpp b/src/distributed/updates_rpc_server.cpp index 8969eb418..8a7c795c7 100644 --- a/src/distributed/updates_rpc_server.cpp +++ b/src/distributed/updates_rpc_server.cpp @@ -62,9 +62,8 @@ template CreatedInfo UpdatesRpcServer::TransactionUpdates::CreateVertex( const std::vector &labels, const std::unordered_map &properties, - std::experimental::optional cypher_id) { - auto result = - db_accessor_->InsertVertex(std::experimental::nullopt, cypher_id); + std::optional 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 guard{lock_}; @@ -76,13 +75,13 @@ CreatedInfo UpdatesRpcServer::TransactionUpdates::CreateVertex( template CreatedInfo UpdatesRpcServer::TransactionUpdates::CreateEdge( gid::Gid from, storage::VertexAddress to, storage::EdgeType edge_type, - int worker_id, std::experimental::optional cypher_id) { + int worker_id, std::optional 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 guard{lock_}; deltas_.emplace(edge.gid(), std::make_pair(edge, std::vector{})); diff --git a/src/distributed/updates_rpc_server.hpp b/src/distributed/updates_rpc_server.hpp index 9eb95c204..c2ba28d94 100644 --- a/src/distributed/updates_rpc_server.hpp +++ b/src/distributed/updates_rpc_server.hpp @@ -58,15 +58,13 @@ class UpdatesRpcServer { CreatedInfo CreateVertex( const std::vector &labels, const std::unordered_map &properties, - std::experimental::optional cypher_id = - std::experimental::nullopt); + std::optional 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 cypher_id = - std::experimental::nullopt); + std::optional cypher_id = std::nullopt); /// Applies all the deltas on the record. UpdateResult Apply(); diff --git a/src/durability/distributed/paths.cpp b/src/durability/distributed/paths.cpp index e673c6da7..18a85abca 100644 --- a/src/durability/distributed/paths.cpp +++ b/src/durability/distributed/paths.cpp @@ -1,7 +1,7 @@ #include "durability/distributed/paths.hpp" -#include -#include +#include +#include #include #include "glog/logging.h" @@ -12,11 +12,11 @@ namespace durability { -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; -std::experimental::optional TransactionIdFromWalFilename( +std::optional 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__worker_" 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_id) { +fs::path WalFilenameForTransactionId(const std::filesystem::path &wal_dir, + int worker_id, + std::optional 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 -TransactionIdFromSnapshotFilename(const std::string &name) { - auto nullopt = std::experimental::nullopt; +std::optional 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; diff --git a/src/durability/distributed/paths.hpp b/src/durability/distributed/paths.hpp index 0f39bafea..808b559d9 100644 --- a/src/durability/distributed/paths.hpp +++ b/src/durability/distributed/paths.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #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 TransactionIdFromWalFilename( +std::optional 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 -TransactionIdFromSnapshotFilename(const std::string &name); +std::optional 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_id = - std::experimental::nullopt); +std::filesystem::path WalFilenameForTransactionId( + const std::filesystem::path &wal_dir, int worker_id, + std::optional tx_id = std::nullopt); } // namespace durability diff --git a/src/durability/distributed/recovery.cpp b/src/durability/distributed/recovery.cpp index f48e09f75..a4314eb05 100644 --- a/src/durability/distributed/recovery.cpp +++ b/src/durability/distributed/recovery.cpp @@ -1,6 +1,6 @@ #include "durability/distributed/recovery.hpp" -#include +#include #include #include @@ -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 ReadWalRecoverableTransactions( RecoveryInfo RecoverOnlySnapshot( const fs::path &durability_dir, database::GraphDb *db, RecoveryData *recovery_data, - std::experimental::optional required_snapshot_tx_id, - int worker_id) { + std::optional 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; diff --git a/src/durability/distributed/recovery.hpp b/src/durability/distributed/recovery.hpp index 288b9f07a..e162a644d 100644 --- a/src/durability/distributed/recovery.hpp +++ b/src/durability/distributed/recovery.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include #include @@ -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 required_snapshot_tx_id, - int worker_id); + const std::filesystem::path &durability_dir, database::GraphDb *db, + durability::RecoveryData *recovery_data, + std::optional 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, diff --git a/src/durability/distributed/snapshooter.cpp b/src/durability/distributed/snapshooter.cpp index 550c3fa5d..e806dc803 100644 --- a/src/durability/distributed/snapshooter.cpp +++ b/src/durability/distributed/snapshooter.cpp @@ -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 { diff --git a/src/durability/distributed/snapshooter.hpp b/src/durability/distributed/snapshooter.hpp index 89265225e..717126aaf 100644 --- a/src/durability/distributed/snapshooter.hpp +++ b/src/durability/distributed/snapshooter.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #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 diff --git a/src/durability/distributed/snapshot_decoder.hpp b/src/durability/distributed/snapshot_decoder.hpp index c95b4d30b..d1bf0cd53 100644 --- a/src/durability/distributed/snapshot_decoder.hpp +++ b/src/durability/distributed/snapshot_decoder.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include "communication/bolt/v1/decoder/decoder.hpp" #include "durability/distributed/snapshot_value.hpp" @@ -13,7 +13,7 @@ class SnapshotDecoder : public communication::bolt::Decoder { explicit SnapshotDecoder(Buffer &buffer) : communication::bolt::Decoder(buffer) {} - std::experimental::optional ReadSnapshotVertex() { + std::optional ReadSnapshotVertex() { communication::bolt::Value dv; SnapshotVertex vertex; @@ -21,7 +21,7 @@ class SnapshotDecoder : public communication::bolt::Decoder { if (!communication::bolt::Decoder::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 { if (!communication::bolt::Decoder::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 { &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 { &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 { } private: - std::experimental::optional ReadSnapshotEdge() { + std::optional ReadSnapshotEdge() { communication::bolt::Value dv; InlinedVertexEdge edge; @@ -77,7 +77,7 @@ class SnapshotDecoder : public communication::bolt::Decoder { if (!communication::bolt::Decoder::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(dv.ValueInt())); @@ -86,7 +86,7 @@ class SnapshotDecoder : public communication::bolt::Decoder { if (!communication::bolt::Decoder::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(dv.ValueInt())); @@ -94,7 +94,7 @@ class SnapshotDecoder : public communication::bolt::Decoder { if (!communication::bolt::Decoder::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(); diff --git a/src/durability/distributed/state_delta.cpp b/src/durability/distributed/state_delta.cpp index 9839464ec..16a0d5f8b 100644 --- a/src/durability/distributed/state_delta.cpp +++ b/src/durability/distributed/state_delta.cpp @@ -247,10 +247,10 @@ void StateDelta::Encode( if (!decoder.ReadValue(&dv)) return nullopt; \ r_val.member = static_cast(dv.value_f()); -std::experimental::optional StateDelta::Decode( +std::optional StateDelta::Decode( HashedFileReader &reader, communication::bolt::Decoder &decoder) { - using std::experimental::nullopt; + using std::nullopt; StateDelta r_val; // The decoded value used as a temporary while decoding. diff --git a/src/durability/distributed/state_delta.lcp b/src/durability/distributed/state_delta.lcp index 6cf2339fc..c679646b2 100644 --- a/src/durability/distributed/state_delta.lcp +++ b/src/durability/distributed/state_delta.lcp @@ -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 Decode( + static std::optional Decode( HashedFileReader &reader, communication::bolt::Decoder &decoder); diff --git a/src/durability/distributed/wal.cpp b/src/durability/distributed/wal.cpp index 931e8ad77..35b59fc98 100644 --- a/src/durability/distributed/wal.cpp +++ b/src/durability/distributed/wal.cpp @@ -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 &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 &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(); diff --git a/src/durability/distributed/wal.hpp b/src/durability/distributed/wal.hpp index a5fc54555..289f908b9 100644 --- a/src/durability/distributed/wal.hpp +++ b/src/durability/distributed/wal.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -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 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}; diff --git a/src/durability/single_node/paths.cpp b/src/durability/single_node/paths.cpp index 122b9c7c5..93d995717 100644 --- a/src/durability/single_node/paths.cpp +++ b/src/durability/single_node/paths.cpp @@ -1,7 +1,7 @@ #include "durability/single_node/paths.hpp" -#include -#include +#include +#include #include #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 TransactionIdFromWalFilename( +std::optional TransactionIdFromWalFilename( const std::string &name) { if (utils::EndsWith(name, "current")) return std::numeric_limits::max(); @@ -31,26 +31,25 @@ std::experimental::optional 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_id) { +fs::path WalFilenameForTransactionId(const std::filesystem::path &wal_dir, + std::optional 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 -TransactionIdFromSnapshotFilename(const std::string &name) { +std::optional 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 diff --git a/src/durability/single_node/paths.hpp b/src/durability/single_node/paths.hpp index a0a45604e..1d0d54051 100644 --- a/src/durability/single_node/paths.hpp +++ b/src/durability/single_node/paths.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #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 TransactionIdFromWalFilename( +std::optional 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_id = - std::experimental::nullopt); +std::filesystem::path WalFilenameForTransactionId( + const std::filesystem::path &wal_dir, + std::optional 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 -TransactionIdFromSnapshotFilename(const std::string &name); +std::optional TransactionIdFromSnapshotFilename( + const std::string &name); } // namespace durability diff --git a/src/durability/single_node/recovery.cpp b/src/durability/single_node/recovery.cpp index f9608fd0c..c2d21b9ab 100644 --- a/src/durability/single_node/recovery.cpp +++ b/src/durability/single_node/recovery.cpp @@ -1,8 +1,8 @@ #include "durability/single_node/recovery.hpp" -#include -#include +#include #include +#include #include #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 ReadWalRecoverableTransactions( RecoveryInfo RecoverOnlySnapshot( const fs::path &durability_dir, database::GraphDb *db, RecoveryData *recovery_data, - std::experimental::optional required_snapshot_tx_id) { + std::optional required_snapshot_tx_id) { // Attempt to recover from snapshot files in reverse order (from newest // backwards). const auto snapshot_dir = durability_dir / kSnapshotDir; diff --git a/src/durability/single_node/recovery.hpp b/src/durability/single_node/recovery.hpp index cc676a151..27a8ec65b 100644 --- a/src/durability/single_node/recovery.hpp +++ b/src/durability/single_node/recovery.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include #include @@ -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 required_snapshot_tx_id); + const std::filesystem::path &durability_dir, database::GraphDb *db, + durability::RecoveryData *recovery_data, + std::optional 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); diff --git a/src/durability/single_node/snapshooter.cpp b/src/durability/single_node/snapshooter.cpp index 5b2582a19..d9b7829af 100644 --- a/src/durability/single_node/snapshooter.cpp +++ b/src/durability/single_node/snapshooter.cpp @@ -12,7 +12,7 @@ #include "glue/communication.hpp" #include "utils/file.hpp" -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; namespace durability { diff --git a/src/durability/single_node/snapshooter.hpp b/src/durability/single_node/snapshooter.hpp index 1ad7568b5..ed01dbf69 100644 --- a/src/durability/single_node/snapshooter.hpp +++ b/src/durability/single_node/snapshooter.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #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 diff --git a/src/durability/single_node/state_delta.cpp b/src/durability/single_node/state_delta.cpp index 6b8efd284..8c8118706 100644 --- a/src/durability/single_node/state_delta.cpp +++ b/src/durability/single_node/state_delta.cpp @@ -273,10 +273,10 @@ void StateDelta::Encode( if (!decoder.ReadValue(&dv)) return nullopt; \ r_val.member = static_cast(dv.value_f()); -std::experimental::optional StateDelta::Decode( +std::optional StateDelta::Decode( HashedFileReader &reader, communication::bolt::Decoder &decoder) { - using std::experimental::nullopt; + using std::nullopt; StateDelta r_val; // The decoded value used as a temporary while decoding. diff --git a/src/durability/single_node/state_delta.lcp b/src/durability/single_node/state_delta.lcp index 38ecd3ce1..7a4d52f33 100644 --- a/src/durability/single_node/state_delta.lcp +++ b/src/durability/single_node/state_delta.lcp @@ -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 Decode( + static std::optional Decode( HashedFileReader &reader, communication::bolt::Decoder &decoder); diff --git a/src/durability/single_node/wal.cpp b/src/durability/single_node/wal.cpp index ca6f67876..a159d6cf1 100644 --- a/src/durability/single_node/wal.cpp +++ b/src/durability/single_node/wal.cpp @@ -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 &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 &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(); } diff --git a/src/durability/single_node/wal.hpp b/src/durability/single_node/wal.hpp index 33e1bbf82..00ddccff7 100644 --- a/src/durability/single_node/wal.hpp +++ b/src/durability/single_node/wal.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -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 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}; diff --git a/src/durability/single_node_ha/paths.cpp b/src/durability/single_node_ha/paths.cpp index be1ef6cbe..34bdfaa99 100644 --- a/src/durability/single_node_ha/paths.cpp +++ b/src/durability/single_node_ha/paths.cpp @@ -1,7 +1,7 @@ #include "durability/single_node_ha/paths.hpp" -#include -#include +#include +#include #include #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 -TransactionIdFromSnapshotFilename(const std::string &name) { - auto nullopt = std::experimental::nullopt; +std::optional 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; diff --git a/src/durability/single_node_ha/paths.hpp b/src/durability/single_node_ha/paths.hpp index 4e04b94cc..f3c1f9ae2 100644 --- a/src/durability/single_node_ha/paths.hpp +++ b/src/durability/single_node_ha/paths.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #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 -TransactionIdFromSnapshotFilename(const std::string &name); +std::optional TransactionIdFromSnapshotFilename( + const std::string &name); } // namespace durability diff --git a/src/durability/single_node_ha/recovery.cpp b/src/durability/single_node_ha/recovery.cpp index 5ff5b0549..10a3db9a2 100644 --- a/src/durability/single_node_ha/recovery.cpp +++ b/src/durability/single_node_ha/recovery.cpp @@ -1,8 +1,8 @@ #include "durability/single_node_ha/recovery.hpp" -#include -#include +#include #include +#include #include #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 { diff --git a/src/durability/single_node_ha/recovery.hpp b/src/durability/single_node_ha/recovery.hpp index be8e72c98..5e0f3cb13 100644 --- a/src/durability/single_node_ha/recovery.hpp +++ b/src/durability/single_node_ha/recovery.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include #include @@ -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, diff --git a/src/durability/single_node_ha/snapshooter.cpp b/src/durability/single_node_ha/snapshooter.cpp index f63eb0c44..ae592cd5c 100644 --- a/src/durability/single_node_ha/snapshooter.cpp +++ b/src/durability/single_node_ha/snapshooter.cpp @@ -12,7 +12,7 @@ #include "glue/communication.hpp" #include "utils/file.hpp" -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; namespace durability { diff --git a/src/durability/single_node_ha/snapshooter.hpp b/src/durability/single_node_ha/snapshooter.hpp index b884d79ce..dda8802a7 100644 --- a/src/durability/single_node_ha/snapshooter.hpp +++ b/src/durability/single_node_ha/snapshooter.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #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 diff --git a/src/durability/single_node_ha/state_delta.cpp b/src/durability/single_node_ha/state_delta.cpp index 1344badd2..36eee8fea 100644 --- a/src/durability/single_node_ha/state_delta.cpp +++ b/src/durability/single_node_ha/state_delta.cpp @@ -203,10 +203,10 @@ void StateDelta::Encode( if (!decoder.ReadValue(&dv)) return nullopt; \ r_val.member = static_cast(dv.value_f()); -std::experimental::optional StateDelta::Decode( +std::optional StateDelta::Decode( HashedFileReader &reader, communication::bolt::Decoder &decoder) { - using std::experimental::nullopt; + using std::nullopt; StateDelta r_val; // The decoded value used as a temporary while decoding. diff --git a/src/durability/single_node_ha/state_delta.lcp b/src/durability/single_node_ha/state_delta.lcp index 00f9bd1ac..4e1495462 100644 --- a/src/durability/single_node_ha/state_delta.lcp +++ b/src/durability/single_node_ha/state_delta.lcp @@ -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 Decode( + static std::optional Decode( HashedFileReader &reader, communication::bolt::Decoder &decoder); diff --git a/src/integrations/kafka/consumer.cpp b/src/integrations/kafka/consumer.cpp index dc77c25f6..8df9aca72 100644 --- a/src/integrations/kafka/consumer.cpp +++ b/src/integrations/kafka/consumer.cpp @@ -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 limit_batches) { +void Consumer::StartConsuming(std::optional 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> Consumer::GetBatch() { return batch; } -void Consumer::Start(std::experimental::optional limit_batches) { +void Consumer::Start(std::optional 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>> -Consumer::Test(std::experimental::optional limit_batches) { +Consumer::Test(std::optional limit_batches) { // All exceptions thrown here are handled by the Bolt protocol. if (!consumer_) { throw ConsumerNotAvailableException(info_.stream_name); diff --git a/src/integrations/kafka/consumer.hpp b/src/integrations/kafka/consumer.hpp index 821a1f3ae..8e83f8abe 100644 --- a/src/integrations/kafka/consumer.hpp +++ b/src/integrations/kafka/consumer.hpp @@ -2,9 +2,9 @@ #pragma once #include -#include #include #include +#include #include #include #include @@ -26,10 +26,10 @@ struct StreamInfo { std::string stream_uri; std::string stream_topic; std::string transform_uri; - std::experimental::optional batch_interval_in_ms; - std::experimental::optional batch_size; + std::optional batch_interval_in_ms; + std::optional batch_size; - std::experimental::optional limit_batches; + std::optional 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 limit_batches); + void Start(std::optional 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>> - Test(std::experimental::optional limit_batches); + Test(std::optional 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 limit_batches); + void StartConsuming(std::optional limit_batches); std::vector> GetBatch(); }; diff --git a/src/integrations/kafka/streams.cpp b/src/integrations/kafka/streams.cpp index 7bb948926..54ad2070c 100644 --- a/src/integrations/kafka/streams.cpp +++ b/src/integrations/kafka/streams.cpp @@ -1,8 +1,8 @@ #include "integrations/kafka/streams.hpp" #include -#include -#include +#include +#include #include @@ -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 limit_batches) { + std::optional limit_batches) { std::lock_guard g(mutex_); auto find_it = consumers_.find(stream_name); if (find_it == consumers_.end()) @@ -254,7 +254,7 @@ std::vector Streams::Show() { std::vector< std::pair>> Streams::Test(const std::string &stream_name, - std::experimental::optional limit_batches) { + std::optional limit_batches) { std::lock_guard g(mutex_); auto find_it = consumers_.find(stream_name); if (find_it == consumers_.end()) diff --git a/src/integrations/kafka/streams.hpp b/src/integrations/kafka/streams.hpp index 7a4523d18..e199b6425 100644 --- a/src/integrations/kafka/streams.hpp +++ b/src/integrations/kafka/streams.hpp @@ -1,8 +1,8 @@ /// @file #pragma once -#include #include +#include #include #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 batch_limit = - std::experimental::nullopt); + std::optional batch_limit = std::nullopt); /// Stop consuming from a stream. /// @@ -106,8 +105,7 @@ class Streams final { std::vector< std::pair>> Test(const std::string &stream_name, - std::experimental::optional batch_limit = - std::experimental::nullopt); + std::optional batch_limit = std::nullopt); private: std::string streams_directory_; diff --git a/src/integrations/kafka/transform.cpp b/src/integrations/kafka/transform.cpp index de6d617e9..606e564dc 100644 --- a/src/integrations/kafka/transform.cpp +++ b/src/integrations/kafka/transform.cpp @@ -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. diff --git a/src/integrations/kafka/transform.hpp b/src/integrations/kafka/transform.hpp index 1fb7084d4..0e7a8e897 100644 --- a/src/integrations/kafka/transform.hpp +++ b/src/integrations/kafka/transform.hpp @@ -1,7 +1,7 @@ /// @file #pragma once -#include +#include #include #include @@ -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}; }; diff --git a/src/io/network/socket.cpp b/src/io/network/socket.cpp index 1c962d266..6acbfd79c 100644 --- a/src/io/network/socket.cpp +++ b/src/io/network/socket.cpp @@ -184,7 +184,7 @@ int Socket::ErrorStatus() const { bool Socket::Listen(int backlog) { return listen(socket_, backlog) == 0; } -std::experimental::optional Socket::Accept() { +std::optional Socket::Accept() { sockaddr_storage addr; socklen_t addr_size = sizeof addr; char addr_decoded[INET6_ADDRSTRLEN]; @@ -192,7 +192,7 @@ std::experimental::optional 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); diff --git a/src/io/network/socket.hpp b/src/io/network/socket.hpp index 83b943062..c13343eff 100644 --- a/src/io/network/socket.hpp +++ b/src/io/network/socket.hpp @@ -1,8 +1,8 @@ #pragma once -#include #include #include +#include #include "io/network/endpoint.hpp" @@ -82,7 +82,7 @@ class Socket { * * @return socket if accepted, nullopt otherwise. */ - std::experimental::optional Accept(); + std::optional Accept(); /** * Sets the socket to non-blocking. diff --git a/src/io/network/utils.cpp b/src/io/network/utils.cpp index 95d707c74..6731bfcf7 100644 --- a/src/io/network/utils.cpp +++ b/src/io/network/utils.cpp @@ -46,10 +46,10 @@ std::string ResolveHostname(std::string hostname) { } /// Gets hostname -std::experimental::optional GetHostname() { +std::optional 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); } diff --git a/src/io/network/utils.hpp b/src/io/network/utils.hpp index 32b86872b..87408878e 100644 --- a/src/io/network/utils.hpp +++ b/src/io/network/utils.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include "io/network/endpoint.hpp" @@ -11,7 +11,7 @@ namespace io::network { std::string ResolveHostname(std::string hostname); /// Gets hostname -std::experimental::optional GetHostname(); +std::optional GetHostname(); // Try to establish a connection to a remote host bool CanEstablishConnection(const Endpoint &endpoint); diff --git a/src/lisp/clone.lisp b/src/lisp/clone.lisp index d8293db54..15c832d59 100644 --- a/src/lisp/clone.lisp +++ b/src/lisp/clone.lisp @@ -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 diff --git a/src/lisp/lcp-test.lisp b/src/lisp/lcp-test.lisp index 69e4b9662..156ea991e 100644 --- a/src/lisp/lcp-test.lisp +++ b/src/lisp/lcp-test.lisp @@ -820,15 +820,15 @@ } }")) (subtest "optional" - (single-member-test (member "std::experimental::optional") + (single-member-test (member "std::optional") "object.member_ = member_;") - (single-member-test (member "std::experimental::optional") + (single-member-test (member "std::optional") "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") diff --git a/src/memgraph.cpp b/src/memgraph.cpp index ba2b2f891..2c74b3e9b 100644 --- a/src/memgraph.cpp +++ b/src/memgraph.cpp @@ -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; + std::optional telemetry; if (FLAGS_telemetry_enabled) { telemetry.emplace( "https://telemetry.memgraph.com/88b5e7e8-746a-11e8-9f85-538a9e9690cc/", diff --git a/src/memgraph_distributed.cpp b/src/memgraph_distributed.cpp index 996eb109a..c9a2ef0fd 100644 --- a/src/memgraph_distributed.cpp +++ b/src/memgraph_distributed.cpp @@ -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"}; diff --git a/src/memgraph_ha.cpp b/src/memgraph_ha.cpp index 850bea04f..43fac609c 100644 --- a/src/memgraph_ha.cpp +++ b/src/memgraph_ha.cpp @@ -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; diff --git a/src/memgraph_init.hpp b/src/memgraph_init.hpp index 02042f5e3..027744b7b 100644 --- a/src/memgraph_init.hpp +++ b/src/memgraph_init.hpp @@ -2,9 +2,9 @@ #pragma once #include -#include -#include +#include #include +#include #include #include @@ -75,7 +75,7 @@ class BoltSession final query::TransactionEngine transaction_engine_; auth::Auth *auth_; - std::experimental::optional user_; + std::optional user_; audit::Log *audit_log_; io::network::Endpoint endpoint_; }; @@ -123,5 +123,4 @@ void InitSignalHandlers(const std::function &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 &memgraph_main); +int WithInit(int argc, char **argv, const std::function &memgraph_main); diff --git a/src/query/frontend/semantic/symbol_generator.cpp b/src/query/frontend/semantic/symbol_generator.cpp index 4bf75c321..e604350dd 100644 --- a/src/query/frontend/semantic/symbol_generator.cpp +++ b/src/query/frontend/semantic/symbol_generator.cpp @@ -4,7 +4,7 @@ #include "query/frontend/semantic/symbol_generator.hpp" -#include +#include #include #include "glog/logging.h" @@ -471,11 +471,10 @@ bool SymbolGenerator::PostVisit(EdgeAtom &) { void SymbolGenerator::VisitWithIdentifiers( Expression *expr, const std::vector &identifiers) { - std::vector, Identifier *>> - prev_symbols; + std::vector, Identifier *>> prev_symbols; // Collect previous symbols if they exist. for (const auto &identifier : identifiers) { - std::experimental::optional prev_symbol; + std::optional prev_symbol; auto prev_symbol_it = scope_.symbols.find(identifier->name_); if (prev_symbol_it != scope_.symbols.end()) { prev_symbol = prev_symbol_it->second; diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index 3445beec7..94fde8b23 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -113,9 +113,9 @@ Callback HandleAuthQuery(AuthQuery *auth_query, auth::Auth *auth, std::lock_guard 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>(); }; @@ -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> 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 params; for (const auto ¶m : result.second) { diff --git a/src/query/plan/cost_estimator.hpp b/src/query/plan/cost_estimator.hpp index 09b6fb57d..8ca9e050b 100644 --- a/src/query/plan/cost_estimator.hpp +++ b/src/query/plan/cost_estimator.hpp @@ -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> BoundToPropertyValue( - std::experimental::optional bound) { + std::optional> BoundToPropertyValue( + std::optional bound) { if (bound) { auto property_value = ConstPropertyValue(bound->value()); if (property_value) return utils::Bound(*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 ConstPropertyValue( + std::optional ConstPropertyValue( const Expression *expression) { if (auto *literal = utils::Downcast(expression)) { return literal->value_; @@ -225,7 +225,7 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor { utils::Downcast(expression)) { return parameters.AtTokenPosition(param_lookup->token_position_); } - return std::experimental::nullopt; + return std::nullopt; } }; diff --git a/src/query/plan/distributed.cpp b/src/query/plan/distributed.cpp index 69dd0d963..c10af200b 100644 --- a/src/query/plan/distributed.cpp +++ b/src/query/plan/distributed.cpp @@ -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 depends_on; + std::optional 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 { - if (!maybe_bound) return std::experimental::nullopt; + auto find_forbidden = [this](auto maybe_bound) -> std::optional { + 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( 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( 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( @@ -698,25 +697,24 @@ class IndependentSubtreeFinder : public DistributedOperatorVisitor { AstStorage *storage_; template - std::experimental::optional ContainsForbidden( - const TCollection &symbols) { + std::optional 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 FindForbidden(const Symbol &symbol) { + std::optional 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 subtree, diff --git a/src/query/plan/distributed_ops.cpp b/src/query/plan/distributed_ops.cpp index cbf267a84..5cd43c742 100644 --- a/src/query/plan/distributed_ops.cpp +++ b/src/query/plan/distributed_ops.cpp @@ -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 worker_id; + std::optional worker_id; std::vector remote_result; std::vector 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 in_edges_; - std::experimental::optional in_edges_it_; - std::experimental::optional out_edges_; - std::experimental::optional out_edges_it_; + std::optional in_edges_; + std::optional in_edges_it_; + std::optional out_edges_; + std::optional out_edges_it_; // Stores the last frame before we yield the frame for future edge. It needs // to be restored afterward. std::vector 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 - current_vertex_addr = last_vertex.ValueVertex().GlobalAddress(); - std::experimental::optional current_edge_addr; + std::optional current_vertex_addr = + last_vertex.ValueVertex().GlobalAddress(); + std::optional current_edge_addr; while (true) { DCHECK(static_cast(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(); } diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index d1ecc11b7..74d71f26e 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -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 input_cursor_; TVerticesFun get_vertices_; - std::experimental::optional::type::value_type> vertices_; - std::experimental::optional vertices_it_; + std::optional vertices_it_; database::GraphDbAccessor &db_; }; @@ -319,8 +319,7 @@ ACCEPT_WITH_INPUT(ScanAll) std::unique_ptr 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>( output_symbol_, input_->MakeCursor(db), std::move(vertices), db); @@ -342,7 +341,7 @@ ACCEPT_WITH_INPUT(ScanAllByLabel) std::unique_ptr 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>( @@ -352,9 +351,8 @@ std::unique_ptr ScanAllByLabel::MakeCursor( ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange( const std::shared_ptr &input, Symbol output_symbol, storage::Label label, storage::Property property, - const std::string &property_name, - std::experimental::optional lower_bound, - std::experimental::optional upper_bound, GraphView graph_view) + const std::string &property_name, std::optional lower_bound, + std::optional 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 ScanAllByLabelPropertyRange::MakeCursor( database::GraphDbAccessor &db) const { auto vertices = [this, &db](Frame &frame, ExecutionContext &context) - -> std::experimental::optional { + -> std::optional { ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, context.db_accessor, graph_view_); - auto convert = [&evaluator](const auto &bound) - -> std::experimental::optional> { - if (!bound) return std::experimental::nullopt; + auto convert = + [&evaluator]( + const auto &bound) -> std::optional> { + if (!bound) return std::nullopt; auto value = bound->value()->Accept(evaluator); try { - return std::experimental::make_optional( + return std::make_optional( utils::Bound(PropertyValue(value), bound->type())); } catch (const TypedValueException &) { throw QueryRuntimeException("'{}' cannot be used as a property value.", @@ -391,13 +389,11 @@ std::unique_ptr 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>( output_symbol_, input_->MakeCursor(db), std::move(vertices), db); @@ -421,20 +417,20 @@ ACCEPT_WITH_INPUT(ScanAllByLabelPropertyValue) std::unique_ptr ScanAllByLabelPropertyValue::MakeCursor( database::GraphDbAccessor &db) const { auto vertices = [this, &db](Frame &frame, ExecutionContext &context) - -> std::experimental::optional std::optional { 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>( 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 &input, Symbol input_symbol, - Symbol node_symbol, Symbol edge_symbol, EdgeAtom::Type type, - EdgeAtom::Direction direction, - const std::vector &edge_types, bool is_reverse, - Expression *lower_bound, Expression *upper_bound, bool existing_node, - ExpansionLambda filter_lambda, - std::experimental::optional weight_lambda, - std::experimental::optional total_weight) +ExpandVariable::ExpandVariable(const std::shared_ptr &input, + Symbol input_symbol, Symbol node_symbol, + Symbol edge_symbol, EdgeAtom::Type type, + EdgeAtom::Direction direction, + const std::vector &edge_types, + bool is_reverse, Expression *lower_bound, + Expression *upper_bound, bool existing_node, + ExpansionLambda filter_lambda, + std::optional weight_lambda, + std::optional total_weight) : input_(input ? input : std::make_shared()), 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 input_cursor_; using VertexEdgeMapT = - std::unordered_map>; + std::unordered_map>; 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(); - 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> - processed_; + std::unordered_map> processed_; // edge/vertex pairs we have yet to visit, for current and next depth std::vector> to_visit_current_; std::vector> 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 current_edge = - std::get<3>(current); + std::optional 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::experimental::optional, WspStateHash> + std::optional, 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> &lhs, - const std::tuple> &rhs) { + bool operator()(const std::tuple> &lhs, + const std::tuple> &rhs) { return std::get<0>(lhs) > std::get<0>(rhs); } }; std::priority_queue< - std::tuple>, - std::vector>>, + std::tuple>, + std::vector< + std::tuple>>, PriorityQueueComparator> pq_; diff --git a/src/query/plan/operator.lcp b/src/query/plan/operator.lcp index 61ebf651d..83b24c151 100644 --- a/src/query/plan/operator.lcp +++ b/src/query/plan/operator.lcp @@ -3,8 +3,8 @@ #pragma once -#include #include +#include #include #include #include @@ -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" :scope :public + (lower-bound "std::optional" :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" :scope :public + (upper-bound "std::optional" :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 lower_bound, - std::experimental::optional upper_bound, + std::optional lower_bound, + std::optional 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 in_edges_; - std::experimental::optional in_edges_it_; - std::experimental::optional out_edges_; - std::experimental::optional out_edges_it_; + std::optional in_edges_; + std::optional in_edges_it_; + std::optional out_edges_; + std::optional 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" :scope :public + (weight-lambda "std::optional" :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" :scope :public + (total-weight "std::optional" :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 weight_lambda, - std::experimental::optional total_weight); + std::optional weight_lambda, + std::optional total_weight); bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override; std::unique_ptr MakeCursor( diff --git a/src/query/plan/planner.hpp b/src/query/plan/planner.hpp index 91bf34354..561c3d74a 100644 --- a/src/query/plan/planner.hpp +++ b/src/query/plan/planner.hpp @@ -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 curr_plan; + std::optional curr_plan; double min_cost = std::numeric_limits::max(); if (use_variable_planner) { diff --git a/src/query/plan/preprocess.cpp b/src/query/plan/preprocess.cpp index b7b4c58d4..cdb29719a 100644 --- a/src/query/plan/preprocess.cpp +++ b/src/query/plan/preprocess.cpp @@ -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 &lower_bound, - const std::experimental::optional &upper_bound) + const std::optional &lower_bound, + const std::optional &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; } diff --git a/src/query/plan/preprocess.hpp b/src/query/plan/preprocess.hpp index e0e0d2a46..96587b2d0 100644 --- a/src/query/plan/preprocess.hpp +++ b/src/query/plan/preprocess.hpp @@ -1,7 +1,7 @@ /// @file #pragma once -#include +#include #include #include #include @@ -89,8 +89,7 @@ class PropertyFilter { Type); /// Construct the range based filter. PropertyFilter(const SymbolTable &, const Symbol &, PropertyIx, - const std::experimental::optional &, - const std::experimental::optional &); + const std::optional &, const std::optional &); /// 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 lower_bound_{}; - std::experimental::optional upper_bound_{}; + std::optional lower_bound_{}; + std::optional upper_bound_{}; }; /// Stores additional information for a filter expression. @@ -122,7 +121,7 @@ struct FilterInfo { /// Labels for Type::Label filtering. std::vector labels; /// Property information for Type::Property filtering. - std::experimental::optional property_filter; + std::optional property_filter; }; /// Stores information on filters used inside the @c Matching of a @c QueryPart. diff --git a/src/query/plan/rewrite/index_lookup.hpp b/src/query/plan/rewrite/index_lookup.hpp index e55cc6e49..317edf75e 100644 --- a/src/query/plan/rewrite/index_lookup.hpp +++ b/src/query/plan/rewrite/index_lookup.hpp @@ -6,8 +6,8 @@ #pragma once #include -#include #include +#include #include #include #include @@ -437,7 +437,7 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor { // Finds the label-property combination which has indexed the lowest amount of // vertices. If the index cannot be found, nullopt is returned. - std::experimental::optional FindBestLabelPropertyIndex( + std::optional FindBestLabelPropertyIndex( const Symbol &symbol, const std::unordered_set &bound_symbols) { auto are_bound = [&bound_symbols](const auto &used_symbols) { for (const auto &used_symbol : used_symbols) { @@ -447,7 +447,7 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor { } return true; }; - std::experimental::optional found; + std::optional found; for (const auto &label : filters_.FilteredLabels(symbol)) { for (const auto &filter : filters_.PropertyFilters(symbol)) { if (filter.property_filter->is_symbol_in_value_ || @@ -496,8 +496,7 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor { // `nullptr` is returned and `input` is not chained. std::unique_ptr GenScanByIndex( const ScanAll &scan, - const std::experimental::optional &max_vertex_count = - std::experimental::nullopt) { + const std::optional &max_vertex_count = std::nullopt) { const auto &input = scan.input(); const auto &node_symbol = scan.output_symbol_; const auto &graph_view = scan.graph_view_; @@ -541,8 +540,7 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor { return std::make_unique( input, node_symbol, GetLabel(found_index->label), GetProperty(prop_filter.property_), prop_filter.property_.name, - std::experimental::make_optional(lower_bound), - std::experimental::nullopt, graph_view); + std::make_optional(lower_bound), std::nullopt, graph_view); } else { CHECK(prop_filter.value_) << "Property filter should either have " "bounds or a value expression."; diff --git a/src/query/plan/rule_based_planner.hpp b/src/query/plan/rule_based_planner.hpp index 5ed58e0b1..9a363265f 100644 --- a/src/query/plan/rule_based_planner.hpp +++ b/src/query/plan/rule_based_planner.hpp @@ -1,7 +1,7 @@ /// @file #pragma once -#include +#include #include "gflags/gflags.h" @@ -415,8 +415,8 @@ class RuleBasedPlanner { edge_types.push_back(GetEdgeType(type)); } if (edge->IsVariable()) { - std::experimental::optional weight_lambda; - std::experimental::optional total_weight; + std::optional weight_lambda; + std::optional total_weight; if (edge->type_ == EdgeAtom::Type::WEIGHTED_SHORTEST_PATH) { weight_lambda.emplace(ExpansionLambda{ diff --git a/src/query/plan/variable_start_planner.hpp b/src/query/plan/variable_start_planner.hpp index c4051b337..a29167502 100644 --- a/src/query/plan/variable_start_planner.hpp +++ b/src/query/plan/variable_start_planner.hpp @@ -212,8 +212,8 @@ class VaryMatchingStart { // being at the end. When there are no nodes, this iterator needs to produce // a single result, which is the original matching passed in. Setting // start_nodes_it_ to end signifies the end of our iteration. - std::experimental::optional::iterator> + std::optional::iterator> start_nodes_it_; }; diff --git a/src/query/plan/vertex_count_cache.hpp b/src/query/plan/vertex_count_cache.hpp index b3d820400..f6bf5d3b5 100644 --- a/src/query/plan/vertex_count_cache.hpp +++ b/src/query/plan/vertex_count_cache.hpp @@ -1,7 +1,7 @@ /// @file #pragma once -#include +#include #include "storage/common/types/property_value.hpp" #include "storage/common/types/types.hpp" @@ -51,8 +51,8 @@ class VertexCountCache { int64_t VerticesCount( storage::Label label, storage::Property property, - const std::experimental::optional> &lower, - const std::experimental::optional> &upper) { + const std::optional> &lower, + const std::optional> &upper) { auto label_prop = std::make_pair(label, property); auto &bounds_vertex_count = property_bounds_vertex_count_[label_prop]; BoundsKey bounds = std::make_pair(lower, upper); @@ -77,8 +77,8 @@ class VertexCountCache { } }; - typedef std::pair>, - std::experimental::optional>> + typedef std::pair>, + std::optional>> BoundsKey; struct BoundsHash { @@ -112,7 +112,7 @@ class VertexCountCache { }; TDbAccessor *db_; - std::experimental::optional vertices_count_; + std::optional vertices_count_; std::unordered_map label_vertex_count_; std::unordered_map label_property_vertex_count_; diff --git a/src/query/transaction_engine.hpp b/src/query/transaction_engine.hpp index f686cd96b..c598b702a 100644 --- a/src/query/transaction_engine.hpp +++ b/src/query/transaction_engine.hpp @@ -20,7 +20,7 @@ class TransactionEngine final { Interpret(const std::string &query, const std::map ¶ms) { // Clear pending results. - results_ = std::experimental::nullopt; + results_ = std::nullopt; // Check the query for transaction commands. auto query_upper = utils::Trim(utils::ToUpperCase(query)); @@ -103,13 +103,13 @@ class TransactionEngine final { } void Abort() { - results_ = std::experimental::nullopt; + results_ = std::nullopt; expect_rollback_ = false; in_explicit_transaction_ = false; if (!db_accessor_) return; db_accessor_->Abort(); #ifndef MG_DISTRIBUTED - db_accessor_ = std::experimental::nullopt; + db_accessor_ = std::nullopt; #else db_accessor_ = nullptr; #endif @@ -119,7 +119,7 @@ class TransactionEngine final { database::GraphDb *db_{nullptr}; Interpreter *interpreter_{nullptr}; #ifndef MG_DISTRIBUTED - std::experimental::optional db_accessor_; + std::optional db_accessor_; #else std::unique_ptr db_accessor_; #endif @@ -127,29 +127,29 @@ class TransactionEngine final { // `database::GraphDbAccessor` is destroyed because the `Results` object holds // references to the `GraphDb` object and will crash the database when // destructed if you are not careful. - std::experimental::optional results_; + std::optional results_; bool in_explicit_transaction_{false}; bool expect_rollback_{false}; void Commit() { - results_ = std::experimental::nullopt; + results_ = std::nullopt; if (!db_accessor_) return; db_accessor_->Commit(); #ifndef MG_DISTRIBUTED - db_accessor_ = std::experimental::nullopt; + db_accessor_ = std::nullopt; #else db_accessor_ = nullptr; #endif } void AdvanceCommand() { - results_ = std::experimental::nullopt; + results_ = std::nullopt; if (!db_accessor_) return; db_accessor_->AdvanceCommand(); } void AbortCommand() { - results_ = std::experimental::nullopt; + results_ = std::nullopt; if (in_explicit_transaction_) { expect_rollback_ = true; } else { diff --git a/src/raft/config.hpp b/src/raft/config.hpp index a17470d53..60fc3fad9 100644 --- a/src/raft/config.hpp +++ b/src/raft/config.hpp @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include @@ -23,7 +23,7 @@ struct Config { int64_t log_size_snapshot_threshold; static Config LoadFromFile(const std::string &raft_config_file) { - if (!std::experimental::filesystem::exists(raft_config_file)) + if (!std::filesystem::exists(raft_config_file)) throw RaftConfigException(raft_config_file); nlohmann::json data; diff --git a/src/raft/coordination.cpp b/src/raft/coordination.cpp index 68532cab2..e6a23e2ac 100644 --- a/src/raft/coordination.cpp +++ b/src/raft/coordination.cpp @@ -10,7 +10,7 @@ namespace raft { -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; Coordination::Coordination( uint16_t server_workers_count, uint16_t client_workers_count, diff --git a/src/raft/coordination.hpp b/src/raft/coordination.hpp index e4ceefaf3..948e37ec0 100644 --- a/src/raft/coordination.hpp +++ b/src/raft/coordination.hpp @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/src/raft/raft_server.cpp b/src/raft/raft_server.cpp index cd2624841..78c992c42 100644 --- a/src/raft/raft_server.cpp +++ b/src/raft/raft_server.cpp @@ -3,9 +3,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -24,7 +24,7 @@ namespace raft { using namespace std::literals::chrono_literals; -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; const std::string kCurrentTermKey = "current_term"; const std::string kVotedForKey = "voted_for"; @@ -330,11 +330,10 @@ void RaftServer::Shutdown() { void RaftServer::SetCurrentTerm(uint64_t new_current_term) { current_term_ = new_current_term; disk_storage_.Put(kCurrentTermKey, std::to_string(new_current_term)); - SetVotedFor(std::experimental::nullopt); + SetVotedFor(std::nullopt); } -void RaftServer::SetVotedFor( - std::experimental::optional new_voted_for) { +void RaftServer::SetVotedFor(std::optional new_voted_for) { voted_for_ = new_voted_for; if (new_voted_for) disk_storage_.Put(kVotedForKey, std::to_string(new_voted_for.value())); @@ -347,11 +346,10 @@ void RaftServer::SetLogSize(uint64_t new_log_size) { disk_storage_.Put(kLogSizeKey, std::to_string(new_log_size)); } -std::experimental::optional -RaftServer::GetSnapshotMetadata() { +std::optional RaftServer::GetSnapshotMetadata() { auto opt_value = disk_storage_.Get(kSnapshotMetadataKey); - if (opt_value == std::experimental::nullopt) { - return std::experimental::nullopt; + if (opt_value == std::nullopt) { + return std::nullopt; } ::capnp::MallocMessageBuilder message; @@ -365,7 +363,7 @@ RaftServer::GetSnapshotMetadata() { message.getRoot().asReader(); SnapshotMetadata deserialized; Load(&deserialized, reader); - return std::experimental::make_optional(deserialized); + return std::make_optional(deserialized); } void RaftServer::PersistSnapshotMetadata( @@ -505,7 +503,7 @@ void RaftServer::RecoverPersistentData() { auto opt_voted_for = disk_storage_.Get(kVotedForKey); if (!opt_voted_for) { - voted_for_ = std::experimental::nullopt; + voted_for_ = std::nullopt; } else { voted_for_ = {std::stoul(opt_voted_for.value())}; } @@ -684,8 +682,7 @@ void RaftServer::SendEntries(uint16_t peer_id, } void RaftServer::SendLogEntries( - uint16_t peer_id, - const std::experimental::optional &snapshot_metadata, + uint16_t peer_id, const std::optional &snapshot_metadata, std::unique_lock *lock) { uint64_t request_term = current_term_; uint64_t request_prev_log_index = next_index_[peer_id] - 1; @@ -1100,7 +1097,7 @@ bool RaftServer::OutOfSync(uint64_t reply_term) { LogEntry RaftServer::GetLogEntry(int index) { auto opt_value = disk_storage_.Get(LogEntryKey(index)); - DCHECK(opt_value != std::experimental::nullopt) + DCHECK(opt_value != std::nullopt) << "Log index (" << index << ") out of bounds."; return DeserializeLogEntry(opt_value.value()); } @@ -1202,7 +1199,7 @@ void RaftServer::NoOpCreate() { void RaftServer::ApplyStateDeltas( const std::vector &deltas) { - std::experimental::optional dba; + std::optional dba; for (auto &delta : deltas) { switch (delta.type) { case database::StateDelta::Type::TRANSACTION_BEGIN: @@ -1213,7 +1210,7 @@ void RaftServer::ApplyStateDeltas( CHECK(dba) << "Missing accessor for transaction" << delta.transaction_id; dba->Commit(); - dba = std::experimental::nullopt; + dba = std::nullopt; break; case database::StateDelta::Type::TRANSACTION_ABORT: LOG(FATAL) << "ApplyStateDeltas shouldn't know about aborted " diff --git a/src/raft/raft_server.hpp b/src/raft/raft_server.hpp index 5a5450ce0..c68dd297f 100644 --- a/src/raft/raft_server.hpp +++ b/src/raft/raft_server.hpp @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ class RaftServer final : public RaftInterface { /// Setter for `voted for` member. It updates the persistent storage as well /// as its in-memory copy. - void SetVotedFor(std::experimental::optional new_voted_for); + void SetVotedFor(std::optional new_voted_for); /// Setter for `log size` member. It updates the persistent storage as well /// as its in-memory copy. @@ -87,7 +87,7 @@ class RaftServer final : public RaftInterface { /// Retrieves persisted snapshot metadata or nullopt if not present. /// Snapshot metadata is a triplet consisting of the last included term, last /// last included log entry index and the snapshot filename. - std::experimental::optional GetSnapshotMetadata(); + std::optional GetSnapshotMetadata(); /// Persists snapshot metadata. void PersistSnapshotMetadata(const SnapshotMetadata &snapshot_metadata); @@ -167,10 +167,9 @@ class RaftServer final : public RaftInterface { database::GraphDb *db_{nullptr}; std::unique_ptr rlog_{nullptr}; - std::atomic mode_; ///< Server's current mode. - uint16_t server_id_; ///< ID of the current server. - std::experimental::filesystem::path - durability_dir_; ///< Durability directory. + std::atomic mode_; ///< Server's current mode. + uint16_t server_id_; ///< ID of the current server. + std::filesystem::path durability_dir_; ///< Durability directory. bool db_recover_on_startup_; ///< Flag indicating if recovery should happen ///< on startup. uint64_t commit_index_; ///< Index of the highest known committed entry. @@ -254,7 +253,7 @@ class RaftServer final : public RaftInterface { storage::KVStore disk_storage_; - std::experimental::optional voted_for_; + std::optional voted_for_; std::atomic current_term_; uint64_t log_size_; @@ -289,10 +288,9 @@ class RaftServer final : public RaftInterface { /// @param snapshot_metadata metadata of the last snapshot, if any. /// @param lock Lock from the peer thread (released while waiting for /// response) - void SendLogEntries( - uint16_t peer_id, - const std::experimental::optional &snapshot_metadata, - std::unique_lock *lock); + void SendLogEntries(uint16_t peer_id, + const std::optional &snapshot_metadata, + std::unique_lock *lock); /// Send Snapshot to peer. This function should only be called in leader /// mode. diff --git a/src/rpc/serialization.hpp b/src/rpc/serialization.hpp index 6fd15ac2c..83b37477d 100644 --- a/src/rpc/serialization.hpp +++ b/src/rpc/serialization.hpp @@ -1,13 +1,13 @@ #pragma once -#include #include +#include #include #include -#include "utils/algorithm.hpp" #include "rpc/serialization.capnp.h" +#include "utils/algorithm.hpp" namespace utils { @@ -93,7 +93,7 @@ void LoadMap( template inline void SaveOptional( - const std::experimental::optional &data, + const std::optional &data, typename capnp::Optional::Builder *builder, const std::function &save) { if (data) { @@ -105,15 +105,15 @@ inline void SaveOptional( } template -inline std::experimental::optional LoadOptional( +inline std::optional LoadOptional( const typename capnp::Optional::Reader &reader, const std::function &load) { switch (reader.which()) { case capnp::Optional::NULLOPT: - return std::experimental::nullopt; + return std::nullopt; case capnp::Optional::VALUE: auto value_reader = reader.getValue(); - return std::experimental::optional{load(value_reader)}; + return std::optional{load(value_reader)}; } } diff --git a/src/stats/metrics.cpp b/src/stats/metrics.cpp index 69552f45b..684f95d2e 100644 --- a/src/stats/metrics.cpp +++ b/src/stats/metrics.cpp @@ -26,7 +26,7 @@ Counter::Counter(int64_t start_value) : Metric(start_value) {} void Counter::Bump(int64_t delta) { value_ += delta; } -std::experimental::optional Counter::Flush() { return value_; } +std::optional Counter::Flush() { return value_; } int64_t Counter::Value() { return value_; } @@ -34,7 +34,7 @@ Gauge::Gauge(int64_t start_value) : Metric(start_value) {} void Gauge::Set(int64_t value) { value_ = value; } -std::experimental::optional Gauge::Flush() { return value_; } +std::optional Gauge::Flush() { return value_; } IntervalMin::IntervalMin(int64_t start_value) : Metric(start_value) {} @@ -44,12 +44,11 @@ void IntervalMin::Add(int64_t value) { ; } -std::experimental::optional IntervalMin::Flush() { +std::optional IntervalMin::Flush() { int64_t curr = value_; value_.compare_exchange_weak(curr, std::numeric_limits::max()); - return curr == std::numeric_limits::max() - ? std::experimental::nullopt - : std::experimental::make_optional(curr); + return curr == std::numeric_limits::max() ? std::nullopt + : std::make_optional(curr); } IntervalMax::IntervalMax(int64_t start_value) : Metric(start_value) {} @@ -60,12 +59,11 @@ void IntervalMax::Add(int64_t value) { ; } -std::experimental::optional IntervalMax::Flush() { +std::optional IntervalMax::Flush() { int64_t curr = value_; value_.compare_exchange_weak(curr, std::numeric_limits::min()); - return curr == std::numeric_limits::min() - ? std::experimental::nullopt - : std::experimental::make_optional(curr); + return curr == std::numeric_limits::min() ? std::nullopt + : std::make_optional(curr); } template diff --git a/src/stats/metrics.hpp b/src/stats/metrics.hpp index c13bcff18..0db7e3f5f 100644 --- a/src/stats/metrics.hpp +++ b/src/stats/metrics.hpp @@ -7,10 +7,10 @@ #pragma once #include -#include #include #include #include +#include #include #include "fmt/format.h" @@ -38,7 +38,7 @@ class Metric { * return the metric value aggregated since the last flush call or nullopt * if there were no updates. */ - virtual std::experimental::optional Flush() = 0; + virtual std::optional Flush() = 0; explicit Metric(int64_t start_value = 0); @@ -61,7 +61,7 @@ class Counter : public Metric { void Bump(int64_t delta = 1); /** Returns the current value of the counter. **/ - std::experimental::optional Flush() override; + std::optional Flush() override; /** Returns the current value of the counter. **/ int64_t Value(); @@ -94,7 +94,7 @@ class Gauge : public Metric { void Set(int64_t value); /** Returns the current gauge value. **/ - std::experimental::optional Flush() override; + std::optional Flush() override; }; /** @@ -124,7 +124,7 @@ class IntervalMin : public Metric { * Returns the minimum value encountered since the last flush period, * or nullopt if no values were added. */ - std::experimental::optional Flush() override; + std::optional Flush() override; }; /** @@ -150,7 +150,7 @@ class IntervalMax : public Metric { * Returns the maximum value encountered since the last flush period, * or nullopt if no values were added. */ - std::experimental::optional Flush() override; + std::optional Flush() override; }; /** diff --git a/src/storage/common/kvstore/kvstore.cpp b/src/storage/common/kvstore/kvstore.cpp index 164ab9a73..7ee35feb5 100644 --- a/src/storage/common/kvstore/kvstore.cpp +++ b/src/storage/common/kvstore/kvstore.cpp @@ -7,12 +7,12 @@ namespace storage { struct KVStore::impl { - std::experimental::filesystem::path storage; + std::filesystem::path storage; std::unique_ptr db; rocksdb::Options options; }; -KVStore::KVStore(std::experimental::filesystem::path storage) +KVStore::KVStore(std::filesystem::path storage) : pimpl_(std::make_unique()) { pimpl_->storage = storage; if (!utils::EnsureDir(pimpl_->storage)) @@ -50,11 +50,10 @@ bool KVStore::PutMultiple(const std::map &items) { return s.ok(); } -std::experimental::optional KVStore::Get( - const std::string &key) const noexcept { +std::optional KVStore::Get(const std::string &key) const noexcept { std::string value; auto s = pimpl_->db->Get(rocksdb::ReadOptions(), key, &value); - if (!s.ok()) return std::experimental::nullopt; + if (!s.ok()) return std::nullopt; return value; } diff --git a/src/storage/common/kvstore/kvstore.hpp b/src/storage/common/kvstore/kvstore.hpp index 79461fcc0..dced49e35 100644 --- a/src/storage/common/kvstore/kvstore.hpp +++ b/src/storage/common/kvstore/kvstore.hpp @@ -1,9 +1,9 @@ #pragma once -#include -#include +#include #include #include +#include #include #include @@ -30,7 +30,7 @@ class KVStore final { * NOTE: Don't instantiate more instances of a KVStore with the same * storage directory because that will lead to undefined behaviour. */ - explicit KVStore(std::experimental::filesystem::path storage); + explicit KVStore(std::filesystem::path storage); KVStore(const KVStore &other) = delete; KVStore(KVStore &&other); @@ -69,8 +69,7 @@ class KVStore final { * @return Value for the given key. std::nullopt in case of any error * OR the value doesn't exist. */ - std::experimental::optional Get(const std::string &key) const - noexcept; + std::optional Get(const std::string &key) const noexcept; /** * Deletes the key and corresponding value from storage. diff --git a/src/storage/common/kvstore/kvstore_dummy.cpp b/src/storage/common/kvstore/kvstore_dummy.cpp index 96abaa8ae..80414fc25 100644 --- a/src/storage/common/kvstore/kvstore_dummy.cpp +++ b/src/storage/common/kvstore/kvstore_dummy.cpp @@ -8,7 +8,7 @@ namespace storage { struct KVStore::impl {}; -KVStore::KVStore(std::experimental::filesystem::path storage) {} +KVStore::KVStore(std::filesystem::path storage) {} KVStore::~KVStore() {} @@ -22,8 +22,7 @@ bool KVStore::PutMultiple(const std::map &items) { "dummy kvstore"; } -std::experimental::optional KVStore::Get( - const std::string &key) const noexcept { +std::optional KVStore::Get(const std::string &key) const noexcept { CHECK(false) << "Unsupported operation (KVStore::Get) -- this is a dummy kvstore"; } diff --git a/src/storage/common/locking/record_lock.cpp b/src/storage/common/locking/record_lock.cpp index c6a81c169..042d94d52 100644 --- a/src/storage/common/locking/record_lock.cpp +++ b/src/storage/common/locking/record_lock.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -17,7 +17,7 @@ namespace { // transaction in that cycle. If start transaction is not in a cycle nullopt is // returned. template -std::experimental::optional FindOldestTxInLockCycle( +std::optional FindOldestTxInLockCycle( tx::TransactionId start, TAccessor &graph_accessor) { std::vector path; std::unordered_set visited; @@ -28,7 +28,7 @@ std::experimental::optional FindOldestTxInLockCycle( visited.insert(current); path.push_back(current); auto it = graph_accessor.find(current); - if (it == graph_accessor.end()) return std::experimental::nullopt; + if (it == graph_accessor.end()) return std::nullopt; current = it->second; } while (visited.find(current) == visited.end()); @@ -40,7 +40,7 @@ std::experimental::optional FindOldestTxInLockCycle( // There is a cycle, but start is not a part of it. Some transaction that is // in a cycle will find it and abort oldest transaction. - return std::experimental::nullopt; + return std::nullopt; } } // namespace diff --git a/src/storage/common/types/property_value_store.cpp b/src/storage/common/types/property_value_store.cpp index dc7fe33d9..087aebf4c 100644 --- a/src/storage/common/types/property_value_store.cpp +++ b/src/storage/common/types/property_value_store.cpp @@ -1,6 +1,6 @@ #include "storage/common/types/property_value_store.hpp" -#include +#include #include #include @@ -10,7 +10,7 @@ #include "glue/communication.hpp" #include "storage/common/pod_buffer.hpp" -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; using namespace communication::bolt; diff --git a/src/storage/common/types/property_value_store.hpp b/src/storage/common/types/property_value_store.hpp index 68dc46d71..8a6218f20 100644 --- a/src/storage/common/types/property_value_store.hpp +++ b/src/storage/common/types/property_value_store.hpp @@ -1,13 +1,13 @@ #pragma once #include -#include +#include #include #include +#include "storage/common/kvstore/kvstore.hpp" #include "storage/common/types/property_value.hpp" #include "storage/common/types/types.hpp" -#include "storage/common/kvstore/kvstore.hpp" /** * A collection of properties accessed in a map-like way using a key of type @@ -126,8 +126,8 @@ class PropertyValueStore { private: const PropertyValueStore *pvs_; std::vector>::const_iterator memory_it_; - std::experimental::optional disk_it_; - std::experimental::optional> disk_prop_; + std::optional disk_it_; + std::optional> disk_prop_; }; size_t size() const; diff --git a/src/storage/distributed/concurrent_id_mapper_master.hpp b/src/storage/distributed/concurrent_id_mapper_master.hpp index 3637987cd..f701092d2 100644 --- a/src/storage/distributed/concurrent_id_mapper_master.hpp +++ b/src/storage/distributed/concurrent_id_mapper_master.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include "distributed/coordination.hpp" #include "storage/distributed/concurrent_id_mapper_single_node.hpp" diff --git a/src/storage/distributed/edges.hpp b/src/storage/distributed/edges.hpp index ff67e07ca..a7e616ef0 100644 --- a/src/storage/distributed/edges.hpp +++ b/src/storage/distributed/edges.hpp @@ -1,15 +1,15 @@ #pragma once -#include +#include #include #include #include "glog/logging.h" -#include "storage/distributed/mvcc/version_list.hpp" #include "storage/common/types/types.hpp" #include "storage/distributed/address.hpp" #include "storage/distributed/address_types.hpp" +#include "storage/distributed/mvcc/version_list.hpp" #include "utils/algorithm.hpp" /** @@ -50,7 +50,7 @@ class Edges { */ Iterator(std::vector::const_iterator position, std::vector::const_iterator end, - std::experimental::optional vertex, + std::optional vertex, const std::vector *edge_types) : position_(position), end_(end), @@ -81,7 +81,7 @@ class Edges { // Optional predicates. If set they define which edges are skipped by the // iterator. - std::experimental::optional vertex_; + std::optional vertex_; // For edge types we use a vector pointer because it's optional. const std::vector *edge_types_ = nullptr; @@ -146,7 +146,7 @@ class Edges { * @param edge_types - The edge types at least one of which must be matched. * If nullptr edges are not filtered on type. */ - auto begin(std::experimental::optional vertex, + auto begin(std::optional vertex, const std::vector *edge_types) const { if (edge_types && edge_types->empty()) edge_types = nullptr; return Iterator(storage_.begin(), storage_.end(), vertex, edge_types); diff --git a/src/storage/distributed/edges_iterator.cpp b/src/storage/distributed/edges_iterator.cpp index 251710293..f17c2c662 100644 --- a/src/storage/distributed/edges_iterator.cpp +++ b/src/storage/distributed/edges_iterator.cpp @@ -26,13 +26,13 @@ EdgesIterable::EdgesIterable( const std::vector *edge_types) { auto sptr = std::make_shared(va); sptr->HoldCachedData(); - begin_.emplace(GetBegin(sptr, from, std::experimental::nullopt, edge_types)); + begin_.emplace(GetBegin(sptr, from, std::nullopt, edge_types)); end_.emplace(GetEnd(sptr, from)); } EdgeAccessorIterator EdgesIterable::GetBegin( std::shared_ptr va, bool from, - std::experimental::optional dest, + std::optional dest, const std::vector *edge_types) { const Edges *edges; diff --git a/src/storage/distributed/edges_iterator.hpp b/src/storage/distributed/edges_iterator.hpp index 7e7f09855..4f2c765fb 100644 --- a/src/storage/distributed/edges_iterator.hpp +++ b/src/storage/distributed/edges_iterator.hpp @@ -2,7 +2,7 @@ #pragma once -#include +#include #include "storage/distributed/edge_accessor.hpp" #include "storage/distributed/edges.hpp" @@ -71,14 +71,14 @@ class EdgeAccessorIterator { } } - void ResetAccessor() { edge_accessor_ = std::experimental::nullopt; } + void ResetAccessor() { edge_accessor_ = std::nullopt; } void CreateOut(const Edges::Element &e); void CreateIn(const Edges::Element &e); std::shared_ptr va_; - std::experimental::optional edge_accessor_; + std::optional edge_accessor_; Edges::Iterator iter_; bool from_; }; @@ -95,8 +95,7 @@ class EdgesIterable { /// be filtered on destination /// @param edge_types - the edge types at least one of which must be matched, /// if nullptr edges are not filtered on type - EdgesIterable(const VertexAccessor &va, bool from, - const VertexAccessor &dest, + EdgesIterable(const VertexAccessor &va, bool from, const VertexAccessor &dest, const std::vector *edge_types = nullptr); /// Creates new iterable that will skip edges whose type is not in edge_types. @@ -113,11 +112,11 @@ class EdgesIterable { private: EdgeAccessorIterator GetBegin( std::shared_ptr va, bool from, - std::experimental::optional dest, + std::optional dest, const std::vector *edge_types = nullptr); EdgeAccessorIterator GetEnd(std::shared_ptr va, bool from); - std::experimental::optional begin_; - std::experimental::optional end_; + std::optional begin_; + std::optional end_; }; diff --git a/src/storage/distributed/gid.hpp b/src/storage/distributed/gid.hpp index 80ad99a37..0a3208e65 100644 --- a/src/storage/distributed/gid.hpp +++ b/src/storage/distributed/gid.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "glog/logging.h" @@ -44,8 +44,7 @@ class Generator { * @param requested_gid - The desired gid. If given, it will be returned and * this generator's state updated accordingly. */ - gid::Gid Next(std::experimental::optional requested_gid = - std::experimental::nullopt) { + gid::Gid Next(std::optional requested_gid = std::nullopt) { if (requested_gid) { if (gid::CreatorWorker(*requested_gid) == worker_id_) utils::EnsureAtomicGe(next_local_id_, gid::LocalId(*requested_gid) + 1); diff --git a/src/storage/distributed/indexes/label_property_index.hpp b/src/storage/distributed/indexes/label_property_index.hpp index e7923a5e5..56e888104 100644 --- a/src/storage/distributed/indexes/label_property_index.hpp +++ b/src/storage/distributed/indexes/label_property_index.hpp @@ -1,13 +1,13 @@ #pragma once -#include +#include #include "data_structures/concurrent/concurrent_map.hpp" #include "data_structures/concurrent/skiplist.hpp" -#include "storage/distributed/mvcc/version_list.hpp" #include "storage/common/index.hpp" #include "storage/common/types/types.hpp" #include "storage/distributed/edge.hpp" +#include "storage/distributed/mvcc/version_list.hpp" #include "storage/distributed/vertex.hpp" #include "transactions/transaction.hpp" #include "utils/bound.hpp" @@ -231,11 +231,10 @@ class LabelPropertyIndex { * @return iterable collection of mvcc:VersionLists pointers that * satisfy the bounds and are visible to the given transaction. */ - auto GetVlists( - const Key &key, - const std::experimental::optional> lower, - const std::experimental::optional> upper, - const tx::Transaction &transaction, bool current_state) { + auto GetVlists(const Key &key, + const std::optional> lower, + const std::optional> upper, + const tx::Transaction &transaction, bool current_state) { DCHECK(ready_for_use_.access().contains(key)) << "Index not yet ready."; auto type = [](const auto &bound) { return bound.value().value().type(); }; diff --git a/src/storage/distributed/mvcc/record.hpp b/src/storage/distributed/mvcc/record.hpp index 8c3735447..78e31f741 100644 --- a/src/storage/distributed/mvcc/record.hpp +++ b/src/storage/distributed/mvcc/record.hpp @@ -1,15 +1,15 @@ #pragma once #include -#include #include +#include #include "transactions/commit_log.hpp" #include "transactions/distributed/engine.hpp" #include "transactions/transaction.hpp" -#include "storage/common/mvcc/version.hpp" #include "storage/common/locking/record_lock.hpp" +#include "storage/common/mvcc/version.hpp" // the mvcc implementation used here is very much like postgresql's // more info: https://momjian.us/main/writings/pgsql/mvcc.pdf @@ -246,8 +246,7 @@ class Record : public Version { */ bool populate_hint_if_possible( const tx::Engine &engine, const uint8_t mask, - const std::experimental::optional tx_cutoff = - std::experimental::nullopt) const { + const std::optional tx_cutoff = std::nullopt) const { DCHECK(mask == Hints::kCre || mask == Hints::kExp) << "Mask should be either for creation or expiration"; if (hints_.Get(mask)) return true; diff --git a/src/storage/distributed/storage.hpp b/src/storage/distributed/storage.hpp index dcf719504..ed1aa64f5 100644 --- a/src/storage/distributed/storage.hpp +++ b/src/storage/distributed/storage.hpp @@ -1,18 +1,18 @@ #pragma once -#include -#include +#include +#include #include "data_structures/concurrent/concurrent_map.hpp" #include "data_structures/concurrent/skiplist.hpp" -#include "storage/distributed/mvcc/version_list.hpp" +#include "storage/common/kvstore/kvstore.hpp" #include "storage/common/types/types.hpp" #include "storage/distributed/address.hpp" #include "storage/distributed/edge.hpp" #include "storage/distributed/indexes/key_index.hpp" #include "storage/distributed/indexes/label_property_index.hpp" +#include "storage/distributed/mvcc/version_list.hpp" #include "storage/distributed/vertex.hpp" -#include "storage/common/kvstore/kvstore.hpp" #include "transactions/type.hpp" namespace distributed { diff --git a/src/storage/distributed/storage_gc.hpp b/src/storage/distributed/storage_gc.hpp index 30d9e4f03..67916450f 100644 --- a/src/storage/distributed/storage_gc.hpp +++ b/src/storage/distributed/storage_gc.hpp @@ -150,9 +150,9 @@ class StorageGc final { * (otherwise that transaction could still be waiting for a resolution of * the query to the commit log about some old transaction) */ - std::experimental::optional GetClogSafeTransaction( + std::optional GetClogSafeTransaction( tx::TransactionId oldest_active) { - std::experimental::optional safe_to_delete; + std::optional safe_to_delete; while (!gc_txid_ranges_.empty() && gc_txid_ranges_.front().second < oldest_active) { safe_to_delete = gc_txid_ranges_.front().first; diff --git a/src/storage/distributed/storage_gc_distributed.hpp b/src/storage/distributed/storage_gc_distributed.hpp index 8d8ef2bdc..4475806d0 100644 --- a/src/storage/distributed/storage_gc_distributed.hpp +++ b/src/storage/distributed/storage_gc_distributed.hpp @@ -1,7 +1,7 @@ /// @file #pragma once -#include +#include #include "storage/distributed/storage_gc.hpp" #include "transactions/type.hpp" @@ -45,7 +45,7 @@ class StorageGcDistributed { void CollectGarbage() { storage_gc_->CollectGarbage(); } - std::experimental::optional GetClogSafeTransaction( + std::optional GetClogSafeTransaction( tx::TransactionId oldest_active) { return storage_gc_->GetClogSafeTransaction(oldest_active); } diff --git a/src/storage/distributed/vertex_accessor.hpp b/src/storage/distributed/vertex_accessor.hpp index b101d12ba..a03bbeaeb 100644 --- a/src/storage/distributed/vertex_accessor.hpp +++ b/src/storage/distributed/vertex_accessor.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include #include @@ -56,8 +56,9 @@ class VertexAccessor final : public RecordAccessor { * @param edge_types - Edge types filter. At least one be matched. If nullptr * or empty, the parameter is ignored. */ - EdgesIterable in(const VertexAccessor &dest, - const std::vector *edge_types = nullptr) const { + EdgesIterable in( + const VertexAccessor &dest, + const std::vector *edge_types = nullptr) const { return EdgesIterable(*this, false, dest, edge_types); } diff --git a/src/storage/single_node/edges.hpp b/src/storage/single_node/edges.hpp index 32d03c2aa..cbe215107 100644 --- a/src/storage/single_node/edges.hpp +++ b/src/storage/single_node/edges.hpp @@ -1,13 +1,13 @@ #pragma once -#include +#include #include #include #include "glog/logging.h" -#include "storage/single_node/mvcc/version_list.hpp" #include "storage/common/types/types.hpp" +#include "storage/single_node/mvcc/version_list.hpp" #include "utils/algorithm.hpp" /** diff --git a/src/storage/single_node/gid.hpp b/src/storage/single_node/gid.hpp index fa0fd6c9e..3c0f719ee 100644 --- a/src/storage/single_node/gid.hpp +++ b/src/storage/single_node/gid.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "glog/logging.h" @@ -32,8 +32,7 @@ class Generator { * @param requested_gid - The desired gid. If given, it will be returned and * this generator's state updated accordingly. */ - gid::Gid Next(std::experimental::optional requested_gid = - std::experimental::nullopt) { + gid::Gid Next(std::optional requested_gid = std::nullopt) { if (requested_gid) { utils::EnsureAtomicGe(next_local_id_, *requested_gid + 1); return *requested_gid; diff --git a/src/storage/single_node/indexes/label_property_index.hpp b/src/storage/single_node/indexes/label_property_index.hpp index 403a5bda1..864f9842f 100644 --- a/src/storage/single_node/indexes/label_property_index.hpp +++ b/src/storage/single_node/indexes/label_property_index.hpp @@ -1,13 +1,13 @@ #pragma once -#include +#include #include "data_structures/concurrent/concurrent_map.hpp" #include "data_structures/concurrent/skiplist.hpp" -#include "storage/single_node/mvcc/version_list.hpp" #include "storage/common/index.hpp" #include "storage/common/types/types.hpp" #include "storage/single_node/edge.hpp" +#include "storage/single_node/mvcc/version_list.hpp" #include "storage/single_node/vertex.hpp" #include "transactions/transaction.hpp" #include "utils/bound.hpp" @@ -75,9 +75,7 @@ class LabelPropertyIndex { /** * Returns if it succeeded in deleting the index and freeing the index memory */ - void DeleteIndex(const Key &key) { - indices_.access().remove(key); - } + void DeleteIndex(const Key &key) { indices_.access().remove(key); } /** NOTE: All update methods aren't supporting the case where two threads * try to update the index with the same value. If both of them conclude that @@ -281,11 +279,10 @@ class LabelPropertyIndex { * @return iterable collection of mvcc:VersionLists pointers that * satisfy the bounds and are visible to the given transaction. */ - auto GetVlists( - const Key &key, - const std::experimental::optional> lower, - const std::experimental::optional> upper, - const tx::Transaction &transaction, bool current_state) { + auto GetVlists(const Key &key, + const std::optional> lower, + const std::optional> upper, + const tx::Transaction &transaction, bool current_state) { DCHECK(IndexExists(key)) << "Index not yet ready."; auto type = [](const auto &bound) { return bound.value().value().type(); }; diff --git a/src/storage/single_node/mvcc/record.hpp b/src/storage/single_node/mvcc/record.hpp index b04757703..e9c2c6b09 100644 --- a/src/storage/single_node/mvcc/record.hpp +++ b/src/storage/single_node/mvcc/record.hpp @@ -1,15 +1,15 @@ #pragma once #include -#include #include +#include #include "transactions/commit_log.hpp" #include "transactions/single_node/engine.hpp" #include "transactions/transaction.hpp" -#include "storage/common/mvcc/version.hpp" #include "storage/common/locking/record_lock.hpp" +#include "storage/common/mvcc/version.hpp" // the mvcc implementation used here is very much like postgresql's // more info: https://momjian.us/main/writings/pgsql/mvcc.pdf @@ -246,8 +246,7 @@ class Record : public Version { */ bool populate_hint_if_possible( const tx::Engine &engine, const uint8_t mask, - const std::experimental::optional tx_cutoff = - std::experimental::nullopt) const { + const std::optional tx_cutoff = std::nullopt) const { DCHECK(mask == Hints::kCre || mask == Hints::kExp) << "Mask should be either for creation or expiration"; if (hints_.Get(mask)) return true; diff --git a/src/storage/single_node/storage.hpp b/src/storage/single_node/storage.hpp index 924575f41..f0cd13492 100644 --- a/src/storage/single_node/storage.hpp +++ b/src/storage/single_node/storage.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include "data_structures/concurrent/concurrent_map.hpp" #include "storage/common/kvstore/kvstore.hpp" diff --git a/src/storage/single_node/storage_gc.hpp b/src/storage/single_node/storage_gc.hpp index 0678aba0a..8464887d5 100644 --- a/src/storage/single_node/storage_gc.hpp +++ b/src/storage/single_node/storage_gc.hpp @@ -4,11 +4,11 @@ #include #include "data_structures/concurrent/concurrent_map.hpp" -#include "storage/single_node/mvcc/version_list.hpp" #include "storage/single_node/deferred_deleter.hpp" #include "storage/single_node/edge.hpp" #include "storage/single_node/garbage_collector.hpp" #include "storage/single_node/gid.hpp" +#include "storage/single_node/mvcc/version_list.hpp" #include "storage/single_node/storage.hpp" #include "storage/single_node/vertex.hpp" #include "transactions/single_node/engine.hpp" @@ -142,9 +142,9 @@ class StorageGc { // alive transaction from the time before the hints were set is still alive // (otherwise that transaction could still be waiting for a resolution of // the query to the commit log about some old transaction) - std::experimental::optional GetClogSafeTransaction( + std::optional GetClogSafeTransaction( tx::TransactionId oldest_active) { - std::experimental::optional safe_to_delete; + std::optional safe_to_delete; while (!gc_txid_ranges_.empty() && gc_txid_ranges_.front().second < oldest_active) { safe_to_delete = gc_txid_ranges_.front().first; diff --git a/src/storage/single_node_ha/edges.hpp b/src/storage/single_node_ha/edges.hpp index b567ce4f2..249add09c 100644 --- a/src/storage/single_node_ha/edges.hpp +++ b/src/storage/single_node_ha/edges.hpp @@ -1,13 +1,13 @@ #pragma once -#include +#include #include #include #include "glog/logging.h" -#include "storage/single_node_ha/mvcc/version_list.hpp" #include "storage/common/types/types.hpp" +#include "storage/single_node_ha/mvcc/version_list.hpp" #include "utils/algorithm.hpp" /** diff --git a/src/storage/single_node_ha/gid.hpp b/src/storage/single_node_ha/gid.hpp index fa0fd6c9e..3c0f719ee 100644 --- a/src/storage/single_node_ha/gid.hpp +++ b/src/storage/single_node_ha/gid.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "glog/logging.h" @@ -32,8 +32,7 @@ class Generator { * @param requested_gid - The desired gid. If given, it will be returned and * this generator's state updated accordingly. */ - gid::Gid Next(std::experimental::optional requested_gid = - std::experimental::nullopt) { + gid::Gid Next(std::optional requested_gid = std::nullopt) { if (requested_gid) { utils::EnsureAtomicGe(next_local_id_, *requested_gid + 1); return *requested_gid; diff --git a/src/storage/single_node_ha/indexes/label_property_index.hpp b/src/storage/single_node_ha/indexes/label_property_index.hpp index 9ca05c464..9ab96c47b 100644 --- a/src/storage/single_node_ha/indexes/label_property_index.hpp +++ b/src/storage/single_node_ha/indexes/label_property_index.hpp @@ -1,13 +1,13 @@ #pragma once -#include +#include #include "data_structures/concurrent/concurrent_map.hpp" #include "data_structures/concurrent/skiplist.hpp" -#include "storage/single_node_ha/mvcc/version_list.hpp" #include "storage/common/index.hpp" #include "storage/common/types/types.hpp" #include "storage/single_node_ha/edge.hpp" +#include "storage/single_node_ha/mvcc/version_list.hpp" #include "storage/single_node_ha/vertex.hpp" #include "transactions/transaction.hpp" #include "utils/bound.hpp" @@ -281,11 +281,10 @@ class LabelPropertyIndex { * @return iterable collection of mvcc:VersionLists pointers that * satisfy the bounds and are visible to the given transaction. */ - auto GetVlists( - const Key &key, - const std::experimental::optional> lower, - const std::experimental::optional> upper, - const tx::Transaction &transaction, bool current_state) { + auto GetVlists(const Key &key, + const std::optional> lower, + const std::optional> upper, + const tx::Transaction &transaction, bool current_state) { DCHECK(IndexExists(key)) << "Index not yet ready."; auto type = [](const auto &bound) { return bound.value().value().type(); }; diff --git a/src/storage/single_node_ha/mvcc/record.hpp b/src/storage/single_node_ha/mvcc/record.hpp index e925da283..3d81626ee 100644 --- a/src/storage/single_node_ha/mvcc/record.hpp +++ b/src/storage/single_node_ha/mvcc/record.hpp @@ -1,15 +1,15 @@ #pragma once #include -#include #include +#include #include "transactions/commit_log.hpp" #include "transactions/single_node_ha/engine.hpp" #include "transactions/transaction.hpp" -#include "storage/common/mvcc/version.hpp" #include "storage/common/locking/record_lock.hpp" +#include "storage/common/mvcc/version.hpp" // the mvcc implementation used here is very much like postgresql's // more info: https://momjian.us/main/writings/pgsql/mvcc.pdf @@ -246,8 +246,7 @@ class Record : public Version { */ bool populate_hint_if_possible( const tx::Engine &engine, const uint8_t mask, - const std::experimental::optional tx_cutoff = - std::experimental::nullopt) const { + const std::optional tx_cutoff = std::nullopt) const { DCHECK(mask == Hints::kCre || mask == Hints::kExp) << "Mask should be either for creation or expiration"; if (hints_.Get(mask)) return true; diff --git a/src/storage/single_node_ha/storage.hpp b/src/storage/single_node_ha/storage.hpp index 9c13a59ac..ac9a56400 100644 --- a/src/storage/single_node_ha/storage.hpp +++ b/src/storage/single_node_ha/storage.hpp @@ -1,15 +1,15 @@ #pragma once -#include -#include +#include +#include #include "data_structures/concurrent/concurrent_map.hpp" -#include "storage/single_node_ha/mvcc/version_list.hpp" -#include "storage/common/types/types.hpp" #include "storage/common/kvstore/kvstore.hpp" +#include "storage/common/types/types.hpp" #include "storage/single_node_ha/edge.hpp" #include "storage/single_node_ha/indexes/key_index.hpp" #include "storage/single_node_ha/indexes/label_property_index.hpp" +#include "storage/single_node_ha/mvcc/version_list.hpp" #include "storage/single_node_ha/vertex.hpp" #include "transactions/type.hpp" diff --git a/src/storage/single_node_ha/storage_gc.hpp b/src/storage/single_node_ha/storage_gc.hpp index 195a214b7..d75eae987 100644 --- a/src/storage/single_node_ha/storage_gc.hpp +++ b/src/storage/single_node_ha/storage_gc.hpp @@ -148,9 +148,9 @@ class StorageGc { // alive transaction from the time before the hints were set is still alive // (otherwise that transaction could still be waiting for a resolution of // the query to the commit log about some old transaction) - std::experimental::optional GetClogSafeTransaction( + std::optional GetClogSafeTransaction( tx::TransactionId oldest_active) { - std::experimental::optional safe_to_delete; + std::optional safe_to_delete; while (!gc_txid_ranges_.empty() && gc_txid_ranges_.front().second < oldest_active) { safe_to_delete = gc_txid_ranges_.front().first; diff --git a/src/telemetry/collectors.cpp b/src/telemetry/collectors.cpp index 9cfda6139..b00007aa2 100644 --- a/src/telemetry/collectors.cpp +++ b/src/telemetry/collectors.cpp @@ -1,6 +1,6 @@ #include "telemetry/collectors.hpp" -#include +#include #include #include @@ -60,11 +60,10 @@ const nlohmann::json GetResourceUsage() { // Find all threads. std::string task_file = fmt::format("/proc/{}/task", pid); - if (!std::experimental::filesystem::exists(task_file)) { + if (!std::filesystem::exists(task_file)) { return nlohmann::json::object(); } - for (auto &file : - std::experimental::filesystem::directory_iterator(task_file)) { + for (auto &file : std::filesystem::directory_iterator(task_file)) { auto split = utils::Split(file.path().string(), "/"); if (split.size() < 1) continue; pid_t tid = std::stoi(split[split.size() - 1]); diff --git a/src/telemetry/telemetry.cpp b/src/telemetry/telemetry.cpp index d78f8a82d..a2a2fef66 100644 --- a/src/telemetry/telemetry.cpp +++ b/src/telemetry/telemetry.cpp @@ -1,6 +1,6 @@ #include "telemetry/telemetry.hpp" -#include +#include #include #include @@ -15,11 +15,10 @@ namespace telemetry { const int kMaxBatchSize = 100; -Telemetry::Telemetry( - const std::string &url, - const std::experimental::filesystem::path &storage_directory, - std::chrono::duration refresh_interval, - const uint64_t send_every_n) +Telemetry::Telemetry(const std::string &url, + const std::filesystem::path &storage_directory, + std::chrono::duration refresh_interval, + const uint64_t send_every_n) : url_(url), uuid_(utils::GenerateUUID()), send_every_n_(send_every_n), diff --git a/src/telemetry/telemetry.hpp b/src/telemetry/telemetry.hpp index b4aecc0ba..39880bd58 100644 --- a/src/telemetry/telemetry.hpp +++ b/src/telemetry/telemetry.hpp @@ -24,7 +24,7 @@ namespace telemetry { class Telemetry final { public: Telemetry(const std::string &url, - const std::experimental::filesystem::path &storage_directory, + const std::filesystem::path &storage_directory, std::chrono::duration refresh_interval = std::chrono::minutes(10), const uint64_t send_every_n = 10); diff --git a/src/transactions/distributed/engine_single_node.hpp b/src/transactions/distributed/engine_single_node.hpp index 68900d842..0cd0a04d4 100644 --- a/src/transactions/distributed/engine_single_node.hpp +++ b/src/transactions/distributed/engine_single_node.hpp @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include "durability/distributed/wal.hpp" diff --git a/src/transactions/single_node/engine.cpp b/src/transactions/single_node/engine.cpp index a22b69d98..b003385d4 100644 --- a/src/transactions/single_node/engine.cpp +++ b/src/transactions/single_node/engine.cpp @@ -21,8 +21,7 @@ Transaction *Engine::Begin() { return BeginTransaction(false); } -Transaction *Engine::BeginBlocking( - std::experimental::optional parent_tx) { +Transaction *Engine::BeginBlocking(std::optional parent_tx) { Snapshot wait_for_txs; { std::lock_guard guard(lock_); diff --git a/src/transactions/single_node/engine.hpp b/src/transactions/single_node/engine.hpp index 6ad2b6800..0d9a30252 100644 --- a/src/transactions/single_node/engine.hpp +++ b/src/transactions/single_node/engine.hpp @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include "durability/single_node/wal.hpp" @@ -34,8 +34,7 @@ class Engine final { /// run (besides this one). This is the reason why this transactions blocks the /// engine from creating new transactions and waits for the existing ones to /// finish. - Transaction *BeginBlocking( - std::experimental::optional parent_tx); + Transaction *BeginBlocking(std::optional parent_tx); CommandId Advance(TransactionId id); CommandId UpdateCommand(TransactionId id); void Commit(const Transaction &t); diff --git a/src/transactions/single_node_ha/engine.cpp b/src/transactions/single_node_ha/engine.cpp index 0eebe260e..5f3e37d04 100644 --- a/src/transactions/single_node_ha/engine.cpp +++ b/src/transactions/single_node_ha/engine.cpp @@ -25,8 +25,7 @@ Transaction *Engine::Begin() { return BeginTransaction(false); } -Transaction *Engine::BeginBlocking( - std::experimental::optional parent_tx) { +Transaction *Engine::BeginBlocking(std::optional parent_tx) { Snapshot wait_for_txs; { std::lock_guard guard(lock_); diff --git a/src/transactions/single_node_ha/engine.hpp b/src/transactions/single_node_ha/engine.hpp index 74fb58d58..b8b293636 100644 --- a/src/transactions/single_node_ha/engine.hpp +++ b/src/transactions/single_node_ha/engine.hpp @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include @@ -36,8 +36,7 @@ class Engine final { /// to run (besides this one). This is the reason why this transactions blocks /// the engine from creating new transactions and waits for the existing ones /// to finish. - Transaction *BeginBlocking( - std::experimental::optional parent_tx); + Transaction *BeginBlocking(std::optional parent_tx); CommandId Advance(TransactionId id); CommandId UpdateCommand(TransactionId id); void Commit(const Transaction &t); diff --git a/src/utils/cache.hpp b/src/utils/cache.hpp index f2bb45563..53bbee69d 100644 --- a/src/utils/cache.hpp +++ b/src/utils/cache.hpp @@ -2,7 +2,7 @@ #pragma once -#include +#include #include namespace utils { @@ -103,15 +103,15 @@ class LruCache { LruCache &operator=(LruCache &&) = delete; ~LruCache() = default; - std::experimental::optional Find(const TKey &key) { + std::optional Find(const TKey &key) { auto found = access_map_.find(key); if (found == access_map_.end()) { - return std::experimental::nullopt; + return std::nullopt; } // move the page to front lru_order_.MovePageToHead(found->second); - return std::experimental::make_optional(found->second->value); + return std::make_optional(found->second->value); } /// Inserts given key, value pair to cache. If key already exists in a diff --git a/src/utils/demangle.cpp b/src/utils/demangle.cpp index 217c2ec72..398c21177 100644 --- a/src/utils/demangle.cpp +++ b/src/utils/demangle.cpp @@ -4,10 +4,10 @@ namespace utils { -std::experimental::optional Demangle(const char *mangled_name) { +std::optional Demangle(const char *mangled_name) { int s; char *type_name = abi::__cxa_demangle(mangled_name, nullptr, nullptr, &s); - std::experimental::optional ret = std::experimental::nullopt; + std::optional ret = std::nullopt; if (s == 0) { ret = type_name; free(type_name); diff --git a/src/utils/demangle.hpp b/src/utils/demangle.hpp index 70556fe6f..7b4a2bfd8 100644 --- a/src/utils/demangle.hpp +++ b/src/utils/demangle.hpp @@ -3,7 +3,7 @@ */ #pragma once -#include +#include #include namespace utils { @@ -12,6 +12,6 @@ namespace utils { * Converts a mangled name to a human-readable name using abi::__cxa_demangle. * Returns nullopt if the conversion failed. */ -std::experimental::optional Demangle(const char *mangled_name); +std::optional Demangle(const char *mangled_name); } // namespace utils diff --git a/src/utils/dynamic_lib.hpp b/src/utils/dynamic_lib.hpp index b654a2026..fbb04c604 100644 --- a/src/utils/dynamic_lib.hpp +++ b/src/utils/dynamic_lib.hpp @@ -2,8 +2,8 @@ #include -#include -namespace fs = std::experimental::filesystem; +#include +namespace fs = std::filesystem; #include #include diff --git a/src/utils/file.cpp b/src/utils/file.cpp index 707fcaca8..66c994391 100644 --- a/src/utils/file.cpp +++ b/src/utils/file.cpp @@ -11,8 +11,7 @@ namespace utils { -std::vector ReadLines( - const std::experimental::filesystem::path &path) noexcept { +std::vector ReadLines(const std::filesystem::path &path) noexcept { std::vector lines; std::ifstream stream(path.c_str()); @@ -26,30 +25,29 @@ std::vector ReadLines( return lines; } -bool EnsureDir(const std::experimental::filesystem::path &dir) noexcept { +bool EnsureDir(const std::filesystem::path &dir) noexcept { std::error_code error_code; // For exception suppression. - if (std::experimental::filesystem::exists(dir, error_code)) - return std::experimental::filesystem::is_directory(dir, error_code); - return std::experimental::filesystem::create_directories(dir, error_code); + if (std::filesystem::exists(dir, error_code)) + return std::filesystem::is_directory(dir, error_code); + return std::filesystem::create_directories(dir, error_code); } -void EnsureDirOrDie(const std::experimental::filesystem::path &dir) { +void EnsureDirOrDie(const std::filesystem::path &dir) { CHECK(EnsureDir(dir)) << "Couldn't create directory '" << dir << "' due to a permission issue or the path exists and " "isn't a directory!"; } -bool DeleteDir(const std::experimental::filesystem::path &dir) noexcept { +bool DeleteDir(const std::filesystem::path &dir) noexcept { std::error_code error_code; // For exception suppression. - if (!std::experimental::filesystem::is_directory(dir, error_code)) - return false; - return std::experimental::filesystem::remove_all(dir, error_code) > 0; + if (!std::filesystem::is_directory(dir, error_code)) return false; + return std::filesystem::remove_all(dir, error_code) > 0; } -bool CopyFile(const std::experimental::filesystem::path &src, - const std::experimental::filesystem::path &dst) noexcept { +bool CopyFile(const std::filesystem::path &src, + const std::filesystem::path &dst) noexcept { std::error_code error_code; // For exception suppression. - return std::experimental::filesystem::copy_file(src, dst, error_code); + return std::filesystem::copy_file(src, dst, error_code); } LogFile::~LogFile() { @@ -79,7 +77,7 @@ LogFile &LogFile::operator=(LogFile &&other) { return *this; } -void LogFile::Open(const std::experimental::filesystem::path &path) { +void LogFile::Open(const std::filesystem::path &path) { CHECK(!IsOpen()) << "While trying to open " << path << " for writing the database used a handle that already has " << path_ @@ -108,9 +106,7 @@ void LogFile::Open(const std::experimental::filesystem::path &path) { bool LogFile::IsOpen() const { return fd_ != -1; } -const std::experimental::filesystem::path &LogFile::path() const { - return path_; -} +const std::filesystem::path &LogFile::path() const { return path_; } void LogFile::Write(const char *data, size_t size) { while (size > 0) { diff --git a/src/utils/file.hpp b/src/utils/file.hpp index e6f7a93ec..a4184ab8c 100644 --- a/src/utils/file.hpp +++ b/src/utils/file.hpp @@ -6,30 +6,29 @@ */ #pragma once -#include +#include namespace utils { /// Reads all lines from the file specified by path. If the file doesn't exist /// or there is an access error the function returns an empty list. -std::vector ReadLines( - const std::experimental::filesystem::path &path) noexcept; +std::vector ReadLines(const std::filesystem::path &path) noexcept; /// Ensures that the given directory either exists after this call. If the /// directory didn't exist prior to the call it is created, if it existed prior /// to the call it is left as is. -bool EnsureDir(const std::experimental::filesystem::path &dir) noexcept; +bool EnsureDir(const std::filesystem::path &dir) noexcept; /// Calls `EnsureDir` and terminates the program if the call failed. It prints /// an error message for which directory the ensuring failed. -void EnsureDirOrDie(const std::experimental::filesystem::path &dir); +void EnsureDirOrDie(const std::filesystem::path &dir); /// Deletes everything from the given directory including the directory. -bool DeleteDir(const std::experimental::filesystem::path &dir) noexcept; +bool DeleteDir(const std::filesystem::path &dir) noexcept; /// Copies the file from `src` to `dst`. -bool CopyFile(const std::experimental::filesystem::path &src, - const std::experimental::filesystem::path &dst) noexcept; +bool CopyFile(const std::filesystem::path &src, + const std::filesystem::path &dst) noexcept; /// This class implements a file handler that is used for mission critical files /// that need to be written and synced to permanent storage. Typical usage for @@ -68,14 +67,14 @@ class LogFile { /// it is created and if the file exists data is appended to the file to /// ensure that no data is ever lost. Files are created with a restrictive /// permission mask (0640). On failure and misuse it crashes the program. - void Open(const std::experimental::filesystem::path &path); + void Open(const std::filesystem::path &path); /// Returns a boolean indicating whether a file is opened. bool IsOpen() const; /// Returns the path to the currently opened file. If a file isn't opened the /// path is empty. - const std::experimental::filesystem::path &path() const; + const std::filesystem::path &path() const; /// Writes data to the currently opened file. On failure and misuse it crashes /// the program. @@ -94,7 +93,7 @@ class LogFile { private: int fd_{-1}; size_t written_since_last_sync_{0}; - std::experimental::filesystem::path path_; + std::filesystem::path path_; }; } // namespace utils diff --git a/src/utils/fswatcher.hpp b/src/utils/fswatcher.hpp index 8423fe715..ff85e615c 100644 --- a/src/utils/fswatcher.hpp +++ b/src/utils/fswatcher.hpp @@ -19,8 +19,8 @@ #include #include -#include -namespace fs = std::experimental::filesystem; +#include +namespace fs = std::filesystem; #include @@ -328,7 +328,6 @@ class FSWatcher { // run separate thread dispatch_thread_ = std::thread([this]() { - DLOG(INFO) << "dispatch thread - start"; while (is_running_.load()) { diff --git a/src/utils/math.hpp b/src/utils/math.hpp index c686fdaff..ac57e4dba 100644 --- a/src/utils/math.hpp +++ b/src/utils/math.hpp @@ -1,14 +1,14 @@ #pragma once #include -#include +#include #include namespace utils { static_assert( - std::experimental::is_same_v, + std::is_same_v, "utils::Log requires uint64_t to be implemented as unsigned long."); /// This function computes the log2 function on integer types. It is faster than diff --git a/src/utils/skip_list.hpp b/src/utils/skip_list.hpp index d8635b019..b7e83a4b3 100644 --- a/src/utils/skip_list.hpp +++ b/src/utils/skip_list.hpp @@ -3,9 +3,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -169,7 +169,7 @@ class SkipListGc final { free(head); head = prev; } - std::experimental::optional item; + std::optional item; while ((item = deleted_.Pop())) { item->second->~TNode(); free(item->second); @@ -265,7 +265,7 @@ class SkipListGc final { tail = next; } TStack leftover; - std::experimental::optional item; + std::optional item; while ((item = deleted_.Pop())) { if (item->first < last_dead) { item->second->~TNode(); @@ -640,8 +640,8 @@ class SkipList final { /// @return uint64_t estimated count of items in the range in the list template uint64_t estimate_range_count( - const std::experimental::optional> &lower, - const std::experimental::optional> &upper, + const std::optional> &lower, + const std::optional> &upper, int max_layer_for_estimation = kSkipListCountEstimateDefaultLayer) const { return skiplist_->template estimate_range_count(lower, upper, @@ -730,8 +730,8 @@ class SkipList final { template uint64_t estimate_range_count( - const std::experimental::optional> &lower, - const std::experimental::optional> &upper, + const std::optional> &lower, + const std::optional> &upper, int max_layer_for_estimation = kSkipListCountEstimateDefaultLayer) const { return skiplist_->template estimate_range_count(lower, upper, @@ -946,10 +946,9 @@ class SkipList final { } template - uint64_t estimate_range_count( - const std::experimental::optional> &lower, - const std::experimental::optional> &upper, - int max_layer_for_estimation) const { + uint64_t estimate_range_count(const std::optional> &lower, + const std::optional> &upper, + int max_layer_for_estimation) const { CHECK(max_layer_for_estimation >= 1 && max_layer_for_estimation <= kSkipListMaxHeight) << "Invalid layer for SkipList count estimation!"; diff --git a/src/utils/stack.hpp b/src/utils/stack.hpp index a0d767e66..2f4b9587a 100644 --- a/src/utils/stack.hpp +++ b/src/utils/stack.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include @@ -90,10 +90,10 @@ class Stack { } } - std::experimental::optional Pop() { + std::optional Pop() { std::lock_guard guard(lock_); while (true) { - if (head_ == nullptr) return std::experimental::nullopt; + if (head_ == nullptr) return std::nullopt; CHECK(head_->used <= TSize) << "utils::Stack has more elements in a " "Block than the block has space!"; if (head_->used == 0) { diff --git a/src/utils/stat.hpp b/src/utils/stat.hpp index fc076a5b0..454690a83 100644 --- a/src/utils/stat.hpp +++ b/src/utils/stat.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -11,16 +11,15 @@ namespace utils { /// Returns the number of bytes a directory is using on disk. If the given path /// isn't a directory, zero will be returned. -inline uint64_t GetDirDiskUsage( - const std::experimental::filesystem::path &path) { - if (!std::experimental::filesystem::is_directory(path)) return 0; +inline uint64_t GetDirDiskUsage(const std::filesystem::path &path) { + if (!std::filesystem::is_directory(path)) return 0; uint64_t size = 0; - for (auto &p : std::experimental::filesystem::directory_iterator(path)) { - if (std::experimental::filesystem::is_directory(p)) { + for (auto &p : std::filesystem::directory_iterator(path)) { + if (std::filesystem::is_directory(p)) { size += GetDirDiskUsage(p); - } else if (std::experimental::filesystem::is_regular_file(p)) { - size += std::experimental::filesystem::file_size(p); + } else if (std::filesystem::is_regular_file(p)) { + size += std::filesystem::file_size(p); } } diff --git a/src/utils/sysinfo/memory.hpp b/src/utils/sysinfo/memory.hpp index 9e0d52612..c7093ad28 100644 --- a/src/utils/sysinfo/memory.hpp +++ b/src/utils/sysinfo/memory.hpp @@ -1,7 +1,7 @@ -#include #include #include #include +#include #include "glog/logging.h" @@ -11,7 +11,7 @@ namespace utils::sysinfo { * Gets the amount of available RAM in kilobytes. If the information is * unavalable an empty value is returned. */ -inline std::experimental::optional AvailableMemoryKilobytes() { +inline std::optional AvailableMemoryKilobytes() { std::string token; std::ifstream meminfo("/proc/meminfo"); while (meminfo >> token) { @@ -20,14 +20,14 @@ inline std::experimental::optional AvailableMemoryKilobytes() { if (meminfo >> mem) { return mem; } else { - return std::experimental::nullopt; + return std::nullopt; } } meminfo.ignore(std::numeric_limits::max(), '\n'); } DLOG(WARNING) << "Failed to read amount of available memory from /proc/meminfo"; - return std::experimental::nullopt; + return std::nullopt; } } // namespace utils::sysinfo diff --git a/tests/benchmark/expansion.cpp b/tests/benchmark/expansion.cpp index 798daeb79..ee6d09f3f 100644 --- a/tests/benchmark/expansion.cpp +++ b/tests/benchmark/expansion.cpp @@ -12,7 +12,7 @@ class ExpansionBenchFixture : public benchmark::Fixture { protected: // GraphDb shouldn't be global constructed/destructed. See // documentation in database/single_node/graph_db.hpp for details. - std::experimental::optional db_; + std::optional db_; query::Interpreter interpreter_; void SetUp(const benchmark::State &state) override { @@ -35,7 +35,7 @@ class ExpansionBenchFixture : public benchmark::Fixture { auto dba = db_->Access(); for (auto vertex : dba.Vertices(false)) dba.DetachRemoveVertex(vertex); dba.Commit(); - db_ = std::experimental::nullopt; + db_ = std::nullopt; } auto &interpreter() { return interpreter_; } diff --git a/tests/benchmark/rpc.cpp b/tests/benchmark/rpc.cpp index bca78d1a6..881b405b6 100644 --- a/tests/benchmark/rpc.cpp +++ b/tests/benchmark/rpc.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -42,10 +42,10 @@ DEFINE_int32(server_port, 0, "Server port"); DEFINE_bool(run_server, true, "Set to false to use external server"); DEFINE_bool(run_benchmark, true, "Set to false to only run server"); -std::experimental::optional server; -std::experimental::optional clients[kThreadsNum]; -std::experimental::optional client_pool; -std::experimental::optional thread_pool; +std::optional server; +std::optional clients[kThreadsNum]; +std::optional client_pool; +std::optional thread_pool; static void BenchmarkRpc(benchmark::State &state) { std::string data(state.range(0), 'a'); diff --git a/tests/concurrent/stack.cpp b/tests/concurrent/stack.cpp index 8afc35dec..ad62287e7 100644 --- a/tests/concurrent/stack.cpp +++ b/tests/concurrent/stack.cpp @@ -37,7 +37,7 @@ int main(int argc, char **argv) { std::this_thread::sleep_for(std::chrono::milliseconds(20)); std::vector found; found.resize(FLAGS_max_value); - std::experimental::optional item; + std::optional item; while (run || (item = stack.Pop())) { if (item) { CHECK(*item < FLAGS_max_value); diff --git a/tests/feature_benchmark/ha/read/benchmark.cpp b/tests/feature_benchmark/ha/read/benchmark.cpp index 73411f260..c137e73d3 100644 --- a/tests/feature_benchmark/ha/read/benchmark.cpp +++ b/tests/feature_benchmark/ha/read/benchmark.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include @@ -29,7 +29,7 @@ DEFINE_string(output_file, "", "Output file where the results should be."); DEFINE_int32(nodes, 1000, "Number of nodes in DB"); DEFINE_int32(edges, 5000, "Number of edges in DB"); -std::experimental::optional GetLeaderEndpoint() { +std::optional GetLeaderEndpoint() { for (int retry = 0; retry < 10; ++retry) { for (int i = 0; i < FLAGS_cluster_size; ++i) { try { @@ -44,7 +44,7 @@ std::experimental::optional GetLeaderEndpoint() { client.Close(); // If we succeeded with the above query, we found the current leader. - return std::experimental::make_optional(endpoint); + return std::make_optional(endpoint); } catch (const communication::bolt::ClientQueryException &) { // This one is not the leader, continue. @@ -58,7 +58,7 @@ std::experimental::optional GetLeaderEndpoint() { std::this_thread::sleep_for(1s); } - return std::experimental::nullopt; + return std::nullopt; } int main(int argc, char **argv) { diff --git a/tests/feature_benchmark/ha/write/benchmark.cpp b/tests/feature_benchmark/ha/write/benchmark.cpp index 9af438d7d..1045b6525 100644 --- a/tests/feature_benchmark/ha/write/benchmark.cpp +++ b/tests/feature_benchmark/ha/write/benchmark.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include @@ -26,7 +26,7 @@ DEFINE_double(duration, 10.0, "How long should the client perform writes (seconds)"); DEFINE_string(output_file, "", "Output file where the results should be."); -std::experimental::optional GetLeaderEndpoint() { +std::optional GetLeaderEndpoint() { for (int retry = 0; retry < 10; ++retry) { for (int i = 0; i < FLAGS_cluster_size; ++i) { try { @@ -41,7 +41,7 @@ std::experimental::optional GetLeaderEndpoint() { client.Close(); // If we succeeded with the above query, we found the current leader. - return std::experimental::make_optional(endpoint); + return std::make_optional(endpoint); } catch (const communication::bolt::ClientQueryException &) { // This one is not the leader, continue. @@ -55,7 +55,7 @@ std::experimental::optional GetLeaderEndpoint() { std::this_thread::sleep_for(1s); } - return std::experimental::nullopt; + return std::nullopt; } int main(int argc, char **argv) { diff --git a/tests/feature_benchmark/kafka/benchmark.cpp b/tests/feature_benchmark/kafka/benchmark.cpp index 42a583e8f..182e9a7c3 100644 --- a/tests/feature_benchmark/kafka/benchmark.cpp +++ b/tests/feature_benchmark/kafka/benchmark.cpp @@ -30,8 +30,7 @@ DEFINE_string(output_file, "", "Output file where shold the results be."); void KafkaBenchmarkMain() { google::SetUsageMessage("Memgraph kafka benchmark database server"); - 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"}; @@ -49,8 +48,7 @@ void KafkaBenchmarkMain() { std::atomic benchmark_finished{false}; integrations::kafka::Streams kafka_streams{ - std::experimental::filesystem::path(FLAGS_durability_directory) / - "streams", + std::filesystem::path(FLAGS_durability_directory) / "streams", [&session_data, &query_counter]( const std::string &query, const std::map ¶ms) { diff --git a/tests/macro_benchmark/clients/common.hpp b/tests/macro_benchmark/clients/common.hpp index 69652ea57..a02c29583 100644 --- a/tests/macro_benchmark/clients/common.hpp +++ b/tests/macro_benchmark/clients/common.hpp @@ -1,8 +1,8 @@ #pragma once #include -#include #include +#include #include #include diff --git a/tests/macro_benchmark/clients/long_running_common.hpp b/tests/macro_benchmark/clients/long_running_common.hpp index 078d3cca7..96bef4b18 100644 --- a/tests/macro_benchmark/clients/long_running_common.hpp +++ b/tests/macro_benchmark/clients/long_running_common.hpp @@ -2,10 +2,10 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -72,7 +72,7 @@ class TestClient { protected: virtual void Step() = 0; - std::experimental::optional Execute( + std::optional Execute( const std::string &query, const std::map ¶ms, const std::string &query_name = "") { communication::bolt::QueryData result; @@ -83,7 +83,7 @@ class TestClient { ExecuteNTimesTillSuccess(client_, query, params, MAX_RETRIES); } catch (const utils::BasicException &e) { serialization_errors.Bump(MAX_RETRIES); - return std::experimental::nullopt; + return std::nullopt; } auto wall_time = timer.Elapsed(); auto metadata = result.metadata; diff --git a/tests/manual/card_fraud_generate_snapshot.cpp b/tests/manual/card_fraud_generate_snapshot.cpp index 21e74584d..36859da4a 100644 --- a/tests/manual/card_fraud_generate_snapshot.cpp +++ b/tests/manual/card_fraud_generate_snapshot.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -10,9 +10,9 @@ #include #include "communication/bolt/v1/encoder/base_encoder.hpp" +#include "durability/distributed/paths.hpp" #include "durability/distributed/snapshot_encoder.hpp" #include "durability/distributed/version.hpp" -#include "durability/distributed/paths.hpp" #include "storage/distributed/address_types.hpp" #include "utils/string.hpp" #include "utils/timer.hpp" diff --git a/tests/manual/distributed_common.hpp b/tests/manual/distributed_common.hpp index d4ca3aad2..134dbdc5b 100644 --- a/tests/manual/distributed_common.hpp +++ b/tests/manual/distributed_common.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include @@ -17,7 +17,7 @@ DECLARE_string(durability_directory); -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; class WorkerInThread { public: diff --git a/tests/manual/distributed_repl.cpp b/tests/manual/distributed_repl.cpp index 3c663e995..4cbb3ac88 100644 --- a/tests/manual/distributed_repl.cpp +++ b/tests/manual/distributed_repl.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -20,7 +20,7 @@ DEFINE_VALIDATED_int32(worker_count, 1, DECLARE_int32(min_log_level); DECLARE_string(durability_directory); -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; const std::string kLocal = "127.0.0.1"; diff --git a/tests/manual/generate_snapshot.cpp b/tests/manual/generate_snapshot.cpp index 3f46241cf..611433b11 100644 --- a/tests/manual/generate_snapshot.cpp +++ b/tests/manual/generate_snapshot.cpp @@ -1,7 +1,7 @@ #include -#include #include #include +#include #include #include #include diff --git a/tests/manual/ha_client.cpp b/tests/manual/ha_client.cpp index c996a4fd4..819ee697e 100644 --- a/tests/manual/ha_client.cpp +++ b/tests/manual/ha_client.cpp @@ -22,7 +22,7 @@ using namespace std::chrono_literals; void Execute(const std::vector &queries) { communication::ClientContext context(FLAGS_use_ssl); - std::experimental::optional client; + std::optional client; communication::bolt::QueryData result; for (size_t k = 0; k < queries.size();) { @@ -41,11 +41,11 @@ void Execute(const std::vector &queries) { result = client->Execute(queries[k], {}); } catch (const communication::bolt::ClientQueryException &) { // This one is not the leader, continue. - client = std::experimental::nullopt; + client = std::nullopt; continue; } catch (const communication::bolt::ClientFatalException &) { // This one seems to be down, continue. - client = std::experimental::nullopt; + client = std::nullopt; continue; } } @@ -66,10 +66,10 @@ void Execute(const std::vector &queries) { try { result = client->Execute(queries[k], {}); } catch (const communication::bolt::ClientQueryException &) { - client = std::experimental::nullopt; + client = std::nullopt; continue; } catch (const communication::bolt::ClientFatalException &e) { - client = std::experimental::nullopt; + client = std::nullopt; continue; } } diff --git a/tests/manual/interactive_planning.cpp b/tests/manual/interactive_planning.cpp index f05851ef2..558221f20 100644 --- a/tests/manual/interactive_planning.cpp +++ b/tests/manual/interactive_planning.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -40,9 +40,9 @@ DEFINE_string(load_mock_db_file, "", * @param prompt The prompt to display. * @return A single command the user entered, or nullopt on EOF. */ -std::experimental::optional ReadLine(const std::string &prompt) { +std::optional ReadLine(const std::string &prompt) { char *line = readline(prompt.c_str()); - if (!line) return std::experimental::nullopt; + if (!line) return std::nullopt; if (*line) add_history(line); std::string r_val(line); @@ -52,11 +52,11 @@ std::experimental::optional ReadLine(const std::string &prompt) { #else -std::experimental::optional ReadLine(const std::string &prompt) { +std::optional ReadLine(const std::string &prompt) { std::cout << prompt; std::string line; std::getline(std::cin, line); - if (std::cin.eof()) return std::experimental::nullopt; + if (std::cin.eof()) return std::nullopt; return line; } @@ -181,8 +181,8 @@ class InteractiveDbAccessor { int64_t VerticesCount( storage::Label label_id, storage::Property property_id, - const std::experimental::optional> lower, - const std::experimental::optional> upper) { + const std::optional> lower, + const std::optional> upper) { auto label = dba_->LabelName(label_id); auto property = dba_->PropertyName(property_id); std::stringstream range_string; @@ -490,8 +490,7 @@ auto MakeLogicalPlans(query::CypherQuery *query, query::AstStorage &ast, void RunInteractivePlanning(database::GraphDbAccessor *dba) { auto in_db_filename = utils::Trim(FLAGS_load_mock_db_file); - if (!in_db_filename.empty() && - !std::experimental::filesystem::exists(in_db_filename)) { + if (!in_db_filename.empty() && !std::filesystem::exists(in_db_filename)) { std::cerr << "File '" << in_db_filename << "' does not exist!" << std::endl; std::exit(EXIT_FAILURE); } diff --git a/tests/manual/kvstore_console.cpp b/tests/manual/kvstore_console.cpp index 17ae5bd6a..d032b05f7 100644 --- a/tests/manual/kvstore_console.cpp +++ b/tests/manual/kvstore_console.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) { CHECK(FLAGS_path != "") << "Please specify a path to the KVStore!"; - storage::KVStore kvstore(std::experimental::filesystem::path{FLAGS_path}); + storage::KVStore kvstore(std::filesystem::path{FLAGS_path}); while (true) { std::string s; @@ -35,7 +35,7 @@ int main(int argc, char **argv) { std::cout << "`get' takes exactly one argument!" << std::endl; } auto item = kvstore.Get(split[1]); - if (item != std::experimental::nullopt) { + if (item != std::nullopt) { std::cout << split[1] << " --> " << *item << std::endl; } else { std::cout << "Key doesn't exist in the database!" << std::endl; diff --git a/tests/manual/snapshot_explorer.cpp b/tests/manual/snapshot_explorer.cpp index 6ca40f4f6..70e708ea2 100644 --- a/tests/manual/snapshot_explorer.cpp +++ b/tests/manual/snapshot_explorer.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -12,7 +12,7 @@ DEFINE_string(snapshot_file, "", "Snapshot file location"); using communication::bolt::Value; -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; int main(int argc, char *argv[]) { gflags::ParseCommandLineFlags(&argc, &argv, true); diff --git a/tests/manual/snapshot_generation/graph_state.hpp b/tests/manual/snapshot_generation/graph_state.hpp index 1192d6734..893cfd718 100644 --- a/tests/manual/snapshot_generation/graph_state.hpp +++ b/tests/manual/snapshot_generation/graph_state.hpp @@ -110,8 +110,7 @@ class GraphState { gid::Gid CreateNode( int worker_id, const std::vector &labels, const std::unordered_map &props) { - auto node_gid = - node_generators_[worker_id]->Next(std::experimental::nullopt); + auto node_gid = node_generators_[worker_id]->Next(std::nullopt); nodes_[node_gid] = {node_gid, labels, props, {}, {}}; for (const auto &label : labels) { @@ -125,8 +124,7 @@ class GraphState { gid::Gid from, gid::Gid to, const std::string &type, const std::unordered_map &props) { int worker_id = gid::CreatorWorker(from); - auto edge_gid = - edge_generators_[worker_id]->Next(std::experimental::nullopt); + auto edge_gid = edge_generators_[worker_id]->Next(std::nullopt); nodes_[from].out_edges.emplace_back(edge_gid); nodes_[to].in_edges.emplace_back(edge_gid); edges_[edge_gid] = Edge{edge_gid, from, to, type, props}; diff --git a/tests/manual/snapshot_generation/snapshot_writer.hpp b/tests/manual/snapshot_generation/snapshot_writer.hpp index f15c58cc9..180835eb6 100644 --- a/tests/manual/snapshot_generation/snapshot_writer.hpp +++ b/tests/manual/snapshot_generation/snapshot_writer.hpp @@ -130,9 +130,8 @@ class SnapshotWriter { void WriteToSnapshot(GraphState &state, const std::string &path) { for (int worker_id = 0; worker_id < state.NumWorkers(); ++worker_id) { - const std::experimental::filesystem::path durability_dir = - path / std::experimental::filesystem::path("worker_" + - std::to_string(worker_id)); + const std::filesystem::path durability_dir = + path / std::filesystem::path("worker_" + std::to_string(worker_id)); if (!utils::EnsureDir(durability_dir / "snapshots")) { LOG(ERROR) << "Unable to create durability directory!"; exit(0); diff --git a/tests/manual/snapshot_generation/value_generator.hpp b/tests/manual/snapshot_generation/value_generator.hpp index 717db852f..98576f944 100644 --- a/tests/manual/snapshot_generation/value_generator.hpp +++ b/tests/manual/snapshot_generation/value_generator.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -31,7 +31,7 @@ class ValueGenerator { } // Generates a single value based on the given config. - std::experimental::optional MakeValue(const json &config) { + std::optional MakeValue(const json &config) { if (config.is_object()) { const std::string &type = config["type"]; const auto ¶m = config["param"]; @@ -91,11 +91,10 @@ class ValueGenerator { // Returns a value specified by config with some probability, and nullopt // otherwise - std::experimental::optional Optional(const json &config) { + std::optional Optional(const json &config) { CHECK(config.is_array() && config.size() == 2) << "Optional value gen config must be a list with 2 elements"; - return Bernoulli(config[0]) ? MakeValue(config[1]) - : std::experimental::nullopt; + return Bernoulli(config[0]) ? MakeValue(config[1]) : std::nullopt; } private: diff --git a/tests/manual/wal_explorer.cpp b/tests/manual/wal_explorer.cpp index 402c6949d..0794065d3 100644 --- a/tests/manual/wal_explorer.cpp +++ b/tests/manual/wal_explorer.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -15,7 +15,7 @@ DEFINE_string(wal_file, "", "WAL file location"); using communication::bolt::Value; -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; std::string StateDeltaTypeToString(database::StateDelta::Type type) { switch (type) { diff --git a/tests/unit/ast_serialization.cpp b/tests/unit/ast_serialization.cpp index 664b7b3ec..bf6350efd 100644 --- a/tests/unit/ast_serialization.cpp +++ b/tests/unit/ast_serialization.cpp @@ -54,8 +54,7 @@ class Base { } void CheckLiteral(Expression *expression, const TypedValue &expected, - const std::experimental::optional &token_position = - std::experimental::nullopt) { + const std::optional &token_position = std::nullopt) { TypedValue value; if (!expected.IsNull() && context_.is_query_cached) { auto *param_lookup = dynamic_cast(expression); @@ -2079,7 +2078,7 @@ TEST_P(CypherMainVisitorTest, UnionAll) { void check_auth_query(Base *ast_generator, std::string input, AuthQuery::Action action, std::string user, std::string role, std::string user_or_role, - std::experimental::optional password, + std::optional password, std::vector privileges) { auto *auth_query = dynamic_cast(ast_generator->ParseQuery(input)); @@ -2304,8 +2303,8 @@ TEST_P(CypherMainVisitorTest, CreateStream) { [this](std::string input, const std::string &stream_name, const std::string &stream_uri, const std::string &stream_topic, const std::string &transform_uri, - std::experimental::optional batch_interval_in_ms, - std::experimental::optional batch_size) { + std::optional batch_interval_in_ms, + std::optional batch_size) { auto &ast_generator = *GetParam(); auto *stream_query = dynamic_cast(ast_generator.ParseQuery(input)); @@ -2341,22 +2340,20 @@ TEST_P(CypherMainVisitorTest, CreateStream) { "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 'tropika' " "WITH TRANSFORM 'localhost/test.py'", - "stream", "localhost", "tropika", "localhost/test.py", - std::experimental::nullopt, std::experimental::nullopt); + "stream", "localhost", "tropika", "localhost/test.py", std::nullopt, + std::nullopt); check_create_stream( "CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' " "WitH TopIC 'tropika' " "WITH TRAnsFORM 'localhost/test.py' bAtCH inTErvAL 168", - "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt); + "stream", "localhost", "tropika", "localhost/test.py", 168, std::nullopt); check_create_stream( "CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' " "WITH TopIC 'tropika' " "WITH TRAnsFORM 'localhost/test.py' bAtCH SizE 17", - "stream", "localhost", "tropika", "localhost/test.py", - std::experimental::nullopt, 17); + "stream", "localhost", "tropika", "localhost/test.py", std::nullopt, 17); check_create_stream( "CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' " @@ -2368,42 +2365,42 @@ TEST_P(CypherMainVisitorTest, CreateStream) { "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TRANSFORM 'localhost/test.py' BATCH INTERVAL 'jedan' ", "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt), + std::nullopt), SyntaxException); EXPECT_THROW(check_create_stream( "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 'tropika' " "WITH TRANSFORM 'localhost/test.py' BATCH SIZE 'jedan' ", "stream", "localhost", "tropika", "localhost/test.py", - std::experimental::nullopt, 17), + std::nullopt, 17), SyntaxException); EXPECT_THROW(check_create_stream( "CREATE STREAM 123 AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 'tropika' " "WITH TRANSFORM 'localhost/test.py' BATCH INTERVAL 168 ", "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt), - SyntaxException); - EXPECT_THROW(check_create_stream( - "CREATE STREAM stream AS LOAD DATA KAFKA localhost " - "WITH TOPIC 'tropika' " - "WITH TRANSFORM 'localhost/test.py'", - "stream", "localhost", "tropika", "localhost/test.py", - std::experimental::nullopt, std::experimental::nullopt), + std::nullopt), SyntaxException); + EXPECT_THROW( + check_create_stream("CREATE STREAM stream AS LOAD DATA KAFKA localhost " + "WITH TOPIC 'tropika' " + "WITH TRANSFORM 'localhost/test.py'", + "stream", "localhost", "tropika", "localhost/test.py", + std::nullopt, std::nullopt), + SyntaxException); EXPECT_THROW(check_create_stream( "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 2" "WITH TRANSFORM localhost/test.py BATCH INTERVAL 168 ", "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt), + std::nullopt), SyntaxException); EXPECT_THROW(check_create_stream( "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 'tropika'" "WITH TRANSFORM localhost/test.py BATCH INTERVAL 168 ", "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt), + std::nullopt), SyntaxException); } @@ -2443,47 +2440,45 @@ TEST_P(CypherMainVisitorTest, ShowStreams) { } TEST_P(CypherMainVisitorTest, StartStopStream) { - auto check_start_stop_stream = - [this](std::string input, const std::string &stream_name, bool is_start, - std::experimental::optional limit_batches) { - auto &ast_generator = *GetParam(); - auto *stream_query = - dynamic_cast(ast_generator.ParseQuery(input)); - ASSERT_TRUE(stream_query); + auto check_start_stop_stream = [this](std::string input, + const std::string &stream_name, + bool is_start, + std::optional limit_batches) { + auto &ast_generator = *GetParam(); + auto *stream_query = + dynamic_cast(ast_generator.ParseQuery(input)); + ASSERT_TRUE(stream_query); - EXPECT_EQ(stream_query->stream_name_, stream_name); - EXPECT_EQ(stream_query->action_, - is_start ? StreamQuery::Action::START_STREAM - : StreamQuery::Action::STOP_STREAM); + EXPECT_EQ(stream_query->stream_name_, stream_name); + EXPECT_EQ(stream_query->action_, is_start + ? StreamQuery::Action::START_STREAM + : StreamQuery::Action::STOP_STREAM); - if (limit_batches) { - ASSERT_TRUE(is_start); - ASSERT_TRUE(stream_query->limit_batches_); - ast_generator.CheckLiteral(stream_query->limit_batches_, - TypedValue(*limit_batches)); - } else { - EXPECT_EQ(stream_query->limit_batches_, nullptr); - } - }; + if (limit_batches) { + ASSERT_TRUE(is_start); + ASSERT_TRUE(stream_query->limit_batches_); + ast_generator.CheckLiteral(stream_query->limit_batches_, + TypedValue(*limit_batches)); + } else { + EXPECT_EQ(stream_query->limit_batches_, nullptr); + } + }; - check_start_stop_stream("stARt STreaM STREAM", "STREAM", true, - std::experimental::nullopt); - check_start_stop_stream("stARt STreaM strim", "strim", true, - std::experimental::nullopt); + check_start_stop_stream("stARt STreaM STREAM", "STREAM", true, std::nullopt); + check_start_stop_stream("stARt STreaM strim", "strim", true, std::nullopt); check_start_stop_stream("StARt STreAM strim LimIT 10 BATchES", "strim", true, 10); - check_start_stop_stream("StoP StrEAM strim", "strim", false, - std::experimental::nullopt); + check_start_stop_stream("StoP StrEAM strim", "strim", false, std::nullopt); EXPECT_THROW(check_start_stop_stream("staRT STReaM 'strim'", "strim", true, - std::experimental::nullopt), + std::nullopt), SyntaxException); EXPECT_THROW(check_start_stop_stream("sTART STReaM strim LImiT 'dva' BATCheS", "strim", true, 2), SyntaxException); EXPECT_THROW(check_start_stop_stream("StoP STreAM 'strim'", "strim", false, - std::experimental::nullopt), + std::nullopt), SyntaxException); EXPECT_THROW(check_start_stop_stream("STOp sTREAM strim LIMit 2 baTCHES", "strim", false, 2), @@ -2513,39 +2508,37 @@ TEST_P(CypherMainVisitorTest, StartStopAllStreams) { } TEST_P(CypherMainVisitorTest, TestStream) { - auto check_test_stream = - [this](std::string input, const std::string &stream_name, - std::experimental::optional limit_batches) { - auto &ast_generator = *GetParam(); - auto *stream_query = - dynamic_cast(ast_generator.ParseQuery(input)); - ASSERT_TRUE(stream_query); - EXPECT_EQ(stream_query->stream_name_, stream_name); - EXPECT_EQ(stream_query->action_, StreamQuery::Action::TEST_STREAM); + auto check_test_stream = [this](std::string input, + const std::string &stream_name, + std::optional limit_batches) { + auto &ast_generator = *GetParam(); + auto *stream_query = + dynamic_cast(ast_generator.ParseQuery(input)); + ASSERT_TRUE(stream_query); + EXPECT_EQ(stream_query->stream_name_, stream_name); + EXPECT_EQ(stream_query->action_, StreamQuery::Action::TEST_STREAM); - if (limit_batches) { - ASSERT_TRUE(stream_query->limit_batches_); - ast_generator.CheckLiteral(stream_query->limit_batches_, - TypedValue(*limit_batches)); - } else { - EXPECT_EQ(stream_query->limit_batches_, nullptr); - } - }; + if (limit_batches) { + ASSERT_TRUE(stream_query->limit_batches_); + ast_generator.CheckLiteral(stream_query->limit_batches_, + TypedValue(*limit_batches)); + } else { + EXPECT_EQ(stream_query->limit_batches_, nullptr); + } + }; - check_test_stream("TesT STreaM strim", "strim", std::experimental::nullopt); - check_test_stream("TesT STreaM STREAM", "STREAM", std::experimental::nullopt); + check_test_stream("TesT STreaM strim", "strim", std::nullopt); + check_test_stream("TesT STreaM STREAM", "STREAM", std::nullopt); check_test_stream("tESt STreAM STREAM LimIT 10 BATchES", "STREAM", 10); - check_test_stream("Test StrEAM STREAM", "STREAM", std::experimental::nullopt); + check_test_stream("Test StrEAM STREAM", "STREAM", std::nullopt); - EXPECT_THROW(check_test_stream("tEST STReaM 'strim'", "strim", - std::experimental::nullopt), + EXPECT_THROW(check_test_stream("tEST STReaM 'strim'", "strim", std::nullopt), SyntaxException); EXPECT_THROW( check_test_stream("test STReaM strim LImiT 'dva' BATCheS", "strim", 2), SyntaxException); - EXPECT_THROW(check_test_stream("test STreAM 'strim'", "strim", - std::experimental::nullopt), + EXPECT_THROW(check_test_stream("test STreAM 'strim'", "strim", std::nullopt), SyntaxException); } diff --git a/tests/unit/auth.cpp b/tests/unit/auth.cpp index 5e5a4b428..686289e2d 100644 --- a/tests/unit/auth.cpp +++ b/tests/unit/auth.cpp @@ -11,7 +11,7 @@ #include "utils/file.hpp" using namespace auth; -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; DECLARE_bool(auth_password_permit_null); DECLARE_string(auth_password_strength_regex); @@ -69,7 +69,7 @@ TEST_F(AuthWithStorage, Authenticate) { ASSERT_FALSE(auth.HasUsers()); auto user = auth.AddUser("test"); - ASSERT_NE(user, std::experimental::nullopt); + ASSERT_NE(user, std::nullopt); ASSERT_TRUE(auth.HasUsers()); ASSERT_TRUE(auth.Authenticate("test", "123")); @@ -77,19 +77,18 @@ TEST_F(AuthWithStorage, Authenticate) { user->UpdatePassword("123"); auth.SaveUser(*user); - ASSERT_NE(auth.Authenticate("test", "123"), std::experimental::nullopt); + ASSERT_NE(auth.Authenticate("test", "123"), std::nullopt); - ASSERT_EQ(auth.Authenticate("test", "456"), std::experimental::nullopt); - ASSERT_NE(auth.Authenticate("test", "123"), std::experimental::nullopt); + ASSERT_EQ(auth.Authenticate("test", "456"), std::nullopt); + ASSERT_NE(auth.Authenticate("test", "123"), std::nullopt); user->UpdatePassword(); auth.SaveUser(*user); - ASSERT_NE(auth.Authenticate("test", "123"), std::experimental::nullopt); - ASSERT_NE(auth.Authenticate("test", "456"), std::experimental::nullopt); + ASSERT_NE(auth.Authenticate("test", "123"), std::nullopt); + ASSERT_NE(auth.Authenticate("test", "456"), std::nullopt); - ASSERT_EQ(auth.Authenticate("nonexistant", "123"), - std::experimental::nullopt); + ASSERT_EQ(auth.Authenticate("nonexistant", "123"), std::nullopt); } TEST_F(AuthWithStorage, UserRolePermissions) { @@ -98,7 +97,7 @@ TEST_F(AuthWithStorage, UserRolePermissions) { ASSERT_TRUE(auth.HasUsers()); auto user = auth.GetUser("test"); - ASSERT_NE(user, std::experimental::nullopt); + ASSERT_NE(user, std::nullopt); // Test initial user permissions. ASSERT_EQ(user->permissions().Has(Permission::MATCH), @@ -127,7 +126,7 @@ TEST_F(AuthWithStorage, UserRolePermissions) { // Create role. ASSERT_TRUE(auth.AddRole("admin")); auto role = auth.GetRole("admin"); - ASSERT_NE(role, std::experimental::nullopt); + ASSERT_NE(role, std::nullopt); // Assign permissions to role and role to user. role->permissions().Grant(Permission::DELETE); diff --git a/tests/unit/bfs_distributed.cpp b/tests/unit/bfs_distributed.cpp index 7bee86a6c..8a21473d6 100644 --- a/tests/unit/bfs_distributed.cpp +++ b/tests/unit/bfs_distributed.cpp @@ -49,7 +49,7 @@ class DistributedDb : public Database { } else { auto vertex = database::InsertVertexIntoRemote( dba, vertex_locations[id], {}, {{dba->Property("id"), (int64_t)id}}, - std::experimental::nullopt); + std::nullopt); vertex_addr.push_back(vertex.GlobalAddress()); } } diff --git a/tests/unit/bfs_single_node.cpp b/tests/unit/bfs_single_node.cpp index 885a24064..9c442054b 100644 --- a/tests/unit/bfs_single_node.cpp +++ b/tests/unit/bfs_single_node.cpp @@ -28,7 +28,7 @@ class SingleNodeDb : public Database { return std::make_unique( input, source_sym, sink_sym, edge_sym, EdgeAtom::Type::BREADTH_FIRST, direction, edge_types, false, lower_bound, upper_bound, existing_node, - filter_lambda, std::experimental::nullopt, std::experimental::nullopt); + filter_lambda, std::nullopt, std::nullopt); } std::pair, std::vector> BuildGraph( diff --git a/tests/unit/concurrent_id_mapper_distributed.cpp b/tests/unit/concurrent_id_mapper_distributed.cpp index 080d79dc3..5d0162e42 100644 --- a/tests/unit/concurrent_id_mapper_distributed.cpp +++ b/tests/unit/concurrent_id_mapper_distributed.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -15,12 +15,9 @@ class DistributedConcurrentIdMapperTest : public ::testing::Test { protected: TestMasterCoordination coordination_; - std::experimental::optional - master_client_pool_; - std::experimental::optional> - master_mapper_; - std::experimental::optional> - worker_mapper_; + std::optional master_client_pool_; + std::optional> master_mapper_; + std::optional> worker_mapper_; void SetUp() override { master_mapper_.emplace(&coordination_); @@ -29,10 +26,10 @@ class DistributedConcurrentIdMapperTest : public ::testing::Test { worker_mapper_.emplace(&master_client_pool_.value()); } void TearDown() override { - worker_mapper_ = std::experimental::nullopt; - master_client_pool_ = std::experimental::nullopt; + worker_mapper_ = std::nullopt; + master_client_pool_ = std::nullopt; coordination_.Stop(); - master_mapper_ = std::experimental::nullopt; + master_mapper_ = std::nullopt; } }; diff --git a/tests/unit/cypher_main_visitor.cpp b/tests/unit/cypher_main_visitor.cpp index 05c4aaee3..6cc628219 100644 --- a/tests/unit/cypher_main_visitor.cpp +++ b/tests/unit/cypher_main_visitor.cpp @@ -51,8 +51,7 @@ class Base { } void CheckLiteral(Expression *expression, const TypedValue &expected, - const std::experimental::optional &token_position = - std::experimental::nullopt) { + const std::optional &token_position = std::nullopt) { TypedValue value; if (!expected.IsNull() && context_.is_query_cached) { auto *param_lookup = dynamic_cast(expression); @@ -2147,7 +2146,7 @@ TEST_P(CypherMainVisitorTest, UnionAll) { void check_auth_query(Base *ast_generator, std::string input, AuthQuery::Action action, std::string user, std::string role, std::string user_or_role, - std::experimental::optional password, + std::optional password, std::vector privileges) { auto *auth_query = dynamic_cast(ast_generator->ParseQuery(input)); @@ -2372,8 +2371,8 @@ TEST_P(CypherMainVisitorTest, CreateStream) { [this](std::string input, const std::string &stream_name, const std::string &stream_uri, const std::string &stream_topic, const std::string &transform_uri, - std::experimental::optional batch_interval_in_ms, - std::experimental::optional batch_size) { + std::optional batch_interval_in_ms, + std::optional batch_size) { auto &ast_generator = *GetParam(); auto *stream_query = dynamic_cast(ast_generator.ParseQuery(input)); @@ -2409,22 +2408,20 @@ TEST_P(CypherMainVisitorTest, CreateStream) { "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 'tropika' " "WITH TRANSFORM 'localhost/test.py'", - "stream", "localhost", "tropika", "localhost/test.py", - std::experimental::nullopt, std::experimental::nullopt); + "stream", "localhost", "tropika", "localhost/test.py", std::nullopt, + std::nullopt); check_create_stream( "CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' " "WitH TopIC 'tropika' " "WITH TRAnsFORM 'localhost/test.py' bAtCH inTErvAL 168", - "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt); + "stream", "localhost", "tropika", "localhost/test.py", 168, std::nullopt); check_create_stream( "CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' " "WITH TopIC 'tropika' " "WITH TRAnsFORM 'localhost/test.py' bAtCH SizE 17", - "stream", "localhost", "tropika", "localhost/test.py", - std::experimental::nullopt, 17); + "stream", "localhost", "tropika", "localhost/test.py", std::nullopt, 17); check_create_stream( "CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' " @@ -2436,42 +2433,42 @@ TEST_P(CypherMainVisitorTest, CreateStream) { "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TRANSFORM 'localhost/test.py' BATCH INTERVAL 'jedan' ", "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt), + std::nullopt), SyntaxException); EXPECT_THROW(check_create_stream( "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 'tropika' " "WITH TRANSFORM 'localhost/test.py' BATCH SIZE 'jedan' ", "stream", "localhost", "tropika", "localhost/test.py", - std::experimental::nullopt, 17), + std::nullopt, 17), SyntaxException); EXPECT_THROW(check_create_stream( "CREATE STREAM 123 AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 'tropika' " "WITH TRANSFORM 'localhost/test.py' BATCH INTERVAL 168 ", "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt), - SyntaxException); - EXPECT_THROW(check_create_stream( - "CREATE STREAM stream AS LOAD DATA KAFKA localhost " - "WITH TOPIC 'tropika' " - "WITH TRANSFORM 'localhost/test.py'", - "stream", "localhost", "tropika", "localhost/test.py", - std::experimental::nullopt, std::experimental::nullopt), + std::nullopt), SyntaxException); + EXPECT_THROW( + check_create_stream("CREATE STREAM stream AS LOAD DATA KAFKA localhost " + "WITH TOPIC 'tropika' " + "WITH TRANSFORM 'localhost/test.py'", + "stream", "localhost", "tropika", "localhost/test.py", + std::nullopt, std::nullopt), + SyntaxException); EXPECT_THROW(check_create_stream( "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 2" "WITH TRANSFORM localhost/test.py BATCH INTERVAL 168 ", "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt), + std::nullopt), SyntaxException); EXPECT_THROW(check_create_stream( "CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' " "WITH TOPIC 'tropika'" "WITH TRANSFORM localhost/test.py BATCH INTERVAL 168 ", "stream", "localhost", "tropika", "localhost/test.py", 168, - std::experimental::nullopt), + std::nullopt), SyntaxException); } @@ -2511,47 +2508,45 @@ TEST_P(CypherMainVisitorTest, ShowStreams) { } TEST_P(CypherMainVisitorTest, StartStopStream) { - auto check_start_stop_stream = - [this](std::string input, const std::string &stream_name, bool is_start, - std::experimental::optional limit_batches) { - auto &ast_generator = *GetParam(); - auto *stream_query = - dynamic_cast(ast_generator.ParseQuery(input)); - ASSERT_TRUE(stream_query); + auto check_start_stop_stream = [this](std::string input, + const std::string &stream_name, + bool is_start, + std::optional limit_batches) { + auto &ast_generator = *GetParam(); + auto *stream_query = + dynamic_cast(ast_generator.ParseQuery(input)); + ASSERT_TRUE(stream_query); - EXPECT_EQ(stream_query->stream_name_, stream_name); - EXPECT_EQ(stream_query->action_, - is_start ? StreamQuery::Action::START_STREAM - : StreamQuery::Action::STOP_STREAM); + EXPECT_EQ(stream_query->stream_name_, stream_name); + EXPECT_EQ(stream_query->action_, is_start + ? StreamQuery::Action::START_STREAM + : StreamQuery::Action::STOP_STREAM); - if (limit_batches) { - ASSERT_TRUE(is_start); - ASSERT_TRUE(stream_query->limit_batches_); - ast_generator.CheckLiteral(stream_query->limit_batches_, - TypedValue(*limit_batches)); - } else { - EXPECT_EQ(stream_query->limit_batches_, nullptr); - } - }; + if (limit_batches) { + ASSERT_TRUE(is_start); + ASSERT_TRUE(stream_query->limit_batches_); + ast_generator.CheckLiteral(stream_query->limit_batches_, + TypedValue(*limit_batches)); + } else { + EXPECT_EQ(stream_query->limit_batches_, nullptr); + } + }; - check_start_stop_stream("stARt STreaM STREAM", "STREAM", true, - std::experimental::nullopt); - check_start_stop_stream("stARt STreaM strim", "strim", true, - std::experimental::nullopt); + check_start_stop_stream("stARt STreaM STREAM", "STREAM", true, std::nullopt); + check_start_stop_stream("stARt STreaM strim", "strim", true, std::nullopt); check_start_stop_stream("StARt STreAM strim LimIT 10 BATchES", "strim", true, 10); - check_start_stop_stream("StoP StrEAM strim", "strim", false, - std::experimental::nullopt); + check_start_stop_stream("StoP StrEAM strim", "strim", false, std::nullopt); EXPECT_THROW(check_start_stop_stream("staRT STReaM 'strim'", "strim", true, - std::experimental::nullopt), + std::nullopt), SyntaxException); EXPECT_THROW(check_start_stop_stream("sTART STReaM strim LImiT 'dva' BATCheS", "strim", true, 2), SyntaxException); EXPECT_THROW(check_start_stop_stream("StoP STreAM 'strim'", "strim", false, - std::experimental::nullopt), + std::nullopt), SyntaxException); EXPECT_THROW(check_start_stop_stream("STOp sTREAM strim LIMit 2 baTCHES", "strim", false, 2), @@ -2581,39 +2576,37 @@ TEST_P(CypherMainVisitorTest, StartStopAllStreams) { } TEST_P(CypherMainVisitorTest, TestStream) { - auto check_test_stream = - [this](std::string input, const std::string &stream_name, - std::experimental::optional limit_batches) { - auto &ast_generator = *GetParam(); - auto *stream_query = - dynamic_cast(ast_generator.ParseQuery(input)); - ASSERT_TRUE(stream_query); - EXPECT_EQ(stream_query->stream_name_, stream_name); - EXPECT_EQ(stream_query->action_, StreamQuery::Action::TEST_STREAM); + auto check_test_stream = [this](std::string input, + const std::string &stream_name, + std::optional limit_batches) { + auto &ast_generator = *GetParam(); + auto *stream_query = + dynamic_cast(ast_generator.ParseQuery(input)); + ASSERT_TRUE(stream_query); + EXPECT_EQ(stream_query->stream_name_, stream_name); + EXPECT_EQ(stream_query->action_, StreamQuery::Action::TEST_STREAM); - if (limit_batches) { - ASSERT_TRUE(stream_query->limit_batches_); - ast_generator.CheckLiteral(stream_query->limit_batches_, - TypedValue(*limit_batches)); - } else { - EXPECT_EQ(stream_query->limit_batches_, nullptr); - } - }; + if (limit_batches) { + ASSERT_TRUE(stream_query->limit_batches_); + ast_generator.CheckLiteral(stream_query->limit_batches_, + TypedValue(*limit_batches)); + } else { + EXPECT_EQ(stream_query->limit_batches_, nullptr); + } + }; - check_test_stream("TesT STreaM strim", "strim", std::experimental::nullopt); - check_test_stream("TesT STreaM STREAM", "STREAM", std::experimental::nullopt); + check_test_stream("TesT STreaM strim", "strim", std::nullopt); + check_test_stream("TesT STreaM STREAM", "STREAM", std::nullopt); check_test_stream("tESt STreAM STREAM LimIT 10 BATchES", "STREAM", 10); - check_test_stream("Test StrEAM STREAM", "STREAM", std::experimental::nullopt); + check_test_stream("Test StrEAM STREAM", "STREAM", std::nullopt); - EXPECT_THROW(check_test_stream("tEST STReaM 'strim'", "strim", - std::experimental::nullopt), + EXPECT_THROW(check_test_stream("tEST STReaM 'strim'", "strim", std::nullopt), SyntaxException); EXPECT_THROW( check_test_stream("test STReaM strim LImiT 'dva' BATCheS", "strim", 2), SyntaxException); - EXPECT_THROW(check_test_stream("test STreAM 'strim'", "strim", - std::experimental::nullopt), + EXPECT_THROW(check_test_stream("test STreAM 'strim'", "strim", std::nullopt), SyntaxException); } diff --git a/tests/unit/distributed_common.hpp b/tests/unit/distributed_common.hpp index 658c8e77b..fa0bcb8bd 100644 --- a/tests/unit/distributed_common.hpp +++ b/tests/unit/distributed_common.hpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -15,7 +15,7 @@ DECLARE_string(durability_directory); -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; class WorkerInThread { public: diff --git a/tests/unit/distributed_coordination.cpp b/tests/unit/distributed_coordination.cpp index 1691044b4..eb7f11509 100644 --- a/tests/unit/distributed_coordination.cpp +++ b/tests/unit/distributed_coordination.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include #include @@ -18,7 +18,7 @@ using namespace distributed; using namespace std::literals::chrono_literals; -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; const int kWorkerCount = 5; const std::string kLocal = "127.0.0.1"; @@ -49,7 +49,7 @@ class WorkerCoordinationInThread { // shutdown by the master. We only wait for the shutdown to be // finished. EXPECT_TRUE(worker->coord.AwaitShutdown()); - worker = std::experimental::nullopt; + worker = std::nullopt; }); while (!init_done) std::this_thread::sleep_for(10ms); @@ -63,13 +63,13 @@ class WorkerCoordinationInThread { auto worker_ids() { return worker->coord.GetWorkerIds(); } void join() { worker_thread_.join(); } void NotifyWorkerRecovered() { - std::experimental::optional no_recovery_info; + std::optional no_recovery_info; worker->discovery.NotifyWorkerRecovered(no_recovery_info); } private: std::thread worker_thread_; - std::experimental::optional worker; + std::optional worker; }; class Distributed : public ::testing::Test { @@ -93,7 +93,7 @@ TEST_F(Distributed, Coordination) { MasterCoordination master_coord({kLocal, 0}); ClusterDiscoveryMaster master_discovery_(&master_coord, tmp_dir("master")); ASSERT_TRUE(master_coord.Start()); - master_coord.SetRecoveredSnapshot(std::experimental::nullopt); + master_coord.SetRecoveredSnapshot(std::nullopt); for (int i = 1; i <= kWorkerCount; ++i) workers.emplace_back(std::make_unique( @@ -124,7 +124,7 @@ TEST_F(Distributed, DesiredAndUniqueId) { MasterCoordination master_coord({kLocal, 0}); ClusterDiscoveryMaster master_discovery_(&master_coord, tmp_dir("master")); ASSERT_TRUE(master_coord.Start()); - master_coord.SetRecoveredSnapshot(std::experimental::nullopt); + master_coord.SetRecoveredSnapshot(std::nullopt); workers.emplace_back(std::make_unique( master_coord.GetServerEndpoint(), tmp_dir("worker42"), 42)); @@ -147,7 +147,7 @@ TEST_F(Distributed, CoordinationWorkersId) { MasterCoordination master_coord({kLocal, 0}); ClusterDiscoveryMaster master_discovery_(&master_coord, tmp_dir("master")); ASSERT_TRUE(master_coord.Start()); - master_coord.SetRecoveredSnapshot(std::experimental::nullopt); + master_coord.SetRecoveredSnapshot(std::nullopt); workers.emplace_back(std::make_unique( master_coord.GetServerEndpoint(), tmp_dir("worker42"), 42)); @@ -173,7 +173,7 @@ TEST_F(Distributed, ClusterDiscovery) { MasterCoordination master_coord({kLocal, 0}); ClusterDiscoveryMaster master_discovery_(&master_coord, tmp_dir("master")); ASSERT_TRUE(master_coord.Start()); - master_coord.SetRecoveredSnapshot(std::experimental::nullopt); + master_coord.SetRecoveredSnapshot(std::nullopt); std::vector ids; int worker_count = 10; @@ -204,7 +204,7 @@ TEST_F(Distributed, KeepsTrackOfRecovered) { MasterCoordination master_coord({kLocal, 0}); ClusterDiscoveryMaster master_discovery_(&master_coord, tmp_dir("master")); ASSERT_TRUE(master_coord.Start()); - master_coord.SetRecoveredSnapshot(std::experimental::nullopt); + master_coord.SetRecoveredSnapshot(std::nullopt); int worker_count = 10; for (int i = 1; i <= worker_count; ++i) { workers.emplace_back(std::make_unique( diff --git a/tests/unit/distributed_dgp_vertex_migrator.cpp b/tests/unit/distributed_dgp_vertex_migrator.cpp index f556387b0..6b664a615 100644 --- a/tests/unit/distributed_dgp_vertex_migrator.cpp +++ b/tests/unit/distributed_dgp_vertex_migrator.cpp @@ -6,8 +6,8 @@ #include "gtest/gtest.h" -#include "distributed/updates_rpc_clients.hpp" #include "distributed/dgp/vertex_migrator.hpp" +#include "distributed/updates_rpc_clients.hpp" using namespace distributed; using namespace database; @@ -133,25 +133,25 @@ class DistributedVertexMigratorTest : public DistributedGraphDbTest { /** * Find vertex with a given cypher_id within a given database. */ - std::experimental::optional FindVertex( - database::GraphDbAccessor *dba, int64_t cypher_id) { + std::optional FindVertex(database::GraphDbAccessor *dba, + int64_t cypher_id) { for (auto &vertex : dba->Vertices(false)) { if (vertex.CypherId() == cypher_id) - return std::experimental::optional(vertex); + return std::optional(vertex); } - return std::experimental::nullopt; + return std::nullopt; } /** * Find edge with a given cypher_id within a given database. */ - std::experimental::optional FindEdge( - database::GraphDbAccessor *dba, int64_t cypher_id) { + std::optional FindEdge(database::GraphDbAccessor *dba, + int64_t cypher_id) { for (auto &edge : dba->Edges(false)) { if (edge.CypherId() == cypher_id) - return std::experimental::optional(edge); + return std::optional(edge); } - return std::experimental::nullopt; + return std::nullopt; } }; diff --git a/tests/unit/distributed_durability.cpp b/tests/unit/distributed_durability.cpp index b148bf919..c1018560b 100644 --- a/tests/unit/distributed_durability.cpp +++ b/tests/unit/distributed_durability.cpp @@ -1,4 +1,4 @@ -#include +#include #include "distributed_common.hpp" diff --git a/tests/unit/distributed_dynamic_worker.cpp b/tests/unit/distributed_dynamic_worker.cpp index 544452ee0..ddfbd3966 100644 --- a/tests/unit/distributed_dynamic_worker.cpp +++ b/tests/unit/distributed_dynamic_worker.cpp @@ -8,7 +8,7 @@ #include "io/network/endpoint.hpp" #include "query_plan_common.hpp" -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; using namespace std::literals::chrono_literals; class DistributedDynamicWorker : public ::testing::Test { diff --git a/tests/unit/distributed_edges_iterator.cpp b/tests/unit/distributed_edges_iterator.cpp index 09c8d89e5..a4a4e4b45 100644 --- a/tests/unit/distributed_edges_iterator.cpp +++ b/tests/unit/distributed_edges_iterator.cpp @@ -2,8 +2,8 @@ #include #include -#include "storage/distributed/edges_iterator.hpp" #include "distributed_common.hpp" +#include "storage/distributed/edges_iterator.hpp" class EdgesIterableTest : public DistributedGraphDbTest { public: @@ -39,39 +39,39 @@ class EdgesIterableTest : public DistributedGraphDbTest { } // master - std::experimental::optional v; + std::optional v; // worker 1 vertices - std::experimental::optional w1_v1_out; - std::experimental::optional w1_v2_out; - std::experimental::optional w1_v3_out; - std::experimental::optional w1_v1_in; - std::experimental::optional w1_v2_in; - std::experimental::optional w1_v3_in; + std::optional w1_v1_out; + std::optional w1_v2_out; + std::optional w1_v3_out; + std::optional w1_v1_in; + std::optional w1_v2_in; + std::optional w1_v3_in; // worker 1 edges - std::experimental::optional w1_e1_out; - std::experimental::optional w1_e2_out; - std::experimental::optional w1_e3_out; - std::experimental::optional w1_e1_in; - std::experimental::optional w1_e2_in; - std::experimental::optional w1_e3_in; + std::optional w1_e1_out; + std::optional w1_e2_out; + std::optional w1_e3_out; + std::optional w1_e1_in; + std::optional w1_e2_in; + std::optional w1_e3_in; // worker 2 vertices - std::experimental::optional w2_v1_out; - std::experimental::optional w2_v2_out; - std::experimental::optional w2_v3_out; - std::experimental::optional w2_v1_in; - std::experimental::optional w2_v2_in; - std::experimental::optional w2_v3_in; + std::optional w2_v1_out; + std::optional w2_v2_out; + std::optional w2_v3_out; + std::optional w2_v1_in; + std::optional w2_v2_in; + std::optional w2_v3_in; // worker 2 edges - std::experimental::optional w2_e1_out; - std::experimental::optional w2_e2_out; - std::experimental::optional w2_e3_out; - std::experimental::optional w2_e1_in; - std::experimental::optional w2_e2_in; - std::experimental::optional w2_e3_in; + std::optional w2_e1_out; + std::optional w2_e2_out; + std::optional w2_e3_out; + std::optional w2_e1_in; + std::optional w2_e2_in; + std::optional w2_e3_in; // types std::string type1{"type1"}; diff --git a/tests/unit/distributed_interpretation.cpp b/tests/unit/distributed_interpretation.cpp index f47fe871e..dd6ec333a 100644 --- a/tests/unit/distributed_interpretation.cpp +++ b/tests/unit/distributed_interpretation.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -33,7 +33,7 @@ class DistributedInterpretationTest : public DistributedGraphDbTest { } void TearDown() override { - interpreter_ = std::experimental::nullopt; + interpreter_ = std::nullopt; DistributedGraphDbTest::TearDown(); } @@ -55,7 +55,7 @@ class DistributedInterpretationTest : public DistributedGraphDbTest { } private: - std::experimental::optional interpreter_; + std::optional interpreter_; }; TEST_F(DistributedInterpretationTest, PullTest) { diff --git a/tests/unit/distributed_query_plan.cpp b/tests/unit/distributed_query_plan.cpp index 86e89e405..f8fd18137 100644 --- a/tests/unit/distributed_query_plan.cpp +++ b/tests/unit/distributed_query_plan.cpp @@ -715,10 +715,10 @@ class Planner { PlanningContext context) : plan_(MakeLogicalPlanForSingleQuery( single_query_parts, &context)) { - query::Parameters parameters; - PostProcessor post_processor(parameters); - plan_ = post_processor.Rewrite(std::move(plan_), &context); - } + query::Parameters parameters; + PostProcessor post_processor(parameters); + plan_ = post_processor.Rewrite(std::move(plan_), &context); + } auto &plan() { return *plan_; } @@ -1873,16 +1873,15 @@ TEST(TestPlanner, DistributedCartesianIndexedScanByLowerWithBothBounds) { auto left_cart = MakeCheckers(ExpectScanAll(), ExpectPullRemote({sym_a})); // We still expect indexed lookup by label property range above lower bound, // because upper bound depends on Cartesian branch. - auto right_cart = - MakeCheckers(ExpectScanAllByLabelPropertyRange( - label, prop, lower_bound, std::experimental::nullopt), - ExpectPullRemote({sym_b})); + auto right_cart = MakeCheckers( + ExpectScanAllByLabelPropertyRange(label, prop, lower_bound, std::nullopt), + ExpectPullRemote({sym_b})); auto expected = ExpectDistributed( MakeCheckers(ExpectDistributedCartesian(left_cart, right_cart), ExpectFilter(), ExpectProduce()), MakeCheckers(ExpectScanAll()), - MakeCheckers(ExpectScanAllByLabelPropertyRange( - label, prop, lower_bound, std::experimental::nullopt))); + MakeCheckers(ExpectScanAllByLabelPropertyRange(label, prop, lower_bound, + std::nullopt))); std::vector properties_by_ix; for (const auto &prop : storage.properties_) { properties_by_ix.push_back(dba.Property(prop)); @@ -1918,16 +1917,15 @@ TEST(TestPlanner, DistributedCartesianIndexedScanByUpperWithBothBounds) { auto left_cart = MakeCheckers(ExpectScanAll(), ExpectPullRemote({sym_a})); // We still expect indexed lookup by label property range below upper bound, // because lower bound depends on Cartesian branch. - auto right_cart = - MakeCheckers(ExpectScanAllByLabelPropertyRange( - label, prop, std::experimental::nullopt, upper_bound), - ExpectPullRemote({sym_b})); + auto right_cart = MakeCheckers( + ExpectScanAllByLabelPropertyRange(label, prop, std::nullopt, upper_bound), + ExpectPullRemote({sym_b})); auto expected = ExpectDistributed( MakeCheckers(ExpectDistributedCartesian(left_cart, right_cart), ExpectFilter(), ExpectProduce()), MakeCheckers(ExpectScanAll()), - MakeCheckers(ExpectScanAllByLabelPropertyRange( - label, prop, std::experimental::nullopt, upper_bound))); + MakeCheckers(ExpectScanAllByLabelPropertyRange(label, prop, std::nullopt, + upper_bound))); std::vector properties_by_ix; for (const auto &prop : storage.properties_) { properties_by_ix.push_back(dba.Property(prop)); diff --git a/tests/unit/distributed_updates.cpp b/tests/unit/distributed_updates.cpp index 5fed1f1fc..f34ee50d7 100644 --- a/tests/unit/distributed_updates.cpp +++ b/tests/unit/distributed_updates.cpp @@ -77,8 +77,8 @@ TEST_F(DistributedGraphDbSimpleUpdatesTest, CreateVertex) { gid::Gid gid; { auto dba = worker(1).Access(); - auto v = database::InsertVertexIntoRemote(dba.get(), 2, {}, {}, - std::experimental::nullopt); + auto v = + database::InsertVertexIntoRemote(dba.get(), 2, {}, {}, std::nullopt); gid = v.gid(); dba->Commit(); } @@ -94,8 +94,8 @@ TEST_F(DistributedGraphDbSimpleUpdatesTest, CreateVertexWithUpdate) { storage::Property prop; { auto dba = worker(1).Access(); - auto v = database::InsertVertexIntoRemote(dba.get(), 2, {}, {}, - std::experimental::nullopt); + auto v = + database::InsertVertexIntoRemote(dba.get(), 2, {}, {}, std::nullopt); gid = v.gid(); prop = dba->Property("prop"); v.PropsSet(prop, 42); @@ -120,8 +120,8 @@ TEST_F(DistributedGraphDbSimpleUpdatesTest, CreateVertexWithData) { l1 = dba->Label("l1"); l2 = dba->Label("l2"); prop = dba->Property("prop"); - auto v = database::InsertVertexIntoRemote( - dba.get(), 2, {l1, l2}, {{prop, 42}}, std::experimental::nullopt); + auto v = database::InsertVertexIntoRemote(dba.get(), 2, {l1, l2}, + {{prop, 42}}, std::nullopt); gid = v.gid(); // Check local visibility before commit. diff --git a/tests/unit/durability.cpp b/tests/unit/durability.cpp index 3003508c4..21c38500c 100644 --- a/tests/unit/durability.cpp +++ b/tests/unit/durability.cpp @@ -1,6 +1,6 @@ -#include -#include +#include #include +#include #include #include #include @@ -33,7 +33,7 @@ DECLARE_string(durability_directory); using namespace std::literals::chrono_literals; -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; // Helper class for performing random CRUD ops on a database. class DbGenerator { @@ -1083,7 +1083,7 @@ TEST_F(Durability, ExistenceConstraintRecoverySnapshotAndWal) { gen.InsertVertex(); gen.InsertVertex(); auto l1 = dba.Label("l1"); - std::vector p1{dba.Property("p1"), dba.Property("p2")}; + std::vector p1{dba.Property("p1"), dba.Property("p2")}; dba.BuildExistenceConstraint(l1, p1); gen.InsertEdge(); auto l2 = dba.Label("l2"); diff --git a/tests/unit/edges_distributed.cpp b/tests/unit/edges_distributed.cpp index eea504270..e77b919fa 100644 --- a/tests/unit/edges_distributed.cpp +++ b/tests/unit/edges_distributed.cpp @@ -71,17 +71,16 @@ TEST(Edges, Filtering) { edges.emplace(va3, ea6, t2); edge_gid++; - auto edge_addresses = - [edges](std::experimental::optional dest, - std::vector *edge_types) { - std::vector ret; - for (auto it = edges.begin(dest, edge_types); it != edges.end(); ++it) - ret.push_back(it->edge); - return ret; - }; + auto edge_addresses = [edges](std::optional dest, + std::vector *edge_types) { + std::vector ret; + for (auto it = edges.begin(dest, edge_types); it != edges.end(); ++it) + ret.push_back(it->edge); + return ret; + }; { // no filtering - EXPECT_THAT(edge_addresses(std::experimental::nullopt, nullptr), + EXPECT_THAT(edge_addresses(std::nullopt, nullptr), ::testing::UnorderedElementsAre(ea1, ea2, ea3, ea4, ea5, ea6)); } { @@ -100,11 +99,11 @@ TEST(Edges, Filtering) { std::vector f2{t2}; std::vector f3{t1, t2}; - EXPECT_THAT(edge_addresses(std::experimental::nullopt, &f1), + EXPECT_THAT(edge_addresses(std::nullopt, &f1), ::testing::UnorderedElementsAre(ea1, ea3, ea5)); - EXPECT_THAT(edge_addresses(std::experimental::nullopt, &f2), + EXPECT_THAT(edge_addresses(std::nullopt, &f2), ::testing::UnorderedElementsAre(ea2, ea4, ea6)); - EXPECT_THAT(edge_addresses(std::experimental::nullopt, &f3), + EXPECT_THAT(edge_addresses(std::nullopt, &f3), ::testing::UnorderedElementsAre(ea1, ea2, ea3, ea4, ea5, ea6)); } diff --git a/tests/unit/graph_db_accessor.cpp b/tests/unit/graph_db_accessor.cpp index ccd686cb3..00c9001c0 100644 --- a/tests/unit/graph_db_accessor.cpp +++ b/tests/unit/graph_db_accessor.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -379,8 +379,8 @@ TEST(GraphDbAccessorTest, Transfer) { // make dba2 that has dba1 in it's snapshot, so data isn't visible auto dba2 = db.Access(); - EXPECT_EQ(dba2.Transfer(v1), std::experimental::nullopt); - EXPECT_EQ(dba2.Transfer(e12), std::experimental::nullopt); + EXPECT_EQ(dba2.Transfer(v1), std::nullopt); + EXPECT_EQ(dba2.Transfer(e12), std::nullopt); // make dba3 that does not have dba1 in it's snapshot dba1.Commit(); diff --git a/tests/unit/graph_db_accessor_index_api.cpp b/tests/unit/graph_db_accessor_index_api.cpp index 1d1733554..7ef90d05e 100644 --- a/tests/unit/graph_db_accessor_index_api.cpp +++ b/tests/unit/graph_db_accessor_index_api.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include @@ -205,18 +205,16 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueCount) { // helper functions auto Inclusive = [](int64_t value) { - return std::experimental::make_optional( - utils::MakeBoundInclusive(PropertyValue(value))); + return std::make_optional(utils::MakeBoundInclusive(PropertyValue(value))); }; auto Exclusive = [](int64_t value) { - return std::experimental::make_optional( - utils::MakeBoundExclusive(PropertyValue(value))); + return std::make_optional(utils::MakeBoundExclusive(PropertyValue(value))); }; auto VerticesCount = [this](auto lower, auto upper) { return dba.VerticesCount(label, property, lower, upper); }; - using std::experimental::nullopt; + using std::nullopt; ::testing::FLAGS_gtest_death_test_style = "threadsafe"; EXPECT_DEATH(VerticesCount(nullopt, nullopt), "bound must be provided"); EXPECT_WITH_MARGIN(VerticesCount(nullopt, Exclusive(4)), 40); @@ -382,25 +380,23 @@ class GraphDbAccessorIndexRange : public GraphDbAccessorIndex { ASSERT_EQ(Count(dba.Vertices(false)), 100); } - auto Vertices(std::experimental::optional> lower, - std::experimental::optional> upper, + auto Vertices(std::optional> lower, + std::optional> upper, bool current_state = false) { return dba.Vertices(label, property, lower, upper, current_state); } auto Inclusive(PropertyValue value) { - return std::experimental::make_optional( - utils::MakeBoundInclusive(PropertyValue(value))); + return std::make_optional(utils::MakeBoundInclusive(PropertyValue(value))); } auto Exclusive(int value) { - return std::experimental::make_optional( - utils::MakeBoundExclusive(PropertyValue(value))); + return std::make_optional(utils::MakeBoundExclusive(PropertyValue(value))); } }; TEST_F(GraphDbAccessorIndexRange, RangeIteration) { - using std::experimental::nullopt; + using std::nullopt; EXPECT_EQ(Count(Vertices(nullopt, Inclusive(7))), 80); EXPECT_EQ(Count(Vertices(nullopt, Exclusive(7))), 70); EXPECT_EQ(Count(Vertices(Inclusive(7), nullopt)), 30); @@ -413,7 +409,7 @@ TEST_F(GraphDbAccessorIndexRange, RangeIteration) { } TEST_F(GraphDbAccessorIndexRange, RangeIterationCurrentState) { - using std::experimental::nullopt; + using std::nullopt; EXPECT_EQ(Count(Vertices(nullopt, Inclusive(7))), 80); for (int i = 0; i < 20; i++) AddVertex(2); EXPECT_EQ(Count(Vertices(nullopt, Inclusive(7))), 80); @@ -423,7 +419,7 @@ TEST_F(GraphDbAccessorIndexRange, RangeIterationCurrentState) { } TEST_F(GraphDbAccessorIndexRange, RangeInterationIncompatibleTypes) { - using std::experimental::nullopt; + using std::nullopt; // using PropertyValue::Null as a bound fails with an assertion ::testing::FLAGS_gtest_death_test_style = "threadsafe"; diff --git a/tests/unit/kvstore.cpp b/tests/unit/kvstore.cpp index 05a6207eb..f78f8b037 100644 --- a/tests/unit/kvstore.cpp +++ b/tests/unit/kvstore.cpp @@ -6,7 +6,7 @@ #include "storage/common/kvstore/kvstore.hpp" #include "utils/file.hpp" -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; class KVStore : public ::testing::Test { protected: @@ -52,11 +52,13 @@ TEST_F(KVStore, PutMultipleGetDeleteMultipleGet) { } TEST_F(KVStore, PutMultipleGetPutAndDeleteMultipleGet) { - storage::KVStore kvstore(test_folder_ / "PutMultipleGetPutAndDeleteMultipleGet"); + storage::KVStore kvstore(test_folder_ / + "PutMultipleGetPutAndDeleteMultipleGet"); ASSERT_TRUE(kvstore.PutMultiple({{"key1", "value1"}, {"key2", "value2"}})); ASSERT_EQ(kvstore.Get("key1").value(), "value1"); ASSERT_EQ(kvstore.Get("key2").value(), "value2"); - ASSERT_TRUE(kvstore.PutAndDeleteMultiple({{"key3", "value3"}}, {"key1", "key2"})); + ASSERT_TRUE( + kvstore.PutAndDeleteMultiple({{"key3", "value3"}}, {"key1", "key2"})); ASSERT_FALSE(static_cast(kvstore.Get("key1"))); ASSERT_FALSE(static_cast(kvstore.Get("key2"))); ASSERT_EQ(kvstore.Get("key3").value(), "value3"); diff --git a/tests/unit/metrics.cpp b/tests/unit/metrics.cpp index 25fd15a7f..82c7e2f98 100644 --- a/tests/unit/metrics.cpp +++ b/tests/unit/metrics.cpp @@ -43,28 +43,28 @@ TEST(Metrics, Gauge) { TEST(Metrics, IntervalMin) { IntervalMin &x = GetIntervalMin("min"); - EXPECT_EQ(x.Flush(), std::experimental::nullopt); + EXPECT_EQ(x.Flush(), std::nullopt); x.Add(5); x.Add(3); EXPECT_EQ(*x.Flush(), 3); - EXPECT_EQ(x.Flush(), std::experimental::nullopt); + EXPECT_EQ(x.Flush(), std::nullopt); x.Add(3); x.Add(5); EXPECT_EQ(*x.Flush(), 3); - EXPECT_EQ(x.Flush(), std::experimental::nullopt); + EXPECT_EQ(x.Flush(), std::nullopt); } TEST(Metrics, IntervalMax) { IntervalMax &x = GetIntervalMax("max"); - EXPECT_EQ(x.Flush(), std::experimental::nullopt); + EXPECT_EQ(x.Flush(), std::nullopt); x.Add(5); x.Add(3); EXPECT_EQ(*x.Flush(), 5); - EXPECT_EQ(x.Flush(), std::experimental::nullopt); + EXPECT_EQ(x.Flush(), std::nullopt); x.Add(3); x.Add(5); EXPECT_EQ(*x.Flush(), 5); - EXPECT_EQ(x.Flush(), std::experimental::nullopt); + EXPECT_EQ(x.Flush(), std::nullopt); } TEST(Metrics, Stopwatch) { diff --git a/tests/unit/plan_pretty_print.cpp b/tests/unit/plan_pretty_print.cpp index 7eb3287f7..893e1d75e 100644 --- a/tests/unit/plan_pretty_print.cpp +++ b/tests/unit/plan_pretty_print.cpp @@ -108,7 +108,7 @@ TEST_F(PrintToJsonTest, ScanAllByLabelPropertyRange) { std::shared_ptr last_op; last_op = std::make_shared( nullptr, GetSymbol("node"), dba.Label("Label"), dba.Property("prop"), - "prop", std::experimental::nullopt, + "prop", std::nullopt, utils::MakeBoundExclusive(LITERAL(20))); Check(last_op.get(), R"( @@ -130,7 +130,7 @@ TEST_F(PrintToJsonTest, ScanAllByLabelPropertyRange) { last_op = std::make_shared( nullptr, GetSymbol("node"), dba.Label("Label"), dba.Property("prop"), "prop", utils::MakeBoundInclusive(LITERAL(1)), - std::experimental::nullopt); + std::nullopt); Check(last_op.get(), R"( { @@ -273,7 +273,7 @@ TEST_F(PrintToJsonTest, ExpandVariable) { false, LITERAL(2), LITERAL(5), false, ExpansionLambda{GetSymbol("inner_node"), GetSymbol("inner_edge"), PROPERTY_LOOKUP("inner_node", dba.Property("unblocked"))}, - std::experimental::nullopt, std::experimental::nullopt); + std::nullopt, std::nullopt); Check(last_op.get(), R"sep( { diff --git a/tests/unit/property_value_store.cpp b/tests/unit/property_value_store.cpp index 191cdd9bf..8a680b4a8 100644 --- a/tests/unit/property_value_store.cpp +++ b/tests/unit/property_value_store.cpp @@ -10,7 +10,7 @@ using Location = storage::Location; -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; DECLARE_string(durability_directory); DECLARE_string(properties_on_disk); @@ -250,8 +250,9 @@ TEST_F(PropertyValueStoreTest, InsertRetrieveListMemory) { } TEST_F(PropertyValueStoreTest, InsertRetrieveListDisk) { - Set(0, Location::Disk, std::vector{1, true, 2.5, "something", - PropertyValue::Null}); + Set(0, Location::Disk, + std::vector{1, true, 2.5, "something", + PropertyValue::Null}); auto p = At(0, Location::Disk); EXPECT_EQ(p.type(), PropertyValue::Type::List); diff --git a/tests/unit/query_common.hpp b/tests/unit/query_common.hpp index 917b44c2b..1bc8d3015 100644 --- a/tests/unit/query_common.hpp +++ b/tests/unit/query_common.hpp @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -222,8 +221,7 @@ auto GetEdgeVariable(AstStorage &storage, const std::string &name, /// /// Name is used to create the Identifier which is assigned to the node. auto GetNode(AstStorage &storage, const std::string &name, - std::experimental::optional label = - std::experimental::nullopt) { + std::optional label = std::nullopt) { auto node = storage.Create(storage.Create(name)); if (label) node->labels_.emplace_back(storage.GetLabelIx(*label)); return node; diff --git a/tests/unit/query_cost_estimator.cpp b/tests/unit/query_cost_estimator.cpp index 20acb2446..71f8635f5 100644 --- a/tests/unit/query_cost_estimator.cpp +++ b/tests/unit/query_cost_estimator.cpp @@ -84,11 +84,10 @@ class QueryCostEstimator : public ::testing::Test { } auto InclusiveBound(Expression *expression) { - return std::experimental::make_optional( - utils::MakeBoundInclusive(expression)); + return std::make_optional(utils::MakeBoundInclusive(expression)); }; - const std::experimental::nullopt_t nullopt = std::experimental::nullopt; + const std::nullopt_t nullopt = std::nullopt; }; // multiply with 1 to avoid linker error (possibly fixed in CLang >= 3.81) @@ -151,12 +150,11 @@ TEST_F(QueryCostEstimator, ScanAllByLabelPropertyRangeLowerConstant) { } } - TEST_F(QueryCostEstimator, ScanAllByLabelPropertyRangeConstExpr) { AddVertices(100, 30, 20); for (auto const_val : {Literal(12), Parameter(12)}) { - auto bound = std::experimental::make_optional( - utils::MakeBoundInclusive(static_cast( + auto bound = + std::make_optional(utils::MakeBoundInclusive(static_cast( storage_.Create(const_val)))); MakeOp(nullptr, NextSymbol(), label, property, "property", bound, nullopt); @@ -173,12 +171,12 @@ TEST_F(QueryCostEstimator, Expand) { } TEST_F(QueryCostEstimator, ExpandVariable) { - MakeOp( - last_op_, NextSymbol(), NextSymbol(), NextSymbol(), - EdgeAtom::Type::DEPTH_FIRST, EdgeAtom::Direction::IN, - std::vector{}, false, nullptr, nullptr, false, - ExpansionLambda{NextSymbol(), NextSymbol(), nullptr}, - std::experimental::nullopt, std::experimental::nullopt); + MakeOp(last_op_, NextSymbol(), NextSymbol(), NextSymbol(), + EdgeAtom::Type::DEPTH_FIRST, EdgeAtom::Direction::IN, + std::vector{}, false, nullptr, + nullptr, false, + ExpansionLambda{NextSymbol(), NextSymbol(), nullptr}, + std::nullopt, std::nullopt); EXPECT_COST(CardParam::kExpandVariable * CostParam::kExpandVariable); } diff --git a/tests/unit/query_plan.cpp b/tests/unit/query_plan.cpp index 5405a4316..819e254cb 100644 --- a/tests/unit/query_plan.cpp +++ b/tests/unit/query_plan.cpp @@ -1087,7 +1087,7 @@ TYPED_TEST(TestPlanner, WhereIndexedLabelPropertyRange) { std::make_pair(GREATER(lit_42, n_prop), Bound::Type::EXCLUSIVE), std::make_pair(GREATER_EQ(lit_42, n_prop), Bound::Type::INCLUSIVE)}; for (const auto &rel_op : upper_bound_rel_op) { - check_planned_range(rel_op.first, std::experimental::nullopt, + check_planned_range(rel_op.first, std::nullopt, Bound(lit_42, rel_op.second)); } } @@ -1100,7 +1100,7 @@ TYPED_TEST(TestPlanner, WhereIndexedLabelPropertyRange) { std::make_pair(GREATER_EQ(n_prop, lit_42), Bound::Type::INCLUSIVE)}; for (const auto &rel_op : lower_bound_rel_op) { check_planned_range(rel_op.first, Bound(lit_42, rel_op.second), - std::experimental::nullopt); + std::nullopt); } } } @@ -1388,10 +1388,10 @@ TYPED_TEST(TestPlanner, FilterRegexMatchIndex) { Bound lower_bound(LITERAL(""), Bound::Type::INCLUSIVE); auto symbol_table = query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); - CheckPlan(planner.plan(), symbol_table, - ExpectScanAllByLabelPropertyRange(label, prop, lower_bound, - std::experimental::nullopt), - ExpectFilter(), ExpectProduce()); + CheckPlan( + planner.plan(), symbol_table, + ExpectScanAllByLabelPropertyRange(label, prop, lower_bound, std::nullopt), + ExpectFilter(), ExpectProduce()); } TYPED_TEST(TestPlanner, FilterRegexMatchPreferEqualityIndex) { @@ -1464,10 +1464,10 @@ TYPED_TEST(TestPlanner, FilterRegexMatchPreferRangeIndex) { Bound lower_bound(lit_42, Bound::Type::EXCLUSIVE); auto symbol_table = query::MakeSymbolTable(query); auto planner = MakePlanner(&dba, storage, symbol_table, query); - CheckPlan(planner.plan(), symbol_table, - ExpectScanAllByLabelPropertyRange(label, prop, lower_bound, - std::experimental::nullopt), - ExpectFilter(), ExpectProduce()); + CheckPlan( + planner.plan(), symbol_table, + ExpectScanAllByLabelPropertyRange(label, prop, lower_bound, std::nullopt), + ExpectFilter(), ExpectProduce()); } } // namespace diff --git a/tests/unit/query_plan_checker.hpp b/tests/unit/query_plan_checker.hpp index df3a450ce..7977e79a6 100644 --- a/tests/unit/query_plan_checker.hpp +++ b/tests/unit/query_plan_checker.hpp @@ -271,10 +271,8 @@ class ExpectScanAllByLabelPropertyRange public: ExpectScanAllByLabelPropertyRange( storage::Label label, storage::Property property, - std::experimental::optional - lower_bound, - std::experimental::optional - upper_bound) + std::optional lower_bound, + std::optional upper_bound) : label_(label), property_(property), lower_bound_(lower_bound), @@ -303,8 +301,8 @@ class ExpectScanAllByLabelPropertyRange private: storage::Label label_; storage::Property property_; - std::experimental::optional lower_bound_; - std::experimental::optional upper_bound_; + std::optional lower_bound_; + std::optional upper_bound_; }; class ExpectCartesian : public OpChecker { diff --git a/tests/unit/query_plan_common.hpp b/tests/unit/query_plan_common.hpp index 4a096e15e..abb9eab8d 100644 --- a/tests/unit/query_plan_common.hpp +++ b/tests/unit/query_plan_common.hpp @@ -119,9 +119,8 @@ ScanAllTuple MakeScanAllByLabel( ScanAllTuple MakeScanAllByLabelPropertyRange( AstStorage &storage, SymbolTable &symbol_table, std::string identifier, storage::Label label, storage::Property property, - const std::string &property_name, - std::experimental::optional lower_bound, - std::experimental::optional upper_bound, + const std::string &property_name, std::optional lower_bound, + std::optional upper_bound, std::shared_ptr input = {nullptr}, GraphView graph_view = GraphView::OLD) { auto node = NODE(identifier); diff --git a/tests/unit/query_plan_edge_cases.cpp b/tests/unit/query_plan_edge_cases.cpp index c4b460102..84c9e8927 100644 --- a/tests/unit/query_plan_edge_cases.cpp +++ b/tests/unit/query_plan_edge_cases.cpp @@ -2,7 +2,7 @@ // that's not easily testable with single-phase testing. instead, for // easy testing and latter readability they are tested end-to-end. -#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -16,8 +16,8 @@ DECLARE_bool(query_cost_planner); class QueryExecution : public testing::Test { protected: - std::experimental::optional db_; - std::experimental::optional dba_; + std::optional db_; + std::optional dba_; void SetUp() { db_.emplace(); @@ -25,8 +25,8 @@ class QueryExecution : public testing::Test { } void TearDown() { - dba_ = std::experimental::nullopt; - db_ = std::experimental::nullopt; + dba_ = std::nullopt; + db_ = std::nullopt; } /** Commits the current transaction and refreshes the dba_ diff --git a/tests/unit/query_plan_match_filter_return.cpp b/tests/unit/query_plan_match_filter_return.cpp index da33f1fbe..2d845f213 100644 --- a/tests/unit/query_plan_match_filter_return.cpp +++ b/tests/unit/query_plan_match_filter_return.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include #include #include @@ -486,8 +486,8 @@ class QueryPlanExpandVariable : public testing::Test { AstStorage storage; SymbolTable symbol_table; - // using std::experimental::nullopt - std::experimental::nullopt_t nullopt = std::experimental::nullopt; + // using std::nullopt + std::nullopt_t nullopt = std::nullopt; void SetUp() { // create the graph @@ -533,8 +533,7 @@ class QueryPlanExpandVariable : public testing::Test { std::shared_ptr input_op, const std::string &node_from, int layer, EdgeAtom::Direction direction, const std::vector &edge_types, - std::experimental::optional lower, - std::experimental::optional upper, Symbol edge_sym, + std::optional lower, std::optional upper, Symbol edge_sym, const std::string &node_to, GraphView graph_view, bool is_reverse = false) { auto n_from = MakeScanAll(storage, symbol_table, node_from, input_op); @@ -550,7 +549,7 @@ class QueryPlanExpandVariable : public testing::Test { if (std::is_same::value) { // convert optional ints to optional expressions - auto convert = [this](std::experimental::optional bound) { + auto convert = [this](std::optional bound) { return bound ? LITERAL(static_cast(bound.value())) : nullptr; }; CHECK(graph_view == GraphView::OLD) @@ -563,7 +562,7 @@ class QueryPlanExpandVariable : public testing::Test { ExpansionLambda{symbol_table.CreateSymbol("inner_edge", false), symbol_table.CreateSymbol("inner_node", false), nullptr}, - std::experimental::nullopt, std::experimental::nullopt); + std::nullopt, std::nullopt); } else return std::make_shared(filter_op, n_from.sym_, n_to_sym, edge_sym, direction, edge_types, false, @@ -619,9 +618,8 @@ class QueryPlanExpandVariable : public testing::Test { TEST_F(QueryPlanExpandVariable, OneVariableExpansion) { auto test_expand = [&](int layer, EdgeAtom::Direction direction, - std::experimental::optional lower, - std::experimental::optional upper, - bool reverse) { + std::optional lower, + std::optional upper, bool reverse) { auto e = Edge("r", direction); return GetEdgeListSizes( AddMatch(nullptr, "n", layer, direction, {}, lower, @@ -677,8 +675,8 @@ TEST_F(QueryPlanExpandVariable, OneVariableExpansion) { TEST_F(QueryPlanExpandVariable, EdgeUniquenessSingleAndVariableExpansion) { auto test_expand = [&](int layer, EdgeAtom::Direction direction, - std::experimental::optional lower, - std::experimental::optional upper, + std::optional lower, + std::optional upper, bool single_expansion_before, bool add_uniqueness_check) { std::shared_ptr last_op{nullptr}; @@ -723,25 +721,24 @@ TEST_F(QueryPlanExpandVariable, EdgeUniquenessSingleAndVariableExpansion) { } TEST_F(QueryPlanExpandVariable, EdgeUniquenessTwoVariableExpansions) { - auto test_expand = [&](int layer, EdgeAtom::Direction direction, - std::experimental::optional lower, - std::experimental::optional upper, - bool add_uniqueness_check) { - auto e1 = Edge("r1", direction); - auto first = - AddMatch(nullptr, "n1", layer, direction, {}, lower, - upper, e1, "m1", GraphView::OLD); - auto e2 = Edge("r2", direction); - auto last_op = - AddMatch(first, "n2", layer, direction, {}, lower, - upper, e2, "m2", GraphView::OLD); - if (add_uniqueness_check) { - last_op = std::make_shared(last_op, e2, - std::vector{e1}); - } + auto test_expand = + [&](int layer, EdgeAtom::Direction direction, std::optional lower, + std::optional upper, bool add_uniqueness_check) { + auto e1 = Edge("r1", direction); + auto first = + AddMatch(nullptr, "n1", layer, direction, {}, lower, + upper, e1, "m1", GraphView::OLD); + auto e2 = Edge("r2", direction); + auto last_op = + AddMatch(first, "n2", layer, direction, {}, lower, + upper, e2, "m2", GraphView::OLD); + if (add_uniqueness_check) { + last_op = std::make_shared( + last_op, e2, std::vector{e1}); + } - return GetEdgeListSizes(last_op, e2); - }; + return GetEdgeListSizes(last_op, e2); + }; EXPECT_EQ(test_expand(0, EdgeAtom::Direction::OUT, 2, 2, false), (map_int{{2, 8 * 8}})); @@ -853,9 +850,8 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test { // params returns a vector of pairs. each pair is (vector-of-edges, // vertex) auto ExpandWShortest(EdgeAtom::Direction direction, - std::experimental::optional max_depth, - Expression *where, - std::experimental::optional node_id = 0, + std::optional max_depth, Expression *where, + std::optional node_id = 0, ScanAllTuple *existing_node_input = nullptr) { // scan the nodes optionally filtering on property value auto n = @@ -1019,25 +1015,24 @@ TEST_F(QueryPlanExpandWeightedShortestPath, Where) { } TEST_F(QueryPlanExpandWeightedShortestPath, ExistingNode) { - auto ExpandPreceeding = - [this](std::experimental::optional preceeding_node_id) { - // scan the nodes optionally filtering on property value - auto n0 = MakeScanAll(storage, symbol_table, "n0"); - if (preceeding_node_id) { - auto filter = std::make_shared( - n0.op_, EQ(PROPERTY_LOOKUP(n0.node_->identifier_, prop), - LITERAL(*preceeding_node_id))); - // inject the filter op into the ScanAllTuple. that way the filter - // op can be passed into the ExpandWShortest function without too - // much refactor - n0.op_ = filter; - } + auto ExpandPreceeding = [this](std::optional preceeding_node_id) { + // scan the nodes optionally filtering on property value + auto n0 = MakeScanAll(storage, symbol_table, "n0"); + if (preceeding_node_id) { + auto filter = std::make_shared( + n0.op_, EQ(PROPERTY_LOOKUP(n0.node_->identifier_, prop), + LITERAL(*preceeding_node_id))); + // inject the filter op into the ScanAllTuple. that way the filter + // op can be passed into the ExpandWShortest function without too + // much refactor + n0.op_ = filter; + } - return ExpandWShortest(EdgeAtom::Direction::OUT, 1000, LITERAL(true), - std::experimental::nullopt, &n0); - }; + return ExpandWShortest(EdgeAtom::Direction::OUT, 1000, LITERAL(true), + std::nullopt, &n0); + }; - EXPECT_EQ(ExpandPreceeding(std::experimental::nullopt).size(), 20); + EXPECT_EQ(ExpandPreceeding(std::nullopt).size(), 20); { auto results = ExpandPreceeding(3); ASSERT_EQ(results.size(), 4); @@ -1047,8 +1042,8 @@ TEST_F(QueryPlanExpandWeightedShortestPath, ExistingNode) { TEST_F(QueryPlanExpandWeightedShortestPath, UpperBound) { { - auto results = ExpandWShortest(EdgeAtom::Direction::BOTH, - std::experimental::nullopt, LITERAL(true)); + auto results = + ExpandWShortest(EdgeAtom::Direction::BOTH, std::nullopt, LITERAL(true)); ASSERT_EQ(results.size(), 4); EXPECT_EQ(GetProp(results[0].vertex), 2); EXPECT_EQ(results[0].total_weight, 3); @@ -1742,17 +1737,15 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeError) { // Lower bound isn't property value auto scan_index = MakeScanAllByLabelPropertyRange( storage, symbol_table, "n", label, prop, "prop", - Bound{ident_m, Bound::Type::INCLUSIVE}, std::experimental::nullopt, - scan_all.op_); + Bound{ident_m, Bound::Type::INCLUSIVE}, std::nullopt, scan_all.op_); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_THROW(PullAll(*scan_index.op_, &context), QueryRuntimeException); } { // Upper bound isn't property value auto scan_index = MakeScanAllByLabelPropertyRange( - storage, symbol_table, "n", label, prop, "prop", - std::experimental::nullopt, Bound{ident_m, Bound::Type::INCLUSIVE}, - scan_all.op_); + storage, symbol_table, "n", label, prop, "prop", std::nullopt, + Bound{ident_m, Bound::Type::INCLUSIVE}, scan_all.op_); auto context = MakeContext(storage, symbol_table, &dba); EXPECT_THROW(PullAll(*scan_index.op_, &context), QueryRuntimeException); } diff --git a/tests/unit/queue.cpp b/tests/unit/queue.cpp index 17091a044..e46148e3e 100644 --- a/tests/unit/queue.cpp +++ b/tests/unit/queue.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -18,7 +18,7 @@ TEST(Queue, PushMaybePop) { Queue q; q.Push(1); EXPECT_EQ(*q.MaybePop(), 1); - EXPECT_EQ(q.MaybePop(), std::experimental::nullopt); + EXPECT_EQ(q.MaybePop(), std::nullopt); q.Push(2); q.Push(3); @@ -29,7 +29,7 @@ TEST(Queue, PushMaybePop) { EXPECT_EQ(*q.MaybePop(), 3); EXPECT_EQ(*q.MaybePop(), 4); EXPECT_EQ(*q.MaybePop(), 5); - EXPECT_EQ(q.MaybePop(), std::experimental::nullopt); + EXPECT_EQ(q.MaybePop(), std::nullopt); } TEST(Queue, Emplace) { @@ -90,14 +90,14 @@ TEST(Queue, AwaitPop) { q.Shutdown(); }); std::this_thread::sleep_for(200ms); - EXPECT_EQ(q.AwaitPop(), std::experimental::nullopt); + EXPECT_EQ(q.AwaitPop(), std::nullopt); t2.join(); } TEST(Queue, AwaitPopTimeout) { std::this_thread::sleep_for(1000ms); Queue q; - EXPECT_EQ(q.AwaitPop(100ms), std::experimental::nullopt); + EXPECT_EQ(q.AwaitPop(100ms), std::nullopt); } TEST(Queue, Concurrent) { @@ -140,7 +140,7 @@ TEST(Queue, Concurrent) { t.join(); } - EXPECT_EQ(q.MaybePop(), std::experimental::nullopt); + EXPECT_EQ(q.MaybePop(), std::nullopt); std::set all_elements; for (auto &r : retrieved) { @@ -151,4 +151,4 @@ TEST(Queue, Concurrent) { EXPECT_EQ(*all_elements.rbegin(), kNumProducers * kNumElementsPerProducer - 1); } -} +} // namespace diff --git a/tests/unit/serialization.cpp b/tests/unit/serialization.cpp index 7d2420b14..1bceada24 100644 --- a/tests/unit/serialization.cpp +++ b/tests/unit/serialization.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "gtest/gtest.h" @@ -6,12 +6,12 @@ #include "capnp/message.h" #include "rpc/serialization.hpp" -using std::experimental::optional; +using std::optional; using std::string_literals::operator""s; -void CheckOptionalInt(const std::experimental::optional &x1) { +void CheckOptionalInt(const std::optional &x1) { ::capnp::MallocMessageBuilder message; - std::experimental::optional y1; + std::optional y1; { auto builder = message.initRoot>(); @@ -34,16 +34,15 @@ void CheckOptionalInt(const std::experimental::optional &x1) { } TEST(Serialization, CapnpOptional) { - std::experimental::optional x1 = {}; - std::experimental::optional x2 = 42; + std::optional x1 = {}; + std::optional x2 = 42; CheckOptionalInt(x1); CheckOptionalInt(x2); } TEST(Serialization, CapnpOptionalNonCopyable) { - std::experimental::optional> data = - std::make_unique(5); + std::optional> data = std::make_unique(5); ::capnp::MallocMessageBuilder message; { auto builder = message.initRoot, std::unique_ptr>(data, &builder, save); } - std::experimental::optional> element; + std::optional> element; { auto reader = message.getRoot>>(); diff --git a/tests/unit/skip_list.cpp b/tests/unit/skip_list.cpp index 915d6d5ff..f9f82cbbc 100644 --- a/tests/unit/skip_list.cpp +++ b/tests/unit/skip_list.cpp @@ -519,22 +519,20 @@ TEST(SkipList, EstimateCount) { } \ } -#define MAKE_RANGE_LOWER_INFINITY_TEST(upper_value, upper_type, blocks) \ - { \ - auto acc = list.access(); \ - uint64_t count = acc.estimate_range_count( \ - std::experimental::nullopt, \ - {{upper_value, utils::BoundType::upper_type}}, 1); \ - ASSERT_EQ(count, kElementMembers *blocks); \ +#define MAKE_RANGE_LOWER_INFINITY_TEST(upper_value, upper_type, blocks) \ + { \ + auto acc = list.access(); \ + uint64_t count = acc.estimate_range_count( \ + std::nullopt, {{upper_value, utils::BoundType::upper_type}}, 1); \ + ASSERT_EQ(count, kElementMembers *blocks); \ } -#define MAKE_RANGE_UPPER_INFINITY_TEST(lower_value, lower_type, blocks) \ - { \ - auto acc = list.access(); \ - uint64_t count = acc.estimate_range_count( \ - {{lower_value, utils::BoundType::lower_type}}, \ - std::experimental::nullopt, 1); \ - ASSERT_EQ(count, kElementMembers *blocks); \ +#define MAKE_RANGE_UPPER_INFINITY_TEST(lower_value, lower_type, blocks) \ + { \ + auto acc = list.access(); \ + uint64_t count = acc.estimate_range_count( \ + {{lower_value, utils::BoundType::lower_type}}, std::nullopt, 1); \ + ASSERT_EQ(count, kElementMembers *blocks); \ } TEST(SkipList, EstimateRangeCount) { @@ -564,7 +562,7 @@ TEST(SkipList, EstimateRangeCount) { utils::Timer timer; for (int64_t i = 0; i < kMaxElements; ++i) { uint64_t count = acc.estimate_range_count( - std::experimental::nullopt, {{i, utils::BoundType::INCLUSIVE}}); + std::nullopt, {{i, utils::BoundType::INCLUSIVE}}); uint64_t must_have = kElementMembers * (i + 1); uint64_t delta = count >= must_have ? count - must_have : must_have - count; @@ -604,8 +602,8 @@ TEST(SkipList, EstimateRangeCount) { { auto acc = list.access(); - uint64_t count = acc.estimate_range_count( - std::experimental::nullopt, std::experimental::nullopt, 1); + uint64_t count = + acc.estimate_range_count(std::nullopt, std::nullopt, 1); ASSERT_EQ(count, kMaxElements * kElementMembers); } } diff --git a/tests/unit/slk_core.cpp b/tests/unit/slk_core.cpp index 1f765acb0..73dd8807e 100644 --- a/tests/unit/slk_core.cpp +++ b/tests/unit/slk_core.cpp @@ -178,52 +178,52 @@ TEST(SlkCore, UniquePtrFull) { } TEST(SlkCore, OptionalPrimitiveEmpty) { - std::experimental::optional original; + std::optional original; slk::Builder builder; slk::Save(original, &builder); ASSERT_EQ(builder.size(), sizeof(bool)); - std::experimental::optional decoded = 5; - ASSERT_NE(decoded, std::experimental::nullopt); + std::optional decoded = 5; + ASSERT_NE(decoded, std::nullopt); slk::Reader reader(builder.data(), builder.size()); slk::Load(&decoded, &reader); - ASSERT_EQ(decoded, std::experimental::nullopt); + ASSERT_EQ(decoded, std::nullopt); } TEST(SlkCore, OptionalPrimitiveFull) { - std::experimental::optional original = 5; + std::optional original = 5; slk::Builder builder; slk::Save(original, &builder); ASSERT_EQ(builder.size(), sizeof(bool) + sizeof(int)); - std::experimental::optional decoded; - ASSERT_EQ(decoded, std::experimental::nullopt); + std::optional decoded; + ASSERT_EQ(decoded, std::nullopt); slk::Reader reader(builder.data(), builder.size()); slk::Load(&decoded, &reader); - ASSERT_NE(decoded, std::experimental::nullopt); + ASSERT_NE(decoded, std::nullopt); ASSERT_EQ(*original, *decoded); } TEST(SlkCore, OptionalStringEmpty) { - std::experimental::optional original; + std::optional original; slk::Builder builder; slk::Save(original, &builder); ASSERT_EQ(builder.size(), sizeof(bool)); - std::experimental::optional decoded = "nandare!"; - ASSERT_NE(decoded, std::experimental::nullopt); + std::optional decoded = "nandare!"; + ASSERT_NE(decoded, std::nullopt); slk::Reader reader(builder.data(), builder.size()); slk::Load(&decoded, &reader); - ASSERT_EQ(decoded, std::experimental::nullopt); + ASSERT_EQ(decoded, std::nullopt); } TEST(SlkCore, OptionalStringFull) { - std::experimental::optional original = "nandare!"; + std::optional original = "nandare!"; slk::Builder builder; slk::Save(original, &builder); ASSERT_EQ(builder.size(), sizeof(bool) + sizeof(uint64_t) + original->size()); - std::experimental::optional decoded; - ASSERT_EQ(decoded, std::experimental::nullopt); + std::optional decoded; + ASSERT_EQ(decoded, std::nullopt); slk::Reader reader(builder.data(), builder.size()); slk::Load(&decoded, &reader); - ASSERT_NE(decoded, std::experimental::nullopt); + ASSERT_NE(decoded, std::nullopt); ASSERT_EQ(*original, *decoded); } @@ -329,11 +329,10 @@ TEST(SlkCore, SharedPtrMultiple) { } TEST(SlkCore, Complex) { - std::unique_ptr>> - original = std::make_unique< - std::vector>>(); + std::unique_ptr>> original = + std::make_unique>>(); original.get()->push_back("nandare!"); - original.get()->push_back(std::experimental::nullopt); + original.get()->push_back(std::nullopt); original.get()->push_back("hai hai hai"); slk::Builder builder; @@ -348,8 +347,7 @@ TEST(SlkCore, Complex) { sizeof(bool) + sizeof(uint64_t) + (*original.get())[2]->size()); // clang-format on - std::unique_ptr>> - decoded; + std::unique_ptr>> decoded; ASSERT_EQ(decoded.get(), nullptr); slk::Reader reader(builder.data(), builder.size()); slk::Load(&decoded, &reader); @@ -359,7 +357,7 @@ TEST(SlkCore, Complex) { struct Foo { std::string name; - std::experimental::optional value; + std::optional value; }; bool operator==(const Foo &a, const Foo &b) { @@ -381,7 +379,7 @@ void Load(Foo *obj, Reader *reader) { TEST(SlkCore, VectorStruct) { std::vector original; original.push_back({"hai hai hai", 5}); - original.push_back({"nandare!", std::experimental::nullopt}); + original.push_back({"nandare!", std::nullopt}); slk::Builder builder; slk::Save(original, &builder); @@ -446,7 +444,7 @@ TEST(SlkCore, VectorSharedPtr) { } TEST(SlkCore, OptionalSharedPtr) { - std::experimental::optional> original = + std::optional> original = std::make_shared("nandare!"); std::vector saved; @@ -456,7 +454,7 @@ TEST(SlkCore, OptionalSharedPtr) { Save(item, builder, &saved); }); - std::experimental::optional> decoded; + std::optional> decoded; std::vector> loaded; slk::Reader reader(builder.data(), builder.size()); @@ -464,7 +462,7 @@ TEST(SlkCore, OptionalSharedPtr) { &decoded, &reader, [&loaded](auto *item, auto *reader) { Load(item, reader, &loaded); }); - ASSERT_NE(decoded, std::experimental::nullopt); + ASSERT_NE(decoded, std::nullopt); ASSERT_EQ(saved.size(), 1); ASSERT_EQ(loaded.size(), 1); diff --git a/tests/unit/small_vector.cpp b/tests/unit/small_vector.cpp index a75e1cb39..09ca47ad8 100644 --- a/tests/unit/small_vector.cpp +++ b/tests/unit/small_vector.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/tests/unit/transaction_engine_single_node.cpp b/tests/unit/transaction_engine_single_node.cpp index 09a4d72cb..acc222351 100644 --- a/tests/unit/transaction_engine_single_node.cpp +++ b/tests/unit/transaction_engine_single_node.cpp @@ -1,6 +1,6 @@ #include "gtest/gtest.h" -#include +#include #include #include @@ -56,7 +56,7 @@ TEST(Engine, ConcurrentBegin) { std::vector threads; SkipList tx_ids; for (int i = 0; i < 10; ++i) { - threads.emplace_back([&engine, accessor = tx_ids.access() ]() mutable { + threads.emplace_back([&engine, accessor = tx_ids.access()]() mutable { for (int j = 0; j < 100; ++j) { auto t = engine.Begin(); accessor.insert(t->id_); @@ -109,7 +109,7 @@ TEST(Engine, BlockingTransaction) { threads.emplace_back([&engine, &blocking_started, &blocking_finished]() { // This should block until other transactions end. blocking_started.store(true); - auto t = engine.BeginBlocking(std::experimental::nullopt); + auto t = engine.BeginBlocking(std::nullopt); engine.Commit(*t); blocking_finished.store(true); }); @@ -125,7 +125,7 @@ TEST(Engine, BlockingTransaction) { // Make sure we can't start any new transaction EXPECT_THROW(engine.Begin(), TransactionEngineError); - EXPECT_THROW(engine.BeginBlocking(std::experimental::nullopt), TransactionEngineError); + EXPECT_THROW(engine.BeginBlocking(std::nullopt), TransactionEngineError); // Release regular transactions. This will cause the blocking transaction to // end also. @@ -146,7 +146,7 @@ TEST(Engine, BlockingTransaction) { engine.Commit(*t); } { - auto t = engine.BeginBlocking(std::experimental::nullopt); + auto t = engine.BeginBlocking(std::nullopt); EXPECT_NE(t, nullptr); engine.Commit(*t); } diff --git a/tests/unit/utils_file.cpp b/tests/unit/utils_file.cpp index a32073a25..eabde9ee5 100644 --- a/tests/unit/utils_file.cpp +++ b/tests/unit/utils_file.cpp @@ -9,7 +9,7 @@ #include "utils/file.hpp" #include "utils/string.hpp" -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; const std::vector kDirsAll = { "existing_dir_777", "existing_dir_770", "existing_dir_700", @@ -114,8 +114,8 @@ class UtilsFileTest : public ::testing::Test { ASSERT_EQ(dir_status.permissions() & fs::perms::all, GetPermsFromFilename(dir)); } - fs::permissions(storage / dir, - fs::perms::add_perms | fs::perms::owner_all); + fs::permissions(storage / dir, fs::perms::owner_all, + fs::perm_options::add); } for (const auto &file : kFilesAll) { ASSERT_TRUE(fs::exists(storage / dir / file)); @@ -137,9 +137,8 @@ class UtilsFileTest : public ::testing::Test { if (fs::exists(storage)) { for (auto &file : fs::recursive_directory_iterator(storage)) { std::error_code error_code; // For exception suppression. - fs::permissions(file.path(), - fs::perms::add_perms | fs::perms::owner_all, - error_code); + fs::permissions(file.path(), fs::perms::owner_all, + fs::perm_options::add, error_code); } fs::remove_all(storage); } diff --git a/tools/src/mg_client/main.cpp b/tools/src/mg_client/main.cpp index 7895ebaea..7b7694588 100644 --- a/tools/src/mg_client/main.cpp +++ b/tools/src/mg_client/main.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -23,7 +23,7 @@ #include "utils/timer.hpp" #include "version.hpp" -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; volatile sig_atomic_t is_shutting_down = 0; @@ -246,14 +246,13 @@ static char **Completer(const char *text, int start, int end) { /// /// @param prompt The prompt to display. /// @return User input line, or nullopt on EOF. -static std::experimental::optional ReadLine( - const std::string &prompt) { +static std::optional ReadLine(const std::string &prompt) { if (default_text.size() > 0) { // Initialize text with remainder of previous query. rl_startup_hook = SetDefaultText; } char *line = readline(prompt.c_str()); - if (!line) return std::experimental::nullopt; + if (!line) return std::nullopt; std::string r_val(line); if (!utils::Trim(r_val).empty()) add_history(line); @@ -267,12 +266,11 @@ static std::experimental::optional ReadLine( /// using getline. /// @param prompt The prompt to display. /// @return User input line, or nullopt on EOF. -static std::experimental::optional ReadLine( - const std::string &prompt) { +static std::optional ReadLine(const std::string &prompt) { std::cout << prompt << default_text; std::string line; std::getline(std::cin, line); - if (std::cin.eof()) return std::experimental::nullopt; + if (std::cin.eof()) return std::nullopt; line = default_text + line; default_text = ""; return line; @@ -280,10 +278,10 @@ static std::experimental::optional ReadLine( #endif // HAS_READLINE -static std::experimental::optional GetLine() { +static std::optional GetLine() { std::string line; std::getline(std::cin, line); - if (std::cin.eof()) return std::experimental::nullopt; + if (std::cin.eof()) return std::nullopt; line = default_text + line; default_text = ""; return line; @@ -320,7 +318,7 @@ static std::pair ParseLine(const std::string &line, return std::make_pair(parsed_line.str(), is_done); } -static std::experimental::optional GetQuery() { +static std::optional GetQuery() { char quote = '\0'; bool escaped = false; auto ret = ParseLine(default_text, "e, &escaped); @@ -330,7 +328,7 @@ static std::experimental::optional GetQuery() { return ret.first; } std::stringstream query; - std::experimental::optional line; + std::optional line; int line_cnt = 0; auto is_done = false; while (!is_done) { @@ -341,7 +339,7 @@ static std::experimental::optional GetQuery() { if (line_cnt == 0 && line && line->size() > 0 && (*line)[0] == ':') { auto trimmed_line = utils::Trim(*line); if (trimmed_line == kCommandQuit) { - return std::experimental::nullopt; + return std::nullopt; } else if (trimmed_line == kCommandHelp) { PrintHelp(); return ""; @@ -352,7 +350,7 @@ static std::experimental::optional GetQuery() { } } } - if (!line) return std::experimental::nullopt; + if (!line) return std::nullopt; if (line->empty()) continue; auto ret = ParseLine(*line, "e, &escaped); query << ret.first; diff --git a/tools/src/mg_import_csv/main.cpp b/tools/src/mg_import_csv/main.cpp index 1f7212397..d5d915913 100644 --- a/tools/src/mg_import_csv/main.cpp +++ b/tools/src/mg_import_csv/main.cpp @@ -1,16 +1,16 @@ #include #include -#include -#include +#include #include +#include #include -#include #include #include +#include -#include "config.hpp" #include "communication/bolt/v1/encoder/base_encoder.hpp" +#include "config.hpp" #include "durability/hashed_file_writer.hpp" #include "durability/single_node/paths.hpp" #include "durability/single_node/snapshooter.hpp" @@ -145,9 +145,9 @@ struct hash { class MemgraphNodeIdMap { public: - std::experimental::optional Get(const NodeId &node_id) const { + std::optional Get(const NodeId &node_id) const { auto found_it = node_id_to_mg_.find(node_id); - if (found_it == node_id_to_mg_.end()) return std::experimental::nullopt; + if (found_it == node_id_to_mg_.end()) return std::nullopt; return found_it->second; } @@ -274,7 +274,7 @@ void WriteNodeRow( const std::vector &fields, const std::vector &row, const std::vector &additional_labels, MemgraphNodeIdMap &node_id_map) { - std::experimental::optional id; + std::optional id; std::vector labels; std::map properties; for (int i = 0; i < row.size(); ++i) { @@ -334,9 +334,9 @@ void WriteRelationshipsRow( communication::bolt::BaseEncoder *encoder, const std::vector &fields, const std::vector &row, const MemgraphNodeIdMap &node_id_map, gid::Gid relationship_id) { - std::experimental::optional start_id; - std::experimental::optional end_id; - std::experimental::optional relationship_type; + std::optional start_id; + std::optional end_id; + std::optional relationship_type; std::map properties; for (int i = 0; i < row.size(); ++i) { const auto &field = fields[i]; @@ -467,12 +467,12 @@ std::string GetOutputPath() { "provide the 'out' flag"; try { auto snapshot_dir = durability_dir + "/snapshots"; - if (!std::experimental::filesystem::exists(snapshot_dir) && - !std::experimental::filesystem::create_directories(snapshot_dir)) { + if (!std::filesystem::exists(snapshot_dir) && + !std::filesystem::create_directories(snapshot_dir)) { LOG(FATAL) << fmt::format("Cannot create snapshot directory '{}'", snapshot_dir); } - } catch (const std::experimental::filesystem::filesystem_error &error) { + } catch (const std::filesystem::filesystem_error &error) { LOG(FATAL) << error.what(); } // TODO: Remove this stupid hack which deletes WAL files just to make snapshot @@ -480,9 +480,9 @@ std::string GetOutputPath() { // detected in memgraph and correctly recovered (or error reported). try { auto wal_dir = durability_dir + "/wal"; - if (std::experimental::filesystem::exists(wal_dir)) { + if (std::filesystem::exists(wal_dir)) { for ([[gnu::unused]] const auto &wal_file : - std::experimental::filesystem::directory_iterator(wal_dir)) { + std::filesystem::directory_iterator(wal_dir)) { if (!FLAGS_overwrite) { LOG(FATAL) << "Durability directory isn't empty. Pass --overwrite to " "remove the old recovery data"; @@ -490,9 +490,9 @@ std::string GetOutputPath() { break; } LOG(WARNING) << "Removing old recovery data!"; - std::experimental::filesystem::remove_all(wal_dir); + std::filesystem::remove_all(wal_dir); } - } catch (const std::experimental::filesystem::filesystem_error &error) { + } catch (const std::filesystem::filesystem_error &error) { LOG(FATAL) << error.what(); } return std::string( @@ -507,7 +507,7 @@ int main(int argc, char *argv[]) { gflags::ParseCommandLineFlags(&argc, &argv, true); google::InitGoogleLogging(argv[0]); std::string output_path(GetOutputPath()); - if (std::experimental::filesystem::exists(output_path) && !FLAGS_overwrite) { + if (std::filesystem::exists(output_path) && !FLAGS_overwrite) { LOG(FATAL) << fmt::format( "File exists: '{}'. Pass --overwrite if you want to overwrite.", output_path); diff --git a/tools/tests/mg_recovery_check.cpp b/tools/tests/mg_recovery_check.cpp index 34ab418f8..26bedc406 100644 --- a/tools/tests/mg_recovery_check.cpp +++ b/tools/tests/mg_recovery_check.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -23,7 +23,7 @@ class RecoveryTest : public ::testing::Test { std::string durability_dir(FLAGS_durability_dir); durability::RecoveryData recovery_data; durability::RecoverOnlySnapshot(durability_dir, &db_, &recovery_data, - std::experimental::nullopt); + std::nullopt); durability::RecoveryTransactions recovery_transactions(&db_); durability::RecoverWal(durability_dir, &db_, &recovery_data, &recovery_transactions);