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 {
4LMDBStoreBase::LMDBStoreBase(std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs)
5 : _dbDirectory(std::move(directory))
6 , _environment((std::make_shared<LMDBEnvironment>(_dbDirectory, mapSizeKb, maxDbs, maxNumReaders)))
7{}
14
20
26
32
33void LMDBStoreBase::copy_store(const std::string& dstPath, bool compact)
34{
35 // Create a write tx to acquire a write lock to prevent writes while copying. From LMDB docs:
36 // "[mdb_copy] can trigger significant file size growth if run in parallel with write transactions,
37 // because pages which they free during copying cannot be reused until the copy is done."
39 call_lmdb_func("mdb_env_copy2",
40 mdb_env_copy2,
41 _environment->underlying(),
42 dstPath.c_str(),
43 static_cast<unsigned int>(compact ? MDB_CP_COMPACT : 0));
44}
45
46} // namespace bb::lmdblib
std::unique_ptr< LMDBDatabaseCreationTransaction > Ptr
std::unique_ptr< LMDBReadTransaction > Ptr
std::shared_ptr< LMDBReadTransaction > SharedPtr
LMDBEnvironment::SharedPtr _environment
LMDBStoreBase(std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs)
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
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