Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
lmdb_store_base.cpp
Go to the documentation of this file.
2
3namespace bb::lmdblib {
5 std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs, bool ephemeral)
6 : _dbDirectory(std::move(directory))
7 , _environment(std::make_shared<LMDBEnvironment>(_dbDirectory, mapSizeKb, maxDbs, maxNumReaders, ephemeral))
8{}
15
21
27
33
34void LMDBStoreBase::copy_store(const std::string& dstPath, bool compact)
35{
36 // Create a write tx to acquire a write lock to prevent writes while copying. From LMDB docs:
37 // "[mdb_copy] can trigger significant file size growth if run in parallel with write transactions,
38 // because pages which they free during copying cannot be reused until the copy is done."
40 call_lmdb_func("mdb_env_copy2",
41 mdb_env_copy2,
42 _environment->underlying(),
43 dstPath.c_str(),
44 static_cast<unsigned int>(compact ? MDB_CP_COMPACT : 0));
45}
46
47} // namespace bb::lmdblib
std::unique_ptr< LMDBDatabaseCreationTransaction > Ptr
std::unique_ptr< LMDBReadTransaction > Ptr
std::shared_ptr< LMDBReadTransaction > SharedPtr
LMDBEnvironment::SharedPtr _environment
void copy_store(const std::string &dstPath, bool compact)
ReadTransaction::SharedPtr create_shared_read_transaction() const
LMDBDatabaseCreationTransaction::Ptr create_db_transaction() const
WriteTransaction::Ptr create_write_transaction() const
LMDBStoreBase(std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs, bool ephemeral=false)
ReadTransaction::Ptr create_read_transaction() const
std::unique_ptr< LMDBWriteTransaction > Ptr
bool call_lmdb_func(int(*f)(TArgs...), TArgs... args)
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13