2017-06-06 23:04:49 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <experimental/filesystem>
|
|
|
|
#include <unordered_map>
|
2017-10-25 19:01:53 +08:00
|
|
|
|
2017-11-13 16:50:49 +08:00
|
|
|
#include "database/graph_db.hpp"
|
2017-10-25 19:01:53 +08:00
|
|
|
#include "durability/hashed_file_reader.hpp"
|
2017-06-06 23:04:49 +08:00
|
|
|
#include "storage/vertex_accessor.hpp"
|
|
|
|
|
|
|
|
namespace fs = std::experimental::filesystem;
|
|
|
|
|
2017-10-25 19:01:53 +08:00
|
|
|
namespace durability {
|
2017-11-13 16:50:49 +08:00
|
|
|
|
|
|
|
/** Reads snapshot metadata from the end of the file without messing up the
|
|
|
|
* hash. */
|
2017-10-25 19:01:53 +08:00
|
|
|
bool ReadSnapshotSummary(HashedFileReader &buffer, int64_t &vertex_count,
|
|
|
|
int64_t &edge_count, uint64_t &hash);
|
|
|
|
|
2017-06-06 23:04:49 +08:00
|
|
|
/**
|
2017-11-20 18:58:05 +08:00
|
|
|
* Recovers database from durability. If recovering fails, false is returned
|
2017-11-13 16:50:49 +08:00
|
|
|
* and db_accessor aborts transaction, else true is returned and transaction is
|
|
|
|
* commited.
|
|
|
|
*
|
2017-11-20 18:58:05 +08:00
|
|
|
* @param durability_dir - Path to durability directory.
|
2017-11-13 16:50:49 +08:00
|
|
|
* @param db - The database to recover into.
|
|
|
|
* @return - If recovery was succesful.
|
2017-06-06 23:04:49 +08:00
|
|
|
*/
|
2017-11-20 18:58:05 +08:00
|
|
|
bool Recover(const std::experimental::filesystem::path &durability_dir,
|
2018-01-12 22:17:04 +08:00
|
|
|
database::GraphDb &db);
|
2017-12-20 19:48:19 +08:00
|
|
|
} // namespace durability
|