datasketches 0.2.0 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/LICENSE +40 -3
- data/NOTICE +1 -1
- data/README.md +7 -7
- data/ext/datasketches/extconf.rb +1 -1
- data/ext/datasketches/theta_wrapper.cpp +20 -4
- data/lib/datasketches/version.rb +1 -1
- data/vendor/datasketches-cpp/CMakeLists.txt +31 -3
- data/vendor/datasketches-cpp/LICENSE +40 -3
- data/vendor/datasketches-cpp/MANIFEST.in +3 -0
- data/vendor/datasketches-cpp/NOTICE +1 -1
- data/vendor/datasketches-cpp/README.md +76 -9
- data/vendor/datasketches-cpp/cmake/DataSketchesConfig.cmake.in +10 -0
- data/vendor/datasketches-cpp/common/CMakeLists.txt +14 -13
- data/vendor/datasketches-cpp/common/include/MurmurHash3.h +11 -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/serde.hpp +7 -7
- data/vendor/datasketches-cpp/cpc/CMakeLists.txt +15 -35
- data/vendor/datasketches-cpp/cpc/include/cpc_common.hpp +10 -3
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor.hpp +19 -19
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +91 -89
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +15 -2
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +126 -90
- data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +1 -1
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +22 -20
- data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +10 -10
- data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +4 -4
- data/vendor/datasketches-cpp/cpc/include/u32_table.hpp +8 -8
- data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +14 -14
- data/vendor/datasketches-cpp/cpc/test/compression_test.cpp +10 -10
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_allocation_test.cpp +17 -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/CMakeLists.txt +5 -15
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +69 -82
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map_impl.hpp +10 -10
- data/vendor/datasketches-cpp/fi/test/reverse_purge_hash_map_test.cpp +2 -2
- data/vendor/datasketches-cpp/hll/CMakeLists.txt +33 -56
- data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +60 -63
- data/vendor/datasketches-cpp/hll/include/AuxHashMap.hpp +19 -19
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +15 -15
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable.hpp +3 -3
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +74 -76
- data/vendor/datasketches-cpp/hll/include/CouponHashSet.hpp +6 -6
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +110 -113
- data/vendor/datasketches-cpp/hll/include/CouponList.hpp +13 -13
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation-internal.hpp +2 -4
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers-internal.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +80 -76
- data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +9 -9
- data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +26 -26
- data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +6 -6
- data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +33 -33
- data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +6 -6
- data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +205 -209
- data/vendor/datasketches-cpp/hll/include/HllArray.hpp +36 -36
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +34 -32
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +22 -22
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +13 -13
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +15 -15
- data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +61 -61
- data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +120 -127
- 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 +21 -21
- data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +1 -1
- data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +34 -34
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +25 -25
- data/vendor/datasketches-cpp/hll/test/CrossCountingTest.cpp +2 -2
- data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +35 -35
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +15 -15
- 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/CMakeLists.txt +9 -19
- 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 +39 -24
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +41 -4
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +76 -64
- 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_test.cpp +133 -46
- 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 +10 -6
- data/vendor/datasketches-cpp/python/README.md +50 -50
- 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/hll_wrapper.cpp +4 -4
- data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +1 -1
- data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +8 -8
- 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 -1
- data/vendor/datasketches-cpp/python/tests/kll_test.py +2 -2
- data/vendor/datasketches-cpp/python/tests/req_test.py +2 -2
- 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 +8 -21
- data/vendor/datasketches-cpp/req/include/req_common.hpp +2 -1
- data/vendor/datasketches-cpp/req/include/req_compactor.hpp +4 -4
- data/vendor/datasketches-cpp/req/include/req_compactor_impl.hpp +26 -39
- data/vendor/datasketches-cpp/req/include/req_sketch.hpp +1 -1
- data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +13 -11
- data/vendor/datasketches-cpp/req/test/req_sketch_test.cpp +52 -52
- data/vendor/datasketches-cpp/sampling/CMakeLists.txt +5 -9
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +10 -5
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +61 -64
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +42 -48
- 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 -13
- data/vendor/datasketches-cpp/setup.py +10 -7
- data/vendor/datasketches-cpp/theta/CMakeLists.txt +26 -45
- data/vendor/datasketches-cpp/theta/include/bounds_on_ratios_in_sampled_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 +137 -0
- data/vendor/datasketches-cpp/theta/include/theta_constants.hpp +9 -4
- data/vendor/datasketches-cpp/theta/include/theta_helpers.hpp +15 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection.hpp +9 -4
- data/vendor/datasketches-cpp/theta/include/theta_intersection_base_impl.hpp +6 -6
- data/vendor/datasketches-cpp/theta/include/theta_intersection_impl.hpp +1 -1
- data/vendor/datasketches-cpp/theta/include/theta_jaccard_similarity_base.hpp +18 -14
- data/vendor/datasketches-cpp/theta/include/theta_set_difference_base_impl.hpp +2 -2
- data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +73 -15
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +247 -103
- data/vendor/datasketches-cpp/theta/include/theta_union.hpp +10 -5
- data/vendor/datasketches-cpp/theta/include/theta_union_base.hpp +3 -1
- data/vendor/datasketches-cpp/theta/include/theta_union_base_impl.hpp +9 -3
- data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +8 -5
- data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base.hpp +11 -5
- data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base_impl.hpp +70 -37
- 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_compact_empty_from_java_v1.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v2.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v1.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v2.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_exact_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +21 -1
- data/vendor/datasketches-cpp/theta/test/theta_jaccard_similarity_test.cpp +58 -2
- data/vendor/datasketches-cpp/theta/test/theta_setop_test.cpp +445 -0
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +437 -1
- data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +41 -9
- data/vendor/datasketches-cpp/tuple/CMakeLists.txt +18 -33
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch.hpp +1 -1
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +50 -63
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union.hpp +1 -1
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union_impl.hpp +3 -3
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +13 -9
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +84 -78
- data/vendor/datasketches-cpp/tuple/include/tuple_union.hpp +6 -1
- data/vendor/datasketches-cpp/tuple/include/tuple_union_impl.hpp +8 -3
- data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +17 -1
- data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +17 -17
- data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +12 -12
- data/vendor/datasketches-cpp/tuple/test/tuple_jaccard_similarity_test.cpp +5 -5
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_allocation_test.cpp +1 -1
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +66 -28
- data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +19 -12
- metadata +18 -7
- data/vendor/datasketches-cpp/theta/test/theta_update_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_update_estimation_from_java.sk +0 -0
@@ -80,11 +80,16 @@ public:
|
|
80
80
|
*/
|
81
81
|
CompactSketch get_result(bool ordered = true) const;
|
82
82
|
|
83
|
+
/**
|
84
|
+
* Reset the union to the initial empty state
|
85
|
+
*/
|
86
|
+
void reset();
|
87
|
+
|
83
88
|
protected:
|
84
89
|
State state_;
|
85
90
|
|
86
91
|
// for builder
|
87
|
-
tuple_union(uint8_t lg_cur_size, uint8_t lg_nom_size, resize_factor rf, uint64_t theta, uint64_t seed, const Policy& policy, const Allocator& allocator);
|
92
|
+
tuple_union(uint8_t lg_cur_size, uint8_t lg_nom_size, resize_factor rf, float p, uint64_t theta, uint64_t seed, const Policy& policy, const Allocator& allocator);
|
88
93
|
};
|
89
94
|
|
90
95
|
template<typename S, typename P, typename A>
|
@@ -20,8 +20,8 @@
|
|
20
20
|
namespace datasketches {
|
21
21
|
|
22
22
|
template<typename S, typename P, typename A>
|
23
|
-
tuple_union<S, P, A>::tuple_union(uint8_t lg_cur_size, uint8_t lg_nom_size, resize_factor rf, uint64_t theta, uint64_t seed, const P& policy, const A& allocator):
|
24
|
-
state_(lg_cur_size, lg_nom_size, rf, theta, seed, internal_policy(policy), allocator)
|
23
|
+
tuple_union<S, P, A>::tuple_union(uint8_t lg_cur_size, uint8_t lg_nom_size, resize_factor rf, float p, uint64_t theta, uint64_t seed, const P& policy, const A& allocator):
|
24
|
+
state_(lg_cur_size, lg_nom_size, rf, p, theta, seed, internal_policy(policy), allocator)
|
25
25
|
{}
|
26
26
|
|
27
27
|
template<typename S, typename P, typename A>
|
@@ -35,13 +35,18 @@ auto tuple_union<S, P, A>::get_result(bool ordered) const -> CompactSketch {
|
|
35
35
|
return state_.get_result(ordered);
|
36
36
|
}
|
37
37
|
|
38
|
+
template<typename S, typename P, typename A>
|
39
|
+
void tuple_union<S, P, A>::reset() {
|
40
|
+
return state_.reset();
|
41
|
+
}
|
42
|
+
|
38
43
|
template<typename S, typename P, typename A>
|
39
44
|
tuple_union<S, P, A>::builder::builder(const P& policy, const A& allocator):
|
40
45
|
tuple_base_builder<builder, P, A>(policy, allocator) {}
|
41
46
|
|
42
47
|
template<typename S, typename P, typename A>
|
43
48
|
auto tuple_union<S, P, A>::builder::build() const -> tuple_union {
|
44
|
-
return tuple_union(this->starting_lg_size(), this->lg_k_, this->rf_, this->starting_theta(), this->seed_, this->policy_, this->allocator_);
|
49
|
+
return tuple_union(this->starting_lg_size(), this->lg_k_, this->rf_, this->p_, this->starting_theta(), this->seed_, this->policy_, this->allocator_);
|
45
50
|
}
|
46
51
|
|
47
52
|
} /* namespace datasketches */
|
@@ -36,6 +36,17 @@ const std::string inputPath = TEST_BINARY_INPUT_PATH;
|
|
36
36
|
const std::string inputPath = "test/";
|
37
37
|
#endif
|
38
38
|
|
39
|
+
TEST_CASE("aod sketch: reset", "[tuple_sketch]") {
|
40
|
+
auto update_sketch = update_array_of_doubles_sketch::builder().build();
|
41
|
+
std::vector<double> a = {1};
|
42
|
+
update_sketch.update(1, a);
|
43
|
+
REQUIRE(!update_sketch.is_empty());
|
44
|
+
REQUIRE(update_sketch.get_num_retained() == 1);
|
45
|
+
update_sketch.reset();
|
46
|
+
REQUIRE(update_sketch.is_empty());
|
47
|
+
REQUIRE(update_sketch.get_num_retained() == 0);
|
48
|
+
}
|
49
|
+
|
39
50
|
TEST_CASE("aod sketch: serialization compatibility with java - empty", "[tuple_sketch]") {
|
40
51
|
auto update_sketch = update_array_of_doubles_sketch::builder().build();
|
41
52
|
REQUIRE(update_sketch.is_empty());
|
@@ -75,7 +86,7 @@ TEST_CASE("aod sketch: serialization compatibility with java - empty configured
|
|
75
86
|
}
|
76
87
|
|
77
88
|
TEST_CASE("aod sketch: serialization compatibility with java - non-empty no entries", "[tuple_sketch]") {
|
78
|
-
auto update_sketch = update_array_of_doubles_sketch::builder().set_p(0.
|
89
|
+
auto update_sketch = update_array_of_doubles_sketch::builder().set_p(0.01f).build();
|
79
90
|
std::vector<double> a = {1};
|
80
91
|
update_sketch.update(1, a);
|
81
92
|
REQUIRE_FALSE(update_sketch.is_empty());
|
@@ -263,6 +274,11 @@ TEST_CASE("aod union: half overlap", "[tuple_sketch]") {
|
|
263
274
|
u.update(update_sketch2);
|
264
275
|
auto result = u.get_result();
|
265
276
|
REQUIRE(result.get_estimate() == Approx(1500).margin(0.01));
|
277
|
+
|
278
|
+
u.reset();
|
279
|
+
result = u.get_result();
|
280
|
+
REQUIRE(result.is_empty());
|
281
|
+
REQUIRE(result.get_num_retained() == 0);
|
266
282
|
}
|
267
283
|
|
268
284
|
TEST_CASE("aod intersection: half overlap", "[tuple_sketch]") {
|
@@ -38,8 +38,8 @@ TEST_CASE("tuple a-not-b: empty", "[tuple_a_not_b]") {
|
|
38
38
|
|
39
39
|
TEST_CASE("tuple a-not-b: non empty no retained keys", "[tuple_a_not_b]") {
|
40
40
|
auto a = update_tuple_sketch<float>::builder().build();
|
41
|
-
a.update(1, 1);
|
42
|
-
auto b = update_tuple_sketch<float>::builder().set_p(0.
|
41
|
+
a.update(1, 1.0f);
|
42
|
+
auto b = update_tuple_sketch<float>::builder().set_p(0.001f).build();
|
43
43
|
tuple_a_not_b<float> a_not_b;
|
44
44
|
|
45
45
|
// B is still empty
|
@@ -51,7 +51,7 @@ TEST_CASE("tuple a-not-b: non empty no retained keys", "[tuple_a_not_b]") {
|
|
51
51
|
REQUIRE(result.get_estimate() == 1.0);
|
52
52
|
|
53
53
|
// B is not empty in estimation mode and no entries
|
54
|
-
b.update(1, 1);
|
54
|
+
b.update(1, 1.0f);
|
55
55
|
REQUIRE(b.get_num_retained() == 0);
|
56
56
|
|
57
57
|
result = a_not_b.compute(a, b);
|
@@ -65,11 +65,11 @@ TEST_CASE("tuple a-not-b: non empty no retained keys", "[tuple_a_not_b]") {
|
|
65
65
|
TEST_CASE("tuple a-not-b: exact mode half overlap", "[tuple_a_not_b]") {
|
66
66
|
auto a = update_tuple_sketch<float>::builder().build();
|
67
67
|
int value = 0;
|
68
|
-
for (int i = 0; i < 1000; i++) a.update(value++, 1);
|
68
|
+
for (int i = 0; i < 1000; i++) a.update(value++, 1.0f);
|
69
69
|
|
70
70
|
auto b = update_tuple_sketch<float>::builder().build();
|
71
71
|
value = 500;
|
72
|
-
for (int i = 0; i < 1000; i++) b.update(value++, 1);
|
72
|
+
for (int i = 0; i < 1000; i++) b.update(value++, 1.0f);
|
73
73
|
|
74
74
|
tuple_a_not_b<float> a_not_b;
|
75
75
|
|
@@ -105,7 +105,7 @@ TEST_CASE("tuple a-not-b: exact mode half overlap", "[tuple_a_not_b]") {
|
|
105
105
|
TEST_CASE("mixed a-not-b: exact mode half overlap", "[tuple_a_not_b]") {
|
106
106
|
auto a = update_tuple_sketch<float>::builder().build();
|
107
107
|
int value = 0;
|
108
|
-
for (int i = 0; i < 1000; i++) a.update(value++, 1);
|
108
|
+
for (int i = 0; i < 1000; i++) a.update(value++, 1.0f);
|
109
109
|
|
110
110
|
auto b = update_theta_sketch::builder().build();
|
111
111
|
value = 500;
|
@@ -145,10 +145,10 @@ TEST_CASE("mixed a-not-b: exact mode half overlap", "[tuple_a_not_b]") {
|
|
145
145
|
TEST_CASE("tuple a-not-b: exact mode disjoint", "[tuple_a_not_b]") {
|
146
146
|
auto a = update_tuple_sketch<float>::builder().build();
|
147
147
|
int value = 0;
|
148
|
-
for (int i = 0; i < 1000; i++) a.update(value++, 1);
|
148
|
+
for (int i = 0; i < 1000; i++) a.update(value++, 1.0f);
|
149
149
|
|
150
150
|
auto b = update_tuple_sketch<float>::builder().build();
|
151
|
-
for (int i = 0; i < 1000; i++) b.update(value++, 1);
|
151
|
+
for (int i = 0; i < 1000; i++) b.update(value++, 1.0f);
|
152
152
|
|
153
153
|
tuple_a_not_b<float> a_not_b;
|
154
154
|
|
@@ -168,7 +168,7 @@ TEST_CASE("tuple a-not-b: exact mode disjoint", "[tuple_a_not_b]") {
|
|
168
168
|
TEST_CASE("tuple a-not-b: exact mode full overlap", "[tuple_a_not_b]") {
|
169
169
|
auto sketch = update_tuple_sketch<float>::builder().build();
|
170
170
|
int value = 0;
|
171
|
-
for (int i = 0; i < 1000; i++) sketch.update(value++, 1);
|
171
|
+
for (int i = 0; i < 1000; i++) sketch.update(value++, 1.0f);
|
172
172
|
|
173
173
|
tuple_a_not_b<float> a_not_b;
|
174
174
|
|
@@ -188,11 +188,11 @@ TEST_CASE("tuple a-not-b: exact mode full overlap", "[tuple_a_not_b]") {
|
|
188
188
|
TEST_CASE("tuple a-not-b: estimation mode half overlap", "[tuple_a_not_b]") {
|
189
189
|
auto a = update_tuple_sketch<float>::builder().build();
|
190
190
|
int value = 0;
|
191
|
-
for (int i = 0; i < 10000; i++) a.update(value++, 1);
|
191
|
+
for (int i = 0; i < 10000; i++) a.update(value++, 1.0f);
|
192
192
|
|
193
193
|
auto b = update_tuple_sketch<float>::builder().build();
|
194
194
|
value = 5000;
|
195
|
-
for (int i = 0; i < 10000; i++) b.update(value++, 1);
|
195
|
+
for (int i = 0; i < 10000; i++) b.update(value++, 1.0f);
|
196
196
|
|
197
197
|
tuple_a_not_b<float> a_not_b;
|
198
198
|
|
@@ -212,10 +212,10 @@ TEST_CASE("tuple a-not-b: estimation mode half overlap", "[tuple_a_not_b]") {
|
|
212
212
|
TEST_CASE("tuple a-not-b: estimation mode disjoint", "[tuple_a_not_b]") {
|
213
213
|
auto a = update_tuple_sketch<float>::builder().build();
|
214
214
|
int value = 0;
|
215
|
-
for (int i = 0; i < 10000; i++) a.update(value++, 1);
|
215
|
+
for (int i = 0; i < 10000; i++) a.update(value++, 1.0f);
|
216
216
|
|
217
217
|
auto b = update_tuple_sketch<float>::builder().build();
|
218
|
-
for (int i = 0; i < 10000; i++) b.update(value++, 1);
|
218
|
+
for (int i = 0; i < 10000; i++) b.update(value++, 1.0f);
|
219
219
|
|
220
220
|
tuple_a_not_b<float> a_not_b;
|
221
221
|
|
@@ -235,7 +235,7 @@ TEST_CASE("tuple a-not-b: estimation mode disjoint", "[tuple_a_not_b]") {
|
|
235
235
|
TEST_CASE("tuple a-not-b: estimation mode full overlap", "[tuple_a_not_b]") {
|
236
236
|
auto sketch = update_tuple_sketch<float>::builder().build();
|
237
237
|
int value = 0;
|
238
|
-
for (int i = 0; i < 10000; i++) sketch.update(value++, 1);
|
238
|
+
for (int i = 0; i < 10000; i++) sketch.update(value++, 1.0f);
|
239
239
|
|
240
240
|
tuple_a_not_b<float> a_not_b;
|
241
241
|
|
@@ -254,7 +254,7 @@ TEST_CASE("tuple a-not-b: estimation mode full overlap", "[tuple_a_not_b]") {
|
|
254
254
|
|
255
255
|
TEST_CASE("tuple a-not-b: seed mismatch", "[tuple_a_not_b]") {
|
256
256
|
auto sketch = update_tuple_sketch<float>::builder().build();
|
257
|
-
sketch.update(1, 1); // non-empty should not be ignored
|
257
|
+
sketch.update(1, 1.0f); // non-empty should not be ignored
|
258
258
|
tuple_a_not_b<float> a_not_b(123);
|
259
259
|
REQUIRE_THROWS_AS(a_not_b.compute(sketch, sketch), std::invalid_argument);
|
260
260
|
}
|
@@ -262,11 +262,11 @@ TEST_CASE("tuple a-not-b: seed mismatch", "[tuple_a_not_b]") {
|
|
262
262
|
TEST_CASE("tuple a-not-b: issue #152", "[tuple_a_not_b]") {
|
263
263
|
auto a = update_tuple_sketch<float>::builder().build();
|
264
264
|
int value = 0;
|
265
|
-
for (int i = 0; i < 10000; i++) a.update(value++, 1);
|
265
|
+
for (int i = 0; i < 10000; i++) a.update(value++, 1.0f);
|
266
266
|
|
267
267
|
auto b = update_tuple_sketch<float>::builder().build();
|
268
268
|
value = 5000;
|
269
|
-
for (int i = 0; i < 25000; i++) b.update(value++, 1);
|
269
|
+
for (int i = 0; i < 25000; i++) b.update(value++, 1.0f);
|
270
270
|
|
271
271
|
tuple_a_not_b<float> a_not_b;
|
272
272
|
|
@@ -59,8 +59,8 @@ TEST_CASE("tuple intersection: empty", "[tuple_intersection]") {
|
|
59
59
|
}
|
60
60
|
|
61
61
|
TEST_CASE("tuple intersection: non empty no retained keys", "[tuple_intersection]") {
|
62
|
-
auto sketch = update_tuple_sketch<float>::builder().set_p(0.
|
63
|
-
sketch.update(1, 1);
|
62
|
+
auto sketch = update_tuple_sketch<float>::builder().set_p(0.001f).build();
|
63
|
+
sketch.update(1, 1.0f);
|
64
64
|
tuple_intersection_float intersection;
|
65
65
|
intersection.update(sketch);
|
66
66
|
auto result = intersection.get_result();
|
@@ -82,11 +82,11 @@ TEST_CASE("tuple intersection: non empty no retained keys", "[tuple_intersection
|
|
82
82
|
TEST_CASE("tuple intersection: exact mode half overlap", "[tuple_intersection]") {
|
83
83
|
auto sketch1 = update_tuple_sketch<float>::builder().build();
|
84
84
|
int value = 0;
|
85
|
-
for (int i = 0; i < 1000; i++) sketch1.update(value++, 1);
|
85
|
+
for (int i = 0; i < 1000; i++) sketch1.update(value++, 1.0f);
|
86
86
|
|
87
87
|
auto sketch2 = update_tuple_sketch<float>::builder().build();
|
88
88
|
value = 500;
|
89
|
-
for (int i = 0; i < 1000; i++) sketch2.update(value++, 1);
|
89
|
+
for (int i = 0; i < 1000; i++) sketch2.update(value++, 1.0f);
|
90
90
|
|
91
91
|
{ // unordered
|
92
92
|
tuple_intersection_float intersection;
|
@@ -111,10 +111,10 @@ TEST_CASE("tuple intersection: exact mode half overlap", "[tuple_intersection]")
|
|
111
111
|
TEST_CASE("tuple intersection: exact mode disjoint", "[tuple_intersection]") {
|
112
112
|
auto sketch1 = update_tuple_sketch<float>::builder().build();
|
113
113
|
int value = 0;
|
114
|
-
for (int i = 0; i < 1000; i++) sketch1.update(value++, 1);
|
114
|
+
for (int i = 0; i < 1000; i++) sketch1.update(value++, 1.0f);
|
115
115
|
|
116
116
|
auto sketch2 = update_tuple_sketch<float>::builder().build();
|
117
|
-
for (int i = 0; i < 1000; i++) sketch2.update(value++, 1);
|
117
|
+
for (int i = 0; i < 1000; i++) sketch2.update(value++, 1.0f);
|
118
118
|
|
119
119
|
{ // unordered
|
120
120
|
tuple_intersection_float intersection;
|
@@ -139,7 +139,7 @@ TEST_CASE("tuple intersection: exact mode disjoint", "[tuple_intersection]") {
|
|
139
139
|
TEST_CASE("mixed intersection: exact mode half overlap", "[tuple_intersection]") {
|
140
140
|
auto sketch1 = update_tuple_sketch<float>::builder().build();
|
141
141
|
int value = 0;
|
142
|
-
for (int i = 0; i < 1000; i++) sketch1.update(value++, 1);
|
142
|
+
for (int i = 0; i < 1000; i++) sketch1.update(value++, 1.0f);
|
143
143
|
|
144
144
|
auto sketch2 = update_theta_sketch::builder().build();
|
145
145
|
value = 500;
|
@@ -168,11 +168,11 @@ TEST_CASE("mixed intersection: exact mode half overlap", "[tuple_intersection]")
|
|
168
168
|
TEST_CASE("tuple intersection: estimation mode half overlap", "[tuple_intersection]") {
|
169
169
|
auto sketch1 = update_tuple_sketch<float>::builder().build();
|
170
170
|
int value = 0;
|
171
|
-
for (int i = 0; i < 10000; i++) sketch1.update(value++, 1);
|
171
|
+
for (int i = 0; i < 10000; i++) sketch1.update(value++, 1.0f);
|
172
172
|
|
173
173
|
auto sketch2 = update_tuple_sketch<float>::builder().build();
|
174
174
|
value = 5000;
|
175
|
-
for (int i = 0; i < 10000; i++) sketch2.update(value++, 1);
|
175
|
+
for (int i = 0; i < 10000; i++) sketch2.update(value++, 1.0f);
|
176
176
|
|
177
177
|
{ // unordered
|
178
178
|
tuple_intersection_float intersection;
|
@@ -197,10 +197,10 @@ TEST_CASE("tuple intersection: estimation mode half overlap", "[tuple_intersecti
|
|
197
197
|
TEST_CASE("tuple intersection: estimation mode disjoint", "[tuple_intersection]") {
|
198
198
|
auto sketch1 = update_tuple_sketch<float>::builder().build();
|
199
199
|
int value = 0;
|
200
|
-
for (int i = 0; i < 10000; i++) sketch1.update(value++, 1);
|
200
|
+
for (int i = 0; i < 10000; i++) sketch1.update(value++, 1.0f);
|
201
201
|
|
202
202
|
auto sketch2 = update_tuple_sketch<float>::builder().build();
|
203
|
-
for (int i = 0; i < 10000; i++) sketch2.update(value++, 1);
|
203
|
+
for (int i = 0; i < 10000; i++) sketch2.update(value++, 1.0f);
|
204
204
|
|
205
205
|
{ // unordered
|
206
206
|
tuple_intersection_float intersection;
|
@@ -224,7 +224,7 @@ TEST_CASE("tuple intersection: estimation mode disjoint", "[tuple_intersection]"
|
|
224
224
|
|
225
225
|
TEST_CASE("tuple intersection: seed mismatch", "[tuple_intersection]") {
|
226
226
|
auto sketch = update_tuple_sketch<float>::builder().build();
|
227
|
-
sketch.update(1, 1); // non-empty should not be ignored
|
227
|
+
sketch.update(1, 1.0f); // non-empty should not be ignored
|
228
228
|
tuple_intersection_float intersection(123);
|
229
229
|
REQUIRE_THROWS_AS(intersection.update(sketch), std::invalid_argument);
|
230
230
|
}
|
@@ -44,7 +44,7 @@ TEST_CASE("tuple jaccard: empty", "[tuple_sketch]") {
|
|
44
44
|
|
45
45
|
TEST_CASE("tuple jaccard: same sketch exact mode", "[tuple_sketch]") {
|
46
46
|
auto sk = update_tuple_sketch<float>::builder().build();
|
47
|
-
for (int i = 0; i < 1000; ++i) sk.update(i, 1);
|
47
|
+
for (int i = 0; i < 1000; ++i) sk.update(i, 1.0f);
|
48
48
|
|
49
49
|
// update sketch
|
50
50
|
auto jc = tuple_jaccard_similarity_float::jaccard(sk, sk);
|
@@ -61,8 +61,8 @@ TEST_CASE("tuple jaccard: full overlap exact mode", "[tuple_sketch]") {
|
|
61
61
|
auto sk_a = update_tuple_sketch<float>::builder().build();
|
62
62
|
auto sk_b = update_tuple_sketch<float>::builder().build();
|
63
63
|
for (int i = 0; i < 1000; ++i) {
|
64
|
-
sk_a.update(i, 1);
|
65
|
-
sk_b.update(i, 1);
|
64
|
+
sk_a.update(i, 1.0f);
|
65
|
+
sk_b.update(i, 1.0f);
|
66
66
|
}
|
67
67
|
|
68
68
|
// update sketches
|
@@ -83,8 +83,8 @@ TEST_CASE("tuple jaccard: disjoint exact mode", "[tuple_sketch]") {
|
|
83
83
|
auto sk_a = update_tuple_sketch<float>::builder().build();
|
84
84
|
auto sk_b = update_tuple_sketch<float>::builder().build();
|
85
85
|
for (int i = 0; i < 1000; ++i) {
|
86
|
-
sk_a.update(i, 1);
|
87
|
-
sk_b.update(i + 1000, 1);
|
86
|
+
sk_a.update(i, 1.0f);
|
87
|
+
sk_b.update(i + 1000, 1.0f);
|
88
88
|
}
|
89
89
|
|
90
90
|
// update sketches
|
@@ -64,7 +64,7 @@ TEST_CASE("tuple sketch with test allocator: estimation mode", "[tuple_sketch]")
|
|
64
64
|
REQUIRE(count == update_sketch.get_num_retained());
|
65
65
|
|
66
66
|
update_sketch.trim();
|
67
|
-
REQUIRE(update_sketch.get_num_retained() == (
|
67
|
+
REQUIRE(update_sketch.get_num_retained() == (1U << update_sketch.get_lg_k()));
|
68
68
|
|
69
69
|
auto compact_sketch = update_sketch.compact();
|
70
70
|
REQUIRE(!compact_sketch.is_empty());
|
@@ -34,18 +34,19 @@ std::ostream& operator<<(std::ostream& os, const three_doubles& tuple) {
|
|
34
34
|
|
35
35
|
#include <catch.hpp>
|
36
36
|
#include <tuple_sketch.hpp>
|
37
|
-
//#include <test_type.hpp>
|
38
37
|
|
39
38
|
namespace datasketches {
|
40
39
|
|
41
40
|
TEST_CASE("tuple sketch float: builder", "[tuple_sketch]") {
|
42
41
|
auto builder = update_tuple_sketch<float>::builder();
|
43
|
-
builder.set_lg_k(10).set_p(0.
|
42
|
+
builder.set_lg_k(10).set_p(0.5f).set_resize_factor(theta_constants::resize_factor::X2).set_seed(123);
|
44
43
|
auto sketch = builder.build();
|
45
44
|
REQUIRE(sketch.get_lg_k() == 10);
|
46
|
-
REQUIRE(sketch.get_theta() == 0
|
45
|
+
REQUIRE(sketch.get_theta() == 1.0); // empty sketch should have theta 1.0
|
47
46
|
REQUIRE(sketch.get_rf() == theta_constants::resize_factor::X2);
|
48
47
|
REQUIRE(sketch.get_seed_hash() == compute_seed_hash(123));
|
48
|
+
sketch.update(1, 0);
|
49
|
+
REQUIRE(sketch.get_theta() == 0.5); // theta = p
|
49
50
|
}
|
50
51
|
|
51
52
|
TEST_CASE("tuple sketch float: empty", "[tuple_sketch]") {
|
@@ -58,7 +59,7 @@ TEST_CASE("tuple sketch float: empty", "[tuple_sketch]") {
|
|
58
59
|
REQUIRE(update_sketch.get_upper_bound(1) == 0);
|
59
60
|
REQUIRE(update_sketch.get_theta() == 1);
|
60
61
|
REQUIRE(update_sketch.get_num_retained() == 0);
|
61
|
-
REQUIRE(
|
62
|
+
REQUIRE(update_sketch.is_ordered());
|
62
63
|
|
63
64
|
auto compact_sketch = update_sketch.compact();
|
64
65
|
std::cout << "sizeof(compact_tuple_sketch<float>)=" << sizeof(compact_sketch) << std::endl;
|
@@ -70,22 +71,49 @@ TEST_CASE("tuple sketch float: empty", "[tuple_sketch]") {
|
|
70
71
|
REQUIRE(compact_sketch.get_theta() == 1);
|
71
72
|
REQUIRE(compact_sketch.get_num_retained() == 0);
|
72
73
|
REQUIRE(compact_sketch.is_ordered());
|
74
|
+
|
75
|
+
// empty is forced to be ordered
|
76
|
+
REQUIRE(update_sketch.compact(false).is_ordered());
|
77
|
+
}
|
78
|
+
|
79
|
+
TEST_CASE("tuple sketch: single item", "[theta_sketch]") {
|
80
|
+
auto update_sketch = update_tuple_sketch<float>::builder().build();
|
81
|
+
update_sketch.update(1, 1.0f);
|
82
|
+
REQUIRE_FALSE(update_sketch.is_empty());
|
83
|
+
REQUIRE_FALSE(update_sketch.is_estimation_mode());
|
84
|
+
REQUIRE(update_sketch.get_theta() == 1.0);
|
85
|
+
REQUIRE(update_sketch.get_estimate() == 1.0);
|
86
|
+
REQUIRE(update_sketch.get_lower_bound(1) == 1.0);
|
87
|
+
REQUIRE(update_sketch.get_upper_bound(1) == 1.0);
|
88
|
+
REQUIRE(update_sketch.is_ordered()); // one item is ordered
|
89
|
+
|
90
|
+
auto compact_sketch = update_sketch.compact();
|
91
|
+
REQUIRE_FALSE(compact_sketch.is_empty());
|
92
|
+
REQUIRE_FALSE(compact_sketch.is_estimation_mode());
|
93
|
+
REQUIRE(compact_sketch.get_theta() == 1.0);
|
94
|
+
REQUIRE(compact_sketch.get_estimate() == 1.0);
|
95
|
+
REQUIRE(compact_sketch.get_lower_bound(1) == 1.0);
|
96
|
+
REQUIRE(compact_sketch.get_upper_bound(1) == 1.0);
|
97
|
+
REQUIRE(compact_sketch.is_ordered());
|
98
|
+
|
99
|
+
// single item is forced to be ordered
|
100
|
+
REQUIRE(update_sketch.compact(false).is_ordered());
|
73
101
|
}
|
74
102
|
|
75
103
|
TEST_CASE("tuple sketch float: exact mode", "[tuple_sketch]") {
|
76
104
|
auto update_sketch = update_tuple_sketch<float>::builder().build();
|
77
|
-
update_sketch.update(1, 1);
|
78
|
-
update_sketch.update(2, 2);
|
79
|
-
update_sketch.update(1, 1);
|
105
|
+
update_sketch.update(1, 1.0f);
|
106
|
+
update_sketch.update(2, 2.0f);
|
107
|
+
update_sketch.update(1, 1.0f);
|
80
108
|
// std::cout << update_sketch.to_string(true);
|
81
|
-
|
82
|
-
|
109
|
+
REQUIRE_FALSE(update_sketch.is_empty());
|
110
|
+
REQUIRE_FALSE(update_sketch.is_estimation_mode());
|
83
111
|
REQUIRE(update_sketch.get_estimate() == 2);
|
84
112
|
REQUIRE(update_sketch.get_lower_bound(1) == 2);
|
85
113
|
REQUIRE(update_sketch.get_upper_bound(1) == 2);
|
86
114
|
REQUIRE(update_sketch.get_theta() == 1);
|
87
115
|
REQUIRE(update_sketch.get_num_retained() == 2);
|
88
|
-
|
116
|
+
REQUIRE_FALSE(update_sketch.is_ordered());
|
89
117
|
int count = 0;
|
90
118
|
for (const auto& entry: update_sketch) {
|
91
119
|
REQUIRE(entry.second == 2);
|
@@ -95,8 +123,8 @@ TEST_CASE("tuple sketch float: exact mode", "[tuple_sketch]") {
|
|
95
123
|
|
96
124
|
auto compact_sketch = update_sketch.compact();
|
97
125
|
// std::cout << compact_sketch.to_string(true);
|
98
|
-
|
99
|
-
|
126
|
+
REQUIRE_FALSE(compact_sketch.is_empty());
|
127
|
+
REQUIRE_FALSE(compact_sketch.is_estimation_mode());
|
100
128
|
REQUIRE(compact_sketch.get_estimate() == 2);
|
101
129
|
REQUIRE(compact_sketch.get_lower_bound(1) == 2);
|
102
130
|
REQUIRE(compact_sketch.get_upper_bound(1) == 2);
|
@@ -151,6 +179,16 @@ TEST_CASE("tuple sketch float: exact mode", "[tuple_sketch]") {
|
|
151
179
|
++it;
|
152
180
|
}
|
153
181
|
}
|
182
|
+
|
183
|
+
update_sketch.reset();
|
184
|
+
REQUIRE(update_sketch.is_empty());
|
185
|
+
REQUIRE_FALSE(update_sketch.is_estimation_mode());
|
186
|
+
REQUIRE(update_sketch.get_estimate() == 0);
|
187
|
+
REQUIRE(update_sketch.get_lower_bound(1) == 0);
|
188
|
+
REQUIRE(update_sketch.get_upper_bound(1) == 0);
|
189
|
+
REQUIRE(update_sketch.get_theta() == 1);
|
190
|
+
REQUIRE(update_sketch.get_num_retained() == 0);
|
191
|
+
REQUIRE(update_sketch.is_ordered());
|
154
192
|
}
|
155
193
|
|
156
194
|
template<typename T>
|
@@ -167,11 +205,11 @@ using max_float_update_tuple_sketch = update_tuple_sketch<float, float, max_valu
|
|
167
205
|
|
168
206
|
TEST_CASE("tuple sketch: float, custom policy", "[tuple_sketch]") {
|
169
207
|
auto update_sketch = max_float_update_tuple_sketch::builder(max_value_policy<float>(5)).build();
|
170
|
-
update_sketch.update(1, 1);
|
171
|
-
update_sketch.update(1, 2);
|
172
|
-
update_sketch.update(2, 10);
|
173
|
-
update_sketch.update(3, 3);
|
174
|
-
update_sketch.update(3, 7);
|
208
|
+
update_sketch.update(1, 1.0f);
|
209
|
+
update_sketch.update(1, 2.0f);
|
210
|
+
update_sketch.update(2, 10.0f);
|
211
|
+
update_sketch.update(3, 3.0f);
|
212
|
+
update_sketch.update(3, 7.0f);
|
175
213
|
// std::cout << update_sketch.to_string(true);
|
176
214
|
int count = 0;
|
177
215
|
float sum = 0;
|
@@ -212,37 +250,37 @@ TEST_CASE("tuple sketch: tuple of doubles", "[tuple_sketch]") {
|
|
212
250
|
TEST_CASE("tuple sketch: float, update with different types of keys", "[tuple_sketch]") {
|
213
251
|
auto sketch = update_tuple_sketch<float>::builder().build();
|
214
252
|
|
215
|
-
sketch.update(static_cast<uint64_t>(1), 1);
|
253
|
+
sketch.update(static_cast<uint64_t>(1), 1.0f);
|
216
254
|
REQUIRE(sketch.get_num_retained() == 1);
|
217
255
|
|
218
|
-
sketch.update(static_cast<int64_t>(1), 1);
|
256
|
+
sketch.update(static_cast<int64_t>(1), 1.0f);
|
219
257
|
REQUIRE(sketch.get_num_retained() == 1);
|
220
258
|
|
221
|
-
sketch.update(static_cast<uint32_t>(1), 1);
|
259
|
+
sketch.update(static_cast<uint32_t>(1), 1.0f);
|
222
260
|
REQUIRE(sketch.get_num_retained() == 1);
|
223
261
|
|
224
|
-
sketch.update(static_cast<int32_t>(1), 1);
|
262
|
+
sketch.update(static_cast<int32_t>(1), 1.0f);
|
225
263
|
REQUIRE(sketch.get_num_retained() == 1);
|
226
264
|
|
227
|
-
sketch.update(static_cast<uint16_t>(1), 1);
|
265
|
+
sketch.update(static_cast<uint16_t>(1), 1.0f);
|
228
266
|
REQUIRE(sketch.get_num_retained() == 1);
|
229
267
|
|
230
|
-
sketch.update(static_cast<int16_t>(1), 1);
|
268
|
+
sketch.update(static_cast<int16_t>(1), 1.0f);
|
231
269
|
REQUIRE(sketch.get_num_retained() == 1);
|
232
270
|
|
233
|
-
sketch.update(static_cast<uint8_t>(1), 1);
|
271
|
+
sketch.update(static_cast<uint8_t>(1), 1.0f);
|
234
272
|
REQUIRE(sketch.get_num_retained() == 1);
|
235
273
|
|
236
|
-
sketch.update(static_cast<int8_t>(1), 1);
|
274
|
+
sketch.update(static_cast<int8_t>(1), 1.0f);
|
237
275
|
REQUIRE(sketch.get_num_retained() == 1);
|
238
276
|
|
239
|
-
sketch.update(1.0, 1);
|
277
|
+
sketch.update(1.0, 1.0f);
|
240
278
|
REQUIRE(sketch.get_num_retained() == 2);
|
241
279
|
|
242
|
-
sketch.update(static_cast<float>(1), 1);
|
280
|
+
sketch.update(static_cast<float>(1), 1.0f);
|
243
281
|
REQUIRE(sketch.get_num_retained() == 2);
|
244
282
|
|
245
|
-
sketch.update("a", 1);
|
283
|
+
sketch.update("a", 1.0f);
|
246
284
|
REQUIRE(sketch.get_num_retained() == 3);
|
247
285
|
}
|
248
286
|
|
@@ -51,9 +51,9 @@ TEST_CASE("tupe_union float: empty theta sketch", "[tuple union]") {
|
|
51
51
|
}
|
52
52
|
|
53
53
|
TEST_CASE("tuple_union float: non-empty no retained entries", "[tuple union]") {
|
54
|
-
auto update_sketch = update_tuple_sketch<float>::builder().set_p(0.
|
54
|
+
auto update_sketch = update_tuple_sketch<float>::builder().set_p(0.001f).build();
|
55
55
|
// std::cout << update_sketch.to_string();
|
56
|
-
update_sketch.update(1, 1);
|
56
|
+
update_sketch.update(1, 1.0f);
|
57
57
|
REQUIRE(!update_sketch.is_empty());
|
58
58
|
REQUIRE(update_sketch.get_num_retained() == 0);
|
59
59
|
auto u = tuple_union<float>::builder().build();
|
@@ -69,28 +69,35 @@ TEST_CASE("tuple_union float: non-empty no retained entries", "[tuple union]") {
|
|
69
69
|
|
70
70
|
TEST_CASE("tuple_union float: simple case", "[tuple union]") {
|
71
71
|
auto update_sketch1 = update_tuple_sketch<float>::builder().build();
|
72
|
-
update_sketch1.update(1, 1);
|
73
|
-
update_sketch1.update(2, 1);
|
72
|
+
update_sketch1.update(1, 1.0f);
|
73
|
+
update_sketch1.update(2, 1.0f);
|
74
74
|
|
75
75
|
auto update_sketch2 = update_tuple_sketch<float>::builder().build();
|
76
|
-
update_sketch2.update(1, 1);
|
77
|
-
update_sketch2.update(3, 1);
|
76
|
+
update_sketch2.update(1, 1.0f);
|
77
|
+
update_sketch2.update(3, 1.0f);
|
78
78
|
|
79
79
|
auto u = tuple_union<float>::builder().build();
|
80
80
|
u.update(update_sketch1);
|
81
81
|
u.update(update_sketch2);
|
82
82
|
auto result = u.get_result();
|
83
83
|
REQUIRE(result.get_num_retained() == 3);
|
84
|
+
|
85
|
+
u.reset();
|
86
|
+
result = u.get_result();
|
87
|
+
REQUIRE(result.is_empty());
|
88
|
+
REQUIRE(result.get_num_retained() == 0);
|
89
|
+
REQUIRE(!result.is_estimation_mode());
|
90
|
+
REQUIRE(result.get_estimate() == 0);
|
84
91
|
}
|
85
92
|
|
86
93
|
TEST_CASE("tuple_union float: exact mode half overlap", "[tuple union]") {
|
87
94
|
auto update_sketch1 = update_tuple_sketch<float>::builder().build();
|
88
95
|
int value = 0;
|
89
|
-
for (int i = 0; i < 1000; ++i) update_sketch1.update(value++, 1);
|
96
|
+
for (int i = 0; i < 1000; ++i) update_sketch1.update(value++, 1.0f);
|
90
97
|
|
91
98
|
auto update_sketch2 = update_tuple_sketch<float>::builder().build();
|
92
99
|
value = 500;
|
93
|
-
for (int i = 0; i < 1000; ++i) update_sketch2.update(value++, 1);
|
100
|
+
for (int i = 0; i < 1000; ++i) update_sketch2.update(value++, 1.0f);
|
94
101
|
|
95
102
|
{ // unordered
|
96
103
|
auto u = tuple_union<float>::builder().build();
|
@@ -115,11 +122,11 @@ TEST_CASE("tuple_union float: exact mode half overlap", "[tuple union]") {
|
|
115
122
|
TEST_CASE("tuple_union float: estimation mode half overlap", "[tuple union]") {
|
116
123
|
auto update_sketch1 = update_tuple_sketch<float>::builder().build();
|
117
124
|
int value = 0;
|
118
|
-
for (int i = 0; i < 10000; ++i) update_sketch1.update(value++, 1);
|
125
|
+
for (int i = 0; i < 10000; ++i) update_sketch1.update(value++, 1.0f);
|
119
126
|
|
120
127
|
auto update_sketch2 = update_tuple_sketch<float>::builder().build();
|
121
128
|
value = 5000;
|
122
|
-
for (int i = 0; i < 10000; ++i) update_sketch2.update(value++, 1);
|
129
|
+
for (int i = 0; i < 10000; ++i) update_sketch2.update(value++, 1.0f);
|
123
130
|
|
124
131
|
{ // unordered
|
125
132
|
auto u = tuple_union<float>::builder().build();
|
@@ -143,7 +150,7 @@ TEST_CASE("tuple_union float: estimation mode half overlap", "[tuple union]") {
|
|
143
150
|
|
144
151
|
TEST_CASE("tuple_union float: seed mismatch", "[tuple union]") {
|
145
152
|
auto update_sketch = update_tuple_sketch<float>::builder().build();
|
146
|
-
update_sketch.update(1, 1); // non-empty should not be ignored
|
153
|
+
update_sketch.update(1, 1.0f); // non-empty should not be ignored
|
147
154
|
|
148
155
|
auto u = tuple_union<float>::builder().set_seed(123).build();
|
149
156
|
REQUIRE_THROWS_AS(u.update(update_sketch), std::invalid_argument);
|
@@ -154,7 +161,7 @@ TEST_CASE("tuple_union float: full overlap with theta sketch", "[tuple union]")
|
|
154
161
|
|
155
162
|
// tuple update
|
156
163
|
auto update_tuple = update_tuple_sketch<float>::builder().build();
|
157
|
-
for (unsigned i = 0; i < 10; ++i) update_tuple.update(i, 1);
|
164
|
+
for (unsigned i = 0; i < 10; ++i) update_tuple.update(i, 1.0f);
|
158
165
|
u.update(update_tuple);
|
159
166
|
|
160
167
|
// tuple compact
|