6525451489
Summary: Start removing `is_remote` from `Address` Remove `GlobalAddress` Remove `GlobalizedAddress` Remove bitmasks from `Address` Remove `is_local` from `Address` Remove `is_local` from `RecordAccessor` Remove `worker_id` from `Address` Remove `worker_id` from `GidGenerator` Unfriend `IndexRpcServer` from `Storage` Remove `LocalizedAddressIfPossible` Make member private Remove `worker_id` from `Storage` Copy function to ease removal of distributed logic Remove `worker_id` from `WriteAheadLog` Remove `worker_id` from `GraphDb` Remove `worker_id` from durability Remove nonexistant function Remove `gid` from `Address` Remove usage of `Address` Remove `Address` Remove `VertexAddress` and `EdgeAddress` Fix Id test Remove `cypher_id` from `VersionList` Remove `cypher_id` from durability Remove `cypher_id` member from `VersionList` Remove `cypher_id` from database Fix recovery (revert D1142) Remove unnecessary functions from `GraphDbAccessor` Revert `InsertEdge` implementation to the way it was in/before D1142 Remove leftover `VertexAddress` from `Edge` Remove `PostCreateIndex` and `PopulateIndexFromBuildIndex` Split durability paths into single node and distributed Fix `TransactionIdFromWalFilename` implementation Fix tests Remove `cypher_id` from `snapshooter` and `durability` test Reviewers: msantl, teon.banek Reviewed By: msantl Subscribers: msantl, pullbot Differential Revision: https://phabricator.memgraph.io/D1647
106 lines
3.5 KiB
C++
106 lines
3.5 KiB
C++
#include <experimental/filesystem>
|
|
#include <iostream>
|
|
|
|
#include <gflags/gflags.h>
|
|
#include <glog/logging.h>
|
|
|
|
#include "communication/bolt/v1/decoder/decoder.hpp"
|
|
#include "durability/hashed_file_reader.hpp"
|
|
#include "durability/single_node/recovery.hpp"
|
|
#include "durability/single_node/version.hpp"
|
|
|
|
DEFINE_string(snapshot_file, "", "Snapshot file location");
|
|
|
|
using communication::bolt::Value;
|
|
namespace fs = std::experimental::filesystem;
|
|
|
|
int main(int argc, char *argv[]) {
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
|
google::InitGoogleLogging(argv[0]);
|
|
|
|
// At the time this was written, the version was 7. This makes sure we update
|
|
// the explorer when we bump the snapshot version.
|
|
static_assert(durability::kVersion == 7,
|
|
"Wrong snapshot version, please update!");
|
|
|
|
fs::path snapshot_path(FLAGS_snapshot_file);
|
|
CHECK(fs::exists(snapshot_path)) << "File doesn't exist!";
|
|
|
|
HashedFileReader reader;
|
|
communication::bolt::Decoder<HashedFileReader> decoder(reader);
|
|
|
|
CHECK(reader.Open(snapshot_path)) << "Couldn't open snapshot file!";
|
|
|
|
auto magic_number = durability::kSnapshotMagic;
|
|
reader.Read(magic_number.data(), magic_number.size());
|
|
CHECK(magic_number == durability::kSnapshotMagic) << "Magic number mismatch";
|
|
|
|
int64_t vertex_count, edge_count;
|
|
uint64_t hash;
|
|
|
|
CHECK(durability::ReadSnapshotSummary(reader, vertex_count, edge_count, hash))
|
|
<< "ReadSnapshotSummary failed";
|
|
|
|
LOG(INFO) << "Vertex count: " << vertex_count;
|
|
LOG(INFO) << "Edge count: " << edge_count;
|
|
LOG(INFO) << "Hash: " << hash;
|
|
|
|
Value dv;
|
|
|
|
decoder.ReadValue(&dv, Value::Type::Int);
|
|
CHECK(dv.ValueInt() == durability::kVersion)
|
|
<< "Snapshot version mismatch"
|
|
<< ", got " << dv.ValueInt() << " expected " << durability::kVersion;
|
|
|
|
decoder.ReadValue(&dv, Value::Type::Int);
|
|
LOG(INFO) << "Vertex generator last id: " << dv.ValueInt();
|
|
|
|
decoder.ReadValue(&dv, Value::Type::Int);
|
|
LOG(INFO) << "Edge generator last id: " << dv.ValueInt();
|
|
|
|
decoder.ReadValue(&dv, Value::Type::Int);
|
|
LOG(INFO) << "Transactional ID of the snapshooter " << dv.ValueInt();
|
|
|
|
decoder.ReadValue(&dv, Value::Type::List);
|
|
for (const auto &value : dv.ValueList()) {
|
|
CHECK(value.IsInt()) << "Transaction is not a number!";
|
|
LOG(INFO) << "Transactional snapshot of the snapshooter "
|
|
<< value.ValueInt();
|
|
}
|
|
|
|
decoder.ReadValue(&dv, Value::Type::List);
|
|
|
|
auto index_value = dv.ValueList();
|
|
for (auto it = index_value.begin(); it != index_value.end();) {
|
|
auto label = *it++;
|
|
CHECK(label.IsString()) << "Label is not a string!";
|
|
CHECK(it != index_value.end()) << "Missing propery for label "
|
|
<< label.ValueString();
|
|
auto property = *it++;
|
|
CHECK(property.IsString()) << "Property is not a string!";
|
|
LOG(INFO) << "Adding label " << label.ValueString() << " and property "
|
|
<< property.ValueString();
|
|
}
|
|
|
|
for (int64_t i = 0; i < vertex_count; ++i) {
|
|
auto vertex = decoder.ReadValue(&dv, Value::Type::Vertex);
|
|
CHECK(vertex) << "Failed to read vertex " << i;
|
|
}
|
|
|
|
for (int64_t i = 0; i < edge_count; ++i) {
|
|
auto edge = decoder.ReadValue(&dv, Value::Type::Edge);
|
|
CHECK(edge) << "Failed to read edge " << i;
|
|
}
|
|
|
|
reader.ReadType(vertex_count);
|
|
LOG(INFO) << "Vertex count: " << vertex_count;
|
|
|
|
reader.ReadType(edge_count);
|
|
LOG(INFO) << "Edge count:" << edge_count;
|
|
|
|
LOG(INFO) << "Hash: " << reader.hash();
|
|
|
|
CHECK(reader.Close()) << "Failed to close the reader";
|
|
return 0;
|
|
}
|