datasketches 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/ext/datasketches/cpc_wrapper.cpp +12 -13
- data/ext/datasketches/ext.cpp +1 -1
- data/ext/datasketches/ext.h +4 -0
- data/ext/datasketches/extconf.rb +1 -1
- data/ext/datasketches/fi_wrapper.cpp +6 -8
- data/ext/datasketches/hll_wrapper.cpp +13 -14
- data/ext/datasketches/kll_wrapper.cpp +28 -76
- data/ext/datasketches/theta_wrapper.cpp +27 -41
- data/ext/datasketches/vo_wrapper.cpp +4 -6
- data/lib/datasketches/version.rb +1 -1
- data/vendor/datasketches-cpp/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/README.md +4 -4
- data/vendor/datasketches-cpp/common/include/MurmurHash3.h +7 -0
- data/vendor/datasketches-cpp/common/include/memory_operations.hpp +12 -0
- data/vendor/datasketches-cpp/common/test/CMakeLists.txt +24 -0
- data/vendor/datasketches-cpp/common/test/integration_test.cpp +77 -0
- data/vendor/datasketches-cpp/common/test/test_allocator.hpp +9 -1
- data/vendor/datasketches-cpp/cpc/include/cpc_common.hpp +3 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor.hpp +2 -2
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +28 -19
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +8 -5
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +19 -14
- data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +2 -2
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +6 -6
- data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +0 -6
- data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +3 -3
- data/vendor/datasketches-cpp/cpc/include/u32_table.hpp +3 -3
- data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +9 -9
- data/vendor/datasketches-cpp/cpc/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_allocation_test.cpp +237 -0
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +15 -10
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +40 -28
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map.hpp +19 -13
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map_impl.hpp +140 -124
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_custom_type_test.cpp +15 -12
- data/vendor/datasketches-cpp/fi/test/reverse_purge_hash_map_test.cpp +3 -3
- data/vendor/datasketches-cpp/hll/CMakeLists.txt +3 -0
- data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +32 -57
- data/vendor/datasketches-cpp/hll/include/AuxHashMap.hpp +9 -8
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +34 -48
- data/vendor/datasketches-cpp/hll/include/CouponHashSet.hpp +10 -10
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +45 -77
- data/vendor/datasketches-cpp/hll/include/CouponList.hpp +11 -12
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +15 -14
- data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +10 -21
- data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +2 -3
- data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +10 -21
- data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +2 -3
- data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +28 -55
- data/vendor/datasketches-cpp/hll/include/HllArray.hpp +8 -8
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +9 -11
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +2 -1
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +34 -31
- data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +3 -28
- data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/RelativeErrorTables.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/hll.hpp +6 -34
- data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +7 -7
- data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +2 -2
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +3 -3
- data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +2 -2
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +46 -50
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +1 -1
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +3 -3
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +10 -3
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +93 -75
- data/vendor/datasketches-cpp/kll/test/kll_sketch_custom_type_test.cpp +11 -10
- data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +45 -42
- data/vendor/datasketches-cpp/python/CMakeLists.txt +2 -0
- data/vendor/datasketches-cpp/python/README.md +6 -3
- data/vendor/datasketches-cpp/python/src/datasketches.cpp +2 -0
- data/vendor/datasketches-cpp/python/src/hll_wrapper.cpp +0 -2
- data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +3 -1
- data/vendor/datasketches-cpp/python/src/req_wrapper.cpp +246 -0
- data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +36 -26
- data/vendor/datasketches-cpp/python/tests/hll_test.py +0 -1
- data/vendor/datasketches-cpp/python/tests/kll_test.py +3 -3
- data/vendor/datasketches-cpp/python/tests/req_test.py +126 -0
- data/vendor/datasketches-cpp/python/tests/theta_test.py +28 -3
- data/vendor/datasketches-cpp/req/CMakeLists.txt +60 -0
- data/vendor/datasketches-cpp/{tuple/include/theta_a_not_b_experimental_impl.hpp → req/include/req_common.hpp} +17 -8
- data/vendor/datasketches-cpp/req/include/req_compactor.hpp +137 -0
- data/vendor/datasketches-cpp/req/include/req_compactor_impl.hpp +501 -0
- data/vendor/datasketches-cpp/req/include/req_quantile_calculator.hpp +69 -0
- data/vendor/datasketches-cpp/req/include/req_quantile_calculator_impl.hpp +60 -0
- data/vendor/datasketches-cpp/req/include/req_sketch.hpp +395 -0
- data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +810 -0
- data/vendor/datasketches-cpp/req/test/CMakeLists.txt +43 -0
- data/vendor/datasketches-cpp/req/test/req_float_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_float_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_float_exact_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_float_raw_items_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_float_single_item_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_sketch_custom_type_test.cpp +128 -0
- data/vendor/datasketches-cpp/req/test/req_sketch_test.cpp +494 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +10 -9
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +82 -70
- data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +5 -5
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +7 -7
- data/vendor/datasketches-cpp/sampling/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_allocation_test.cpp +96 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +0 -31
- data/vendor/datasketches-cpp/setup.py +5 -3
- data/vendor/datasketches-cpp/theta/CMakeLists.txt +30 -3
- data/vendor/datasketches-cpp/{tuple → theta}/include/bounds_on_ratios_in_sampled_sets.hpp +2 -1
- data/vendor/datasketches-cpp/{tuple → theta}/include/bounds_on_ratios_in_theta_sketched_sets.hpp +1 -1
- data/vendor/datasketches-cpp/theta/include/theta_a_not_b.hpp +12 -29
- data/vendor/datasketches-cpp/theta/include/theta_a_not_b_impl.hpp +5 -46
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_comparators.hpp +0 -0
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_constants.hpp +2 -0
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_helpers.hpp +0 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection.hpp +22 -29
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_intersection_base.hpp +0 -0
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_intersection_base_impl.hpp +0 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection_impl.hpp +8 -90
- data/vendor/datasketches-cpp/{tuple/test/theta_union_experimental_test.cpp → theta/include/theta_jaccard_similarity.hpp} +11 -18
- data/vendor/datasketches-cpp/{tuple/include/jaccard_similarity.hpp → theta/include/theta_jaccard_similarity_base.hpp} +6 -22
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_set_difference_base.hpp +0 -0
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_set_difference_base_impl.hpp +5 -0
- data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +132 -266
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +200 -650
- data/vendor/datasketches-cpp/theta/include/theta_union.hpp +27 -60
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_union_base.hpp +1 -1
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_union_base_impl.hpp +5 -0
- data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +13 -69
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_update_sketch_base.hpp +3 -19
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_update_sketch_base_impl.hpp +6 -1
- data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/{tuple → theta}/test/theta_jaccard_similarity_test.cpp +2 -3
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +37 -234
- data/vendor/datasketches-cpp/tuple/CMakeLists.txt +3 -35
- data/vendor/datasketches-cpp/tuple/include/tuple_jaccard_similarity.hpp +38 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +28 -13
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +6 -6
- data/vendor/datasketches-cpp/tuple/test/CMakeLists.txt +1 -6
- data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +1 -4
- data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +1 -4
- data/vendor/datasketches-cpp/tuple/test/tuple_jaccard_similarity_test.cpp +2 -1
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_allocation_test.cpp +2 -2
- data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +1 -4
- metadata +43 -34
- data/vendor/datasketches-cpp/tuple/include/theta_a_not_b_experimental.hpp +0 -53
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental.hpp +0 -78
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental_impl.hpp +0 -43
- data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental.hpp +0 -393
- data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental_impl.hpp +0 -481
- data/vendor/datasketches-cpp/tuple/include/theta_union_experimental.hpp +0 -88
- data/vendor/datasketches-cpp/tuple/include/theta_union_experimental_impl.hpp +0 -47
- data/vendor/datasketches-cpp/tuple/test/theta_a_not_b_experimental_test.cpp +0 -250
- data/vendor/datasketches-cpp/tuple/test/theta_compact_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_compact_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_compact_single_item_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_intersection_experimental_test.cpp +0 -224
- data/vendor/datasketches-cpp/tuple/test/theta_sketch_experimental_test.cpp +0 -247
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
namespace datasketches {
|
|
33
33
|
|
|
34
34
|
template<typename A>
|
|
35
|
-
hll_union_alloc<A>::hll_union_alloc(const int lg_max_k):
|
|
35
|
+
hll_union_alloc<A>::hll_union_alloc(const int lg_max_k, const A& allocator):
|
|
36
36
|
lg_max_k(HllUtil<A>::checkLgK(lg_max_k)),
|
|
37
|
-
gadget(lg_max_k, target_hll_type::HLL_8)
|
|
37
|
+
gadget(lg_max_k, target_hll_type::HLL_8, false, allocator)
|
|
38
38
|
{}
|
|
39
39
|
|
|
40
40
|
template<typename A>
|
|
@@ -149,16 +149,6 @@ double hll_union_alloc<A>::get_upper_bound(const int num_std_dev) const {
|
|
|
149
149
|
return gadget.get_upper_bound(num_std_dev);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
template<typename A>
|
|
153
|
-
int hll_union_alloc<A>::get_compact_serialization_bytes() const {
|
|
154
|
-
return gadget.get_compact_serialization_bytes();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
template<typename A>
|
|
158
|
-
int hll_union_alloc<A>::get_updatable_serialization_bytes() const {
|
|
159
|
-
return gadget.get_updatable_serialization_bytes();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
152
|
template<typename A>
|
|
163
153
|
int hll_union_alloc<A>::get_lg_config_k() const {
|
|
164
154
|
return gadget.get_lg_config_k();
|
|
@@ -169,11 +159,6 @@ void hll_union_alloc<A>::reset() {
|
|
|
169
159
|
gadget.reset();
|
|
170
160
|
}
|
|
171
161
|
|
|
172
|
-
template<typename A>
|
|
173
|
-
bool hll_union_alloc<A>::is_compact() const {
|
|
174
|
-
return gadget.is_compact();
|
|
175
|
-
}
|
|
176
|
-
|
|
177
162
|
template<typename A>
|
|
178
163
|
bool hll_union_alloc<A>::is_empty() const {
|
|
179
164
|
return gadget.is_empty();
|
|
@@ -194,21 +179,11 @@ bool hll_union_alloc<A>::is_estimation_mode() const {
|
|
|
194
179
|
return gadget.is_estimation_mode();
|
|
195
180
|
}
|
|
196
181
|
|
|
197
|
-
template<typename A>
|
|
198
|
-
int hll_union_alloc<A>::get_serialization_version() const {
|
|
199
|
-
return HllUtil<A>::SER_VER;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
182
|
template<typename A>
|
|
203
183
|
target_hll_type hll_union_alloc<A>::get_target_type() const {
|
|
204
184
|
return target_hll_type::HLL_8;
|
|
205
185
|
}
|
|
206
186
|
|
|
207
|
-
template<typename A>
|
|
208
|
-
int hll_union_alloc<A>::get_max_serialization_bytes(const int lg_k) {
|
|
209
|
-
return hll_sketch_alloc<A>::get_max_updatable_serialization_bytes(lg_k, target_hll_type::HLL_8);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
187
|
template<typename A>
|
|
213
188
|
double hll_union_alloc<A>::get_rel_err(const bool upper_bound, const bool unioned,
|
|
214
189
|
const int lg_config_k, const int num_std_dev) {
|
|
@@ -226,7 +201,7 @@ HllSketchImpl<A>* hll_union_alloc<A>::copy_or_downsample(const HllSketchImpl<A>*
|
|
|
226
201
|
return src->copyAs(HLL_8);
|
|
227
202
|
}
|
|
228
203
|
typedef typename std::allocator_traits<A>::template rebind_alloc<Hll8Array<A>> hll8Alloc;
|
|
229
|
-
Hll8Array<A>* tgtHllArr = new (hll8Alloc().allocate(1)) Hll8Array<A>(tgt_lg_k, false);
|
|
204
|
+
Hll8Array<A>* tgtHllArr = new (hll8Alloc(src->getAllocator()).allocate(1)) Hll8Array<A>(tgt_lg_k, false, src->getAllocator());
|
|
230
205
|
tgtHllArr->mergeHll(*src);
|
|
231
206
|
//both of these are required for isomorphism
|
|
232
207
|
tgtHllArr->putHipAccum(src->getHipAccum());
|
|
@@ -36,7 +36,7 @@ enum hll_mode { LIST = 0, SET, HLL };
|
|
|
36
36
|
|
|
37
37
|
// template provides internal consistency and allows static float values
|
|
38
38
|
// but we don't use the template parameter anywhere
|
|
39
|
-
template<typename A = std::allocator<
|
|
39
|
+
template<typename A = std::allocator<uint8_t> >
|
|
40
40
|
class HllUtil final {
|
|
41
41
|
public:
|
|
42
42
|
// preamble stuff
|
|
@@ -108,7 +108,7 @@ class hll_union_alloc;
|
|
|
108
108
|
template<typename A> using AllocU8 = typename std::allocator_traits<A>::template rebind_alloc<uint8_t>;
|
|
109
109
|
template<typename A> using vector_u8 = std::vector<uint8_t, AllocU8<A>>;
|
|
110
110
|
|
|
111
|
-
template<typename A = std::allocator<
|
|
111
|
+
template<typename A = std::allocator<uint8_t> >
|
|
112
112
|
class hll_sketch_alloc final {
|
|
113
113
|
public:
|
|
114
114
|
/**
|
|
@@ -119,7 +119,7 @@ class hll_sketch_alloc final {
|
|
|
119
119
|
* keeping memory use constant (if HLL_6 or HLL_8) at the cost of
|
|
120
120
|
* starting out using much more memory
|
|
121
121
|
*/
|
|
122
|
-
explicit hll_sketch_alloc(int lg_config_k, target_hll_type tgt_type = HLL_4, bool start_full_size = false);
|
|
122
|
+
explicit hll_sketch_alloc(int lg_config_k, target_hll_type tgt_type = HLL_4, bool start_full_size = false, const A& allocator = A());
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Copy constructor
|
|
@@ -140,14 +140,14 @@ class hll_sketch_alloc final {
|
|
|
140
140
|
* Reconstructs a sketch from a serialized image on a stream.
|
|
141
141
|
* @param is An input stream with a binary image of a sketch
|
|
142
142
|
*/
|
|
143
|
-
static hll_sketch_alloc deserialize(std::istream& is);
|
|
143
|
+
static hll_sketch_alloc deserialize(std::istream& is, const A& allocator = A());
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* Reconstructs a sketch from a serialized image in a byte array.
|
|
147
147
|
* @param is bytes An input array with a binary image of a sketch
|
|
148
148
|
* @param len Length of the input array, in bytes
|
|
149
149
|
*/
|
|
150
|
-
static hll_sketch_alloc deserialize(const void* bytes, size_t len);
|
|
150
|
+
static hll_sketch_alloc deserialize(const void* bytes, size_t len, const A& allocator = A());
|
|
151
151
|
|
|
152
152
|
//! Class destructor
|
|
153
153
|
virtual ~hll_sketch_alloc();
|
|
@@ -423,7 +423,7 @@ class hll_sketch_alloc final {
|
|
|
423
423
|
* author Kevin Lang
|
|
424
424
|
*/
|
|
425
425
|
|
|
426
|
-
template<typename A = std::allocator<
|
|
426
|
+
template<typename A = std::allocator<uint8_t> >
|
|
427
427
|
class hll_union_alloc {
|
|
428
428
|
public:
|
|
429
429
|
/**
|
|
@@ -431,7 +431,7 @@ class hll_union_alloc {
|
|
|
431
431
|
* @param lg_max_k The maximum size, in log2, of k. The value must
|
|
432
432
|
* be between 7 and 21, inclusive.
|
|
433
433
|
*/
|
|
434
|
-
explicit hll_union_alloc(int lg_max_k);
|
|
434
|
+
explicit hll_union_alloc(int lg_max_k, const A& allocator = A());
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
437
|
* Returns the current cardinality estimate
|
|
@@ -468,18 +468,6 @@ class hll_union_alloc {
|
|
|
468
468
|
*/
|
|
469
469
|
double get_upper_bound(int num_std_dev) const;
|
|
470
470
|
|
|
471
|
-
/**
|
|
472
|
-
* Returns the size of the union serialized in compact form.
|
|
473
|
-
* @return Size of the union serialized in compact form, in bytes.
|
|
474
|
-
*/
|
|
475
|
-
int get_compact_serialization_bytes() const;
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* Returns the size of the union serialized without compaction.
|
|
479
|
-
* @return Size of the union serialized without compaction, in bytes.
|
|
480
|
-
*/
|
|
481
|
-
int get_updatable_serialization_bytes() const;
|
|
482
|
-
|
|
483
471
|
/**
|
|
484
472
|
* Returns union's configured lg_k value.
|
|
485
473
|
* @return Configured lg_k value.
|
|
@@ -492,12 +480,6 @@ class hll_union_alloc {
|
|
|
492
480
|
*/
|
|
493
481
|
target_hll_type get_target_type() const;
|
|
494
482
|
|
|
495
|
-
/**
|
|
496
|
-
* Indicates if the union is currently stored compacted.
|
|
497
|
-
* @return True if the union is stored in compact form.
|
|
498
|
-
*/
|
|
499
|
-
bool is_compact() const;
|
|
500
|
-
|
|
501
483
|
/**
|
|
502
484
|
* Indicates if the union is currently empty.
|
|
503
485
|
* @return True if the union is empty.
|
|
@@ -605,15 +587,6 @@ class hll_union_alloc {
|
|
|
605
587
|
*/
|
|
606
588
|
void update(const void* data, size_t length_bytes);
|
|
607
589
|
|
|
608
|
-
/**
|
|
609
|
-
* Returns the maximum size in bytes that this union operator can grow to given a lg_k.
|
|
610
|
-
*
|
|
611
|
-
* @param lg_k The maximum Log2 of k for this union operator. This value must be
|
|
612
|
-
* between 4 and 21 inclusively.
|
|
613
|
-
* @return the maximum size in bytes that this union operator can grow to.
|
|
614
|
-
*/
|
|
615
|
-
static int get_max_serialization_bytes(int lg_k);
|
|
616
|
-
|
|
617
590
|
/**
|
|
618
591
|
* Gets the current (approximate) Relative Error (RE) asymptotic values given several
|
|
619
592
|
* parameters. This is used primarily for testing.
|
|
@@ -645,7 +618,6 @@ class hll_union_alloc {
|
|
|
645
618
|
void coupon_update(int coupon);
|
|
646
619
|
|
|
647
620
|
hll_mode get_current_mode() const;
|
|
648
|
-
int get_serialization_version() const;
|
|
649
621
|
bool is_out_of_order_flag() const;
|
|
650
622
|
bool is_estimation_mode() const;
|
|
651
623
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
namespace datasketches {
|
|
26
26
|
|
|
27
27
|
TEST_CASE("aux hash map: check must replace", "[aux_hash_map]") {
|
|
28
|
-
AuxHashMap
|
|
28
|
+
AuxHashMap<std::allocator<uint8_t>>* map = new AuxHashMap<std::allocator<uint8_t>>(3, 7, std::allocator<uint8_t>());
|
|
29
29
|
map->mustAdd(100, 5);
|
|
30
30
|
int val = map->mustFindValueFor(100);
|
|
31
31
|
REQUIRE(val == 5);
|
|
@@ -40,9 +40,9 @@ TEST_CASE("aux hash map: check must replace", "[aux_hash_map]") {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
TEST_CASE("aux hash map: check grow space", "[aux_hash_map]") {
|
|
43
|
-
auto map = std::unique_ptr<AuxHashMap
|
|
44
|
-
AuxHashMap
|
|
45
|
-
AuxHashMap
|
|
43
|
+
auto map = std::unique_ptr<AuxHashMap<std::allocator<uint8_t>>, std::function<void(AuxHashMap<std::allocator<uint8_t>>*)>>(
|
|
44
|
+
AuxHashMap<std::allocator<uint8_t>>::newAuxHashMap(3, 7, std::allocator<uint8_t>()),
|
|
45
|
+
AuxHashMap<std::allocator<uint8_t>>::make_deleter()
|
|
46
46
|
);
|
|
47
47
|
REQUIRE(map->getLgAuxArrInts() == 3);
|
|
48
48
|
for (int i = 1; i <= 7; ++i) {
|
|
@@ -63,17 +63,17 @@ TEST_CASE("aux hash map: check grow space", "[aux_hash_map]") {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
TEST_CASE("aux hash map: check exception must find value for", "[aux_hash_map]") {
|
|
66
|
-
AuxHashMap
|
|
66
|
+
AuxHashMap<std::allocator<uint8_t>> map(3, 7, std::allocator<uint8_t>());
|
|
67
67
|
map.mustAdd(100, 5);
|
|
68
68
|
REQUIRE_THROWS_AS(map.mustFindValueFor(101), std::invalid_argument);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
TEST_CASE("aux hash map: check exception must add", "[aux_hash_map]") {
|
|
72
|
-
AuxHashMap
|
|
72
|
+
AuxHashMap<std::allocator<uint8_t>>* map = AuxHashMap<std::allocator<uint8_t>>::newAuxHashMap(3, 7, std::allocator<uint8_t>());
|
|
73
73
|
map->mustAdd(100, 5);
|
|
74
74
|
REQUIRE_THROWS_AS(map->mustAdd(100, 6), std::invalid_argument);
|
|
75
75
|
|
|
76
|
-
AuxHashMap
|
|
76
|
+
AuxHashMap<std::allocator<uint8_t>>::make_deleter()(map);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
} /* namespace datasketches */
|
|
@@ -43,7 +43,7 @@ TEST_CASE("coupon hash set: check corrupt bytearray", "[coupon_hash_set]") {
|
|
|
43
43
|
// fail in HllSketchImpl
|
|
44
44
|
REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
|
|
45
45
|
// fail in CouponHashSet
|
|
46
|
-
REQUIRE_THROWS_AS(CouponHashSet
|
|
46
|
+
REQUIRE_THROWS_AS(CouponHashSet<std::allocator<uint8_t>>::newSet(bytes, size, std::allocator<uint8_t>()), std::invalid_argument);
|
|
47
47
|
bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = HllUtil<>::HASH_SET_PREINTS;
|
|
48
48
|
|
|
49
49
|
bytes[HllUtil<>::SER_VER_BYTE] = 0;
|
|
@@ -88,7 +88,7 @@ TEST_CASE("coupon hash set: check corrupt stream", "[coupon_hash_set]") {
|
|
|
88
88
|
// fail in HllSketchImpl
|
|
89
89
|
REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
|
|
90
90
|
// fail in CouponHashSet
|
|
91
|
-
REQUIRE_THROWS_AS(CouponHashSet
|
|
91
|
+
REQUIRE_THROWS_AS(CouponHashSet<std::allocator<uint8_t>>::newSet(ss, std::allocator<uint8_t>()), std::invalid_argument);
|
|
92
92
|
ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
|
|
93
93
|
ss.put(HllUtil<>::HASH_SET_PREINTS);
|
|
94
94
|
|
|
@@ -36,7 +36,7 @@ void println_string(std::string str) {
|
|
|
36
36
|
|
|
37
37
|
TEST_CASE("coupon list: check iterator", "[coupon_list]") {
|
|
38
38
|
int lgConfigK = 8;
|
|
39
|
-
CouponList
|
|
39
|
+
CouponList<std::allocator<uint8_t>> cl(lgConfigK, HLL_4, LIST, std::allocator<uint8_t>());
|
|
40
40
|
for (int i = 1; i <= 7; ++i) { cl.couponUpdate(HllUtil<>::pair(i, i)); } // not hashes but distinct values
|
|
41
41
|
const int mask = (1 << lgConfigK) - 1;
|
|
42
42
|
int idx = 0;
|
|
@@ -120,7 +120,7 @@ TEST_CASE("coupon list: check corrupt bytearray data", "[coupon_list]") {
|
|
|
120
120
|
|
|
121
121
|
bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = 0;
|
|
122
122
|
REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
|
|
123
|
-
REQUIRE_THROWS_AS(CouponList
|
|
123
|
+
REQUIRE_THROWS_AS(CouponList<std::allocator<uint8_t>>::newList(bytes, size, std::allocator<uint8_t>()), std::invalid_argument);
|
|
124
124
|
|
|
125
125
|
bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = HllUtil<>::LIST_PREINTS;
|
|
126
126
|
|
|
@@ -154,7 +154,7 @@ TEST_CASE("coupon list: check corrupt stream data", "[coupon_list]") {
|
|
|
154
154
|
ss.put(0);
|
|
155
155
|
ss.seekg(0);
|
|
156
156
|
REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
|
|
157
|
-
REQUIRE_THROWS_AS(CouponList
|
|
157
|
+
REQUIRE_THROWS_AS(CouponList<std::allocator<uint8_t>>::newList(ss, std::allocator<uint8_t>()), std::invalid_argument);
|
|
158
158
|
ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
|
|
159
159
|
ss.put(HllUtil<>::LIST_PREINTS);
|
|
160
160
|
|
|
@@ -111,7 +111,7 @@ TEST_CASE("hll array: check corrupt bytearray", "[hll_array]") {
|
|
|
111
111
|
|
|
112
112
|
bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = 0;
|
|
113
113
|
REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
|
|
114
|
-
REQUIRE_THROWS_AS(HllArray
|
|
114
|
+
REQUIRE_THROWS_AS(HllArray<std::allocator<uint8_t>>::newHll(bytes, size, std::allocator<uint8_t>()), std::invalid_argument);
|
|
115
115
|
bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = HllUtil<>::HLL_PREINTS;
|
|
116
116
|
|
|
117
117
|
bytes[HllUtil<>::SER_VER_BYTE] = 0;
|
|
@@ -150,7 +150,7 @@ TEST_CASE("hll array: check corrupt stream", "[hll_array]") {
|
|
|
150
150
|
ss.put(0);
|
|
151
151
|
ss.seekg(0);
|
|
152
152
|
REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
|
|
153
|
-
REQUIRE_THROWS_AS(HllArray
|
|
153
|
+
REQUIRE_THROWS_AS(HllArray<std::allocator<uint8_t>>::newHll(ss, std::allocator<uint8_t>()), std::invalid_argument);
|
|
154
154
|
ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
|
|
155
155
|
ss.put(HllUtil<>::HLL_PREINTS);
|
|
156
156
|
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
|
|
25
25
|
namespace datasketches {
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
using hll_sketch_test_alloc = hll_sketch_alloc<test_allocator<uint8_t>>;
|
|
28
|
+
using alloc = test_allocator<uint8_t>;
|
|
28
29
|
|
|
29
30
|
static void runCheckCopy(int lgConfigK, target_hll_type tgtHllType) {
|
|
30
|
-
hll_sketch_test_alloc sk(lgConfigK, tgtHllType);
|
|
31
|
+
hll_sketch_test_alloc sk(lgConfigK, tgtHllType, false, 0);
|
|
31
32
|
|
|
32
33
|
for (int i = 0; i < 7; ++i) {
|
|
33
34
|
sk.update(i);
|
|
@@ -71,7 +72,7 @@ static void copyAs(target_hll_type srcType, target_hll_type dstType) {
|
|
|
71
72
|
int n3 = 1000;
|
|
72
73
|
int base = 0;
|
|
73
74
|
|
|
74
|
-
hll_sketch_test_alloc src(lgK, srcType);
|
|
75
|
+
hll_sketch_test_alloc src(lgK, srcType, false, 0);
|
|
75
76
|
for (int i = 0; i < n1; ++i) {
|
|
76
77
|
src.update(i + base);
|
|
77
78
|
}
|
|
@@ -110,7 +111,7 @@ TEST_CASE("hll sketch: check misc1", "[hll_sketch]") {
|
|
|
110
111
|
{
|
|
111
112
|
int lgConfigK = 8;
|
|
112
113
|
target_hll_type srcType = target_hll_type::HLL_8;
|
|
113
|
-
hll_sketch_test_alloc sk(lgConfigK, srcType);
|
|
114
|
+
hll_sketch_test_alloc sk(lgConfigK, srcType, false, 0);
|
|
114
115
|
|
|
115
116
|
for (int i = 0; i < 7; ++i) { sk.update(i); } // LIST
|
|
116
117
|
REQUIRE(sk.get_compact_serialization_bytes() == 36);
|
|
@@ -135,7 +136,7 @@ TEST_CASE("hll sketch: check num std dev", "[hll_sketch]") {
|
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
void checkSerializationSizes(const int lgConfigK, target_hll_type tgtHllType) {
|
|
138
|
-
hll_sketch_test_alloc sk(lgConfigK, tgtHllType);
|
|
139
|
+
hll_sketch_test_alloc sk(lgConfigK, tgtHllType, false, 0);
|
|
139
140
|
int i;
|
|
140
141
|
|
|
141
142
|
// LIST
|
|
@@ -162,27 +163,23 @@ TEST_CASE("hll sketch: check ser sizes", "[hll_sketch]") {
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
TEST_CASE("hll sketch: exercise to string", "[hll_sketch]") {
|
|
165
|
-
|
|
166
|
-
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
for (int i = 0; i < 25; ++i) { sk.update(i); }
|
|
177
|
-
oss << sk.to_string(false, true, true, true);
|
|
178
|
-
}
|
|
179
|
-
REQUIRE(test_allocator_total_bytes == 0);
|
|
166
|
+
hll_sketch sk(15, HLL_4);
|
|
167
|
+
for (int i = 0; i < 25; ++i) { sk.update(i); }
|
|
168
|
+
std::ostringstream oss(std::ios::binary);
|
|
169
|
+
oss << sk.to_string(false, true, true, true);
|
|
170
|
+
for (int i = 25; i < (1 << 20); ++i) { sk.update(i); }
|
|
171
|
+
oss << sk.to_string(false, true, true, true);
|
|
172
|
+
oss << sk.to_string(false, true, true, false);
|
|
173
|
+
|
|
174
|
+
sk = hll_sketch(8, HLL_8);
|
|
175
|
+
for (int i = 0; i < 25; ++i) { sk.update(i); }
|
|
176
|
+
oss << sk.to_string(false, true, true, true);
|
|
180
177
|
}
|
|
181
178
|
|
|
182
179
|
// Creates and serializes then deserializes sketch.
|
|
183
180
|
// Returns true if deserialized sketch is compact.
|
|
184
181
|
static bool checkCompact(const int lgK, const int n, const target_hll_type type, bool compact) {
|
|
185
|
-
hll_sketch_test_alloc sk(lgK, type);
|
|
182
|
+
hll_sketch_test_alloc sk(lgK, type, false, 0);
|
|
186
183
|
for (int i = 0; i < n; ++i) { sk.update(i); }
|
|
187
184
|
|
|
188
185
|
std::stringstream ss(std::ios::in | std::ios::out | std::ios::binary);
|
|
@@ -194,7 +191,7 @@ static bool checkCompact(const int lgK, const int n, const target_hll_type type,
|
|
|
194
191
|
REQUIRE(ss.tellp() == sk.get_updatable_serialization_bytes());
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
hll_sketch_test_alloc sk2 = hll_sketch_test_alloc::deserialize(ss);
|
|
194
|
+
hll_sketch_test_alloc sk2 = hll_sketch_test_alloc::deserialize(ss, alloc(0));
|
|
198
195
|
REQUIRE(sk2.get_estimate() == Approx(n).margin(0.01));
|
|
199
196
|
bool isCompact = sk2.is_compact();
|
|
200
197
|
|
|
@@ -233,11 +230,10 @@ TEST_CASE("hll sketch: check compact flag", "[hll_sketch]") {
|
|
|
233
230
|
TEST_CASE("hll sketch: check k limits", "[hll_sketch]") {
|
|
234
231
|
test_allocator_total_bytes = 0;
|
|
235
232
|
{
|
|
236
|
-
hll_sketch_test_alloc sketch1(HllUtil<>::MIN_LOG_K, target_hll_type::HLL_8);
|
|
237
|
-
hll_sketch_test_alloc sketch2(HllUtil<>::MAX_LOG_K, target_hll_type::HLL_4);
|
|
238
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc(HllUtil<>::MIN_LOG_K - 1), std::invalid_argument);
|
|
239
|
-
|
|
240
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc(HllUtil<>::MAX_LOG_K + 1), std::invalid_argument);
|
|
233
|
+
hll_sketch_test_alloc sketch1(HllUtil<>::MIN_LOG_K, target_hll_type::HLL_8, false, 0);
|
|
234
|
+
hll_sketch_test_alloc sketch2(HllUtil<>::MAX_LOG_K, target_hll_type::HLL_4, false, 0);
|
|
235
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc(HllUtil<>::MIN_LOG_K - 1, target_hll_type::HLL_4, false, 0), std::invalid_argument);
|
|
236
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc(HllUtil<>::MAX_LOG_K + 1, target_hll_type::HLL_4, false, 0), std::invalid_argument);
|
|
241
237
|
}
|
|
242
238
|
REQUIRE(test_allocator_total_bytes == 0);
|
|
243
239
|
}
|
|
@@ -245,7 +241,7 @@ TEST_CASE("hll sketch: check k limits", "[hll_sketch]") {
|
|
|
245
241
|
TEST_CASE("hll sketch: check input types", "[hll_sketch]") {
|
|
246
242
|
test_allocator_total_bytes = 0;
|
|
247
243
|
{
|
|
248
|
-
hll_sketch_test_alloc sk(8, target_hll_type::HLL_8);
|
|
244
|
+
hll_sketch_test_alloc sk(8, target_hll_type::HLL_8, false, 0);
|
|
249
245
|
|
|
250
246
|
// inserting the same value as a variety of input types
|
|
251
247
|
sk.update((uint8_t) 102);
|
|
@@ -271,19 +267,19 @@ TEST_CASE("hll sketch: check input types", "[hll_sketch]") {
|
|
|
271
267
|
sk.update(str.c_str(), str.length());
|
|
272
268
|
REQUIRE(sk.get_estimate() == Approx(4.0).margin(0.01));
|
|
273
269
|
|
|
274
|
-
sk = hll_sketch_test_alloc(8, target_hll_type::HLL_6);
|
|
270
|
+
sk = hll_sketch_test_alloc(8, target_hll_type::HLL_6, false, 0);
|
|
275
271
|
sk.update((float) 0.0);
|
|
276
272
|
sk.update((float) -0.0);
|
|
277
273
|
sk.update((double) 0.0);
|
|
278
274
|
sk.update((double) -0.0);
|
|
279
275
|
REQUIRE(sk.get_estimate() == Approx(1.0).margin(0.01));
|
|
280
276
|
|
|
281
|
-
sk = hll_sketch_test_alloc(8, target_hll_type::HLL_4);
|
|
277
|
+
sk = hll_sketch_test_alloc(8, target_hll_type::HLL_4, false, 0);
|
|
282
278
|
sk.update(std::nanf("3"));
|
|
283
279
|
sk.update(std::nan("9"));
|
|
284
280
|
REQUIRE(sk.get_estimate() == Approx(1.0).margin(0.01));
|
|
285
281
|
|
|
286
|
-
sk = hll_sketch_test_alloc(8, target_hll_type::HLL_4);
|
|
282
|
+
sk = hll_sketch_test_alloc(8, target_hll_type::HLL_4, false, 0);
|
|
287
283
|
sk.update(nullptr, 0);
|
|
288
284
|
sk.update("");
|
|
289
285
|
REQUIRE(sk.is_empty());
|
|
@@ -294,24 +290,24 @@ TEST_CASE("hll sketch: check input types", "[hll_sketch]") {
|
|
|
294
290
|
TEST_CASE("hll sketch: deserialize list mode buffer overrun", "[hll_sketch]") {
|
|
295
291
|
test_allocator_total_bytes = 0;
|
|
296
292
|
{
|
|
297
|
-
hll_sketch_test_alloc sketch(10);
|
|
293
|
+
hll_sketch_test_alloc sketch(10, target_hll_type::HLL_4, false, 0);
|
|
298
294
|
sketch.update(1);
|
|
299
295
|
auto bytes = sketch.serialize_compact();
|
|
300
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 7), std::out_of_range);
|
|
301
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), bytes.size() - 1), std::out_of_range);
|
|
296
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 7, 0), std::out_of_range);
|
|
297
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), bytes.size() - 1, 0), std::out_of_range);
|
|
302
298
|
|
|
303
299
|
// ckeck for leaks on stream exceptions
|
|
304
300
|
{
|
|
305
301
|
std::stringstream ss;
|
|
306
302
|
ss.exceptions(std::ios::failbit | std::ios::badbit);
|
|
307
303
|
ss.str(std::string((char*)bytes.data(), 7));
|
|
308
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss), std::ios_base::failure);
|
|
304
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
|
|
309
305
|
}
|
|
310
306
|
{
|
|
311
307
|
std::stringstream ss;
|
|
312
308
|
ss.exceptions(std::ios::failbit | std::ios::badbit);
|
|
313
309
|
ss.str(std::string((char*)bytes.data(), bytes.size() - 1));
|
|
314
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss), std::ios_base::failure);
|
|
310
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
|
|
315
311
|
}
|
|
316
312
|
}
|
|
317
313
|
REQUIRE(test_allocator_total_bytes == 0);
|
|
@@ -320,25 +316,25 @@ TEST_CASE("hll sketch: deserialize list mode buffer overrun", "[hll_sketch]") {
|
|
|
320
316
|
TEST_CASE("hll sketch: deserialize set mode buffer overrun", "[hll_sketch]") {
|
|
321
317
|
test_allocator_total_bytes = 0;
|
|
322
318
|
{
|
|
323
|
-
hll_sketch_test_alloc sketch(10);
|
|
319
|
+
hll_sketch_test_alloc sketch(10, target_hll_type::HLL_4, false, 0);
|
|
324
320
|
for (int i = 0; i < 10; ++i) sketch.update(i);
|
|
325
321
|
//std::cout << sketch.to_string();
|
|
326
322
|
auto bytes = sketch.serialize_updatable();
|
|
327
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 7), std::out_of_range);
|
|
328
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), bytes.size() - 1), std::out_of_range);
|
|
323
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 7, 0), std::out_of_range);
|
|
324
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), bytes.size() - 1, 0), std::out_of_range);
|
|
329
325
|
|
|
330
326
|
// ckeck for leaks on stream exceptions
|
|
331
327
|
{
|
|
332
328
|
std::stringstream ss;
|
|
333
329
|
ss.exceptions(std::ios::failbit | std::ios::badbit);
|
|
334
330
|
ss.str(std::string((char*)bytes.data(), 7));
|
|
335
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss), std::ios_base::failure);
|
|
331
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
|
|
336
332
|
}
|
|
337
333
|
{
|
|
338
334
|
std::stringstream ss;
|
|
339
335
|
ss.exceptions(std::ios::failbit | std::ios::badbit);
|
|
340
336
|
ss.str(std::string((char*)bytes.data(), bytes.size() - 1));
|
|
341
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss), std::ios_base::failure);
|
|
337
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
|
|
342
338
|
}
|
|
343
339
|
}
|
|
344
340
|
REQUIRE(test_allocator_total_bytes == 0);
|
|
@@ -348,39 +344,39 @@ TEST_CASE("hll sketch: deserialize HLL mode buffer overrun", "[hll_sketch]") {
|
|
|
348
344
|
test_allocator_total_bytes = 0;
|
|
349
345
|
{
|
|
350
346
|
// this sketch should have aux table
|
|
351
|
-
hll_sketch_test_alloc sketch(15);
|
|
347
|
+
hll_sketch_test_alloc sketch(15, target_hll_type::HLL_4, false, 0);
|
|
352
348
|
for (int i = 0; i < 14444; ++i) sketch.update(i);
|
|
353
349
|
//std::cout << sketch.to_string();
|
|
354
350
|
auto bytes = sketch.serialize_compact();
|
|
355
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 7), std::out_of_range);
|
|
356
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 15), std::out_of_range);
|
|
357
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 16420), std::out_of_range); // before aux table
|
|
358
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), bytes.size() - 1), std::out_of_range);
|
|
351
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 7, 0), std::out_of_range);
|
|
352
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 15, 0), std::out_of_range);
|
|
353
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), 16420, 0), std::out_of_range); // before aux table
|
|
354
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(bytes.data(), bytes.size() - 1, 0), std::out_of_range);
|
|
359
355
|
|
|
360
356
|
// ckeck for leaks on stream exceptions
|
|
361
357
|
{
|
|
362
358
|
std::stringstream ss;
|
|
363
359
|
ss.exceptions(std::ios::failbit | std::ios::badbit);
|
|
364
360
|
ss.str(std::string((char*)bytes.data(), 7));
|
|
365
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss), std::ios_base::failure);
|
|
361
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
|
|
366
362
|
}
|
|
367
363
|
{
|
|
368
364
|
std::stringstream ss;
|
|
369
365
|
ss.exceptions(std::ios::failbit | std::ios::badbit);
|
|
370
366
|
ss.str(std::string((char*)bytes.data(), 15));
|
|
371
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss), std::ios_base::failure);
|
|
367
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
|
|
372
368
|
}
|
|
373
369
|
{
|
|
374
370
|
std::stringstream ss;
|
|
375
371
|
ss.exceptions(std::ios::failbit | std::ios::badbit);
|
|
376
372
|
ss.str(std::string((char*)bytes.data(), 16420)); // before aux table
|
|
377
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss), std::ios_base::failure);
|
|
373
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
|
|
378
374
|
}
|
|
379
375
|
{
|
|
380
376
|
std::stringstream ss;
|
|
381
377
|
ss.exceptions(std::ios::failbit | std::ios::badbit);
|
|
382
378
|
ss.str(std::string((char*)bytes.data(), bytes.size() - 1));
|
|
383
|
-
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss), std::ios_base::failure);
|
|
379
|
+
REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
|
|
384
380
|
}
|
|
385
381
|
}
|
|
386
382
|
REQUIRE(test_allocator_total_bytes == 0);
|