4#include <nlohmann/json.hpp>
7#include "rocksdb/options.h"
8#include "rocksdb/slice.h"
10#include "rocksdb/options.h"
11#include "rocksdb/utilities/transaction_db.h"
15using ROCKSDB_NAMESPACE::PinnableSlice;
16using ROCKSDB_NAMESPACE::ReadOptions;
17using ROCKSDB_NAMESPACE::Status;
18using ROCKSDB_NAMESPACE::WriteBatch;
19using ROCKSDB_NAMESPACE::WriteOptions;
51 Status s =
m_database->Put(WriteOptions(), key, entry);
62 Status s =
m_database->Get(ReadOptions(), hash, &value);
67 std::string dbEntryStr =
GetEntry(key);
68 nlohmann::json dbEntry = nlohmann::json::parse(dbEntryStr);
69 nlohmann::json entryToMerge = nlohmann::json::parse(entry);
70 dbEntry.merge_patch(entryToMerge);
71 std::string combinedEntry = dbEntry.dump();
75 batch.Put(key, combinedEntry);
76 Status s =
m_database->Write(WriteOptions(), &batch);
#define DB_INITIALIZATION
ERRORCODE InitializeDatabase()
std::string UpdateEntry(std::string key, std::string entry)
static void CloseDatabase()
Flushes and closes the database. Safe to call if it was never opened.
std::string GetEntry(std::string hash)
BOOL AddEntry(std::string key, std::string entry)
rocksdb::Options m_options
#define PANOPTES_DATABASE_PATH
std::string GetExecutableDirectory()