-
Notifications
You must be signed in to change notification settings - Fork 1
/
rocksdb.hpp
30 lines (24 loc) · 815 Bytes
/
rocksdb.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include <rocksdb/db.h>
#include <rocksdb/merge_operator.h>
#include "utils.hpp"
struct RocksDB {
using Slice = rocksdb::Slice; // basically a string_view
std::shared_ptr<rocksdb::DB> db;
rocksdb::Options opts{};
rocksdb::WriteOptions writeopts{};
RocksDB();
RocksDB(rocksdb::Options o) : opts(o) {}
void open(const std::string& path);
void openRO(const std::string& path);
template <typename F> void forEach(F&& f) {
rocksdb::Iterator* it = db->NewIterator(rocksdb::ReadOptions());
for (it->SeekToFirst(); it->Valid(); it->Next()) {
std::forward<F>(f)(it);
}
assert(it->status().ok()); // Check for any errors found during the scan
delete it;
}
void add(const multikmap_t& kmap, const Alphabet& alpha, int K,
DynamicProgress<ProgressBar>* bars = nullptr);
};