From caaab41108872e1f95723d69a65c3e92d54fe90f Mon Sep 17 00:00:00 2001 From: Dominik Gleich Date: Fri, 22 Dec 2017 13:33:15 +0100 Subject: [PATCH] Add new snapshot format support Reviewers: florijan Reviewed By: florijan Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1082 --- tests/manual/generate_snapshot.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/manual/generate_snapshot.cpp b/tests/manual/generate_snapshot.cpp index bfe384350..91ec26501 100644 --- a/tests/manual/generate_snapshot.cpp +++ b/tests/manual/generate_snapshot.cpp @@ -75,6 +75,10 @@ class Writer { durability::kMagicNumber.size()); encoder_.WriteTypedValue(durability::kVersion); + // ID of the vertex generator. + encoder_.WriteInt(0); + // ID of the edge generator. + encoder_.WriteInt(0); // Transactional ID of the snapshooter. encoder_.WriteInt(0); // Transactional Snapshot is an empty list of transaction IDs. @@ -93,7 +97,7 @@ class Writer { encoder_.WriteRAW(underlying_cast(communication::bolt::Marker::TinyStruct) + 3); encoder_.WriteRAW(underlying_cast(communication::bolt::Signature::Node)); - auto id = node_counter_++; + auto id = node_generator_.Next(std::experimental::nullopt); encoder_.WriteInt(id); encoder_.WriteList( std::vector{labels.begin(), labels.end()}); @@ -109,7 +113,7 @@ class Writer { 5); encoder_.WriteRAW( underlying_cast(communication::bolt::Signature::Relationship)); - auto id = edge_counter_++; + auto id = edge_generator_.Next(std::experimental::nullopt); encoder_.WriteInt(id); encoder_.WriteInt(bolt_id_from); encoder_.WriteInt(bolt_id_to); @@ -119,15 +123,15 @@ class Writer { } void Close() { - buffer_.WriteValue(node_counter_); - buffer_.WriteValue(edge_counter_); + buffer_.WriteValue(node_generator_.LocalCount()); + buffer_.WriteValue(edge_generator_.LocalCount()); buffer_.WriteValue(buffer_.hash()); buffer_.Close(); } private: - int64_t node_counter_{0}; - int64_t edge_counter_{0}; + gid::GidGenerator node_generator_{0}; + gid::GidGenerator edge_generator_{0}; HashedFileWriter buffer_; communication::bolt::BaseEncoder encoder_{buffer_}; };