datasketches 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -31,7 +31,7 @@ class Hll4Iterator;
|
|
31
31
|
template<typename A>
|
32
32
|
class Hll4Array final : public HllArray<A> {
|
33
33
|
public:
|
34
|
-
explicit Hll4Array(int lgConfigK, bool startFullSize);
|
34
|
+
explicit Hll4Array(int lgConfigK, bool startFullSize, const A& allocator);
|
35
35
|
explicit Hll4Array(const Hll4Array<A>& that);
|
36
36
|
|
37
37
|
virtual ~Hll4Array();
|
@@ -27,40 +27,29 @@
|
|
27
27
|
namespace datasketches {
|
28
28
|
|
29
29
|
template<typename A>
|
30
|
-
Hll6Array<A>::Hll6Array(const int lgConfigK, const bool startFullSize)
|
31
|
-
|
32
|
-
const int numBytes = this->hll6ArrBytes(lgConfigK);
|
33
|
-
typedef typename std::allocator_traits<A>::template rebind_alloc<uint8_t> uint8Alloc;
|
34
|
-
this->hllByteArr = uint8Alloc().allocate(numBytes);
|
35
|
-
std::fill(this->hllByteArr, this->hllByteArr + numBytes, 0);
|
36
|
-
}
|
37
|
-
|
38
|
-
template<typename A>
|
39
|
-
Hll6Array<A>::Hll6Array(const Hll6Array<A>& that) :
|
40
|
-
HllArray<A>(that)
|
30
|
+
Hll6Array<A>::Hll6Array(const int lgConfigK, const bool startFullSize, const A& allocator):
|
31
|
+
HllArray<A>(lgConfigK, target_hll_type::HLL_6, startFullSize, allocator)
|
41
32
|
{
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
template<typename A>
|
46
|
-
Hll6Array<A>::~Hll6Array() {
|
47
|
-
// hllByteArr deleted in parent
|
33
|
+
const int numBytes = this->hll6ArrBytes(lgConfigK);
|
34
|
+
this->hllByteArr.resize(numBytes, 0);
|
48
35
|
}
|
49
36
|
|
50
37
|
template<typename A>
|
51
38
|
std::function<void(HllSketchImpl<A>*)> Hll6Array<A>::get_deleter() const {
|
52
39
|
return [](HllSketchImpl<A>* ptr) {
|
53
|
-
|
40
|
+
using Hll6Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll6Array<A>>;
|
54
41
|
Hll6Array<A>* hll = static_cast<Hll6Array<A>*>(ptr);
|
42
|
+
Hll6Alloc hll6Alloc(hll->getAllocator());
|
55
43
|
hll->~Hll6Array();
|
56
|
-
hll6Alloc
|
44
|
+
hll6Alloc.deallocate(hll, 1);
|
57
45
|
};
|
58
46
|
}
|
59
47
|
|
60
48
|
template<typename A>
|
61
49
|
Hll6Array<A>* Hll6Array<A>::copy() const {
|
62
|
-
|
63
|
-
|
50
|
+
using Hll6Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll6Array<A>>;
|
51
|
+
Hll6Alloc hll6Alloc(this->getAllocator());
|
52
|
+
return new (hll6Alloc.allocate(1)) Hll6Array<A>(*this);
|
64
53
|
}
|
65
54
|
|
66
55
|
template<typename A>
|
@@ -30,10 +30,9 @@ class Hll6Iterator;
|
|
30
30
|
template<typename A>
|
31
31
|
class Hll6Array final : public HllArray<A> {
|
32
32
|
public:
|
33
|
-
|
34
|
-
explicit Hll6Array(const Hll6Array<A>& that);
|
33
|
+
Hll6Array(int lgConfigK, bool startFullSize, const A& allocator);
|
35
34
|
|
36
|
-
virtual ~Hll6Array();
|
35
|
+
virtual ~Hll6Array() = default;
|
37
36
|
virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const;
|
38
37
|
|
39
38
|
virtual Hll6Array* copy() const;
|
@@ -25,40 +25,29 @@
|
|
25
25
|
namespace datasketches {
|
26
26
|
|
27
27
|
template<typename A>
|
28
|
-
Hll8Array<A>::Hll8Array(const int lgConfigK, const bool startFullSize)
|
29
|
-
|
30
|
-
const int numBytes = this->hll8ArrBytes(lgConfigK);
|
31
|
-
typedef typename std::allocator_traits<A>::template rebind_alloc<uint8_t> uint8Alloc;
|
32
|
-
this->hllByteArr = uint8Alloc().allocate(numBytes);
|
33
|
-
std::fill(this->hllByteArr, this->hllByteArr + numBytes, 0);
|
34
|
-
}
|
35
|
-
|
36
|
-
template<typename A>
|
37
|
-
Hll8Array<A>::Hll8Array(const Hll8Array<A>& that) :
|
38
|
-
HllArray<A>(that)
|
28
|
+
Hll8Array<A>::Hll8Array(const int lgConfigK, const bool startFullSize, const A& allocator):
|
29
|
+
HllArray<A>(lgConfigK, target_hll_type::HLL_8, startFullSize, allocator)
|
39
30
|
{
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
template<typename A>
|
44
|
-
Hll8Array<A>::~Hll8Array() {
|
45
|
-
// hllByteArr deleted in parent
|
31
|
+
const int numBytes = this->hll8ArrBytes(lgConfigK);
|
32
|
+
this->hllByteArr.resize(numBytes, 0);
|
46
33
|
}
|
47
34
|
|
48
35
|
template<typename A>
|
49
36
|
std::function<void(HllSketchImpl<A>*)> Hll8Array<A>::get_deleter() const {
|
50
37
|
return [](HllSketchImpl<A>* ptr) {
|
51
|
-
typedef typename std::allocator_traits<A>::template rebind_alloc<Hll8Array<A>> hll8Alloc;
|
52
38
|
Hll8Array<A>* hll = static_cast<Hll8Array<A>*>(ptr);
|
39
|
+
using Hll8Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll8Array<A>>;
|
40
|
+
Hll8Alloc hll8Alloc(hll->getAllocator());
|
53
41
|
hll->~Hll8Array();
|
54
|
-
hll8Alloc
|
42
|
+
hll8Alloc.deallocate(hll, 1);
|
55
43
|
};
|
56
44
|
}
|
57
45
|
|
58
46
|
template<typename A>
|
59
47
|
Hll8Array<A>* Hll8Array<A>::copy() const {
|
60
|
-
|
61
|
-
|
48
|
+
using Hll8Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll8Array<A>>;
|
49
|
+
Hll8Alloc hll8Alloc(this->getAllocator());
|
50
|
+
return new (hll8Alloc.allocate(1)) Hll8Array<A>(*this);
|
62
51
|
}
|
63
52
|
|
64
53
|
template<typename A>
|
@@ -30,10 +30,9 @@ class Hll8Iterator;
|
|
30
30
|
template<typename A>
|
31
31
|
class Hll8Array final : public HllArray<A> {
|
32
32
|
public:
|
33
|
-
|
34
|
-
explicit Hll8Array(const Hll8Array& that);
|
33
|
+
Hll8Array(int lgConfigK, bool startFullSize, const A& allocator);
|
35
34
|
|
36
|
-
virtual ~Hll8Array();
|
35
|
+
virtual ~Hll8Array() = default;
|
37
36
|
virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const;
|
38
37
|
|
39
38
|
virtual Hll8Array<A>* copy() const;
|
@@ -35,48 +35,16 @@
|
|
35
35
|
namespace datasketches {
|
36
36
|
|
37
37
|
template<typename A>
|
38
|
-
HllArray<A>::HllArray(const int lgConfigK, const target_hll_type tgtHllType, bool startFullSize)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
template<typename A>
|
50
|
-
HllArray<A>::HllArray(const HllArray<A>& that):
|
51
|
-
HllSketchImpl<A>(that.lgConfigK, that.tgtHllType, hll_mode::HLL, that.startFullSize),
|
52
|
-
hipAccum(that.hipAccum),
|
53
|
-
kxq0(that.kxq0),
|
54
|
-
kxq1(that.kxq1),
|
55
|
-
hllByteArr(nullptr),
|
56
|
-
curMin(that.curMin),
|
57
|
-
numAtCurMin(that.numAtCurMin),
|
58
|
-
oooFlag(that.oooFlag)
|
59
|
-
{
|
60
|
-
const int arrayLen = that.getHllByteArrBytes();
|
61
|
-
typedef typename std::allocator_traits<A>::template rebind_alloc<uint8_t> uint8Alloc;
|
62
|
-
hllByteArr = uint8Alloc().allocate(arrayLen);
|
63
|
-
std::copy(that.hllByteArr, that.hllByteArr + arrayLen, hllByteArr);
|
64
|
-
}
|
65
|
-
|
66
|
-
template<typename A>
|
67
|
-
HllArray<A>::~HllArray() {
|
68
|
-
// need to determine number of bytes to deallocate
|
69
|
-
int hllArrBytes = 0;
|
70
|
-
if (this->tgtHllType == target_hll_type::HLL_4) {
|
71
|
-
hllArrBytes = hll4ArrBytes(this->lgConfigK);
|
72
|
-
} else if (this->tgtHllType == target_hll_type::HLL_6) {
|
73
|
-
hllArrBytes = hll6ArrBytes(this->lgConfigK);
|
74
|
-
} else { // tgtHllType == HLL_8
|
75
|
-
hllArrBytes = hll8ArrBytes(this->lgConfigK);
|
76
|
-
}
|
77
|
-
typedef typename std::allocator_traits<A>::template rebind_alloc<uint8_t> uint8Alloc;
|
78
|
-
uint8Alloc().deallocate(hllByteArr, hllArrBytes);
|
79
|
-
}
|
38
|
+
HllArray<A>::HllArray(const int lgConfigK, const target_hll_type tgtHllType, bool startFullSize, const A& allocator):
|
39
|
+
HllSketchImpl<A>(lgConfigK, tgtHllType, hll_mode::HLL, startFullSize),
|
40
|
+
hipAccum(0.0),
|
41
|
+
kxq0(1 << lgConfigK),
|
42
|
+
kxq1(0.0),
|
43
|
+
hllByteArr(allocator),
|
44
|
+
curMin(0),
|
45
|
+
numAtCurMin(1 << lgConfigK),
|
46
|
+
oooFlag(false)
|
47
|
+
{}
|
80
48
|
|
81
49
|
template<typename A>
|
82
50
|
HllArray<A>* HllArray<A>::copyAs(const target_hll_type tgtHllType) const {
|
@@ -93,7 +61,7 @@ HllArray<A>* HllArray<A>::copyAs(const target_hll_type tgtHllType) const {
|
|
93
61
|
}
|
94
62
|
|
95
63
|
template<typename A>
|
96
|
-
HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len) {
|
64
|
+
HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len, const A& allocator) {
|
97
65
|
if (len < HllUtil<A>::HLL_BYTE_ARR_START) {
|
98
66
|
throw std::out_of_range("Input data length insufficient to hold HLL array");
|
99
67
|
}
|
@@ -143,11 +111,11 @@ HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len) {
|
|
143
111
|
int auxLgIntArrSize = (int) data[4];
|
144
112
|
const size_t offset = HllUtil<A>::HLL_BYTE_ARR_START + arrayBytes;
|
145
113
|
const uint8_t* auxDataStart = data + offset;
|
146
|
-
auxHashMap = AuxHashMap<A>::deserialize(auxDataStart, len - offset, lgK, auxCount, auxLgIntArrSize, comapctFlag);
|
114
|
+
auxHashMap = AuxHashMap<A>::deserialize(auxDataStart, len - offset, lgK, auxCount, auxLgIntArrSize, comapctFlag, allocator);
|
147
115
|
aux_ptr = aux_hash_map_ptr(auxHashMap, auxHashMap->make_deleter());
|
148
116
|
}
|
149
117
|
|
150
|
-
HllArray<A>* sketch = HllSketchImplFactory<A>::newHll(lgK, tgtHllType, startFullSizeFlag);
|
118
|
+
HllArray<A>* sketch = HllSketchImplFactory<A>::newHll(lgK, tgtHllType, startFullSizeFlag, allocator);
|
151
119
|
sketch->putCurMin(curMin);
|
152
120
|
sketch->putOutOfOrderFlag(oooFlag);
|
153
121
|
if (!oooFlag) sketch->putHipAccum(hip);
|
@@ -155,7 +123,7 @@ HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len) {
|
|
155
123
|
sketch->putKxQ1(kxq1);
|
156
124
|
sketch->putNumAtCurMin(numAtCurMin);
|
157
125
|
|
158
|
-
std::memcpy(sketch->hllByteArr, data + HllUtil<A>::HLL_BYTE_ARR_START, arrayBytes);
|
126
|
+
std::memcpy(sketch->hllByteArr.data(), data + HllUtil<A>::HLL_BYTE_ARR_START, arrayBytes);
|
159
127
|
|
160
128
|
if (auxHashMap != nullptr)
|
161
129
|
((Hll4Array<A>*)sketch)->putAuxHashMap(auxHashMap);
|
@@ -165,7 +133,7 @@ HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len) {
|
|
165
133
|
}
|
166
134
|
|
167
135
|
template<typename A>
|
168
|
-
HllArray<A>* HllArray<A>::newHll(std::istream& is) {
|
136
|
+
HllArray<A>* HllArray<A>::newHll(std::istream& is, const A& allocator) {
|
169
137
|
uint8_t listHeader[8];
|
170
138
|
is.read((char*)listHeader, 8 * sizeof(uint8_t));
|
171
139
|
|
@@ -192,7 +160,7 @@ HllArray<A>* HllArray<A>::newHll(std::istream& is) {
|
|
192
160
|
const int lgK = (int) listHeader[HllUtil<A>::LG_K_BYTE];
|
193
161
|
const int curMin = (int) listHeader[HllUtil<A>::HLL_CUR_MIN_BYTE];
|
194
162
|
|
195
|
-
HllArray* sketch = HllSketchImplFactory<A>::newHll(lgK, tgtHllType, startFullSizeFlag);
|
163
|
+
HllArray* sketch = HllSketchImplFactory<A>::newHll(lgK, tgtHllType, startFullSizeFlag, allocator);
|
196
164
|
typedef std::unique_ptr<HllArray<A>, std::function<void(HllSketchImpl<A>*)>> hll_array_ptr;
|
197
165
|
hll_array_ptr sketch_ptr(sketch, sketch->get_deleter());
|
198
166
|
sketch->putCurMin(curMin);
|
@@ -211,11 +179,11 @@ HllArray<A>* HllArray<A>::newHll(std::istream& is) {
|
|
211
179
|
is.read((char*)&auxCount, sizeof(auxCount));
|
212
180
|
sketch->putNumAtCurMin(numAtCurMin);
|
213
181
|
|
214
|
-
is.read((char*)sketch->hllByteArr, sketch->getHllByteArrBytes());
|
182
|
+
is.read((char*)sketch->hllByteArr.data(), sketch->getHllByteArrBytes());
|
215
183
|
|
216
184
|
if (auxCount > 0) { // necessarily TgtHllType == HLL_4
|
217
185
|
int auxLgIntArrSize = listHeader[4];
|
218
|
-
AuxHashMap<A>* auxHashMap = AuxHashMap<A>::deserialize(is, lgK, auxCount, auxLgIntArrSize, comapctFlag);
|
186
|
+
AuxHashMap<A>* auxHashMap = AuxHashMap<A>::deserialize(is, lgK, auxCount, auxLgIntArrSize, comapctFlag, allocator);
|
219
187
|
((Hll4Array<A>*)sketch)->putAuxHashMap(auxHashMap);
|
220
188
|
}
|
221
189
|
|
@@ -228,7 +196,7 @@ HllArray<A>* HllArray<A>::newHll(std::istream& is) {
|
|
228
196
|
template<typename A>
|
229
197
|
vector_u8<A> HllArray<A>::serialize(bool compact, unsigned header_size_bytes) const {
|
230
198
|
const size_t sketchSizeBytes = (compact ? getCompactSerializationBytes() : getUpdatableSerializationBytes()) + header_size_bytes;
|
231
|
-
vector_u8<A> byteArr(sketchSizeBytes);
|
199
|
+
vector_u8<A> byteArr(sketchSizeBytes, 0, getAllocator());
|
232
200
|
uint8_t* bytes = byteArr.data() + header_size_bytes;
|
233
201
|
AuxHashMap<A>* auxHashMap = getAuxHashMap();
|
234
202
|
|
@@ -249,7 +217,7 @@ vector_u8<A> HllArray<A>::serialize(bool compact, unsigned header_size_bytes) co
|
|
249
217
|
std::memcpy(bytes + HllUtil<A>::AUX_COUNT_INT, &auxCount, sizeof(int));
|
250
218
|
|
251
219
|
const int hllByteArrBytes = getHllByteArrBytes();
|
252
|
-
std::memcpy(bytes + getMemDataStart(), hllByteArr, hllByteArrBytes);
|
220
|
+
std::memcpy(bytes + getMemDataStart(), hllByteArr.data(), hllByteArrBytes);
|
253
221
|
|
254
222
|
// aux map if HLL_4
|
255
223
|
if (this->tgtHllType == HLL_4) {
|
@@ -309,7 +277,7 @@ void HllArray<A>::serialize(std::ostream& os, const bool compact) const {
|
|
309
277
|
|
310
278
|
const int auxCount = (auxHashMap == nullptr ? 0 : auxHashMap->getAuxCount());
|
311
279
|
os.write((char*)&auxCount, sizeof(auxCount));
|
312
|
-
os.write((char*)hllByteArr, getHllByteArrBytes());
|
280
|
+
os.write((char*)hllByteArr.data(), getHllByteArrBytes());
|
313
281
|
|
314
282
|
// aux map if HLL_4
|
315
283
|
if (this->tgtHllType == HLL_4) {
|
@@ -639,12 +607,12 @@ double HllArray<A>::getHllRawEstimate(const int lgConfigK, const double kxqSum)
|
|
639
607
|
|
640
608
|
template<typename A>
|
641
609
|
typename HllArray<A>::const_iterator HllArray<A>::begin(bool all) const {
|
642
|
-
return const_iterator(hllByteArr, 1 << this->lgConfigK, 0, this->tgtHllType, nullptr, 0, all);
|
610
|
+
return const_iterator(hllByteArr.data(), 1 << this->lgConfigK, 0, this->tgtHllType, nullptr, 0, all);
|
643
611
|
}
|
644
612
|
|
645
613
|
template<typename A>
|
646
614
|
typename HllArray<A>::const_iterator HllArray<A>::end() const {
|
647
|
-
return const_iterator(hllByteArr, 1 << this->lgConfigK, 1 << this->lgConfigK, this->tgtHllType, nullptr, 0, false);
|
615
|
+
return const_iterator(hllByteArr.data(), 1 << this->lgConfigK, 1 << this->lgConfigK, this->tgtHllType, nullptr, 0, false);
|
648
616
|
}
|
649
617
|
|
650
618
|
template<typename A>
|
@@ -701,6 +669,11 @@ uint8_t HllArray<A>::const_iterator::get_value(const uint8_t* array, size_t inde
|
|
701
669
|
return array[index];
|
702
670
|
}
|
703
671
|
|
672
|
+
template<typename A>
|
673
|
+
A HllArray<A>::getAllocator() const {
|
674
|
+
return hllByteArr.get_allocator();
|
675
|
+
}
|
676
|
+
|
704
677
|
}
|
705
678
|
|
706
679
|
#endif // _HLLARRAY_INTERNAL_HPP_
|
@@ -28,19 +28,18 @@ namespace datasketches {
|
|
28
28
|
template<typename A>
|
29
29
|
class AuxHashMap;
|
30
30
|
|
31
|
-
template<typename A
|
31
|
+
template<typename A>
|
32
32
|
class HllArray : public HllSketchImpl<A> {
|
33
33
|
public:
|
34
|
-
|
35
|
-
explicit HllArray(const HllArray<A>& that);
|
34
|
+
HllArray(int lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator);
|
36
35
|
|
37
|
-
static HllArray* newHll(const void* bytes, size_t len);
|
38
|
-
static HllArray* newHll(std::istream& is);
|
36
|
+
static HllArray* newHll(const void* bytes, size_t len, const A& allocator);
|
37
|
+
static HllArray* newHll(std::istream& is, const A& allocator);
|
39
38
|
|
40
39
|
virtual vector_u8<A> serialize(bool compact, unsigned header_size_bytes) const;
|
41
40
|
virtual void serialize(std::ostream& os, bool compact) const;
|
42
41
|
|
43
|
-
virtual ~HllArray();
|
42
|
+
virtual ~HllArray() = default;
|
44
43
|
virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const = 0;
|
45
44
|
|
46
45
|
virtual HllArray* copy() const = 0;
|
@@ -95,6 +94,8 @@ class HllArray : public HllSketchImpl<A> {
|
|
95
94
|
virtual const_iterator begin(bool all = false) const;
|
96
95
|
virtual const_iterator end() const;
|
97
96
|
|
97
|
+
virtual A getAllocator() const;
|
98
|
+
|
98
99
|
protected:
|
99
100
|
void hipAndKxQIncrementalUpdate(uint8_t oldValue, uint8_t newValue);
|
100
101
|
double getHllBitMapEstimate(int lgConfigK, int curMin, int numAtCurMin) const;
|
@@ -103,7 +104,7 @@ class HllArray : public HllSketchImpl<A> {
|
|
103
104
|
double hipAccum;
|
104
105
|
double kxq0;
|
105
106
|
double kxq1;
|
106
|
-
|
107
|
+
vector_u8<A> hllByteArr; //init by sub-classes
|
107
108
|
int curMin; //always zero for Hll6 and Hll8, only tracked by Hll4Array
|
108
109
|
int numAtCurMin; //interpreted as num zeros when curMin == 0
|
109
110
|
bool oooFlag; //Out-Of-Order Flag
|
@@ -115,7 +116,6 @@ template<typename A>
|
|
115
116
|
class HllArray<A>::const_iterator: public std::iterator<std::input_iterator_tag, uint32_t> {
|
116
117
|
public:
|
117
118
|
const_iterator(const uint8_t* array, size_t array_slze, size_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset, bool all);
|
118
|
-
//const_iterator(const uint8_t* array, size_t array_slze, size_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset);
|
119
119
|
const_iterator& operator++();
|
120
120
|
bool operator!=(const const_iterator& other) const;
|
121
121
|
uint32_t operator*() const;
|
@@ -42,28 +42,26 @@ typedef union {
|
|
42
42
|
} longDoubleUnion;
|
43
43
|
|
44
44
|
template<typename A>
|
45
|
-
hll_sketch_alloc<A>::hll_sketch_alloc(int lg_config_k, target_hll_type tgt_type, bool start_full_size) {
|
45
|
+
hll_sketch_alloc<A>::hll_sketch_alloc(int lg_config_k, target_hll_type tgt_type, bool start_full_size, const A& allocator) {
|
46
46
|
HllUtil<A>::checkLgK(lg_config_k);
|
47
47
|
if (start_full_size) {
|
48
|
-
sketch_impl = HllSketchImplFactory<A>::newHll(lg_config_k, tgt_type, start_full_size);
|
48
|
+
sketch_impl = HllSketchImplFactory<A>::newHll(lg_config_k, tgt_type, start_full_size, allocator);
|
49
49
|
} else {
|
50
50
|
typedef typename std::allocator_traits<A>::template rebind_alloc<CouponList<A>> clAlloc;
|
51
|
-
sketch_impl = new (clAlloc().allocate(1)) CouponList<A>(lg_config_k, tgt_type, hll_mode::LIST);
|
51
|
+
sketch_impl = new (clAlloc(allocator).allocate(1)) CouponList<A>(lg_config_k, tgt_type, hll_mode::LIST, allocator);
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
55
55
|
template<typename A>
|
56
|
-
hll_sketch_alloc<A> hll_sketch_alloc<A>::deserialize(std::istream& is) {
|
57
|
-
HllSketchImpl<A>* impl = HllSketchImplFactory<A>::deserialize(is);
|
58
|
-
hll_sketch_alloc<A>
|
59
|
-
return sketch;
|
56
|
+
hll_sketch_alloc<A> hll_sketch_alloc<A>::deserialize(std::istream& is, const A& allocator) {
|
57
|
+
HllSketchImpl<A>* impl = HllSketchImplFactory<A>::deserialize(is, allocator);
|
58
|
+
return hll_sketch_alloc<A>(impl);
|
60
59
|
}
|
61
60
|
|
62
61
|
template<typename A>
|
63
|
-
hll_sketch_alloc<A> hll_sketch_alloc<A>::deserialize(const void* bytes, size_t len) {
|
64
|
-
HllSketchImpl<A>* impl = HllSketchImplFactory<A>::deserialize(bytes, len);
|
65
|
-
hll_sketch_alloc<A>
|
66
|
-
return sketch;
|
62
|
+
hll_sketch_alloc<A> hll_sketch_alloc<A>::deserialize(const void* bytes, size_t len, const A& allocator) {
|
63
|
+
HllSketchImpl<A>* impl = HllSketchImplFactory<A>::deserialize(bytes, len, allocator);
|
64
|
+
return hll_sketch_alloc<A>(impl);
|
67
65
|
}
|
68
66
|
|
69
67
|
template<typename A>
|
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
namespace datasketches {
|
29
29
|
|
30
|
-
template<typename A
|
30
|
+
template<typename A>
|
31
31
|
class HllSketchImpl {
|
32
32
|
public:
|
33
33
|
HllSketchImpl(int lgConfigK, target_hll_type tgtHllType, hll_mode mode, bool startFullSize);
|
@@ -66,6 +66,7 @@ class HllSketchImpl {
|
|
66
66
|
virtual bool isEmpty() const = 0;
|
67
67
|
virtual bool isOutOfOrderFlag() const = 0;
|
68
68
|
virtual void putOutOfOrderFlag(bool oooFlag) = 0;
|
69
|
+
virtual A getAllocator() const = 0;
|
69
70
|
bool isStartFullSize() const;
|
70
71
|
|
71
72
|
protected:
|
@@ -31,15 +31,15 @@
|
|
31
31
|
|
32
32
|
namespace datasketches {
|
33
33
|
|
34
|
-
template<typename A
|
34
|
+
template<typename A>
|
35
35
|
class HllSketchImplFactory final {
|
36
36
|
public:
|
37
|
-
static HllSketchImpl<A>* deserialize(std::istream& os);
|
38
|
-
static HllSketchImpl<A>* deserialize(const void* bytes, size_t len);
|
37
|
+
static HllSketchImpl<A>* deserialize(std::istream& os, const A& allocator);
|
38
|
+
static HllSketchImpl<A>* deserialize(const void* bytes, size_t len, const A& allocator);
|
39
39
|
|
40
40
|
static CouponHashSet<A>* promoteListToSet(const CouponList<A>& list);
|
41
41
|
static HllArray<A>* promoteListOrSetToHll(const CouponList<A>& list);
|
42
|
-
static HllArray<A>* newHll(int lgConfigK, target_hll_type tgtHllType, bool startFullSize
|
42
|
+
static HllArray<A>* newHll(int lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator);
|
43
43
|
|
44
44
|
// resets the input impl, deleting the input pointer and returning a new pointer
|
45
45
|
static HllSketchImpl<A>* reset(HllSketchImpl<A>* impl, bool startFullSize);
|
@@ -51,8 +51,8 @@ public:
|
|
51
51
|
|
52
52
|
template<typename A>
|
53
53
|
CouponHashSet<A>* HllSketchImplFactory<A>::promoteListToSet(const CouponList<A>& list) {
|
54
|
-
|
55
|
-
CouponHashSet<A>* chSet = new (
|
54
|
+
using ChsAlloc = typename std::allocator_traits<A>::template rebind_alloc<CouponHashSet<A>>;
|
55
|
+
CouponHashSet<A>* chSet = new (ChsAlloc(list.getAllocator()).allocate(1)) CouponHashSet<A>(list.getLgConfigK(), list.getTgtHllType(), list.getAllocator());
|
56
56
|
for (auto coupon: list) {
|
57
57
|
chSet->couponUpdate(coupon);
|
58
58
|
}
|
@@ -61,7 +61,7 @@ CouponHashSet<A>* HllSketchImplFactory<A>::promoteListToSet(const CouponList<A>&
|
|
61
61
|
|
62
62
|
template<typename A>
|
63
63
|
HllArray<A>* HllSketchImplFactory<A>::promoteListOrSetToHll(const CouponList<A>& src) {
|
64
|
-
HllArray<A>* tgtHllArr = HllSketchImplFactory<A>::newHll(src.getLgConfigK(), src.getTgtHllType());
|
64
|
+
HllArray<A>* tgtHllArr = HllSketchImplFactory<A>::newHll(src.getLgConfigK(), src.getTgtHllType(), false, src.getAllocator());
|
65
65
|
tgtHllArr->putKxQ0(1 << src.getLgConfigK());
|
66
66
|
for (auto coupon: src) {
|
67
67
|
tgtHllArr->couponUpdate(coupon);
|
@@ -72,48 +72,48 @@ HllArray<A>* HllSketchImplFactory<A>::promoteListOrSetToHll(const CouponList<A>&
|
|
72
72
|
}
|
73
73
|
|
74
74
|
template<typename A>
|
75
|
-
HllSketchImpl<A>* HllSketchImplFactory<A>::deserialize(std::istream& is) {
|
75
|
+
HllSketchImpl<A>* HllSketchImplFactory<A>::deserialize(std::istream& is, const A& allocator) {
|
76
76
|
// we'll hand off the sketch based on PreInts so we don't need
|
77
77
|
// to move the stream pointer back and forth -- perhaps somewhat fragile?
|
78
78
|
const int preInts = is.peek();
|
79
79
|
if (preInts == HllUtil<A>::HLL_PREINTS) {
|
80
|
-
return HllArray<A>::newHll(is);
|
80
|
+
return HllArray<A>::newHll(is, allocator);
|
81
81
|
} else if (preInts == HllUtil<A>::HASH_SET_PREINTS) {
|
82
|
-
return CouponHashSet<A>::newSet(is);
|
82
|
+
return CouponHashSet<A>::newSet(is, allocator);
|
83
83
|
} else if (preInts == HllUtil<A>::LIST_PREINTS) {
|
84
|
-
return CouponList<A>::newList(is);
|
84
|
+
return CouponList<A>::newList(is, allocator);
|
85
85
|
} else {
|
86
86
|
throw std::invalid_argument("Attempt to deserialize unknown object type");
|
87
87
|
}
|
88
88
|
}
|
89
89
|
|
90
90
|
template<typename A>
|
91
|
-
HllSketchImpl<A>* HllSketchImplFactory<A>::deserialize(const void* bytes, size_t len) {
|
91
|
+
HllSketchImpl<A>* HllSketchImplFactory<A>::deserialize(const void* bytes, size_t len, const A& allocator) {
|
92
92
|
// read current mode directly
|
93
93
|
const int preInts = static_cast<const uint8_t*>(bytes)[0];
|
94
94
|
if (preInts == HllUtil<A>::HLL_PREINTS) {
|
95
|
-
return HllArray<A>::newHll(bytes, len);
|
95
|
+
return HllArray<A>::newHll(bytes, len, allocator);
|
96
96
|
} else if (preInts == HllUtil<A>::HASH_SET_PREINTS) {
|
97
|
-
return CouponHashSet<A>::newSet(bytes, len);
|
97
|
+
return CouponHashSet<A>::newSet(bytes, len, allocator);
|
98
98
|
} else if (preInts == HllUtil<A>::LIST_PREINTS) {
|
99
|
-
return CouponList<A>::newList(bytes, len);
|
99
|
+
return CouponList<A>::newList(bytes, len, allocator);
|
100
100
|
} else {
|
101
101
|
throw std::invalid_argument("Attempt to deserialize unknown object type");
|
102
102
|
}
|
103
103
|
}
|
104
104
|
|
105
105
|
template<typename A>
|
106
|
-
HllArray<A>* HllSketchImplFactory<A>::newHll(int lgConfigK, target_hll_type tgtHllType, bool startFullSize) {
|
106
|
+
HllArray<A>* HllSketchImplFactory<A>::newHll(int lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator) {
|
107
107
|
switch (tgtHllType) {
|
108
108
|
case HLL_8:
|
109
|
-
|
110
|
-
return new (
|
109
|
+
using Hll8Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll8Array<A>>;
|
110
|
+
return new (Hll8Alloc(allocator).allocate(1)) Hll8Array<A>(lgConfigK, startFullSize, allocator);
|
111
111
|
case HLL_6:
|
112
|
-
|
113
|
-
return new (
|
112
|
+
using Hll6Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll6Array<A>>;
|
113
|
+
return new (Hll6Alloc(allocator).allocate(1)) Hll6Array<A>(lgConfigK, startFullSize, allocator);
|
114
114
|
case HLL_4:
|
115
|
-
|
116
|
-
return new (
|
115
|
+
using Hll4Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll4Array<A>>;
|
116
|
+
return new (Hll4Alloc(allocator).allocate(1)) Hll4Array<A>(lgConfigK, startFullSize, allocator);
|
117
117
|
}
|
118
118
|
throw std::logic_error("Invalid target_hll_type");
|
119
119
|
}
|
@@ -121,12 +121,12 @@ HllArray<A>* HllSketchImplFactory<A>::newHll(int lgConfigK, target_hll_type tgtH
|
|
121
121
|
template<typename A>
|
122
122
|
HllSketchImpl<A>* HllSketchImplFactory<A>::reset(HllSketchImpl<A>* impl, bool startFullSize) {
|
123
123
|
if (startFullSize) {
|
124
|
-
HllArray<A>* hll = newHll(impl->getLgConfigK(), impl->getTgtHllType(), startFullSize);
|
124
|
+
HllArray<A>* hll = newHll(impl->getLgConfigK(), impl->getTgtHllType(), startFullSize, impl->getAllocator());
|
125
125
|
impl->get_deleter()(impl);
|
126
126
|
return hll;
|
127
127
|
} else {
|
128
|
-
|
129
|
-
CouponList<A>* cl = new (
|
128
|
+
using ClAlloc = typename std::allocator_traits<A>::template rebind_alloc<CouponList<A>>;
|
129
|
+
CouponList<A>* cl = new (ClAlloc(impl->getAllocator()).allocate(1)) CouponList<A>(impl->getLgConfigK(), impl->getTgtHllType(), hll_mode::LIST, impl->getAllocator());
|
130
130
|
impl->get_deleter()(impl);
|
131
131
|
return cl;
|
132
132
|
}
|
@@ -135,8 +135,9 @@ HllSketchImpl<A>* HllSketchImplFactory<A>::reset(HllSketchImpl<A>* impl, bool st
|
|
135
135
|
template<typename A>
|
136
136
|
Hll4Array<A>* HllSketchImplFactory<A>::convertToHll4(const HllArray<A>& srcHllArr) {
|
137
137
|
const int lgConfigK = srcHllArr.getLgConfigK();
|
138
|
-
|
139
|
-
Hll4Array<A>* hll4Array = new (
|
138
|
+
using Hll4Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll4Array<A>>;
|
139
|
+
Hll4Array<A>* hll4Array = new (Hll4Alloc(srcHllArr.getAllocator()).allocate(1))
|
140
|
+
Hll4Array<A>(lgConfigK, srcHllArr.isStartFullSize(), srcHllArr.getAllocator());
|
140
141
|
hll4Array->putOutOfOrderFlag(srcHllArr.isOutOfOrderFlag());
|
141
142
|
hll4Array->mergeHll(srcHllArr);
|
142
143
|
hll4Array->putHipAccum(srcHllArr.getHipAccum());
|
@@ -146,8 +147,9 @@ Hll4Array<A>* HllSketchImplFactory<A>::convertToHll4(const HllArray<A>& srcHllAr
|
|
146
147
|
template<typename A>
|
147
148
|
Hll6Array<A>* HllSketchImplFactory<A>::convertToHll6(const HllArray<A>& srcHllArr) {
|
148
149
|
const int lgConfigK = srcHllArr.getLgConfigK();
|
149
|
-
|
150
|
-
Hll6Array<A>* hll6Array = new (
|
150
|
+
using Hll6Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll6Array<A>>;
|
151
|
+
Hll6Array<A>* hll6Array = new (Hll6Alloc(srcHllArr.getAllocator()).allocate(1))
|
152
|
+
Hll6Array<A>(lgConfigK, srcHllArr.isStartFullSize(), srcHllArr.getAllocator());
|
151
153
|
hll6Array->putOutOfOrderFlag(srcHllArr.isOutOfOrderFlag());
|
152
154
|
hll6Array->mergeHll(srcHllArr);
|
153
155
|
hll6Array->putHipAccum(srcHllArr.getHipAccum());
|
@@ -157,8 +159,9 @@ Hll6Array<A>* HllSketchImplFactory<A>::convertToHll6(const HllArray<A>& srcHllAr
|
|
157
159
|
template<typename A>
|
158
160
|
Hll8Array<A>* HllSketchImplFactory<A>::convertToHll8(const HllArray<A>& srcHllArr) {
|
159
161
|
const int lgConfigK = srcHllArr.getLgConfigK();
|
160
|
-
|
161
|
-
Hll8Array<A>* hll8Array = new (
|
162
|
+
using Hll8Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll8Array<A>>;
|
163
|
+
Hll8Array<A>* hll8Array = new (Hll8Alloc(srcHllArr.getAllocator()).allocate(1))
|
164
|
+
Hll8Array<A>(lgConfigK, srcHllArr.isStartFullSize(), srcHllArr.getAllocator());
|
162
165
|
hll8Array->putOutOfOrderFlag(srcHllArr.isOutOfOrderFlag());
|
163
166
|
hll8Array->mergeHll(srcHllArr);
|
164
167
|
hll8Array->putHipAccum(srcHllArr.getHipAccum());
|