Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "lmdb.h"
5#include <cstdint>
6#include <iostream>
7#include <optional>
8#include <string>
9#include <vector>
10namespace bb::lmdblib {
11using Key = std::vector<uint8_t>;
12using Value = std::vector<uint8_t>;
13using KeysVector = std::vector<Key>;
17using OptionalValuesVector = std::vector<OptionalValues>;
18using KeyDupValuesVector = std::vector<KeyValuesPair>;
20using KeyOptionalValuesVector = std::vector<KeyOptionalValuesPair>;
21
22struct DBStats {
23 std::string name;
24 uint64_t numDataItems;
25 uint64_t totalUsedSize;
26
27 DBStats() = default;
28 DBStats(const DBStats& other) = default;
29 DBStats(DBStats&& other) noexcept { *this = std::move(other); }
30 ~DBStats() = default;
31 DBStats(std::string name, MDB_stat& stat)
32 : name(std::move(name))
33 , numDataItems(stat.ms_entries)
34 , totalUsedSize(stat.ms_psize * (stat.ms_branch_pages + stat.ms_leaf_pages + stat.ms_overflow_pages))
35 {}
36 DBStats(const std::string& name, uint64_t numDataItems, uint64_t totalUsedSize)
37 : name(name)
40 {}
41
43
44 bool operator==(const DBStats& other) const
45 {
46 return name == other.name && numDataItems == other.numDataItems && totalUsedSize == other.totalUsedSize;
47 }
48
49 DBStats& operator=(const DBStats& other) = default;
50
51 DBStats& operator=(DBStats&& other) noexcept
52 {
53 if (this != &other) {
54 name = std::move(other.name);
55 numDataItems = other.numDataItems;
56 totalUsedSize = other.totalUsedSize;
57 }
58 return *this;
59 }
60
61 friend std::ostream& operator<<(std::ostream& os, const DBStats& stats)
62 {
63 os << "DB " << stats.name << ", num items: " << stats.numDataItems
64 << ", total used size: " << stats.totalUsedSize;
65 return os;
66 }
67};
68
69} // namespace bb::lmdblib
#define MSGPACK_FIELDS(...)
Definition msgpack.hpp:118
std::vector< Key > KeysVector
Definition types.hpp:13
std::pair< Key, OptionalValues > KeyOptionalValuesPair
Definition types.hpp:19
std::vector< uint8_t > Key
Definition types.hpp:11
std::vector< uint8_t > Value
Definition types.hpp:12
std::vector< KeyValuesPair > KeyDupValuesVector
Definition types.hpp:18
std::vector< OptionalValues > OptionalValuesVector
Definition types.hpp:17
std::vector< Value > ValuesVector
Definition types.hpp:14
std::pair< Key, ValuesVector > KeyValuesPair
Definition types.hpp:15
std::vector< KeyOptionalValuesPair > KeyOptionalValuesVector
Definition types.hpp:20
std::optional< ValuesVector > OptionalValues
Definition types.hpp:16
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
DBStats(std::string name, MDB_stat &stat)
Definition types.hpp:31
DBStats & operator=(const DBStats &other)=default
uint64_t totalUsedSize
Definition types.hpp:25
friend std::ostream & operator<<(std::ostream &os, const DBStats &stats)
Definition types.hpp:61
DBStats(const std::string &name, uint64_t numDataItems, uint64_t totalUsedSize)
Definition types.hpp:36
uint64_t numDataItems
Definition types.hpp:24
std::string name
Definition types.hpp:23
DBStats(const DBStats &other)=default
DBStats(DBStats &&other) noexcept
Definition types.hpp:29
DBStats & operator=(DBStats &&other) noexcept
Definition types.hpp:51