|
22 | 22 | #ifndef LIBBITCOIN_SYSTEM_FILTER_GOLOMB_HPP |
23 | 23 | #define LIBBITCOIN_SYSTEM_FILTER_GOLOMB_HPP |
24 | 24 |
|
25 | | -#include <iostream> |
26 | 25 | #include <bitcoin/system/data/data.hpp> |
27 | 26 | #include <bitcoin/system/define.hpp> |
28 | 27 | #include <bitcoin/system/hash/hash.hpp> |
| 28 | +#include <bitcoin/system/stream/stream.hpp> |
29 | 29 |
|
30 | 30 | namespace libbitcoin { |
31 | 31 | namespace system { |
32 | | -namespace golomb { |
33 | 32 |
|
34 | | -// Golomb-coded set construction |
35 | | -// ---------------------------------------------------------------------------- |
| 33 | +class BC_API golomb |
| 34 | +{ |
| 35 | +public: |
| 36 | + |
| 37 | + /// Golomb-coded set construction |
| 38 | + /// ----------------------------------------------------------------------- |
| 39 | + |
| 40 | + static void construct(bitwriter& writer, const data_stack& items, |
| 41 | + uint8_t bits, const siphash_key& entropy, |
| 42 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 43 | + |
| 44 | + static data_chunk construct(const data_stack& items, |
| 45 | + uint8_t bits, const siphash_key& entropy, |
| 46 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 47 | + |
| 48 | + static data_chunk construct(const data_stack& items, |
| 49 | + uint8_t bits, const half_hash& entropy, |
| 50 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 51 | + |
| 52 | + /// Single element match |
| 53 | + /// ----------------------------------------------------------------------- |
| 54 | + |
| 55 | + static bool match_single(bitreader& reader, |
| 56 | + const data_chunk& target, uint64_t set_size, |
| 57 | + const siphash_key& entropy, uint8_t bits, |
| 58 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 59 | + |
| 60 | + static bool match_single(const data_chunk& compressed_set, |
| 61 | + const data_chunk& target, uint64_t set_size, |
| 62 | + const half_hash& entropy, uint8_t bits, |
| 63 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 64 | + |
| 65 | + static bool match_single(const data_chunk& compressed_set, |
| 66 | + const data_chunk& target, uint64_t set_size, |
| 67 | + const siphash_key& entropy, uint8_t bits, |
| 68 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 69 | + |
| 70 | + /// Intersection match |
| 71 | + /// ----------------------------------------------------------------------- |
| 72 | + |
| 73 | + static bool match_stack(bitreader& reader, |
| 74 | + const data_stack& targets, uint64_t set_size, |
| 75 | + const siphash_key& entropy, uint8_t bits, |
| 76 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 77 | + |
| 78 | + static bool match_stack(const data_chunk& compressed_set, |
| 79 | + const data_stack& targets, uint64_t set_size, |
| 80 | + const half_hash& entropy, uint8_t bits, |
| 81 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 82 | + |
| 83 | + static bool match_stack(const data_chunk& compressed_set, |
| 84 | + const data_stack& targets, uint64_t set_size, |
| 85 | + const siphash_key& entropy, uint8_t bits, |
| 86 | + uint64_t target_false_positive_rate) NOEXCEPT; |
| 87 | + |
| 88 | +private: |
| 89 | + static void encode(bitwriter& writer, uint64_t value, |
| 90 | + uint8_t modulo_exponent) NOEXCEPT; |
| 91 | + static uint64_t decode(bitreader& reader, |
| 92 | + uint8_t modulo_exponent) NOEXCEPT; |
| 93 | + static uint64_t hash_to_range(const data_slice& item, |
| 94 | + uint64_t bound, const siphash_key& key) NOEXCEPT; |
| 95 | + static std::vector<uint64_t> hashed_set_construct(const data_stack& items, |
| 96 | + uint64_t set_size, uint64_t target_false_positive_rate, |
| 97 | + const siphash_key& key) NOEXCEPT; |
| 98 | +}; |
36 | 99 |
|
37 | | -BC_API data_chunk construct(const data_stack& items, uint8_t bits, |
38 | | - const half_hash& entropy, uint64_t target_false_positive_rate) NOEXCEPT; |
39 | | - |
40 | | -BC_API data_chunk construct(const data_stack& items, uint8_t bits, |
41 | | - const siphash_key& entropy, uint64_t target_false_positive_rate) NOEXCEPT; |
42 | | - |
43 | | -BC_API void construct(std::ostream& stream, const data_stack& items, |
44 | | - uint8_t bits, const half_hash& entropy, |
45 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
46 | | - |
47 | | -BC_API void construct(std::ostream& stream, const data_stack& items, |
48 | | - uint8_t bits, const siphash_key& entropy, |
49 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
50 | | - |
51 | | -// Single element match |
52 | | -// ---------------------------------------------------------------------------- |
53 | | - |
54 | | -BC_API bool match(const data_chunk& target, const data_chunk& compressed_set, |
55 | | - uint64_t set_size, const half_hash& entropy, uint8_t bits, |
56 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
57 | | - |
58 | | -BC_API bool match(const data_chunk& target, const data_chunk& compressed_set, |
59 | | - uint64_t set_size, const siphash_key& entropy, uint8_t bits, |
60 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
61 | | - |
62 | | -BC_API bool match(const data_chunk& target, std::istream& compressed_set, |
63 | | - uint64_t set_size, const half_hash& entropy, uint8_t bits, |
64 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
65 | | - |
66 | | -BC_API bool match(const data_chunk& target, std::istream& compressed_set, |
67 | | - uint64_t set_size, const siphash_key& entropy, uint8_t bits, |
68 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
69 | | - |
70 | | -// Intersection match |
71 | | -// ---------------------------------------------------------------------------- |
72 | | - |
73 | | -BC_API bool match(const data_stack& targets, const data_chunk& compressed_set, |
74 | | - uint64_t set_size, const half_hash& entropy, uint8_t bits, |
75 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
76 | | - |
77 | | -BC_API bool match(const data_stack& targets, const data_chunk& compressed_set, |
78 | | - uint64_t set_size, const siphash_key& entropy, uint8_t bits, |
79 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
80 | | - |
81 | | -BC_API bool match(const data_stack& targets, std::istream& compressed_set, |
82 | | - uint64_t set_size, const half_hash& entropy, uint8_t bits, |
83 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
84 | | - |
85 | | -BC_API bool match(const data_stack& targets, std::istream& compressed_set, |
86 | | - uint64_t set_size, const siphash_key& entropy, uint8_t bits, |
87 | | - uint64_t target_false_positive_rate) NOEXCEPT; |
88 | | - |
89 | | -} // namespace golomb |
90 | 100 | } // namespace system |
91 | 101 | } // namespace libbitcoin |
92 | 102 |
|
|
0 commit comments