Code improvements on disk storage (#1153)
* Improvements based on a code review --------- Co-authored-by: Aidar Samerkhanov <aidar.samerkhanov@memgraph.io>
This commit is contained in:
parent
030b554ffd
commit
4b3ba908c7
@ -20,6 +20,7 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
|
#include "storage/v2/config.hpp"
|
||||||
#include "storage/v2/edge_accessor.hpp"
|
#include "storage/v2/edge_accessor.hpp"
|
||||||
#include "storage/v2/inmemory/storage.hpp"
|
#include "storage/v2/inmemory/storage.hpp"
|
||||||
#include "utils/exceptions.hpp"
|
#include "utils/exceptions.hpp"
|
||||||
@ -700,13 +701,14 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<NodeId, memgraph::storage::Gid> node_id_map;
|
std::unordered_map<NodeId, memgraph::storage::Gid> node_id_map;
|
||||||
std::unique_ptr<memgraph::storage::Storage> store{new memgraph::storage::InMemoryStorage{{
|
auto store = std::make_unique<memgraph::storage::InMemoryStorage>(memgraph::storage::Config{
|
||||||
|
|
||||||
.items = {.properties_on_edges = FLAGS_storage_properties_on_edges},
|
.items = {.properties_on_edges = FLAGS_storage_properties_on_edges},
|
||||||
.durability = {.storage_directory = FLAGS_data_directory,
|
.durability = {.storage_directory = FLAGS_data_directory,
|
||||||
.recover_on_startup = false,
|
.recover_on_startup = false,
|
||||||
.snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::DISABLED,
|
.snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::DISABLED,
|
||||||
.snapshot_on_exit = true},
|
.snapshot_on_exit = true},
|
||||||
}}};
|
});
|
||||||
|
|
||||||
memgraph::utils::Timer load_timer;
|
memgraph::utils::Timer load_timer;
|
||||||
|
|
||||||
|
@ -221,8 +221,7 @@ class ReplQueryHandler final : public query::ReplicationQueryHandler {
|
|||||||
if (!mem_storage->SetMainReplicationRole()) {
|
if (!mem_storage->SetMainReplicationRole()) {
|
||||||
throw QueryRuntimeException("Couldn't set role to main!");
|
throw QueryRuntimeException("Couldn't set role to main!");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (replication_role == ReplicationQuery::ReplicationRole::REPLICA) {
|
|
||||||
if (!port || *port < 0 || *port > std::numeric_limits<uint16_t>::max()) {
|
if (!port || *port < 0 || *port > std::numeric_limits<uint16_t>::max()) {
|
||||||
throw QueryRuntimeException("Port number invalid!");
|
throw QueryRuntimeException("Port number invalid!");
|
||||||
}
|
}
|
||||||
@ -1382,7 +1381,7 @@ InterpreterContext::InterpreterContext(const storage::Config storage_config, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InterpreterContext::InterpreterContext(std::unique_ptr<storage::Storage> db, InterpreterConfig interpreter_config,
|
InterpreterContext::InterpreterContext(std::unique_ptr<storage::Storage> &&db, InterpreterConfig interpreter_config,
|
||||||
const std::filesystem::path &data_directory, query::AuthQueryHandler *ah,
|
const std::filesystem::path &data_directory, query::AuthQueryHandler *ah,
|
||||||
query::AuthChecker *ac)
|
query::AuthChecker *ac)
|
||||||
: db(std::move(db)),
|
: db(std::move(db)),
|
||||||
|
@ -245,7 +245,7 @@ struct InterpreterContext {
|
|||||||
const std::filesystem::path &data_directory, query::AuthQueryHandler *ah = nullptr,
|
const std::filesystem::path &data_directory, query::AuthQueryHandler *ah = nullptr,
|
||||||
query::AuthChecker *ac = nullptr);
|
query::AuthChecker *ac = nullptr);
|
||||||
|
|
||||||
InterpreterContext(std::unique_ptr<storage::Storage> db, InterpreterConfig interpreter_config,
|
InterpreterContext(std::unique_ptr<storage::Storage> &&db, InterpreterConfig interpreter_config,
|
||||||
const std::filesystem::path &data_directory, query::AuthQueryHandler *ah = nullptr,
|
const std::filesystem::path &data_directory, query::AuthQueryHandler *ah = nullptr,
|
||||||
query::AuthChecker *ac = nullptr);
|
query::AuthChecker *ac = nullptr);
|
||||||
|
|
||||||
|
@ -106,7 +106,9 @@ bool VertexHasLabel(const Vertex &vertex, LabelId label, Transaction *transactio
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Delta::Action::DELETE_DESERIALIZED_OBJECT:
|
case Delta::Action::DELETE_DESERIALIZED_OBJECT:
|
||||||
case Delta::Action::DELETE_OBJECT:
|
case Delta::Action::DELETE_OBJECT: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Delta::Action::RECREATE_OBJECT: {
|
case Delta::Action::RECREATE_OBJECT: {
|
||||||
deleted = false;
|
deleted = false;
|
||||||
break;
|
break;
|
||||||
@ -136,6 +138,7 @@ PropertyValue GetVertexProperty(const Vertex &vertex, PropertyId property, Trans
|
|||||||
}
|
}
|
||||||
case Delta::Action::DELETE_DESERIALIZED_OBJECT:
|
case Delta::Action::DELETE_DESERIALIZED_OBJECT:
|
||||||
case Delta::Action::DELETE_OBJECT:
|
case Delta::Action::DELETE_OBJECT:
|
||||||
|
break;
|
||||||
case Delta::Action::RECREATE_OBJECT: {
|
case Delta::Action::RECREATE_OBJECT: {
|
||||||
deleted = false;
|
deleted = false;
|
||||||
break;
|
break;
|
||||||
|
@ -221,6 +221,7 @@ class Storage {
|
|||||||
StorageMode GetStorageMode() const;
|
StorageMode GetStorageMode() const;
|
||||||
|
|
||||||
virtual void FreeMemory(std::unique_lock<utils::RWLock> main_guard) = 0;
|
virtual void FreeMemory(std::unique_lock<utils::RWLock> main_guard) = 0;
|
||||||
|
|
||||||
void FreeMemory() { FreeMemory({}); }
|
void FreeMemory() { FreeMemory({}); }
|
||||||
|
|
||||||
virtual std::unique_ptr<Accessor> Access(std::optional<IsolationLevel> override_isolation_level) = 0;
|
virtual std::unique_ptr<Accessor> Access(std::optional<IsolationLevel> override_isolation_level) = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user