datasketches 0.1.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/LICENSE +40 -3
- data/NOTICE +1 -1
- 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 +10 -0
- data/vendor/datasketches-cpp/LICENSE +40 -3
- data/vendor/datasketches-cpp/NOTICE +1 -1
- data/vendor/datasketches-cpp/README.md +4 -4
- data/vendor/datasketches-cpp/common/include/MurmurHash3.h +18 -7
- data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +8 -8
- data/vendor/datasketches-cpp/common/include/bounds_binomial_proportions.hpp +12 -15
- data/vendor/datasketches-cpp/common/include/common_defs.hpp +26 -0
- data/vendor/datasketches-cpp/common/include/conditional_forward.hpp +20 -8
- data/vendor/datasketches-cpp/common/include/count_zeros.hpp +2 -2
- data/vendor/datasketches-cpp/common/include/memory_operations.hpp +12 -0
- data/vendor/datasketches-cpp/common/include/serde.hpp +7 -7
- 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 +13 -3
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor.hpp +20 -20
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +116 -105
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +22 -6
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +140 -101
- data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +2 -2
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +20 -20
- data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +10 -16
- data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +6 -6
- data/vendor/datasketches-cpp/cpc/include/u32_table.hpp +10 -10
- data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +21 -21
- data/vendor/datasketches-cpp/cpc/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/cpc/test/compression_test.cpp +10 -10
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_allocation_test.cpp +237 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +25 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +1 -1
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +15 -10
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +102 -105
- 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 +141 -125
- 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 +5 -5
- data/vendor/datasketches-cpp/hll/CMakeLists.txt +3 -0
- data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +81 -109
- data/vendor/datasketches-cpp/hll/include/AuxHashMap.hpp +25 -24
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +15 -15
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable.hpp +5 -5
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +89 -105
- data/vendor/datasketches-cpp/hll/include/CouponHashSet.hpp +13 -13
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +130 -165
- data/vendor/datasketches-cpp/hll/include/CouponList.hpp +21 -22
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation-internal.hpp +2 -4
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers-internal.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +88 -83
- data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +9 -9
- data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +34 -45
- data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +7 -8
- data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +41 -52
- data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +7 -8
- data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +220 -251
- data/vendor/datasketches-cpp/hll/include/HllArray.hpp +42 -42
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +36 -38
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +22 -22
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +15 -14
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +47 -44
- data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +62 -87
- data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +121 -128
- data/vendor/datasketches-cpp/hll/include/RelativeErrorTables.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/coupon_iterator-internal.hpp +9 -9
- data/vendor/datasketches-cpp/hll/include/coupon_iterator.hpp +5 -5
- data/vendor/datasketches-cpp/hll/include/hll.hpp +25 -53
- data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +8 -8
- data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +36 -36
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +28 -28
- data/vendor/datasketches-cpp/hll/test/CrossCountingTest.cpp +2 -2
- data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +37 -37
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +57 -61
- data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +10 -14
- data/vendor/datasketches-cpp/hll/test/IsomorphicTest.cpp +3 -3
- data/vendor/datasketches-cpp/hll/test/ToFromByteArrayTest.cpp +4 -4
- data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +5 -4
- data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +6 -6
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +14 -6
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +40 -25
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +50 -6
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +164 -136
- data/vendor/datasketches-cpp/kll/include/kolmogorov_smirnov.hpp +67 -0
- data/vendor/datasketches-cpp/kll/include/kolmogorov_smirnov_impl.hpp +78 -0
- data/vendor/datasketches-cpp/kll/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_custom_type_test.cpp +11 -10
- data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +178 -88
- data/vendor/datasketches-cpp/kll/test/kolmogorov_smirnov_test.cpp +111 -0
- data/vendor/datasketches-cpp/pyproject.toml +4 -2
- data/vendor/datasketches-cpp/python/CMakeLists.txt +12 -6
- data/vendor/datasketches-cpp/python/README.md +52 -49
- data/vendor/datasketches-cpp/python/pybind11Path.cmd +3 -0
- data/vendor/datasketches-cpp/python/src/cpc_wrapper.cpp +1 -1
- data/vendor/datasketches-cpp/python/src/datasketches.cpp +2 -0
- data/vendor/datasketches-cpp/python/src/hll_wrapper.cpp +4 -6
- data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +4 -2
- data/vendor/datasketches-cpp/python/src/req_wrapper.cpp +246 -0
- data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +38 -28
- data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +11 -5
- data/vendor/datasketches-cpp/python/src/vo_wrapper.cpp +2 -2
- data/vendor/datasketches-cpp/python/tests/hll_test.py +1 -2
- data/vendor/datasketches-cpp/python/tests/kll_test.py +5 -5
- 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/python/tests/vector_of_kll_test.py +4 -4
- data/vendor/datasketches-cpp/python/tests/vo_test.py +3 -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} +18 -8
- data/vendor/datasketches-cpp/req/include/req_compactor.hpp +137 -0
- data/vendor/datasketches-cpp/req/include/req_compactor_impl.hpp +488 -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 +19 -13
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +130 -127
- data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +5 -5
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +41 -49
- 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_sketch_test.cpp +6 -6
- data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +13 -44
- data/vendor/datasketches-cpp/setup.py +11 -6
- data/vendor/datasketches-cpp/theta/CMakeLists.txt +30 -3
- data/vendor/datasketches-cpp/{tuple → theta}/include/bounds_on_ratios_in_sampled_sets.hpp +3 -2
- data/vendor/datasketches-cpp/{tuple → theta}/include/bounds_on_ratios_in_theta_sketched_sets.hpp +1 -1
- data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser.hpp +67 -0
- data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser_impl.hpp +70 -0
- 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 +11 -4
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_helpers.hpp +0 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection.hpp +26 -28
- 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} +24 -36
- 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 +163 -256
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +250 -651
- 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 +6 -1
- data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +13 -69
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_update_sketch_base.hpp +10 -21
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_update_sketch_base_impl.hpp +44 -30
- data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +23 -1
- data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +21 -1
- data/vendor/datasketches-cpp/{tuple → theta}/test/theta_jaccard_similarity_test.cpp +60 -5
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +74 -235
- data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +22 -2
- data/vendor/datasketches-cpp/tuple/CMakeLists.txt +3 -35
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +47 -60
- 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 +57 -70
- data/vendor/datasketches-cpp/tuple/test/CMakeLists.txt +1 -6
- data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +1 -1
- data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +18 -21
- data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +13 -16
- data/vendor/datasketches-cpp/tuple/test/tuple_jaccard_similarity_test.cpp +7 -6
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_allocation_test.cpp +3 -3
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +20 -20
- data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +13 -16
- metadata +51 -36
- 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
@@ -23,6 +23,7 @@
|
|
23
23
|
#include "CouponList.hpp"
|
24
24
|
#include "CubicInterpolation.hpp"
|
25
25
|
#include "HllUtil.hpp"
|
26
|
+
#include "count_zeros.hpp"
|
26
27
|
|
27
28
|
#include <algorithm>
|
28
29
|
#include <cmath>
|
@@ -30,161 +31,134 @@
|
|
30
31
|
namespace datasketches {
|
31
32
|
|
32
33
|
template<typename A>
|
33
|
-
CouponList<A>::CouponList(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
40
|
-
oooFlag = false;
|
41
|
-
const int arrayLen = 1 << lgCouponArrInts;
|
42
|
-
typedef typename std::allocator_traits<A>::template rebind_alloc<int> intAlloc;
|
43
|
-
couponIntArr = intAlloc().allocate(arrayLen);
|
44
|
-
std::fill(couponIntArr, couponIntArr + arrayLen, 0);
|
45
|
-
couponCount = 0;
|
46
|
-
}
|
47
|
-
|
48
|
-
template<typename A>
|
49
|
-
CouponList<A>::CouponList(const CouponList& that)
|
50
|
-
: HllSketchImpl<A>(that.lgConfigK, that.tgtHllType, that.mode, false),
|
51
|
-
lgCouponArrInts(that.lgCouponArrInts),
|
52
|
-
couponCount(that.couponCount),
|
53
|
-
oooFlag(that.oooFlag) {
|
54
|
-
|
55
|
-
const int numItems = 1 << lgCouponArrInts;
|
56
|
-
typedef typename std::allocator_traits<A>::template rebind_alloc<int> intAlloc;
|
57
|
-
couponIntArr = intAlloc().allocate(numItems);
|
58
|
-
std::copy(that.couponIntArr, that.couponIntArr + numItems, couponIntArr);
|
59
|
-
}
|
60
|
-
|
61
|
-
template<typename A>
|
62
|
-
CouponList<A>::CouponList(const CouponList& that, const target_hll_type tgtHllType)
|
63
|
-
: HllSketchImpl<A>(that.lgConfigK, tgtHllType, that.mode, false),
|
64
|
-
lgCouponArrInts(that.lgCouponArrInts),
|
65
|
-
couponCount(that.couponCount),
|
66
|
-
oooFlag(that.oooFlag) {
|
67
|
-
|
68
|
-
const int numItems = 1 << lgCouponArrInts;
|
69
|
-
typedef typename std::allocator_traits<A>::template rebind_alloc<int> intAlloc;
|
70
|
-
couponIntArr = intAlloc().allocate(numItems);
|
71
|
-
std::copy(that.couponIntArr, that.couponIntArr + numItems, couponIntArr);
|
72
|
-
}
|
34
|
+
CouponList<A>::CouponList(uint8_t lgConfigK, target_hll_type tgtHllType, hll_mode mode, const A& allocator):
|
35
|
+
HllSketchImpl<A>(lgConfigK, tgtHllType, mode, false),
|
36
|
+
couponCount_(0),
|
37
|
+
oooFlag_(false),
|
38
|
+
coupons_(1ULL << (mode == hll_mode::LIST ? hll_constants::LG_INIT_LIST_SIZE : hll_constants::LG_INIT_SET_SIZE), 0, allocator)
|
39
|
+
{}
|
73
40
|
|
74
41
|
template<typename A>
|
75
|
-
CouponList<A
|
76
|
-
|
77
|
-
|
78
|
-
|
42
|
+
CouponList<A>::CouponList(const CouponList& that, const target_hll_type tgtHllType):
|
43
|
+
HllSketchImpl<A>(that.lgConfigK_, tgtHllType, that.mode_, false),
|
44
|
+
couponCount_(that.couponCount_),
|
45
|
+
oooFlag_(that.oooFlag_),
|
46
|
+
coupons_(that.coupons_)
|
47
|
+
{}
|
79
48
|
|
80
49
|
template<typename A>
|
81
50
|
std::function<void(HllSketchImpl<A>*)> CouponList<A>::get_deleter() const {
|
82
51
|
return [](HllSketchImpl<A>* ptr) {
|
83
52
|
CouponList<A>* cl = static_cast<CouponList<A>*>(ptr);
|
53
|
+
ClAlloc cla(cl->getAllocator());
|
84
54
|
cl->~CouponList();
|
85
|
-
|
55
|
+
cla.deallocate(cl, 1);
|
86
56
|
};
|
87
57
|
}
|
88
58
|
|
89
59
|
template<typename A>
|
90
60
|
CouponList<A>* CouponList<A>::copy() const {
|
91
|
-
|
61
|
+
ClAlloc cla(coupons_.get_allocator());
|
62
|
+
return new (cla.allocate(1)) CouponList<A>(*this);
|
92
63
|
}
|
93
64
|
|
94
65
|
template<typename A>
|
95
66
|
CouponList<A>* CouponList<A>::copyAs(target_hll_type tgtHllType) const {
|
96
|
-
|
67
|
+
ClAlloc cla(coupons_.get_allocator());
|
68
|
+
return new (cla.allocate(1)) CouponList<A>(*this, tgtHllType);
|
97
69
|
}
|
98
70
|
|
99
71
|
template<typename A>
|
100
|
-
CouponList<A>* CouponList<A>::newList(const void* bytes, size_t len) {
|
101
|
-
if (len <
|
72
|
+
CouponList<A>* CouponList<A>::newList(const void* bytes, size_t len, const A& allocator) {
|
73
|
+
if (len < hll_constants::LIST_INT_ARR_START) {
|
102
74
|
throw std::out_of_range("Input data length insufficient to hold CouponHashSet");
|
103
75
|
}
|
104
76
|
|
105
77
|
const uint8_t* data = static_cast<const uint8_t*>(bytes);
|
106
|
-
if (data[
|
78
|
+
if (data[hll_constants::PREAMBLE_INTS_BYTE] != hll_constants::LIST_PREINTS) {
|
107
79
|
throw std::invalid_argument("Incorrect number of preInts in input stream");
|
108
80
|
}
|
109
|
-
if (data[
|
81
|
+
if (data[hll_constants::SER_VER_BYTE] != hll_constants::SER_VER) {
|
110
82
|
throw std::invalid_argument("Wrong ser ver in input stream");
|
111
83
|
}
|
112
|
-
if (data[
|
84
|
+
if (data[hll_constants::FAMILY_BYTE] != hll_constants::FAMILY_ID) {
|
113
85
|
throw std::invalid_argument("Input stream is not an HLL sketch");
|
114
86
|
}
|
115
87
|
|
116
|
-
hll_mode mode = HllSketchImpl<A>::extractCurMode(data[
|
88
|
+
hll_mode mode = HllSketchImpl<A>::extractCurMode(data[hll_constants::MODE_BYTE]);
|
117
89
|
if (mode != LIST) {
|
118
|
-
throw std::invalid_argument("Calling
|
90
|
+
throw std::invalid_argument("Calling list constructor with non-list mode data");
|
119
91
|
}
|
120
92
|
|
121
|
-
target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[
|
93
|
+
target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[hll_constants::MODE_BYTE]);
|
122
94
|
|
123
|
-
const
|
124
|
-
const bool compact = ((data[
|
125
|
-
const bool oooFlag = ((data[
|
126
|
-
const bool emptyFlag = ((data[
|
95
|
+
const uint8_t lgK = data[hll_constants::LG_K_BYTE];
|
96
|
+
const bool compact = ((data[hll_constants::FLAGS_BYTE] & hll_constants::COMPACT_FLAG_MASK) ? true : false);
|
97
|
+
const bool oooFlag = ((data[hll_constants::FLAGS_BYTE] & hll_constants::OUT_OF_ORDER_FLAG_MASK) ? true : false);
|
98
|
+
const bool emptyFlag = ((data[hll_constants::FLAGS_BYTE] & hll_constants::EMPTY_FLAG_MASK) ? true : false);
|
127
99
|
|
128
|
-
const
|
129
|
-
const
|
130
|
-
const size_t expectedLength =
|
100
|
+
const uint32_t couponCount = data[hll_constants::LIST_COUNT_BYTE];
|
101
|
+
const uint32_t couponsInArray = (compact ? couponCount : (1 << HllUtil<A>::computeLgArrInts(LIST, couponCount, lgK)));
|
102
|
+
const size_t expectedLength = hll_constants::LIST_INT_ARR_START + (couponsInArray * sizeof(uint32_t));
|
131
103
|
if (len < expectedLength) {
|
132
104
|
throw std::out_of_range("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
|
133
105
|
+ ", found: " + std::to_string(len));
|
134
106
|
}
|
135
107
|
|
136
|
-
|
137
|
-
sketch
|
108
|
+
ClAlloc cla(allocator);
|
109
|
+
CouponList<A>* sketch = new (cla.allocate(1)) CouponList<A>(lgK, tgtHllType, mode, allocator);
|
110
|
+
sketch->couponCount_ = couponCount;
|
138
111
|
sketch->putOutOfOrderFlag(oooFlag); // should always be false for LIST
|
139
112
|
|
140
113
|
if (!emptyFlag) {
|
141
114
|
// only need to read valid coupons, unlike in stream case
|
142
|
-
std::memcpy(sketch->
|
115
|
+
std::memcpy(sketch->coupons_.data(), data + hll_constants::LIST_INT_ARR_START, couponCount * sizeof(uint32_t));
|
143
116
|
}
|
144
117
|
|
145
118
|
return sketch;
|
146
119
|
}
|
147
120
|
|
148
121
|
template<typename A>
|
149
|
-
CouponList<A>* CouponList<A>::newList(std::istream& is) {
|
122
|
+
CouponList<A>* CouponList<A>::newList(std::istream& is, const A& allocator) {
|
150
123
|
uint8_t listHeader[8];
|
151
|
-
|
124
|
+
read(is, listHeader, 8 * sizeof(uint8_t));
|
152
125
|
|
153
|
-
if (listHeader[
|
126
|
+
if (listHeader[hll_constants::PREAMBLE_INTS_BYTE] != hll_constants::LIST_PREINTS) {
|
154
127
|
throw std::invalid_argument("Incorrect number of preInts in input stream");
|
155
128
|
}
|
156
|
-
if (listHeader[
|
129
|
+
if (listHeader[hll_constants::SER_VER_BYTE] != hll_constants::SER_VER) {
|
157
130
|
throw std::invalid_argument("Wrong ser ver in input stream");
|
158
131
|
}
|
159
|
-
if (listHeader[
|
132
|
+
if (listHeader[hll_constants::FAMILY_BYTE] != hll_constants::FAMILY_ID) {
|
160
133
|
throw std::invalid_argument("Input stream is not an HLL sketch");
|
161
134
|
}
|
162
135
|
|
163
|
-
hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[
|
136
|
+
hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[hll_constants::MODE_BYTE]);
|
164
137
|
if (mode != LIST) {
|
165
|
-
throw std::invalid_argument("Calling list
|
138
|
+
throw std::invalid_argument("Calling list constructor with non-list mode data");
|
166
139
|
}
|
167
140
|
|
168
|
-
const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[
|
141
|
+
const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[hll_constants::MODE_BYTE]);
|
169
142
|
|
170
|
-
const
|
171
|
-
const bool compact = ((listHeader[
|
172
|
-
const bool oooFlag = ((listHeader[
|
173
|
-
const bool emptyFlag = ((listHeader[
|
143
|
+
const uint8_t lgK = listHeader[hll_constants::LG_K_BYTE];
|
144
|
+
const bool compact = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::COMPACT_FLAG_MASK) ? true : false);
|
145
|
+
const bool oooFlag = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::OUT_OF_ORDER_FLAG_MASK) ? true : false);
|
146
|
+
const bool emptyFlag = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::EMPTY_FLAG_MASK) ? true : false);
|
174
147
|
|
175
|
-
|
176
|
-
|
148
|
+
ClAlloc cla(allocator);
|
149
|
+
CouponList<A>* sketch = new (cla.allocate(1)) CouponList<A>(lgK, tgtHllType, mode, allocator);
|
150
|
+
using coupon_list_ptr = std::unique_ptr<CouponList<A>, std::function<void(HllSketchImpl<A>*)>>;
|
177
151
|
coupon_list_ptr ptr(sketch, sketch->get_deleter());
|
178
|
-
const
|
179
|
-
sketch->
|
152
|
+
const uint32_t couponCount = listHeader[hll_constants::LIST_COUNT_BYTE];
|
153
|
+
sketch->couponCount_ = couponCount;
|
180
154
|
sketch->putOutOfOrderFlag(oooFlag); // should always be false for LIST
|
181
155
|
|
182
156
|
if (!emptyFlag) {
|
183
157
|
// For stream processing, need to read entire number written to stream so read
|
184
158
|
// pointer ends up set correctly.
|
185
159
|
// If not compact, still need to read empty items even though in order.
|
186
|
-
const
|
187
|
-
is.
|
160
|
+
const uint32_t numToRead = (compact ? couponCount : static_cast<uint32_t>(sketch->coupons_.size()));
|
161
|
+
read(is, sketch->coupons_.data(), numToRead * sizeof(uint32_t));
|
188
162
|
}
|
189
163
|
|
190
164
|
if (!is.good())
|
@@ -196,20 +170,20 @@ CouponList<A>* CouponList<A>::newList(std::istream& is) {
|
|
196
170
|
template<typename A>
|
197
171
|
vector_u8<A> CouponList<A>::serialize(bool compact, unsigned header_size_bytes) const {
|
198
172
|
const size_t sketchSizeBytes = (compact ? getCompactSerializationBytes() : getUpdatableSerializationBytes()) + header_size_bytes;
|
199
|
-
vector_u8<A> byteArr(sketchSizeBytes);
|
173
|
+
vector_u8<A> byteArr(sketchSizeBytes, 0, getAllocator());
|
200
174
|
uint8_t* bytes = byteArr.data() + header_size_bytes;
|
201
175
|
|
202
|
-
bytes[
|
203
|
-
bytes[
|
204
|
-
bytes[
|
205
|
-
bytes[
|
206
|
-
bytes[
|
207
|
-
bytes[
|
208
|
-
bytes[
|
209
|
-
bytes[
|
210
|
-
|
211
|
-
if (this->
|
212
|
-
std::memcpy(bytes +
|
176
|
+
bytes[hll_constants::PREAMBLE_INTS_BYTE] = static_cast<uint8_t>(getPreInts());
|
177
|
+
bytes[hll_constants::SER_VER_BYTE] = static_cast<uint8_t>(hll_constants::SER_VER);
|
178
|
+
bytes[hll_constants::FAMILY_BYTE] = static_cast<uint8_t>(hll_constants::FAMILY_ID);
|
179
|
+
bytes[hll_constants::LG_K_BYTE] = static_cast<uint8_t>(this->lgConfigK_);
|
180
|
+
bytes[hll_constants::LG_ARR_BYTE] = count_trailing_zeros_in_u32(static_cast<uint32_t>(coupons_.size()));
|
181
|
+
bytes[hll_constants::FLAGS_BYTE] = this->makeFlagsByte(compact);
|
182
|
+
bytes[hll_constants::LIST_COUNT_BYTE] = static_cast<uint8_t>(this->mode_ == LIST ? couponCount_ : 0);
|
183
|
+
bytes[hll_constants::MODE_BYTE] = this->makeModeByte();
|
184
|
+
|
185
|
+
if (this->mode_ == SET) {
|
186
|
+
std::memcpy(bytes + hll_constants::HASH_SET_COUNT_INT, &couponCount_, sizeof(couponCount_));
|
213
187
|
}
|
214
188
|
|
215
189
|
// coupons
|
@@ -217,12 +191,12 @@ vector_u8<A> CouponList<A>::serialize(bool compact, unsigned header_size_bytes)
|
|
217
191
|
const int sw = (isCompact() ? 2 : 0) | (compact ? 1 : 0);
|
218
192
|
switch (sw) {
|
219
193
|
case 0: { // src updatable, dst updatable
|
220
|
-
std::memcpy(bytes + getMemDataStart(),
|
194
|
+
std::memcpy(bytes + getMemDataStart(), coupons_.data(), coupons_.size() * sizeof(uint32_t));
|
221
195
|
break;
|
222
196
|
}
|
223
197
|
case 1: { // src updatable, dst compact
|
224
198
|
bytes += getMemDataStart(); // reusing pointer for incremental writes
|
225
|
-
for (uint32_t coupon: *this) {
|
199
|
+
for (const uint32_t coupon: *this) {
|
226
200
|
std::memcpy(bytes, &coupon, sizeof(coupon));
|
227
201
|
bytes += sizeof(coupon);
|
228
202
|
}
|
@@ -239,33 +213,33 @@ vector_u8<A> CouponList<A>::serialize(bool compact, unsigned header_size_bytes)
|
|
239
213
|
template<typename A>
|
240
214
|
void CouponList<A>::serialize(std::ostream& os, const bool compact) const {
|
241
215
|
// header
|
242
|
-
const uint8_t preInts
|
243
|
-
|
244
|
-
const uint8_t serialVersion(
|
245
|
-
|
246
|
-
const uint8_t familyId(
|
247
|
-
|
248
|
-
const uint8_t lgKByte
|
249
|
-
|
250
|
-
const uint8_t lgArrIntsByte((
|
251
|
-
|
252
|
-
const uint8_t flagsByte
|
253
|
-
|
254
|
-
|
255
|
-
if (this->
|
256
|
-
const uint8_t listCount(
|
257
|
-
|
216
|
+
const uint8_t preInts = getPreInts();
|
217
|
+
write(os, preInts);
|
218
|
+
const uint8_t serialVersion(hll_constants::SER_VER);
|
219
|
+
write(os, serialVersion);
|
220
|
+
const uint8_t familyId(hll_constants::FAMILY_ID);
|
221
|
+
write(os, familyId);
|
222
|
+
const uint8_t lgKByte = this->lgConfigK_;
|
223
|
+
write(os, lgKByte);
|
224
|
+
const uint8_t lgArrIntsByte = count_trailing_zeros_in_u32(static_cast<uint32_t>(coupons_.size()));
|
225
|
+
write(os, lgArrIntsByte);
|
226
|
+
const uint8_t flagsByte = this->makeFlagsByte(compact);
|
227
|
+
write(os, flagsByte);
|
228
|
+
|
229
|
+
if (this->mode_ == LIST) {
|
230
|
+
const uint8_t listCount = static_cast<uint8_t>(couponCount_);
|
231
|
+
write(os, listCount);
|
258
232
|
} else { // mode == SET
|
259
|
-
|
260
|
-
|
233
|
+
const uint8_t unused = 0;
|
234
|
+
write(os, unused);
|
261
235
|
}
|
262
236
|
|
263
|
-
const uint8_t modeByte
|
264
|
-
|
237
|
+
const uint8_t modeByte = this->makeModeByte();
|
238
|
+
write(os, modeByte);
|
265
239
|
|
266
|
-
if (this->
|
240
|
+
if (this->mode_ == SET) {
|
267
241
|
// writing as int, already stored as int
|
268
|
-
|
242
|
+
write(os, couponCount_);
|
269
243
|
}
|
270
244
|
|
271
245
|
// coupons
|
@@ -273,12 +247,12 @@ void CouponList<A>::serialize(std::ostream& os, const bool compact) const {
|
|
273
247
|
const int sw = (isCompact() ? 2 : 0) | (compact ? 1 : 0);
|
274
248
|
switch (sw) {
|
275
249
|
case 0: { // src updatable, dst updatable
|
276
|
-
os.
|
250
|
+
write(os, coupons_.data(), coupons_.size() * sizeof(uint32_t));
|
277
251
|
break;
|
278
252
|
}
|
279
253
|
case 1: { // src updatable, dst compact
|
280
|
-
for (uint32_t coupon: *this) {
|
281
|
-
|
254
|
+
for (const uint32_t coupon: *this) {
|
255
|
+
write(os, coupon);
|
282
256
|
}
|
283
257
|
break;
|
284
258
|
}
|
@@ -291,15 +265,14 @@ void CouponList<A>::serialize(std::ostream& os, const bool compact) const {
|
|
291
265
|
}
|
292
266
|
|
293
267
|
template<typename A>
|
294
|
-
HllSketchImpl<A>* CouponList<A>::couponUpdate(
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
if (this->lgConfigK < 8) {
|
268
|
+
HllSketchImpl<A>* CouponList<A>::couponUpdate(uint32_t coupon) {
|
269
|
+
for (size_t i = 0; i < coupons_.size(); ++i) { // search for empty slot
|
270
|
+
const uint32_t couponAtIdx = coupons_[i];
|
271
|
+
if (couponAtIdx == hll_constants::EMPTY) {
|
272
|
+
coupons_[i] = coupon; // the actual update
|
273
|
+
++couponCount_;
|
274
|
+
if (couponCount_ == static_cast<uint32_t>(coupons_.size())) { // array full
|
275
|
+
if (this->lgConfigK_ < 8) {
|
303
276
|
return promoteHeapListOrSetToHll(*this);
|
304
277
|
}
|
305
278
|
return promoteHeapListToSet(*this);
|
@@ -320,76 +293,68 @@ double CouponList<A>::getCompositeEstimate() const { return getEstimate(); }
|
|
320
293
|
|
321
294
|
template<typename A>
|
322
295
|
double CouponList<A>::getEstimate() const {
|
323
|
-
const
|
324
|
-
|
325
|
-
return fmax(est, couponCount);
|
296
|
+
const double est = CubicInterpolation<A>::usingXAndYTables(couponCount_);
|
297
|
+
return fmax(est, couponCount_);
|
326
298
|
}
|
327
299
|
|
328
300
|
template<typename A>
|
329
|
-
double CouponList<A>::getLowerBound(
|
301
|
+
double CouponList<A>::getLowerBound(uint8_t numStdDev) const {
|
330
302
|
HllUtil<A>::checkNumStdDev(numStdDev);
|
331
|
-
const
|
332
|
-
const double
|
333
|
-
|
334
|
-
return fmax(tmp, couponCount);
|
303
|
+
const double est = CubicInterpolation<A>::usingXAndYTables(couponCount_);
|
304
|
+
const double tmp = est / (1.0 + (numStdDev * hll_constants::COUPON_RSE));
|
305
|
+
return fmax(tmp, couponCount_);
|
335
306
|
}
|
336
307
|
|
337
308
|
template<typename A>
|
338
|
-
double CouponList<A>::getUpperBound(
|
309
|
+
double CouponList<A>::getUpperBound(uint8_t numStdDev) const {
|
339
310
|
HllUtil<A>::checkNumStdDev(numStdDev);
|
340
|
-
const
|
341
|
-
const double
|
342
|
-
|
343
|
-
return fmax(tmp, couponCount);
|
311
|
+
const double est = CubicInterpolation<A>::usingXAndYTables(couponCount_);
|
312
|
+
const double tmp = est / (1.0 - (numStdDev * hll_constants::COUPON_RSE));
|
313
|
+
return fmax(tmp, couponCount_);
|
344
314
|
}
|
345
315
|
|
346
316
|
template<typename A>
|
347
317
|
bool CouponList<A>::isEmpty() const { return getCouponCount() == 0; }
|
348
318
|
|
349
319
|
template<typename A>
|
350
|
-
|
351
|
-
return getMemDataStart() + (
|
320
|
+
uint32_t CouponList<A>::getUpdatableSerializationBytes() const {
|
321
|
+
return getMemDataStart() + static_cast<uint32_t>(coupons_.size()) * sizeof(uint32_t);
|
352
322
|
}
|
353
323
|
|
354
324
|
template<typename A>
|
355
|
-
|
356
|
-
return
|
325
|
+
uint32_t CouponList<A>::getCouponCount() const {
|
326
|
+
return couponCount_;
|
357
327
|
}
|
358
328
|
|
359
329
|
template<typename A>
|
360
|
-
|
361
|
-
return getMemDataStart() + (
|
330
|
+
uint32_t CouponList<A>::getCompactSerializationBytes() const {
|
331
|
+
return getMemDataStart() + (couponCount_ << 2);
|
362
332
|
}
|
363
333
|
|
364
334
|
template<typename A>
|
365
|
-
|
366
|
-
return
|
335
|
+
uint32_t CouponList<A>::getMemDataStart() const {
|
336
|
+
return hll_constants::LIST_INT_ARR_START;
|
367
337
|
}
|
368
338
|
|
369
339
|
template<typename A>
|
370
|
-
|
371
|
-
return
|
340
|
+
uint8_t CouponList<A>::getPreInts() const {
|
341
|
+
return hll_constants::LIST_PREINTS;
|
372
342
|
}
|
373
343
|
|
374
344
|
template<typename A>
|
375
345
|
bool CouponList<A>::isCompact() const { return false; }
|
376
346
|
|
377
347
|
template<typename A>
|
378
|
-
bool CouponList<A>::isOutOfOrderFlag() const { return
|
348
|
+
bool CouponList<A>::isOutOfOrderFlag() const { return oooFlag_; }
|
379
349
|
|
380
350
|
template<typename A>
|
381
351
|
void CouponList<A>::putOutOfOrderFlag(bool oooFlag) {
|
382
|
-
|
383
|
-
}
|
384
|
-
|
385
|
-
template<typename A>
|
386
|
-
int CouponList<A>::getLgCouponArrInts() const {
|
387
|
-
return lgCouponArrInts;
|
352
|
+
oooFlag_ = oooFlag;
|
388
353
|
}
|
389
354
|
|
390
355
|
template<typename A>
|
391
|
-
|
392
|
-
return
|
356
|
+
A CouponList<A>::getAllocator() const {
|
357
|
+
return coupons_.get_allocator();
|
393
358
|
}
|
394
359
|
|
395
360
|
template<typename A>
|
@@ -404,12 +369,12 @@ HllSketchImpl<A>* CouponList<A>::promoteHeapListOrSetToHll(CouponList& src) {
|
|
404
369
|
|
405
370
|
template<typename A>
|
406
371
|
coupon_iterator<A> CouponList<A>::begin(bool all) const {
|
407
|
-
return coupon_iterator<A>(
|
372
|
+
return coupon_iterator<A>(coupons_.data(), coupons_.size(), 0, all);
|
408
373
|
}
|
409
374
|
|
410
375
|
template<typename A>
|
411
376
|
coupon_iterator<A> CouponList<A>::end() const {
|
412
|
-
return coupon_iterator<A>(
|
377
|
+
return coupon_iterator<A>(coupons_.data(), coupons_.size(), coupons_.size(), false);
|
413
378
|
}
|
414
379
|
|
415
380
|
}
|
@@ -30,58 +30,57 @@ namespace datasketches {
|
|
30
30
|
template<typename A>
|
31
31
|
class HllSketchImplFactory;
|
32
32
|
|
33
|
-
template<typename A
|
33
|
+
template<typename A>
|
34
34
|
class CouponList : public HllSketchImpl<A> {
|
35
35
|
public:
|
36
|
-
|
37
|
-
|
38
|
-
explicit CouponList(const CouponList& that, target_hll_type tgtHllType);
|
36
|
+
CouponList(uint8_t lgConfigK, target_hll_type tgtHllType, hll_mode mode, const A& allocator);
|
37
|
+
CouponList(const CouponList& that, target_hll_type tgtHllType);
|
39
38
|
|
40
|
-
static CouponList* newList(const void* bytes, size_t len);
|
41
|
-
static CouponList* newList(std::istream& is);
|
39
|
+
static CouponList* newList(const void* bytes, size_t len, const A& allocator);
|
40
|
+
static CouponList* newList(std::istream& is, const A& allocator);
|
42
41
|
virtual vector_u8<A> serialize(bool compact, unsigned header_size_bytes) const;
|
43
42
|
virtual void serialize(std::ostream& os, bool compact) const;
|
44
43
|
|
45
|
-
virtual ~CouponList();
|
44
|
+
virtual ~CouponList() = default;
|
46
45
|
virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const;
|
47
46
|
|
48
47
|
virtual CouponList* copy() const;
|
49
48
|
virtual CouponList* copyAs(target_hll_type tgtHllType) const;
|
50
49
|
|
51
|
-
virtual HllSketchImpl<A>* couponUpdate(
|
50
|
+
virtual HllSketchImpl<A>* couponUpdate(uint32_t coupon);
|
52
51
|
|
53
52
|
virtual double getEstimate() const;
|
54
53
|
virtual double getCompositeEstimate() const;
|
55
|
-
virtual double getUpperBound(
|
56
|
-
virtual double getLowerBound(
|
54
|
+
virtual double getUpperBound(uint8_t numStdDev) const;
|
55
|
+
virtual double getLowerBound(uint8_t numStdDev) const;
|
57
56
|
|
58
57
|
virtual bool isEmpty() const;
|
59
|
-
virtual
|
58
|
+
virtual uint32_t getCouponCount() const;
|
60
59
|
|
61
60
|
coupon_iterator<A> begin(bool all = false) const;
|
62
61
|
coupon_iterator<A> end() const;
|
63
62
|
|
64
63
|
protected:
|
65
|
-
|
64
|
+
using ClAlloc = typename std::allocator_traits<A>::template rebind_alloc<CouponList<A>>;
|
65
|
+
|
66
|
+
using vector_int = std::vector<uint32_t, typename std::allocator_traits<A>::template rebind_alloc<uint32_t>>;
|
66
67
|
|
67
68
|
HllSketchImpl<A>* promoteHeapListToSet(CouponList& list);
|
68
69
|
HllSketchImpl<A>* promoteHeapListOrSetToHll(CouponList& src);
|
69
70
|
|
70
|
-
virtual
|
71
|
-
virtual
|
72
|
-
virtual
|
73
|
-
virtual
|
71
|
+
virtual uint32_t getUpdatableSerializationBytes() const;
|
72
|
+
virtual uint32_t getCompactSerializationBytes() const;
|
73
|
+
virtual uint32_t getMemDataStart() const;
|
74
|
+
virtual uint8_t getPreInts() const;
|
74
75
|
virtual bool isCompact() const;
|
75
76
|
virtual bool isOutOfOrderFlag() const;
|
76
77
|
virtual void putOutOfOrderFlag(bool oooFlag);
|
77
78
|
|
78
|
-
virtual
|
79
|
-
virtual int* getCouponIntArr() const;
|
79
|
+
virtual A getAllocator() const;
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
int* couponIntArr;
|
81
|
+
uint32_t couponCount_;
|
82
|
+
bool oooFlag_;
|
83
|
+
vector_int coupons_;
|
85
84
|
|
86
85
|
friend class HllSketchImplFactory<A>;
|
87
86
|
};
|
@@ -102,10 +102,8 @@ double CubicInterpolation<A>::usingXAndYTables(const double xArr[], const double
|
|
102
102
|
else if (offset == numEntries-2) { // corner case
|
103
103
|
return (interpolateUsingXAndYTables<A>(xArr, yArr, (offset-2), x));
|
104
104
|
}
|
105
|
-
|
106
|
-
|
107
|
-
}
|
108
|
-
throw std::logic_error("Exception should be unreachable");
|
105
|
+
// main case
|
106
|
+
return (interpolateUsingXAndYTables<A>(xArr, yArr, (offset-1), x));
|
109
107
|
}
|
110
108
|
|
111
109
|
// In C: again-two-registers cubic_interpolate_aux L1368
|
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
namespace datasketches {
|
26
26
|
|
27
|
-
template<typename A = std::allocator<
|
27
|
+
template<typename A = std::allocator<uint8_t>>
|
28
28
|
class CubicInterpolation {
|
29
29
|
public:
|
30
30
|
static double usingXAndYTables(const double xArr[], const double yArr[],
|
@@ -40,4 +40,4 @@ class CubicInterpolation {
|
|
40
40
|
|
41
41
|
#include "CubicInterpolation-internal.hpp"
|
42
42
|
|
43
|
-
#endif /* _CUBICINTERPOLATION_HPP_ */
|
43
|
+
#endif /* _CUBICINTERPOLATION_HPP_ */
|
@@ -68,7 +68,7 @@ double HarmonicNumbers<A>::harmonicNumber(const uint64_t x_i) {
|
|
68
68
|
if (x_i < NUM_EXACT_HARMONIC_NUMBERS) {
|
69
69
|
return tableOfExactHarmonicNumbers[x_i];
|
70
70
|
} else {
|
71
|
-
double x = x_i;
|
71
|
+
double x = static_cast<double>(x_i);
|
72
72
|
double invSq = 1.0 / (x * x);
|
73
73
|
double sum = log(x) + EULER_MASCHERONI_CONSTANT + (1.0 / (2.0 * x));
|
74
74
|
/* note: the number of terms included from this series expansion is appropriate
|
@@ -25,7 +25,7 @@
|
|
25
25
|
|
26
26
|
namespace datasketches {
|
27
27
|
|
28
|
-
template<typename A = std::allocator<
|
28
|
+
template<typename A = std::allocator<uint8_t>>
|
29
29
|
class HarmonicNumbers {
|
30
30
|
public:
|
31
31
|
/**
|
@@ -45,4 +45,4 @@ class HarmonicNumbers {
|
|
45
45
|
|
46
46
|
#include "HarmonicNumbers-internal.hpp"
|
47
47
|
|
48
|
-
#endif /* _HARMONICNUMBERS_HPP_ */
|
48
|
+
#endif /* _HARMONICNUMBERS_HPP_ */
|