Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
lmdb_cursor.hpp
Go to the documentation of this file.
1#pragma once
3#include "lmdb.h"
4#include <cstdint>
5#include <memory>
6
7namespace bb::lmdblib {
8class LMDBReadTransaction;
9class LMDBDatabase;
11 public:
13 using SharedPtr = std::shared_ptr<LMDBCursor>;
14
16 LMDBCursor(const LMDBCursor& other) = delete;
17 LMDBCursor(LMDBCursor&& other) = delete;
18 LMDBCursor& operator=(const LMDBCursor& other) = delete;
19 LMDBCursor& operator=(LMDBCursor&& other) = delete;
21
22 MDB_cursor* underlying() const;
23 const MDB_dbi& underlying_db() const;
24 MDB_txn* underlying_tx() const;
25
26 uint64_t id() const;
27
28 bool set_at_key(Key& key) const;
29 bool set_at_key_gte(Key& key) const;
30 bool set_at_start() const;
31 bool set_at_end() const;
32 bool read_next(uint64_t numKeysToRead, KeyDupValuesVector& keyValuePairs) const;
33 bool read_prev(uint64_t numKeysToRead, KeyDupValuesVector& keyValuePairs) const;
34 bool count_until_next(const Key& key, uint64_t& count) const;
35 bool count_until_prev(const Key& key, uint64_t& count) const;
36
37 private:
38 mutable std::mutex _mtx;
41 uint64_t _id;
42 MDB_cursor* _cursor;
43};
44} // namespace bb::lmdblib
std::unique_ptr< LMDBCursor > Ptr
bool set_at_key(Key &key) const
uint64_t id() const
LMDBCursor(std::shared_ptr< LMDBReadTransaction > tx, std::shared_ptr< LMDBDatabase > db, uint64_t id)
const MDB_dbi & underlying_db() const
bool count_until_next(const Key &key, uint64_t &count) const
MDB_txn * underlying_tx() const
bool read_next(uint64_t numKeysToRead, KeyDupValuesVector &keyValuePairs) const
LMDBCursor(const LMDBCursor &other)=delete
bool set_at_key_gte(Key &key) const
bool read_prev(uint64_t numKeysToRead, KeyDupValuesVector &keyValuePairs) const
MDB_cursor * underlying() const
LMDBCursor & operator=(LMDBCursor &&other)=delete
std::shared_ptr< LMDBCursor > SharedPtr
std::shared_ptr< LMDBReadTransaction > _tx
LMDBCursor & operator=(const LMDBCursor &other)=delete
std::shared_ptr< LMDBDatabase > _db
bool count_until_prev(const Key &key, uint64_t &count) const
LMDBCursor(LMDBCursor &&other)=delete
std::vector< uint8_t > Key
Definition types.hpp:11
std::vector< KeyValuesPair > KeyDupValuesVector
Definition types.hpp:18
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13