datasketches 0.5.1 → 0.5.3
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 +9 -0
- data/ext/datasketches/cpc_wrapper.cpp +8 -9
- data/ext/datasketches/fi_wrapper.cpp +4 -5
- data/ext/datasketches/hll_wrapper.cpp +9 -10
- data/ext/datasketches/kll_wrapper.cpp +13 -12
- data/ext/datasketches/theta_wrapper.cpp +11 -13
- data/ext/datasketches/vo_wrapper.cpp +1 -2
- data/lib/datasketches/version.rb +1 -1
- data/vendor/datasketches-cpp/CMakeLists.txt +5 -3
- data/vendor/datasketches-cpp/CODE_OF_CONDUCT.md +1 -1
- data/vendor/datasketches-cpp/LICENSE +14 -0
- data/vendor/datasketches-cpp/README.md +67 -73
- data/vendor/datasketches-cpp/benchmarks/CMakeLists.txt +52 -0
- data/vendor/datasketches-cpp/benchmarks/benchmark_count_min_sketch.cpp +153 -0
- data/vendor/datasketches-cpp/benchmarks/benchmark_count_min_sketch_serialization.cpp +161 -0
- data/vendor/datasketches-cpp/common/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +2 -2
- data/vendor/datasketches-cpp/common/include/fdlibm_log.hpp +101 -0
- data/vendor/datasketches-cpp/common/include/serde.hpp +6 -0
- data/vendor/datasketches-cpp/common/test/CMakeLists.txt +44 -2
- data/vendor/datasketches-cpp/common/test/binomial_bounds_test.cpp +279 -0
- data/vendor/datasketches-cpp/common/test/deserialize_hardening_test.cpp +188 -0
- data/vendor/datasketches-cpp/count/include/count_min.hpp +17 -4
- data/vendor/datasketches-cpp/count/include/count_min_impl.hpp +65 -83
- data/vendor/datasketches-cpp/count/test/count_min_test.cpp +63 -7
- data/vendor/datasketches-cpp/cpc/include/compression_data.hpp +2 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +16 -7
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +1 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +54 -36
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +27 -27
- data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +7 -7
- data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +5 -5
- data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +16 -16
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +35 -0
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +28 -3
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +41 -25
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map.hpp +3 -1
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map_impl.hpp +10 -5
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_serialize_for_java.cpp +24 -0
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_test.cpp +116 -0
- data/vendor/datasketches-cpp/filters/include/bloom_filter.hpp +1 -1
- data/vendor/datasketches-cpp/filters/include/bloom_filter_impl.hpp +32 -12
- data/vendor/datasketches-cpp/filters/test/bloom_filter_test.cpp +28 -1
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +1 -2
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +19 -5
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation-internal.hpp +4 -4
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers-internal.hpp +2 -1
- data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +4 -4
- data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +3 -3
- data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +6 -3
- data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +35 -29
- data/vendor/datasketches-cpp/hll/include/HllArray.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +3 -5
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +5 -11
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +2 -4
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +11 -10
- data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +17 -8
- data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +12 -3
- data/vendor/datasketches-cpp/hll/include/coupon_iterator-internal.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/coupon_iterator.hpp +3 -0
- data/vendor/datasketches-cpp/hll/include/hll.hpp +11 -4
- data/vendor/datasketches-cpp/hll/include/hll.private.hpp +19 -0
- data/vendor/datasketches-cpp/hll/test/CMakeLists.txt +2 -0
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +64 -0
- data/vendor/datasketches-cpp/hll/test/HllFullSizeTest.cpp +137 -0
- data/vendor/datasketches-cpp/hll/test/HllKxqRebuildTest.cpp +150 -0
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +3 -3
- data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +71 -1
- data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +10 -10
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +10 -1
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +33 -24
- data/vendor/datasketches-cpp/kll/test/kll_sketch_deserialize_from_java_test.cpp +24 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_serialize_for_java.cpp +10 -0
- data/vendor/datasketches-cpp/quantiles/include/quantiles_sketch.hpp +11 -2
- data/vendor/datasketches-cpp/quantiles/include/quantiles_sketch_impl.hpp +24 -15
- data/vendor/datasketches-cpp/req/include/req_sketch.hpp +9 -0
- data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +24 -15
- data/vendor/datasketches-cpp/req/test/req_sketch_deserialize_from_java_test.cpp +46 -0
- data/vendor/datasketches-cpp/req/test/req_sketch_serialize_for_java.cpp +20 -0
- data/vendor/datasketches-cpp/req/test/req_sketch_test.cpp +70 -0
- data/vendor/datasketches-cpp/sampling/include/ebpps_sample_impl.hpp +17 -8
- data/vendor/datasketches-cpp/sampling/include/ebpps_sketch.hpp +13 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +10 -1
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +6 -7
- data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +5 -1
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +2 -1
- data/vendor/datasketches-cpp/sampling/test/ebpps_allocation_test.cpp +1 -1
- data/vendor/datasketches-cpp/sampling/test/ebpps_sketch_test.cpp +2 -2
- data/vendor/datasketches-cpp/sampling/test/var_opt_allocation_test.cpp +1 -1
- data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +10 -4
- data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +12 -0
- data/vendor/datasketches-cpp/tdigest/include/tdigest.hpp +38 -2
- data/vendor/datasketches-cpp/tdigest/include/tdigest_impl.hpp +168 -9
- data/vendor/datasketches-cpp/tdigest/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/tdigest/test/tdigest_iterator_test.cpp +274 -0
- data/vendor/datasketches-cpp/tdigest/test/tdigest_test.cpp +275 -0
- data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser.hpp +2 -0
- data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser_impl.hpp +24 -3
- data/vendor/datasketches-cpp/theta/include/theta_constants.hpp +4 -2
- data/vendor/datasketches-cpp/theta/include/theta_helpers.hpp +32 -0
- data/vendor/datasketches-cpp/theta/include/theta_set_difference_base_impl.hpp +4 -2
- data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +22 -4
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +60 -38
- data/vendor/datasketches-cpp/theta/include/theta_union_base_impl.hpp +2 -6
- data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base_impl.hpp +2 -2
- data/vendor/datasketches-cpp/theta/test/bit_packing_test.cpp +50 -0
- data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +22 -0
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +315 -0
- data/vendor/datasketches-cpp/tools/rat-check.sh +68 -0
- data/vendor/datasketches-cpp/tuple/include/array_tuple_sketch.hpp +35 -4
- data/vendor/datasketches-cpp/tuple/include/array_tuple_sketch_impl.hpp +2 -2
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +41 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +5 -4
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +59 -0
- data/vendor/datasketches-cpp/version.cfg.in +1 -1
- metadata +12 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a91d4d694972af601b74f32fdec1d52fb48d6bf9ee0c16332219d3755afd4c6
|
|
4
|
+
data.tar.gz: 5ca86cc02447be6af32c4eb1368fb93641cca227781a4e7827f2b1d3d43532bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aaafc9cff65cd3827524ee7ae9d32076471adaaf8c17924121c1ca8f303cc76beafbf3fbaae4dea31895f31265b1a522795b3e6905a8275ba1eb3ae329032153
|
|
7
|
+
data.tar.gz: 07ffe0606651871f0b10f4b31d383ef78db3c1fe2ae83021686e3ed835bb6f7437554ffe342f68f703bae799dae3176f391a0d3e642b42a620f160c079d5579d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
#include <cstdint>
|
|
1
2
|
#include <sstream>
|
|
2
3
|
#include <string>
|
|
3
4
|
|
|
4
5
|
#include <cpc_sketch.hpp>
|
|
5
6
|
#include <cpc_union.hpp>
|
|
6
7
|
#include <rice/rice.hpp>
|
|
7
|
-
#include <rice/stl.hpp>
|
|
8
8
|
|
|
9
9
|
using datasketches::cpc_sketch;
|
|
10
10
|
using datasketches::cpc_union;
|
|
@@ -23,11 +23,11 @@ void init_cpc(Rice::Module& m) {
|
|
|
23
23
|
"update",
|
|
24
24
|
[](cpc_sketch& self, Rice::Object datum) {
|
|
25
25
|
if (FIXNUM_P(datum.value())) {
|
|
26
|
-
|
|
26
|
+
self.update(Rice::detail::From_Ruby<int64_t>().convert(datum));
|
|
27
27
|
} else if (datum.is_a(rb_cNumeric)) {
|
|
28
|
-
|
|
28
|
+
self.update(Rice::detail::From_Ruby<double>().convert(datum));
|
|
29
29
|
} else {
|
|
30
|
-
|
|
30
|
+
self.update(datum.to_s().str());
|
|
31
31
|
}
|
|
32
32
|
})
|
|
33
33
|
.define_method(
|
|
@@ -40,19 +40,18 @@ void init_cpc(Rice::Module& m) {
|
|
|
40
40
|
[](cpc_sketch& self) {
|
|
41
41
|
std::ostringstream oss;
|
|
42
42
|
self.serialize(oss);
|
|
43
|
-
return oss.str();
|
|
43
|
+
return Rice::String(oss.str());
|
|
44
44
|
})
|
|
45
45
|
// TODO change to summary?
|
|
46
46
|
.define_method(
|
|
47
47
|
"to_string",
|
|
48
48
|
[](cpc_sketch& self) {
|
|
49
|
-
return self.to_string();
|
|
49
|
+
return Rice::String(self.to_string());
|
|
50
50
|
})
|
|
51
51
|
.define_singleton_function(
|
|
52
52
|
"deserialize",
|
|
53
|
-
[](
|
|
54
|
-
|
|
55
|
-
return cpc_sketch::deserialize(iss);
|
|
53
|
+
[](Rice::String is) {
|
|
54
|
+
return cpc_sketch::deserialize(is.c_str(), is.length());
|
|
56
55
|
});
|
|
57
56
|
|
|
58
57
|
Rice::define_class_under<cpc_union>(m, "CpcUnion")
|
|
@@ -27,19 +27,18 @@ void bind_fi_sketch(Rice::Module& m, const char* name) {
|
|
|
27
27
|
[](datasketches::frequent_items_sketch<T>& self) {
|
|
28
28
|
std::ostringstream oss;
|
|
29
29
|
self.serialize(oss);
|
|
30
|
-
return oss.str();
|
|
30
|
+
return Rice::String(oss.str());
|
|
31
31
|
})
|
|
32
32
|
// TODO change to summary?
|
|
33
33
|
.define_method(
|
|
34
34
|
"to_string",
|
|
35
35
|
[](datasketches::frequent_items_sketch<T>& self) {
|
|
36
|
-
return self.to_string();
|
|
36
|
+
return Rice::String(self.to_string());
|
|
37
37
|
})
|
|
38
38
|
.define_singleton_function(
|
|
39
39
|
"deserialize",
|
|
40
|
-
[](
|
|
41
|
-
|
|
42
|
-
return datasketches::frequent_items_sketch<T>::deserialize(iss);
|
|
40
|
+
[](Rice::String is) {
|
|
41
|
+
return datasketches::frequent_items_sketch<T>::deserialize(is.c_str(), is.length());
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
#include <cstdint>
|
|
1
2
|
#include <sstream>
|
|
2
3
|
#include <string>
|
|
3
4
|
|
|
4
5
|
#include <hll.hpp>
|
|
5
6
|
#include <rice/rice.hpp>
|
|
6
|
-
#include <rice/stl.hpp>
|
|
7
7
|
|
|
8
8
|
using datasketches::hll_sketch;
|
|
9
9
|
using datasketches::hll_union;
|
|
@@ -19,11 +19,11 @@ void init_hll(Rice::Module& m) {
|
|
|
19
19
|
"update",
|
|
20
20
|
[](hll_sketch& self, Rice::Object datum) {
|
|
21
21
|
if (FIXNUM_P(datum.value())) {
|
|
22
|
-
|
|
22
|
+
self.update(Rice::detail::From_Ruby<int64_t>().convert(datum));
|
|
23
23
|
} else if (datum.is_a(rb_cNumeric)) {
|
|
24
|
-
|
|
24
|
+
self.update(Rice::detail::From_Ruby<double>().convert(datum));
|
|
25
25
|
} else {
|
|
26
|
-
|
|
26
|
+
self.update(datum.to_s().str());
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
.define_method(
|
|
@@ -36,26 +36,25 @@ void init_hll(Rice::Module& m) {
|
|
|
36
36
|
[](hll_sketch& self) {
|
|
37
37
|
std::ostringstream oss;
|
|
38
38
|
self.serialize_compact(oss);
|
|
39
|
-
return oss.str();
|
|
39
|
+
return Rice::String(oss.str());
|
|
40
40
|
})
|
|
41
41
|
.define_method(
|
|
42
42
|
"serialize_updatable",
|
|
43
43
|
[](hll_sketch& self) {
|
|
44
44
|
std::ostringstream oss;
|
|
45
45
|
self.serialize_updatable(oss);
|
|
46
|
-
return oss.str();
|
|
46
|
+
return Rice::String(oss.str());
|
|
47
47
|
})
|
|
48
48
|
// TODO change to summary?
|
|
49
49
|
.define_method(
|
|
50
50
|
"to_string",
|
|
51
51
|
[](hll_sketch& self) {
|
|
52
|
-
return self.to_string();
|
|
52
|
+
return Rice::String(self.to_string());
|
|
53
53
|
})
|
|
54
54
|
.define_singleton_function(
|
|
55
55
|
"deserialize",
|
|
56
|
-
[](
|
|
57
|
-
|
|
58
|
-
return hll_sketch::deserialize(iss);
|
|
56
|
+
[](Rice::String is) {
|
|
57
|
+
return hll_sketch::deserialize(is.c_str(), is.length());
|
|
59
58
|
});
|
|
60
59
|
|
|
61
60
|
Rice::define_class_under<hll_union>(m, "HllUnion")
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
#include <cstdint>
|
|
1
2
|
#include <sstream>
|
|
2
3
|
#include <string>
|
|
3
4
|
#include <vector>
|
|
4
5
|
|
|
5
6
|
#include <kll_sketch.hpp>
|
|
6
7
|
#include <rice/rice.hpp>
|
|
7
|
-
#include <rice/stl.hpp>
|
|
8
8
|
|
|
9
9
|
using datasketches::kll_sketch;
|
|
10
10
|
|
|
@@ -16,8 +16,8 @@ namespace Rice::detail {
|
|
|
16
16
|
|
|
17
17
|
explicit To_Ruby(Arg* arg) : arg_(arg) { }
|
|
18
18
|
|
|
19
|
-
VALUE convert(std::vector<T
|
|
20
|
-
auto a = rb_ary_new2
|
|
19
|
+
VALUE convert(const std::vector<T>& x) {
|
|
20
|
+
auto a = detail::protect(rb_ary_new2, x.size());
|
|
21
21
|
for (const auto& v : x) {
|
|
22
22
|
detail::protect(rb_ary_push, a, To_Ruby<T>().convert(v));
|
|
23
23
|
}
|
|
@@ -51,13 +51,15 @@ void bind_kll_sketch(Rice::Module& m, const char* name) {
|
|
|
51
51
|
}, Rice::Arg("item"), Rice::Arg("inclusive")=false)
|
|
52
52
|
.define_method(
|
|
53
53
|
"pmf",
|
|
54
|
-
[](kll_sketch<T>& self,
|
|
55
|
-
|
|
54
|
+
[](kll_sketch<T>& self, Rice::Array rb_split_points, bool inclusive) {
|
|
55
|
+
std::vector<T> split_points = rb_split_points.to_vector<T>();
|
|
56
|
+
return self.get_PMF(split_points.data(), split_points.size(), inclusive);
|
|
56
57
|
}, Rice::Arg("split_points"), Rice::Arg("inclusive")=false)
|
|
57
58
|
.define_method(
|
|
58
59
|
"cdf",
|
|
59
|
-
[](kll_sketch<T>& self,
|
|
60
|
-
|
|
60
|
+
[](kll_sketch<T>& self, Rice::Array rb_split_points, bool inclusive) {
|
|
61
|
+
std::vector<T> split_points = rb_split_points.to_vector<T>();
|
|
62
|
+
return self.get_CDF(split_points.data(), split_points.size(), inclusive);
|
|
61
63
|
}, Rice::Arg("split_points"), Rice::Arg("inclusive")=false)
|
|
62
64
|
.define_method(
|
|
63
65
|
"merge",
|
|
@@ -74,19 +76,18 @@ void bind_kll_sketch(Rice::Module& m, const char* name) {
|
|
|
74
76
|
[](kll_sketch<T>& self) {
|
|
75
77
|
std::ostringstream oss;
|
|
76
78
|
self.serialize(oss);
|
|
77
|
-
return oss.str();
|
|
79
|
+
return Rice::String(oss.str());
|
|
78
80
|
})
|
|
79
81
|
// TODO change to summary?
|
|
80
82
|
.define_method(
|
|
81
83
|
"to_string",
|
|
82
84
|
[](kll_sketch<T>& self) {
|
|
83
|
-
return self.to_string();
|
|
85
|
+
return Rice::String(self.to_string());
|
|
84
86
|
})
|
|
85
87
|
.define_singleton_function(
|
|
86
88
|
"deserialize",
|
|
87
|
-
[](
|
|
88
|
-
|
|
89
|
-
return kll_sketch<T>::deserialize(iss);
|
|
89
|
+
[](Rice::String is) {
|
|
90
|
+
return kll_sketch<T>::deserialize(is.c_str(), is.length());
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
#include <
|
|
1
|
+
#include <cstdint>
|
|
2
2
|
#include <string>
|
|
3
3
|
|
|
4
4
|
#include <rice/rice.hpp>
|
|
5
|
-
#include <
|
|
5
|
+
#include <theta_a_not_b.hpp>
|
|
6
|
+
#include <theta_intersection.hpp>
|
|
6
7
|
#include <theta_sketch.hpp>
|
|
7
8
|
#include <theta_union.hpp>
|
|
8
|
-
#include <theta_intersection.hpp>
|
|
9
|
-
#include <theta_a_not_b.hpp>
|
|
10
9
|
|
|
11
10
|
using datasketches::theta_sketch;
|
|
12
11
|
using datasketches::update_theta_sketch;
|
|
@@ -43,9 +42,8 @@ void init_theta(Rice::Module& m) {
|
|
|
43
42
|
Rice::define_class_under<compact_theta_sketch, theta_sketch>(m, "CompactThetaSketch")
|
|
44
43
|
.define_singleton_function(
|
|
45
44
|
"deserialize",
|
|
46
|
-
[](
|
|
47
|
-
|
|
48
|
-
return compact_theta_sketch::deserialize(iss);
|
|
45
|
+
[](Rice::String is) {
|
|
46
|
+
return compact_theta_sketch::deserialize(is.c_str(), is.length());
|
|
49
47
|
});
|
|
50
48
|
|
|
51
49
|
Rice::define_class_under<update_theta_sketch, theta_sketch>(m, "UpdateThetaSketch")
|
|
@@ -59,16 +57,16 @@ void init_theta(Rice::Module& m) {
|
|
|
59
57
|
return builder.build();
|
|
60
58
|
},
|
|
61
59
|
Rice::Arg("lg_k")=datasketches::theta_constants::DEFAULT_LG_K, Rice::Arg("p")=1.0, Rice::Arg("seed")=DEFAULT_SEED)
|
|
62
|
-
.define_method("compact", &update_theta_sketch::compact, Rice::Arg("ordered")=true)
|
|
60
|
+
.define_method("compact", &update_theta_sketch::compact, Rice::Arg("ordered")=true, Rice::Arg("trim")=false)
|
|
63
61
|
.define_method(
|
|
64
62
|
"update",
|
|
65
63
|
[](update_theta_sketch& self, Rice::Object datum) {
|
|
66
64
|
if (FIXNUM_P(datum.value())) {
|
|
67
|
-
|
|
65
|
+
self.update(Rice::detail::From_Ruby<int64_t>().convert(datum));
|
|
68
66
|
} else if (datum.is_a(rb_cNumeric)) {
|
|
69
|
-
|
|
67
|
+
self.update(Rice::detail::From_Ruby<double>().convert(datum));
|
|
70
68
|
} else {
|
|
71
|
-
|
|
69
|
+
self.update(datum.to_s().str());
|
|
72
70
|
}
|
|
73
71
|
})
|
|
74
72
|
.define_method(
|
|
@@ -80,14 +78,14 @@ void init_theta(Rice::Module& m) {
|
|
|
80
78
|
Rice::define_class_under<theta_union>(m, "ThetaUnion")
|
|
81
79
|
.define_singleton_function(
|
|
82
80
|
"new",
|
|
83
|
-
[](uint8_t lg_k,
|
|
81
|
+
[](uint8_t lg_k, float p, uint64_t seed) {
|
|
84
82
|
theta_union::builder builder;
|
|
85
83
|
builder.set_lg_k(lg_k);
|
|
86
84
|
builder.set_p(p);
|
|
87
85
|
builder.set_seed(seed);
|
|
88
86
|
return builder.build();
|
|
89
87
|
},
|
|
90
|
-
Rice::Arg("lg_k")=datasketches::theta_constants::DEFAULT_LG_K, Rice::Arg("p")=1.
|
|
88
|
+
Rice::Arg("lg_k")=datasketches::theta_constants::DEFAULT_LG_K, Rice::Arg("p")=1.0f, Rice::Arg("seed")=DEFAULT_SEED)
|
|
91
89
|
.define_method("update", &theta_union::update<const theta_sketch&>)
|
|
92
90
|
.define_method("result", &theta_union::get_result, Rice::Arg("ordered")=true);
|
|
93
91
|
|
data/lib/datasketches/version.rb
CHANGED
|
@@ -59,7 +59,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERS
|
|
|
59
59
|
add_compile_options(-Wimplicit-fallthrough=3)
|
|
60
60
|
endif()
|
|
61
61
|
|
|
62
|
-
# Code generation options, to ensure
|
|
62
|
+
# Code generation options, to ensure shared libraries work and are portable
|
|
63
63
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
64
64
|
set(CMAKE_C_EXTENSIONS OFF)
|
|
65
65
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
@@ -74,6 +74,8 @@ if (BUILD_TESTS)
|
|
|
74
74
|
enable_testing()
|
|
75
75
|
endif()
|
|
76
76
|
|
|
77
|
+
option(BUILD_BENCHMARKS "Build benchmarks" OFF)
|
|
78
|
+
|
|
77
79
|
option(COVERAGE "Enable code coverage reporting (g++/clang only)" OFF)
|
|
78
80
|
if(COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
79
81
|
set(CMAKE_BUILD_TYPE "Debug" FORCE)
|
|
@@ -121,8 +123,8 @@ add_subdirectory(density)
|
|
|
121
123
|
add_subdirectory(tdigest)
|
|
122
124
|
add_subdirectory(filters)
|
|
123
125
|
|
|
124
|
-
if (
|
|
125
|
-
add_subdirectory(
|
|
126
|
+
if (BUILD_BENCHMARKS)
|
|
127
|
+
add_subdirectory(benchmarks)
|
|
126
128
|
endif()
|
|
127
129
|
|
|
128
130
|
target_link_libraries(datasketches INTERFACE hll cpc kll fi theta sampling req quantiles count)
|
|
@@ -296,3 +296,17 @@ APPENDIX B: Additional licenses relevant to this product.
|
|
|
296
296
|
Code Locations:
|
|
297
297
|
* common/include/ceiling_power_of_2.hpp
|
|
298
298
|
that is adapted from the above.
|
|
299
|
+
|
|
300
|
+
=============================================================
|
|
301
|
+
FDLIBM
|
|
302
|
+
=============================================================
|
|
303
|
+
Original source code:
|
|
304
|
+
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
305
|
+
Developed at SunSoft, a Sun Microsystems, Inc. business.
|
|
306
|
+
|
|
307
|
+
Permission to use, copy, modify, and distribute this software is freely
|
|
308
|
+
granted, provided that this notice is preserved.
|
|
309
|
+
|
|
310
|
+
Code Locations:
|
|
311
|
+
common/include/fdlibm_log.hpp
|
|
312
|
+
that is adapted from __ieee754_log in FDLIBM 5.3.
|
|
@@ -1,106 +1,100 @@
|
|
|
1
1
|
# Apache DataSketches Core C++ Library Component
|
|
2
|
-
This is the core C++ component of the Apache DataSketches library. It contains all of the key sketching algorithms that are in the Java component and can be accessed directly from user applications.
|
|
3
2
|
|
|
4
|
-
This
|
|
3
|
+
This is the core C++ component of the Apache DataSketches library. It contains all the key sketching algorithms from the Java implementation and can be accessed directly by user applications.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
This component is also a dependency of other library components that create adaptors for target systems, such as [PostgreSQL](https://github.com/apache/datasketches-postgresql).
|
|
6
|
+
|
|
7
|
+
Note that we have parallel core library components for Java, Python, GO, and Rust implementations of many of the same sketch algorithms:
|
|
8
|
+
|
|
9
|
+
- [datasketches-java](https://github.com/apache/datasketches-java)
|
|
10
|
+
- [datasketches-python](https://github.com/apache/datasketches-python)
|
|
11
|
+
- [datasketches-go](https://github.com/apache/datasketches-go)
|
|
12
|
+
- [datasketches-rust](https://github.com/apache/datasketches-rust)
|
|
7
13
|
|
|
8
14
|
Please visit the main [Apache DataSketches website](https://datasketches.apache.org) for more information.
|
|
9
15
|
|
|
10
|
-
If you are interested in making contributions to this site please see our [Community](https://datasketches.apache.org/docs/Community/) page for how to contact us.
|
|
16
|
+
If you are interested in making contributions to this site, please see our [Community](https://datasketches.apache.org/docs/Community/) page for how to contact us.
|
|
11
17
|
|
|
12
18
|
---
|
|
13
19
|
|
|
14
20
|
This code requires C++11.
|
|
15
21
|
|
|
16
|
-
This library is header-only. The build process
|
|
22
|
+
This library is header-only. The provided build process is only for unit tests.
|
|
17
23
|
|
|
18
|
-
Building the unit tests requires
|
|
24
|
+
Building the unit tests requires CMake 3.12.0 or higher.
|
|
19
25
|
|
|
20
|
-
Installing the latest
|
|
26
|
+
Installing the latest CMake on OSX: `brew install cmake`.
|
|
21
27
|
|
|
22
|
-
Building and running unit tests using
|
|
28
|
+
Building and running unit tests using CMake for OSX and Linux:
|
|
23
29
|
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
```shell
|
|
31
|
+
cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release
|
|
32
|
+
cmake --build build/Release -t all test
|
|
27
33
|
```
|
|
28
34
|
|
|
29
|
-
Building and running unit tests using
|
|
35
|
+
Building and running unit tests using CMake for Windows from the command line:
|
|
30
36
|
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
```shell
|
|
38
|
+
cd build
|
|
39
|
+
cmake ..
|
|
40
|
+
cd ..
|
|
41
|
+
cmake --build build --config Release
|
|
42
|
+
cmake --build build --config Release --target RUN_TESTS
|
|
37
43
|
```
|
|
38
44
|
|
|
39
|
-
To install a local distribution (OSX and Linux), use the following command. The
|
|
40
|
-
CMAKE_INSTALL_PREFIX variable controls the destination. If not specified, it
|
|
41
|
-
defaults to installing in /usr (/usr/include, /usr/lib, etc). In the command below,
|
|
42
|
-
the installation will be in /tmp/install/DataSketches (/tmp/install/DataSketches/include,
|
|
43
|
-
/tmp/install/DataSketches/lib, etc)
|
|
45
|
+
To install a local distribution (OSX and Linux), use the following command. The `CMAKE_INSTALL_PREFIX` variable controls the destination. If not specified, it defaults to installing in /usr (/usr/include, /usr/lib, etc). In the command below, the installation will be in /tmp/install/DataSketches (/tmp/install/DataSketches/include, /tmp/install/DataSketches/lib, etc).
|
|
44
46
|
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
```shell
|
|
48
|
+
cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/install/DataSketches
|
|
49
|
+
cmake --build build/Release -t install
|
|
48
50
|
```
|
|
49
51
|
|
|
50
|
-
To generate an installable package using
|
|
51
|
-
use the following command. The type of packaging is controlled by the CPACK_GENERATOR
|
|
52
|
-
variable (semi-colon separated list). Cmake usually supports packaging types such as RPM,
|
|
53
|
-
DEB, STGZ, TGZ, TZ, ZIP, etc.
|
|
52
|
+
To generate an installable package using CMake's built-in cpack packaging tool, use the following command. The type of packaging is controlled by the `CPACK_GENERATOR` variable (semi-colon separated list). CMake usually supports packaging formats such as RPM, DEB, STGZ, TGZ, TZ, and ZIP.
|
|
54
53
|
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
```shell
|
|
55
|
+
cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR="RPM;STGZ;TGZ"
|
|
56
|
+
cmake --build build/Release -t package
|
|
58
57
|
```
|
|
59
58
|
|
|
60
59
|
The DataSketches project can be included in other projects' CMakeLists.txt files in one of two ways.
|
|
61
|
-
If DataSketches has been installed on the host (using an RPM, DEB, "make install" into /usr/local, or some
|
|
62
|
-
way, then CMake's `find_package` command can be used like this:
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
If DataSketches has been installed on the host (using an RPM, DEB, "make install" into /usr/local, or some way, then CMake's `find_package` command can be used like this:
|
|
62
|
+
|
|
63
|
+
```cmake
|
|
64
|
+
find_package(DataSketches 3.2 REQUIRED)
|
|
65
|
+
target_link_library(my_dependent_target PUBLIC ${DATASKETCHES_LIB})
|
|
67
66
|
```
|
|
68
67
|
|
|
69
68
|
When used with find_package, DataSketches exports several variables, including
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
set(datasketches_INSTALL_DIR ${INSTALL_DIR})
|
|
102
|
-
message("Source dir of datasketches = ${datasketches_INSTALL_DIR}")
|
|
103
|
-
target_include_directories(my_dependent_target
|
|
104
|
-
PRIVATE ${datasketches_INSTALL_DIR}/include/DataSketches)
|
|
105
|
-
add_dependencies(my_dependent_target datasketches)
|
|
70
|
+
- `DATASKETCHES_VERSION`: The version number of the datasketches package that was imported.
|
|
71
|
+
- `DATASKETCHES_INCLUDE_DIR`: The directory that should be added to access DataSketches include files. Because CMake automatically includes the interface directories for included target libraries when using `target_link_library`, under normal circumstances, there will be no need to include this directly
|
|
72
|
+
- `DATASKETCHES_LIB`: The name of the DataSketches target to include as a dependency. Projects pulling in DataSketches should reference this with `target_link_library` in order to set up all the correct dependencies and include paths.
|
|
73
|
+
|
|
74
|
+
If you don't have DataSketches installed locally, dependent projects can pull it directly from GitHub using CMake's `ExternalProject` module. The code would look something like this:
|
|
75
|
+
|
|
76
|
+
```cmake
|
|
77
|
+
cmake_policy(SET CMP0097 NEW)
|
|
78
|
+
include(ExternalProject)
|
|
79
|
+
ExternalProject_Add(datasketches
|
|
80
|
+
GIT_REPOSITORY https://github.com/apache/datasketches-cpp.git
|
|
81
|
+
GIT_TAG 3.2.0
|
|
82
|
+
GIT_SHALLOW true
|
|
83
|
+
GIT_SUBMODULES ""
|
|
84
|
+
INSTALL_DIR /tmp/datasketches-prefix
|
|
85
|
+
CMAKE_ARGS -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/datasketches-prefix
|
|
86
|
+
|
|
87
|
+
# Override the install command to add DESTDIR
|
|
88
|
+
# This is necessary to work around an oddity in the RPM (but not other) package
|
|
89
|
+
# generation, as CMake otherwise picks up the Datasketch files when building
|
|
90
|
+
# an RPM for a dependent package. (RPM scans the directory for files in addition to installing
|
|
91
|
+
# those files referenced in an "install" rule in the cmake file)
|
|
92
|
+
INSTALL_COMMAND env DESTDIR= ${CMAKE_COMMAND} --build . --target install
|
|
93
|
+
)
|
|
94
|
+
ExternalProject_Get_property(datasketches INSTALL_DIR)
|
|
95
|
+
set(datasketches_INSTALL_DIR ${INSTALL_DIR})
|
|
96
|
+
message("Source dir of datasketches = ${datasketches_INSTALL_DIR}")
|
|
97
|
+
target_include_directories(my_dependent_target
|
|
98
|
+
PRIVATE ${datasketches_INSTALL_DIR}/include/DataSketches)
|
|
99
|
+
add_dependencies(my_dependent_target datasketches)
|
|
106
100
|
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
if (NOT TARGET benchmark::benchmark_main)
|
|
19
|
+
include(FetchContent)
|
|
20
|
+
|
|
21
|
+
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable google-benchmark tests" FORCE)
|
|
22
|
+
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable google-benchmark gtest tests" FORCE)
|
|
23
|
+
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable google-benchmark install rules" FORCE)
|
|
24
|
+
set(BENCHMARK_INSTALL_DOCS OFF CACHE BOOL "Disable google-benchmark documentation install" FORCE)
|
|
25
|
+
set(BENCHMARK_ENABLE_WERROR OFF CACHE BOOL "Disable google-benchmark warnings as errors" FORCE)
|
|
26
|
+
|
|
27
|
+
FetchContent_Declare(
|
|
28
|
+
googlebenchmark
|
|
29
|
+
GIT_REPOSITORY https://github.com/google/benchmark.git
|
|
30
|
+
GIT_TAG v1.7.1
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
FetchContent_MakeAvailable(googlebenchmark)
|
|
34
|
+
endif()
|
|
35
|
+
|
|
36
|
+
add_executable(count_min_sketch_benchmark)
|
|
37
|
+
|
|
38
|
+
target_link_libraries(count_min_sketch_benchmark
|
|
39
|
+
PRIVATE
|
|
40
|
+
count
|
|
41
|
+
benchmark::benchmark_main
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
set_target_properties(count_min_sketch_benchmark PROPERTIES
|
|
45
|
+
CXX_STANDARD_REQUIRED YES
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
target_sources(count_min_sketch_benchmark
|
|
49
|
+
PRIVATE
|
|
50
|
+
benchmark_count_min_sketch.cpp
|
|
51
|
+
benchmark_count_min_sketch_serialization.cpp
|
|
52
|
+
)
|