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;
40 LMDBStore(LMDBStore&& other) = delete;
41 LMDBStore& operator=(const LMDBStore& other) = delete;
42 LMDBStore& operator=(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
51 Cursor::Ptr create_cursor(ReadTransaction::SharedPtr tx, const std::string& dbName);
52
54
55 private:
56 // mutex to protect the databases map
57 mutable std::mutex databasesMutex;
58 std::unordered_map<std::string, LMDBDatabase::SharedPtr> databases;
59
60 void put(KeyDupValuesVector& toWrite,
62 const LMDBDatabase& db,
65 // Returns the database of the given name
66 Database::SharedPtr get_database(const std::string& name);
67 // Returns all databases
69 // Returns database corresponding to the requested put operations
70 // Databases are returned in the order of the puts
71 // Throws if any of the databases are not found
73};
74} // 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
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< FF > 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