datasketches 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +1 -1
  4. data/ext/datasketches/kll_wrapper.cpp +5 -1
  5. data/lib/datasketches/version.rb +1 -1
  6. data/vendor/datasketches-cpp/CMakeLists.txt +4 -3
  7. data/vendor/datasketches-cpp/common/CMakeLists.txt +4 -0
  8. data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +1 -0
  9. data/vendor/datasketches-cpp/common/include/common_defs.hpp +14 -0
  10. data/vendor/datasketches-cpp/{kll → common}/include/kolmogorov_smirnov.hpp +5 -3
  11. data/vendor/datasketches-cpp/{kll → common}/include/kolmogorov_smirnov_impl.hpp +13 -16
  12. data/vendor/datasketches-cpp/common/include/quantile_sketch_sorted_view.hpp +121 -0
  13. data/vendor/datasketches-cpp/common/include/quantile_sketch_sorted_view_impl.hpp +91 -0
  14. data/vendor/datasketches-cpp/common/test/test_type.hpp +2 -0
  15. data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +1 -0
  16. data/vendor/datasketches-cpp/cpc/include/cpc_confidence.hpp +1 -0
  17. data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +2 -0
  18. data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +1 -0
  19. data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +2 -0
  20. data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +37 -5
  21. data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +25 -9
  22. data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_custom_type_test.cpp +2 -1
  23. data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_test.cpp +1 -0
  24. data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +2 -0
  25. data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +1 -0
  26. data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +2 -2
  27. data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +1 -0
  28. data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +2 -0
  29. data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +2 -0
  30. data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +1 -0
  31. data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +1 -0
  32. data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +2 -0
  33. data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +1 -0
  34. data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +59 -0
  35. data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +2 -0
  36. data/vendor/datasketches-cpp/hll/test/TablesTest.cpp +1 -0
  37. data/vendor/datasketches-cpp/kll/CMakeLists.txt +0 -4
  38. data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +0 -4
  39. data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +3 -0
  40. data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +96 -42
  41. data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +105 -127
  42. data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +94 -25
  43. data/vendor/datasketches-cpp/kll/test/kolmogorov_smirnov_test.cpp +1 -1
  44. data/vendor/datasketches-cpp/pyproject.toml +1 -1
  45. data/vendor/datasketches-cpp/python/CMakeLists.txt +8 -1
  46. data/vendor/datasketches-cpp/python/README.md +7 -0
  47. data/vendor/datasketches-cpp/python/src/datasketches.cpp +4 -0
  48. data/vendor/datasketches-cpp/python/src/fi_wrapper.cpp +6 -1
  49. data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +48 -13
  50. data/vendor/datasketches-cpp/python/src/ks_wrapper.cpp +68 -0
  51. data/vendor/datasketches-cpp/python/src/quantiles_wrapper.cpp +240 -0
  52. data/vendor/datasketches-cpp/python/src/req_wrapper.cpp +9 -2
  53. data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +1 -0
  54. data/vendor/datasketches-cpp/python/tests/kll_test.py +10 -4
  55. data/vendor/datasketches-cpp/python/tests/quantiles_test.py +126 -0
  56. data/vendor/datasketches-cpp/quantiles/CMakeLists.txt +42 -0
  57. data/vendor/datasketches-cpp/quantiles/include/quantiles_sketch.hpp +641 -0
  58. data/vendor/datasketches-cpp/quantiles/include/quantiles_sketch_impl.hpp +1309 -0
  59. data/vendor/datasketches-cpp/quantiles/test/CMakeLists.txt +44 -0
  60. data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.3.0.sk +0 -0
  61. data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.6.0.sk +0 -0
  62. data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.8.0.sk +0 -0
  63. data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.8.3.sk +0 -0
  64. data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.3.0.sk +0 -0
  65. data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.6.0.sk +0 -0
  66. data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.8.0.sk +0 -0
  67. data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.8.3.sk +0 -0
  68. data/vendor/datasketches-cpp/quantiles/test/kolmogorov_smirnov_test.cpp +110 -0
  69. data/vendor/datasketches-cpp/quantiles/test/quantiles_compatibility_test.cpp +129 -0
  70. data/vendor/datasketches-cpp/quantiles/test/quantiles_sketch_test.cpp +912 -0
  71. data/vendor/datasketches-cpp/req/CMakeLists.txt +0 -2
  72. data/vendor/datasketches-cpp/req/include/req_common.hpp +0 -5
  73. data/vendor/datasketches-cpp/req/include/req_compactor_impl.hpp +3 -2
  74. data/vendor/datasketches-cpp/req/include/req_sketch.hpp +62 -23
  75. data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +62 -59
  76. data/vendor/datasketches-cpp/req/test/req_sketch_test.cpp +5 -0
  77. data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +44 -7
  78. data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +31 -26
  79. data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +41 -6
  80. data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +25 -9
  81. data/vendor/datasketches-cpp/sampling/test/var_opt_allocation_test.cpp +2 -2
  82. data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +1 -0
  83. data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +1 -0
  84. data/vendor/datasketches-cpp/setup.py +1 -1
  85. data/vendor/datasketches-cpp/theta/include/bounds_on_ratios_in_sampled_sets.hpp +1 -0
  86. data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser_impl.hpp +8 -6
  87. data/vendor/datasketches-cpp/theta/include/theta_intersection_base_impl.hpp +1 -0
  88. data/vendor/datasketches-cpp/theta/include/theta_set_difference_base_impl.hpp +1 -0
  89. data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +7 -45
  90. data/vendor/datasketches-cpp/theta/include/theta_union_base_impl.hpp +1 -0
  91. data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base_impl.hpp +1 -0
  92. data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +2 -0
  93. data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +2 -0
  94. data/vendor/datasketches-cpp/theta/test/theta_setop_test.cpp +1 -0
  95. data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +29 -1
  96. data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +2 -0
  97. data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +16 -0
  98. data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +1 -0
  99. data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +1 -0
  100. data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +1 -0
  101. data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +1 -0
  102. metadata +25 -9
  103. data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +0 -75
  104. data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +0 -184
  105. data/vendor/datasketches-cpp/req/include/req_quantile_calculator.hpp +0 -69
  106. data/vendor/datasketches-cpp/req/include/req_quantile_calculator_impl.hpp +0 -60
