Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
lmdb_store.hpp
Go to the documentation of this file.
1#pragma once
2
11#include <cstdint>
12#include <memory>
13#include <mutex>
14#include <optional>
15#include <unordered_map>
16#include <vector>
17namespace bb::lmdblib {
18
23class LMDBStore : public LMDBStoreBase {
24 public:
31
37
39 LMDBStore(const LMDBStore& other) = delete;
43 ~LMDBStore() override = default;
44
45 void open_database(const std::string& name, bool duplicateKeysPermitted = false);
46 void close_database(const std::string& name);
47
49 void get(KeysVector& keys, OptionalValuesVector& values, const std::string& name);
50 void has(const KeyOptionalValuesVector& entries, std::vector<bool>& results, const std::string& name);
51
52 Cursor::Ptr create_cursor(ReadTransaction::SharedPtr tx, const std::string& dbName);
53
55
56 private:
57 // mutex to protect the databases map
58 mutable std::mutex databasesMutex;
59 std::unordered_map<std::string, LMDBDatabase::SharedPtr> databases;
60
61 void put(KeyDupValuesVector& toWrite,
63 const LMDBDatabase& db,
66 // Returns the database of the given name
67 Database::SharedPtr get_database(const std::string& name);
68 // Returns all databases
70 // Returns database corresponding to the requested put operations
71 // Databases are returned in the order of the puts
72 // Throws if any of the databases are not found
74};
75} // namespace bb::lmdblib
std::unique_ptr< LMDBCursor > Ptr
std::shared_ptr< LMDBDatabase > SharedPtr
std::shared_ptr< LMDBReadTransaction > SharedPtr
std::shared_ptr< LMDBStore > SharedPtr
std::vector< Database::SharedPtr > get_databases() const
std::unique_ptr< LMDBStore > Ptr
Database::SharedPtr get_database(const std::string &name)
void open_database(const std::string &name, bool duplicateKeysPermitted=false)
LMDBStore(const LMDBStore &other)=delete
std::pair< uint64_t, uint64_t > get_stats(std::vector< DBStats > &stats) const
void close_database(const std::string &name)
LMDBStore(LMDBStore &&other)=delete
void put(std::vector< PutData > &data)
LMDBStore & operator=(LMDBStore &&other)=delete
std::unordered_map< std::string, LMDBDatabase::SharedPtr > databases
void has(const KeyOptionalValuesVector &entries, std::vector< bool > &results, const std::string &name)
LMDBStore & operator=(const LMDBStore &other)=delete
Cursor::Ptr create_cursor(ReadTransaction::SharedPtr tx, const std::string &dbName)
~LMDBStore() override=default
void get(KeysVector &keys, OptionalValuesVector &values, const std::string &name)
const std::vector< MemoryValue > data
std::vector< Key > KeysVector
Definition types.hpp:13
std::vector< KeyValuesPair > KeyDupValuesVector
Definition types.hpp:18
std::vector< OptionalValues > OptionalValuesVector
Definition types.hpp:17
std::vector< KeyOptionalValuesPair > KeyOptionalValuesVector
Definition types.hpp:20
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
KeyOptionalValuesVector toDelete