datasketches 0.2.3 → 0.2.6
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 +12 -0
- data/README.md +8 -8
- data/ext/datasketches/kll_wrapper.cpp +7 -3
- data/ext/datasketches/theta_wrapper.cpp +20 -4
- data/lib/datasketches/version.rb +1 -1
- data/vendor/datasketches-cpp/CMakeLists.txt +25 -5
- data/vendor/datasketches-cpp/MANIFEST.in +3 -0
- data/vendor/datasketches-cpp/NOTICE +6 -5
- data/vendor/datasketches-cpp/README.md +76 -9
- data/vendor/datasketches-cpp/cmake/DataSketchesConfig.cmake.in +10 -0
- data/vendor/datasketches-cpp/common/CMakeLists.txt +18 -13
- data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +1 -0
- data/vendor/datasketches-cpp/common/include/common_defs.hpp +14 -0
- data/vendor/datasketches-cpp/{kll → common}/include/kolmogorov_smirnov.hpp +5 -3
- data/vendor/datasketches-cpp/{kll → common}/include/kolmogorov_smirnov_impl.hpp +13 -16
- data/vendor/datasketches-cpp/common/include/quantile_sketch_sorted_view.hpp +121 -0
- data/vendor/datasketches-cpp/common/include/quantile_sketch_sorted_view_impl.hpp +91 -0
- data/vendor/datasketches-cpp/common/test/test_type.hpp +2 -0
- data/vendor/datasketches-cpp/cpc/CMakeLists.txt +15 -35
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +3 -1
- data/vendor/datasketches-cpp/cpc/include/cpc_confidence.hpp +1 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +5 -3
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +10 -6
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_allocation_test.cpp +17 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +1 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +2 -0
- data/vendor/datasketches-cpp/fi/CMakeLists.txt +5 -15
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +37 -5
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +29 -11
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_custom_type_test.cpp +2 -1
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_test.cpp +1 -0
- data/vendor/datasketches-cpp/hll/CMakeLists.txt +33 -56
- data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +2 -0
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +1 -0
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +1 -0
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +6 -4
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +2 -0
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +2 -0
- data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +1 -0
- data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +1 -0
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +2 -0
- data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +1 -0
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +59 -0
- data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +2 -0
- data/vendor/datasketches-cpp/hll/test/TablesTest.cpp +1 -0
- data/vendor/datasketches-cpp/kll/CMakeLists.txt +5 -19
- data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +0 -4
- data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +5 -2
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +108 -41
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +150 -132
- data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +165 -31
- data/vendor/datasketches-cpp/kll/test/kolmogorov_smirnov_test.cpp +1 -1
- data/vendor/datasketches-cpp/pyproject.toml +1 -1
- data/vendor/datasketches-cpp/python/CMakeLists.txt +8 -1
- data/vendor/datasketches-cpp/python/README.md +13 -9
- data/vendor/datasketches-cpp/python/src/datasketches.cpp +4 -0
- data/vendor/datasketches-cpp/python/src/fi_wrapper.cpp +6 -1
- data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +48 -13
- data/vendor/datasketches-cpp/python/src/ks_wrapper.cpp +68 -0
- data/vendor/datasketches-cpp/python/src/quantiles_wrapper.cpp +240 -0
- data/vendor/datasketches-cpp/python/src/req_wrapper.cpp +9 -2
- data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +1 -0
- data/vendor/datasketches-cpp/python/tests/kll_test.py +10 -4
- data/vendor/datasketches-cpp/python/tests/quantiles_test.py +126 -0
- data/vendor/datasketches-cpp/quantiles/CMakeLists.txt +42 -0
- data/vendor/datasketches-cpp/quantiles/include/quantiles_sketch.hpp +656 -0
- data/vendor/datasketches-cpp/quantiles/include/quantiles_sketch_impl.hpp +1373 -0
- data/vendor/datasketches-cpp/quantiles/test/CMakeLists.txt +44 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.3.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.6.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.8.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.8.3.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.3.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.6.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.8.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.8.3.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/kolmogorov_smirnov_test.cpp +110 -0
- data/vendor/datasketches-cpp/quantiles/test/quantiles_compatibility_test.cpp +129 -0
- data/vendor/datasketches-cpp/quantiles/test/quantiles_sketch_test.cpp +975 -0
- data/vendor/datasketches-cpp/req/CMakeLists.txt +6 -21
- data/vendor/datasketches-cpp/req/include/req_common.hpp +0 -5
- data/vendor/datasketches-cpp/req/include/req_compactor.hpp +6 -0
- data/vendor/datasketches-cpp/req/include/req_compactor_impl.hpp +30 -2
- data/vendor/datasketches-cpp/req/include/req_sketch.hpp +73 -23
- data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +95 -63
- data/vendor/datasketches-cpp/req/test/req_sketch_test.cpp +74 -3
- data/vendor/datasketches-cpp/sampling/CMakeLists.txt +5 -9
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +44 -7
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +44 -33
- data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +41 -6
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +33 -15
- data/vendor/datasketches-cpp/sampling/test/var_opt_allocation_test.cpp +2 -2
- data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +1 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +1 -0
- data/vendor/datasketches-cpp/setup.py +1 -1
- data/vendor/datasketches-cpp/theta/CMakeLists.txt +26 -45
- data/vendor/datasketches-cpp/theta/include/bounds_on_ratios_in_sampled_sets.hpp +1 -0
- data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser_impl.hpp +92 -23
- data/vendor/datasketches-cpp/theta/include/theta_helpers.hpp +15 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection_base_impl.hpp +7 -6
- data/vendor/datasketches-cpp/theta/include/theta_set_difference_base_impl.hpp +3 -2
- data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +32 -15
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +150 -93
- data/vendor/datasketches-cpp/theta/include/theta_union.hpp +6 -1
- data/vendor/datasketches-cpp/theta/include/theta_union_base.hpp +3 -1
- data/vendor/datasketches-cpp/theta/include/theta_union_base_impl.hpp +9 -2
- data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +8 -5
- data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base.hpp +5 -4
- data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base_impl.hpp +34 -9
- data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +2 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v1.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v2.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v1.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v2.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_exact_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +2 -0
- data/vendor/datasketches-cpp/theta/test/theta_setop_test.cpp +446 -0
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +429 -1
- data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +25 -11
- data/vendor/datasketches-cpp/tuple/CMakeLists.txt +18 -33
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch.hpp +1 -1
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +3 -3
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union.hpp +1 -1
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union_impl.hpp +3 -3
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +29 -9
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +34 -14
- data/vendor/datasketches-cpp/tuple/include/tuple_union.hpp +6 -1
- data/vendor/datasketches-cpp/tuple/include/tuple_union_impl.hpp +8 -3
- data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +16 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +1 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +1 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +46 -8
- data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +8 -0
- metadata +33 -12
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +0 -75
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +0 -184
- data/vendor/datasketches-cpp/req/include/req_quantile_calculator.hpp +0 -69
- data/vendor/datasketches-cpp/req/include/req_quantile_calculator_impl.hpp +0 -60
- data/vendor/datasketches-cpp/theta/test/theta_update_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_update_estimation_from_java.sk +0 -0
|
@@ -32,64 +32,41 @@ target_include_directories(hll
|
|
|
32
32
|
target_link_libraries(hll INTERFACE common)
|
|
33
33
|
target_compile_features(hll INTERFACE cxx_std_11)
|
|
34
34
|
|
|
35
|
-
# TODO: would be useful if this didn't need to be reproduced in target_sources(), too
|
|
36
|
-
set(hll_HEADERS "")
|
|
37
|
-
list(APPEND hll_HEADERS "include/hll.hpp;include/AuxHashMap.hpp;include/CompositeInterpolationXTable.hpp")
|
|
38
|
-
list(APPEND hll_HEADERS "include/hll.private.hpp;include/HllSketchImplFactory.hpp")
|
|
39
|
-
list(APPEND hll_HEADERS "include/CouponHashSet.hpp;include/CouponList.hpp")
|
|
40
|
-
list(APPEND hll_HEADERS "include/CubicInterpolation.hpp;include/HarmonicNumbers.hpp;include/Hll4Array.hpp")
|
|
41
|
-
list(APPEND hll_HEADERS "include/Hll6Array.hpp;include/Hll8Array.hpp;include/HllArray.hpp")
|
|
42
|
-
list(APPEND hll_HEADERS "include/HllSketchImpl.hpp")
|
|
43
|
-
list(APPEND hll_HEADERS "include/HllUtil.hpp;include/coupon_iterator.hpp")
|
|
44
|
-
list(APPEND hll_HEADERS "include/RelativeErrorTables.hpp;include/AuxHashMap-internal.hpp")
|
|
45
|
-
list(APPEND hll_HEADERS "include/CompositeInterpolationXTable-internal.hpp")
|
|
46
|
-
list(APPEND hll_HEADERS "include/CouponHashSet-internal.hpp;include/CouponList-internal.hpp")
|
|
47
|
-
list(APPEND hll_HEADERS "include/CubicInterpolation-internal.hpp;include/HarmonicNumbers-internal.hpp")
|
|
48
|
-
list(APPEND hll_HEADERS "include/Hll4Array-internal.hpp;include/Hll6Array-internal.hpp")
|
|
49
|
-
list(APPEND hll_HEADERS "include/Hll8Array-internal.hpp;include/HllArray-internal.hpp")
|
|
50
|
-
list(APPEND hll_HEADERS "include/HllSketch-internal.hpp")
|
|
51
|
-
list(APPEND hll_HEADERS "include/HllSketchImpl-internal.hpp;include/HllUnion-internal.hpp")
|
|
52
|
-
list(APPEND hll_HEADERS "include/coupon_iterator-internal.hpp;include/RelativeErrorTables-internal.hpp")
|
|
53
|
-
|
|
54
35
|
install(TARGETS hll
|
|
55
36
|
EXPORT ${PROJECT_NAME}
|
|
56
37
|
)
|
|
57
38
|
|
|
58
|
-
install(FILES
|
|
39
|
+
install(FILES
|
|
40
|
+
include/hll.hpp
|
|
41
|
+
include/AuxHashMap.hpp
|
|
42
|
+
include/CompositeInterpolationXTable.hpp
|
|
43
|
+
include/hll.private.hpp
|
|
44
|
+
include/HllSketchImplFactory.hpp
|
|
45
|
+
include/CouponHashSet.hpp
|
|
46
|
+
include/CouponList.hpp
|
|
47
|
+
include/CubicInterpolation.hpp
|
|
48
|
+
include/HarmonicNumbers.hpp
|
|
49
|
+
include/Hll4Array.hpp
|
|
50
|
+
include/Hll6Array.hpp
|
|
51
|
+
include/Hll8Array.hpp
|
|
52
|
+
include/HllArray.hpp
|
|
53
|
+
include/HllSketchImpl.hpp
|
|
54
|
+
include/HllUtil.hpp
|
|
55
|
+
include/coupon_iterator.hpp
|
|
56
|
+
include/RelativeErrorTables.hpp
|
|
57
|
+
include/AuxHashMap-internal.hpp
|
|
58
|
+
include/CompositeInterpolationXTable-internal.hpp
|
|
59
|
+
include/CouponHashSet-internal.hpp
|
|
60
|
+
include/CouponList-internal.hpp
|
|
61
|
+
include/CubicInterpolation-internal.hpp
|
|
62
|
+
include/HarmonicNumbers-internal.hpp
|
|
63
|
+
include/Hll4Array-internal.hpp
|
|
64
|
+
include/Hll6Array-internal.hpp
|
|
65
|
+
include/Hll8Array-internal.hpp
|
|
66
|
+
include/HllArray-internal.hpp
|
|
67
|
+
include/HllSketch-internal.hpp
|
|
68
|
+
include/HllSketchImpl-internal.hpp
|
|
69
|
+
include/HllUnion-internal.hpp
|
|
70
|
+
include/coupon_iterator-internal.hpp
|
|
71
|
+
include/RelativeErrorTables-internal.hpp
|
|
59
72
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/DataSketches")
|
|
60
|
-
|
|
61
|
-
target_sources(hll
|
|
62
|
-
INTERFACE
|
|
63
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/hll.hpp
|
|
64
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/hll.private.hpp
|
|
65
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/AuxHashMap.hpp
|
|
66
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/CompositeInterpolationXTable.hpp
|
|
67
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/CouponHashSet.hpp
|
|
68
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/CouponList.hpp
|
|
69
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/CubicInterpolation.hpp
|
|
70
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HarmonicNumbers.hpp
|
|
71
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/Hll4Array.hpp
|
|
72
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/Hll6Array.hpp
|
|
73
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/Hll8Array.hpp
|
|
74
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HllArray.hpp
|
|
75
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HllSketchImpl.hpp
|
|
76
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HllSketchImplFactory.hpp
|
|
77
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HllUtil.hpp
|
|
78
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/RelativeErrorTables.hpp
|
|
79
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/coupon_iterator.hpp
|
|
80
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/AuxHashMap-internal.hpp
|
|
81
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/CompositeInterpolationXTable-internal.hpp
|
|
82
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/CouponHashSet-internal.hpp
|
|
83
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/CouponList-internal.hpp
|
|
84
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/CubicInterpolation-internal.hpp
|
|
85
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HarmonicNumbers-internal.hpp
|
|
86
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/Hll4Array-internal.hpp
|
|
87
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/Hll6Array-internal.hpp
|
|
88
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/Hll8Array-internal.hpp
|
|
89
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HllArray-internal.hpp
|
|
90
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HllSketch-internal.hpp
|
|
91
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HllSketchImpl-internal.hpp
|
|
92
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/HllUnion-internal.hpp
|
|
93
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/RelativeErrorTables-internal.hpp
|
|
94
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/coupon_iterator-internal.hpp
|
|
95
|
-
)
|
|
@@ -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
|
-
|
|
119
|
+
couponsInArray * sizeof(uint32_t));
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
return sketch;
|
|
@@ -246,10 +246,12 @@ string<A> hll_sketch_alloc<A>::to_string(const bool summary,
|
|
|
246
246
|
const bool detail,
|
|
247
247
|
const bool aux_detail,
|
|
248
248
|
const bool all) const {
|
|
249
|
-
|
|
249
|
+
// Using a temporary stream for implementation here does not comply with AllocatorAwareContainer requirements.
|
|
250
|
+
// The stream does not support passing an allocator instance, and alternatives are complicated.
|
|
251
|
+
std::stringstream os;
|
|
250
252
|
if (summary) {
|
|
251
253
|
os << "### HLL sketch summary:" << std::endl
|
|
252
|
-
<< " Log Config K : " << get_lg_config_k() << std::endl
|
|
254
|
+
<< " Log Config K : " << std::to_string(get_lg_config_k()) << std::endl
|
|
253
255
|
<< " Hll Target : " << type_as_string() << std::endl
|
|
254
256
|
<< " Current Mode : " << mode_as_string() << std::endl
|
|
255
257
|
<< " LB : " << get_lower_bound(1) << std::endl
|
|
@@ -258,7 +260,7 @@ string<A> hll_sketch_alloc<A>::to_string(const bool summary,
|
|
|
258
260
|
<< " OutOfOrder flag: " << (is_out_of_order_flag() ? "true" : "false") << std::endl;
|
|
259
261
|
if (get_current_mode() == HLL) {
|
|
260
262
|
HllArray<A>* hllArray = (HllArray<A>*) sketch_impl;
|
|
261
|
-
os << " CurMin : " << hllArray->getCurMin() << std::endl
|
|
263
|
+
os << " CurMin : " << std::to_string(hllArray->getCurMin()) << std::endl
|
|
262
264
|
<< " NumAtCurMin : " << hllArray->getNumAtCurMin() << std::endl
|
|
263
265
|
<< " HipAccum : " << hllArray->getHipAccum() << std::endl
|
|
264
266
|
<< " KxQ0 : " << hllArray->getKxQ0() << std::endl
|
|
@@ -338,7 +340,7 @@ string<A> hll_sketch_alloc<A>::to_string(const bool summary,
|
|
|
338
340
|
}
|
|
339
341
|
}
|
|
340
342
|
|
|
341
|
-
return os.str();
|
|
343
|
+
return string<A>(os.str().c_str(), sketch_impl->getAllocator());
|
|
342
344
|
}
|
|
343
345
|
|
|
344
346
|
template<typename A>
|
|
@@ -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
|
|
|
@@ -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 */
|
|
@@ -32,27 +32,13 @@ target_include_directories(kll
|
|
|
32
32
|
target_link_libraries(kll INTERFACE common)
|
|
33
33
|
target_compile_features(kll INTERFACE cxx_std_11)
|
|
34
34
|
|
|
35
|
-
set(kll_HEADERS "")
|
|
36
|
-
list(APPEND kll_HEADERS "include/kll_sketch.hpp")
|
|
37
|
-
list(APPEND kll_HEADERS "include/kll_sketch_impl.hpp")
|
|
38
|
-
list(APPEND kll_HEADERS "include/kll_helper.hpp")
|
|
39
|
-
list(APPEND kll_HEADERS "include/kll_helper_impl.hpp")
|
|
40
|
-
list(APPEND kll_HEADERS "include/kll_quantile_calculator.hpp")
|
|
41
|
-
list(APPEND kll_HEADERS "include/kll_quantile_calculator_impl.hpp")
|
|
42
|
-
|
|
43
35
|
install(TARGETS kll
|
|
44
36
|
EXPORT ${PROJECT_NAME}
|
|
45
37
|
)
|
|
46
38
|
|
|
47
|
-
install(FILES
|
|
39
|
+
install(FILES
|
|
40
|
+
include/kll_sketch.hpp
|
|
41
|
+
include/kll_sketch_impl.hpp
|
|
42
|
+
include/kll_helper.hpp
|
|
43
|
+
include/kll_helper_impl.hpp
|
|
48
44
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/DataSketches")
|
|
49
|
-
|
|
50
|
-
target_sources(kll
|
|
51
|
-
INTERFACE
|
|
52
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/kll_helper.hpp
|
|
53
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/kll_helper_impl.hpp
|
|
54
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/kll_sketch.hpp
|
|
55
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/kll_sketch_impl.hpp
|
|
56
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/kll_quantile_calculator.hpp
|
|
57
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/kll_quantile_calculator_impl.hpp
|
|
58
|
-
)
|
|
@@ -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
|
|
|
@@ -227,7 +230,7 @@ kll_helper::compress_result kll_helper::general_compress(uint16_t k, uint8_t m,
|
|
|
227
230
|
// move level over as is
|
|
228
231
|
// make sure we are not moving data upwards
|
|
229
232
|
if (raw_beg < out_levels[current_level]) throw std::logic_error("wrong move");
|
|
230
|
-
std::move(
|
|
233
|
+
std::move(items + raw_beg, items + raw_lim, items + out_levels[current_level]);
|
|
231
234
|
out_levels[current_level + 1] = out_levels[current_level] + raw_pop;
|
|
232
235
|
} else {
|
|
233
236
|
// The sketch is too full AND this level is too full, so we compact it
|
|
@@ -248,7 +251,7 @@ kll_helper::compress_result kll_helper::general_compress(uint16_t k, uint8_t m,
|
|
|
248
251
|
|
|
249
252
|
// level zero might not be sorted, so we must sort it if we wish to compact it
|
|
250
253
|
if ((current_level == 0) && !is_level_zero_sorted) {
|
|
251
|
-
std::sort(
|
|
254
|
+
std::sort(items + adj_beg, items + adj_beg + adj_pop, C());
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
if (pop_above == 0) { // Level above is empty, so halve up
|