@@ -23,6 +23,7 @@
23
23
  #include <cstring>
24
24
  #include <limits>
25
25
  #include <sstream>
26
+ #include <stdexcept>
26
27
 
27
28
  #include "memory_operations.hpp"
28
29
 
@@ -160,7 +161,8 @@ frequent_items_sketch<T, W, H, E, S, A>::get_frequent_items(frequent_items_error
160
161
  }
161
162
 
162
163
  template<typename T, typename W, typename H, typename E, typename S, typename A>
163
- void frequent_items_sketch<T, W, H, E, S, A>::serialize(std::ostream& os) const {
164
+ template<typename SerDe>
165
+ void frequent_items_sketch<T, W, H, E, S, A>::serialize(std::ostream& os, const SerDe& sd) const {
164
166
  const uint8_t preamble_longs = is_empty() ? PREAMBLE_LONGS_EMPTY : PREAMBLE_LONGS_NONEMPTY;
165
167
  write(os, preamble_longs);
166
168
  const uint8_t serial_version = SERIAL_VERSION;
@@ -198,23 +200,25 @@ void frequent_items_sketch<T, W, H, E, S, A>::serialize(std::ostream& os) const
198
200
  }
199
201
  write(os, weights, sizeof(W) * num_items);
200
202
  aw.deallocate(weights, num_items);
201
- S().serialize(os, items, num_items);
203
+ sd.serialize(os, items, num_items);
202
204
  for (i = 0; i < num_items; i++) items[i].~T();
203
205
  alloc.deallocate(items, num_items);
204
206
  }
205
207
  }
206
208
 
