CCF
Loading...
Searching...
No Matches
seqnos_by_key_bucketed.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
6#include "ccf/node_context.h"
8
10{
11 // Stores only a subset of results in-memory, on-demand, and dumps the
12 // remainder to disk. The size of the per-key buckets which will be retained,
13 // and the number of buckets which may be held in-memory, are configurable
15 {
16 protected:
17 struct Impl;
18 std::shared_ptr<Impl> impl = nullptr;
19
20 void visit_entry(
21 const ccf::TxID& tx_id,
22 const ccf::ByteVector& k,
23 const ccf::ByteVector& v) override;
24
25 nlohmann::json describe() override;
26
27 std::optional<SeqNoCollection> get_write_txs_impl(
28 const ccf::ByteVector& serialised_key, ccf::SeqNo from, ccf::SeqNo to);
29
30 public:
32 const std::string& map_name_,
33 ccf::AbstractNodeContext& node_context,
34 size_t seqnos_per_bucket_ = 1000,
35 size_t max_buckets_ = 10);
36
37 size_t max_requestable_range() const;
38 };
39
40 template <typename M>
42 {
43 public:
45
47 const M& map,
48 ccf::AbstractNodeContext& node_context,
49 size_t seqnos_per_bucket_ = 1000,
50 size_t max_buckets_ = 10) :
52 map.get_name(), node_context, seqnos_per_bucket_, max_buckets_)
53 {}
54
55 std::optional<SeqNoCollection> get_write_txs_in_range(
56 const typename M::Key& key, ccf::SeqNo from, ccf::SeqNo to)
57 {
58 return get_write_txs_impl(M::KeySerialiser::to_serialised(key), from, to);
59 }
60 };
61
62 template <typename V>
64 {
65 public:
67
69 const V& value,
70 ccf::AbstractNodeContext& node_context,
71 size_t seqnos_per_bucket_ = 1000,
72 size_t max_buckets_ = 10) :
74 value.get_name(), node_context, seqnos_per_bucket_, max_buckets_)
75 {}
76
77 std::optional<SeqNoCollection> get_write_txs_in_range(
78 ccf::SeqNo from, ccf::SeqNo to)
79 {
80 static const auto singleton = V::create_unit();
81 return get_write_txs_impl(singleton, from, to);
82 }
83 };
84}
std::string get_name() const
Definition strategy.h:31
Definition seqnos_by_key_bucketed.h:15
std::optional< SeqNoCollection > get_write_txs_impl(const ccf::ByteVector &serialised_key, ccf::SeqNo from, ccf::SeqNo to)
Definition seqnos_by_key_bucketed.cpp:421
nlohmann::json describe() override
Definition seqnos_by_key_bucketed.cpp:407
SeqnosByKey_Bucketed_Untyped(const std::string &map_name_, ccf::AbstractNodeContext &node_context, size_t seqnos_per_bucket_=1000, size_t max_buckets_=10)
Definition seqnos_by_key_bucketed.cpp:427
size_t max_requestable_range() const
Definition seqnos_by_key_bucketed.cpp:454
void visit_entry(const ccf::TxID &tx_id, const ccf::ByteVector &k, const ccf::ByteVector &v) override
Definition seqnos_by_key_bucketed.cpp:358
std::shared_ptr< Impl > impl
Definition seqnos_by_key_bucketed.h:18
Definition seqnos_by_key_bucketed.h:42
SeqnosByKey_Bucketed(const M &map, ccf::AbstractNodeContext &node_context, size_t seqnos_per_bucket_=1000, size_t max_buckets_=10)
Definition seqnos_by_key_bucketed.h:46
std::optional< SeqNoCollection > get_write_txs_in_range(const typename M::Key &key, ccf::SeqNo from, ccf::SeqNo to)
Definition seqnos_by_key_bucketed.h:55
Definition seqnos_by_key_bucketed.h:64
SeqnosForValue_Bucketed(const V &value, ccf::AbstractNodeContext &node_context, size_t seqnos_per_bucket_=1000, size_t max_buckets_=10)
Definition seqnos_by_key_bucketed.h:68
std::optional< SeqNoCollection > get_write_txs_in_range(ccf::SeqNo from, ccf::SeqNo to)
Definition seqnos_by_key_bucketed.h:77
Definition visit_each_entry_in_map.h:15
Definition seqnos_by_key_bucketed.h:10
llvm_vecsmall::SmallVector< uint8_t, 8 > ByteVector
Definition byte_vector.h:14
uint64_t SeqNo
Definition tx_id.h:36
Definition map_serializers.h:11
Definition node_context.h:12
Definition tx_id.h:44