-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRocksDB.h
45 lines (36 loc) · 1.31 KB
/
RocksDB.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Aleth: Ethereum C++ client, tools and libraries.
// Copyright 2017-2019 Aleth Authors.
// Licensed under the GNU General Public License, Version 3.
#pragma once
#include "db.h"
#include <boost/filesystem.hpp>
#include <rocksdb/db.h>
#include <rocksdb/write_batch.h>
namespace dev
{
namespace db
{
class RocksDB : public DatabaseFace
{
public:
static rocksdb::ReadOptions defaultReadOptions();
static rocksdb::WriteOptions defaultWriteOptions();
static rocksdb::Options defaultDBOptions();
explicit RocksDB(boost::filesystem::path const& _path,
rocksdb::ReadOptions _readOptions = defaultReadOptions(),
rocksdb::WriteOptions _writeOptions = defaultWriteOptions(),
rocksdb::Options _dbOptions = defaultDBOptions());
std::string lookup(Slice _key) const override;
bool exists(Slice _key) const override;
void insert(Slice _key, Slice _value) override;
void kill(Slice _key) override;
std::unique_ptr<WriteBatchFace> createWriteBatch() const override;
void commit(std::unique_ptr<WriteBatchFace> _batch) override;
void forEach(std::function<bool(Slice, Slice)> f) const override;
private:
std::unique_ptr<rocksdb::DB> m_db;
rocksdb::ReadOptions const m_readOptions;
rocksdb::WriteOptions const m_writeOptions;
};
} // namespace db
} // namespace dev