207
209
  template<typename T, typename W, typename H, typename E, typename S, typename A>
208
- size_t frequent_items_sketch<T, W, H, E, S, A>::get_serialized_size_bytes() const {
210
+ template<typename SerDe>
211
+ size_t frequent_items_sketch<T, W, H, E, S, A>::get_serialized_size_bytes(const SerDe& sd) const {
209
212
  if (is_empty()) return PREAMBLE_LONGS_EMPTY * sizeof(uint64_t);
210
213
  size_t size = PREAMBLE_LONGS_NONEMPTY * sizeof(uint64_t) + map.get_num_active() * sizeof(W);
211
- for (auto it: map) size += S().size_of_item(it.first);
214
+ for (auto it: map) size += sd.size_of_item(it.first);
212
215
  return size;
213
216
  }
214
217
 
215
218
  template<typename T, typename W, typename H, typename E, typename S, typename A>
216
- auto frequent_items_sketch<T, W, H, E, S, A>::serialize(unsigned header_size_bytes) const -> vector_bytes {
217
- const size_t size = header_size_bytes + get_serialized_size_bytes();
219
+ template<typename SerDe>
220
+ auto frequent_items_sketch<T, W, H, E, S, A>::serialize(unsigned header_size_bytes, const SerDe& sd) const -> vector_bytes {
221
+ const size_t size = header_size_bytes + get_serialized_size_bytes(sd);
218
222
  vector_bytes bytes(size, 0, map.get_allocator());
219
223
  uint8_t* ptr = bytes.data() + header_size_bytes;
220
224
  uint8_t* end_ptr = ptr + size;
@@ -255,7 +259,7 @@ auto frequent_items_sketch<T, W, H, E, S, A>::serialize(unsigned header_size_byt
255
259
  ptr += copy_to_mem(weights, ptr, sizeof(W) * num_items);
256
260
  aw.deallocate(weights, num_items);
257
261
  const size_t bytes_remaining = end_ptr - ptr;
258
- ptr += S().serialize(ptr, bytes_remaining, items, num_items);
262
+ ptr += sd.serialize(ptr, bytes_remaining, items, num_items);
259
263
  for (i = 0; i < num_items; i++) items[i].~T();
260
264
  alloc.deallocate(items, num_items);
261
265
  }
@@ -284,6 +288,12 @@ private:
284
288
 
285
289
  template<typename T, typename W, typename H, typename E, typename S, typename A>
286
290
  frequent_items_sketch<T, W, H, E, S, A> frequent_items_sketch<T, W, H, E, S, A>::deserialize(std::istream& is, const A& allocator) {
291
+ return deserialize(is, S(), allocator);
292
+ }
293
+
294
+ template<typename T, typename W, typename H, typename E, typename S, typename A>
295
+ template<typename SerDe>
296
+ frequent_items_sketch<T, W, H, E, S, A> frequent_items_sketch<T, W, H, E, S, A>::deserialize(std::istream& is, const SerDe& sd, const A& allocator) {
287
297
  const auto preamble_longs = read<uint8_t>(is);
288
298
  const auto serial_version = read<uint8_t>(is);
289
299
  const auto family_id = read<uint8_t>(is);
@@ -312,7 +322,7 @@ frequent_items_sketch<T, W, H, E, S, A> frequent_items_sketch<T, W, H, E, S, A>:
312
322
  read(is, weights.data(), sizeof(W) * num_items);
313
323
  A alloc(allocator);
314
324
  std::unique_ptr<T, items_deleter> items(alloc.allocate(num_items), items_deleter(num_items, false, alloc));
315
- S().deserialize(is, items.get(), num_items);
325
+ sd.deserialize(is, items.get(), num_items);
316
326
  items.get_deleter().set_destroy(true); // serde did not throw, so the items must be constructed
317
327
  for (uint32_t i = 0; i < num_items; i++) {
318
328
  sketch.update(std::move(items.get()[i]), weights[i]);
@@ -327,6 +337,12 @@ frequent_items_sketch<T, W, H, E, S, A> frequent_items_sketch<T, W, H, E, S, A>:
327
337
 
328
338
  template<typename T, typename W, typename H, typename E, typename S, typename A>
329
339
  frequent_items_sketch<T, W, H, E, S, A> frequent_items_sketch<T, W, H, E, S, A>::deserialize(const void* bytes, size_t size, const A& allocator) {
340
+ return deserialize(bytes, size, S(), allocator);
341
+ }
342
+
343
+ template<typename T, typename W, typename H, typename E, typename S, typename A>
344
+ template<typename SerDe>
345
+ frequent_items_sketch<T, W, H, E, S, A> frequent_items_sketch<T, W, H, E, S, A>::deserialize(const void* bytes, size_t size, const SerDe& sd, const A& allocator) {
330
346
  ensure_minimum_memory(size, 8);
331
347
  const char* ptr = static_cast<const char*>(bytes);
332
348
  const char* base = static_cast<const char*>(bytes);
@@ -370,7 +386,7 @@ frequent_items_sketch<T, W, H, E, S, A> frequent_items_sketch<T, W, H, E, S, A>:
370
386
  A alloc(allocator);
371
387
  std::unique_ptr<T, items_deleter> items(alloc.allocate(num_items), items_deleter(num_items, false, alloc));
372
388
  const size_t bytes_remaining = size - (ptr - base);
373
- ptr += S().deserialize(ptr, bytes_remaining, items.get(), num_items);
389
+ ptr += sd.deserialize(ptr, bytes_remaining, items.get(), num_items);
374
390
  items.get_deleter().set_destroy(true); // serde did not throw, so the items must be constructed
375
391
  for (uint32_t i = 0; i < num_items; i++) {
376
392
  sketch.update(std::move(items.get()[i]), weights[i]);
@@ -19,6 +19,7 @@
19
19
 
20
20
  #include <catch.hpp>
21
21
  #include <sstream>
22
+ #include <stdexcept>
22
23
 
23
24
  #include "frequent_items_sketch.hpp"
24
25
  #include "test_type.hpp"
@@ -59,7 +60,7 @@ TEST_CASE("frequent items: custom type", "[frequent_items_sketch]") {
59
60
  REQUIRE(sketch.get_maximum_error() == sketch2.get_maximum_error());
60
61
 
61
62
  auto bytes = sketch.serialize();
62
- auto sketch3 = frequent_test_type_sketch::deserialize(bytes.data(), bytes.size(), 0);
63
+ auto sketch3 = frequent_test_type_sketch::deserialize(bytes.data(), bytes.size(), alloc(0));
63
64
  REQUIRE_FALSE(sketch3.is_empty());
64
65
  REQUIRE(sketch3.get_total_weight() == 17);
65
66
  REQUIRE(sketch3.get_estimate(1) == 10);
@@ -20,6 +20,7 @@
20
20
  #include <catch.hpp>
21
21
  #include <sstream>
22
22
  #include <fstream>
23
+ #include <stdexcept>
23
24
 
24
25
  #include "frequent_items_sketch.hpp"
25
26
 
@@ -20,6 +20,8 @@
20
20
  #ifndef _AUXHASHMAP_INTERNAL_HPP_
21
21
  #define _AUXHASHMAP_INTERNAL_HPP_
22
22
 
23
+ #include <stdexcept>
24
+
23
25
  #include "HllUtil.hpp"
24
26
  #include "AuxHashMap.hpp"
25
27
 
@@ -24,6 +24,7 @@
24
24
  #include "CompositeInterpolationXTable.hpp"
25
25
 
26
26
  #include <exception>
27
+ #include <stdexcept>
27
28
 
28
29
  namespace datasketches {
29
30
 
@@ -24,6 +24,7 @@
24
24
 
25
25
  #include <cstring>
26
26
  #include <exception>
27
+ #include <stdexcept>
27
28
 
28
29
  namespace datasketches {
29
30
 
@@ -113,10 +114,9 @@ CouponHashSet<A>* CouponHashSet<A>::newSet(const void* bytes, size_t len, const
113
114
  } else {
114
115
  sketch->coupons_.resize(1ULL << lgArrInts);
115
116
  sketch->couponCount_ = couponCount;
116
- // only need to read valid coupons, unlike in stream case
117
117
  std::memcpy(sketch->coupons_.data(),
118
118
  data + hll_constants::HASH_SET_INT_ARR_START,
119
- couponCount * sizeof(uint32_t));
119
+ couponsInArray * sizeof(uint32_t));
120
120
  }
121
121
 
122
122
  return sketch;
@@ -27,6 +27,7 @@
27
27
 
28
28
  #include <algorithm>
29
29
  #include <cmath>
30
+ #include <stdexcept>
30
31
 
31
32
  namespace datasketches {
32
33
 
@@ -23,6 +23,8 @@
23
23
  #include "HllSketchImpl.hpp"
24
24
  #include "HllSketchImplFactory.hpp"
25
25
 
26
+ #include <stdexcept>
27
+
26
28
  namespace datasketches {
27
29
 
28
30
  template<typename A>
@@ -20,6 +20,8 @@
20
20
  #ifndef _HLLSKETCHIMPLFACTORY_HPP_
21
21
  #define _HLLSKETCHIMPLFACTORY_HPP_
22
22
 
23
+ #include <stdexcept>
24
+
23
25
  #include "HllUtil.hpp"
24
26
  #include "HllSketchImpl.hpp"
25
27
  #include "CouponList.hpp"
@@ -19,6 +19,7 @@
19
19
 
20
20
  #include <catch.hpp>
21
21
  #include <memory>
22
+ #include <stdexcept>
22
23
 
23
24
  #include "AuxHashMap.hpp"
24
25
 
@@ -26,6 +26,7 @@
26
26
  #include <cmath>
27
27
  #include <string>
28
28
  #include <exception>
29
+ #include <stdexcept>
29
30
 
30
31
  namespace datasketches {
31
32
 
@@ -23,6 +23,7 @@
23
23
  #include <cmath>
24
24
  #include <string>
25
25
  #include <exception>
26
+ #include <stdexcept>
26
27
 
27
28
  #include "hll.hpp"
28
29
  #include "CouponList.hpp"
@@ -31,6 +32,7 @@
31
32
  namespace datasketches {
32
33
 
33
34
  void println_string(std::string str) {
35
+ unused(str);
34
36
  //std::cout << str << std::endl;
35
37
  }
36
38
 
@@ -21,6 +21,7 @@
21
21
 
22
22
  #include <exception>
23
23
  #include <sstream>
24
+ #include <stdexcept>
24
25
  #include <catch.hpp>
25
26
 
26
27
  namespace datasketches {
@@ -17,6 +17,8 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
+ #include <stdexcept>
21
+
20
22
  #include "hll.hpp"
21
23
 
22
24
  #include <catch.hpp>
@@ -382,4 +384,61 @@ TEST_CASE("hll sketch: deserialize HLL mode buffer overrun", "[hll_sketch]") {
382
384
  REQUIRE(test_allocator_total_bytes == 0);
383
385
  }
384
386
 
387
+ TEST_CASE("hll sketch: bytes serialize-deserialize-serialize list mode") {
388
+ test_allocator_total_bytes = 0;
389
+ {
390
+ hll_sketch_test_alloc s1(10, target_hll_type::HLL_4, false, 0);
391
+ s1.update(1);
392
+ s1.update(2);
393
+ s1.update(3);
394
+ std::cout << s1.to_string();
395
+ auto bytes1 = s1.serialize_compact();
396
+ auto s2 = hll_sketch_test_alloc::deserialize(bytes1.data(), bytes1.size(), 0);
397
+ auto bytes2 = s2.serialize_compact();
398
+ REQUIRE(bytes1 == bytes2);
399
+ }
400
+ REQUIRE(test_allocator_total_bytes == 0);
401
+ }
402
+
403
+ TEST_CASE("hll sketch: updatable bytes serialize-deserialize-serialize set mode") {
404
+ test_allocator_total_bytes = 0;
405
+ {
406
+ hll_sketch_test_alloc s1(10, target_hll_type::HLL_4, false, 0);
407
+ for (int i = 0; i < 10; ++i) s1.update(i);
408
+ std::cout << s1.to_string();
409
+ auto bytes1 = s1.serialize_updatable();
410
+ auto s2 = hll_sketch_test_alloc::deserialize(bytes1.data(), bytes1.size(), 0);
411
+
412
+ auto bytes2 = s2.serialize_updatable();
413
+ REQUIRE(bytes1 == bytes2);
414
+ }
415
+ REQUIRE(test_allocator_total_bytes == 0);
416
+ }
417
+
418
+ TEST_CASE("hll sketch: compact bytes serialize-deserialize-serialize set mode") {
419
+ test_allocator_total_bytes = 0;
420
+ {
421
+ hll_sketch_test_alloc s1(10, target_hll_type::HLL_4, false, 0);
422
+ for (int i = 0; i < 10; ++i) s1.update(i);
423
+ std::cout << s1.to_string();
424
+ auto bytes1 = s1.serialize_compact();
425
+ auto s2 = hll_sketch_test_alloc::deserialize(bytes1.data(), bytes1.size(), 0);
426
+
427
+ // cannot just compare bytes here
428
+ // hash set does not preserve the order after reconstruction in compact mode
429
+ // add more to push them to HLL mode
430
+ for (int i = 10; i < 100; ++i) {
431
+ s1.update(i);
432
+ s2.update(i);
433
+ }
434
+ std::cout << s1.to_string();
435
+ std::cout << s2.to_string();
436
+
437
+ auto bytes2 = s1.serialize_compact();
438
+ auto bytes3 = s2.serialize_compact();
439
+ REQUIRE(bytes2 == bytes3);
440
+ }
441
+ REQUIRE(test_allocator_total_bytes == 0);
442
+ }
443
+
385
444
  } /* namespace datasketches */
@@ -19,12 +19,14 @@
19
19
 
20
20
  #include <catch.hpp>
21
21
  #include <sstream>
22
+ #include <stdexcept>
22
23
 
23
24
  #include "hll.hpp"
24
25
 
25
26
  namespace datasketches {
26
27
 
27
28
  static void println(std::string& str) {
29
+ unused(str);
28
30
  //std::cout << str << "\n";
29
31
  }
30
32
 
@@ -17,6 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
+ #include <stdexcept>
20
21
 
21
22
  #include <catch.hpp>
22
23
 
@@ -41,8 +41,4 @@ install(FILES
41
41
  include/kll_sketch_impl.hpp
42
42
  include/kll_helper.hpp
43
43
  include/kll_helper_impl.hpp
44
- include/kll_quantile_calculator.hpp
45
- include/kll_quantile_calculator_impl.hpp
46
- include/kolmogorov_smirnov.hpp
47
- include/kolmogorov_smirnov_impl.hpp
48
44
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/DataSketches")
@@ -22,13 +22,9 @@
22
22
 
23
23
  #include <random>
24
24
  #include <stdexcept>
25
- #include <chrono>
26
25
 
27
26
  namespace datasketches {
28
27
 
29
- static std::independent_bits_engine<std::mt19937, 1, uint32_t>
30
- random_bit(static_cast<uint32_t>(std::chrono::system_clock::now().time_since_epoch().count()));
31
-
32
28
  #ifdef KLL_VALIDATION
33
29
  extern uint32_t kll_next_offset;
34
30
  #endif
@@ -21,6 +21,9 @@
21
21
  #define KLL_HELPER_IMPL_HPP_
22
22
 
23
23
  #include <algorithm>
24
+ #include <stdexcept>
25
+
26
+ #include "common_defs.hpp"
24
27
 
25
28
  namespace datasketches {
26
29