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
@@ -0,0 +1,445 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
4
|
+
* distributed with this work for additional information
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
7
|
+
* "License"); you may not use this file except in compliance
|
8
|
+
* with the License. You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
13
|
+
* software distributed under the License is distributed on an
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
* KIND, either express or implied. See the License for the
|
16
|
+
* specific language governing permissions and limitations
|
17
|
+
* under the License.
|
18
|
+
*/
|
19
|
+
|
20
|
+
#include <sstream>
|
21
|
+
|
22
|
+
#include <catch.hpp>
|
23
|
+
#include <theta_union.hpp>
|
24
|
+
#include <theta_intersection.hpp>
|
25
|
+
#include <theta_a_not_b.hpp>
|
26
|
+
|
27
|
+
namespace datasketches {
|
28
|
+
|
29
|
+
static const uint64_t GT_MIDP_V = 3L;
|
30
|
+
static const float MIDP = 0.5f;
|
31
|
+
|
32
|
+
static const uint64_t GT_LOWP_V = 6L;
|
33
|
+
static const float LOWP = 0.1f;
|
34
|
+
static const long LT_LOWP_V = 4L;
|
35
|
+
|
36
|
+
static const double LOWP_THETA = LOWP;
|
37
|
+
|
38
|
+
enum SkType {
|
39
|
+
EMPTY, // { 1.0, 0, T} Bin: 101 Oct: 05
|
40
|
+
EXACT, // { 1.0, >0, F} Bin: 110 Oct: 06, specify only value
|
41
|
+
ESTIMATION, // {<1.0, >0, F} Bin: 010 Oct: 02, specify only value
|
42
|
+
DEGENERATE // {<1.0, 0, F} Bin: 000 Oct: 00, specify p, value
|
43
|
+
};
|
44
|
+
|
45
|
+
void check_result(std::string comment, compact_theta_sketch sk, double theta, uint32_t entries, bool empty) {
|
46
|
+
bool thetaOk = sk.get_theta() == theta;
|
47
|
+
bool entriesOk = sk.get_num_retained() == entries;
|
48
|
+
bool emptyOk = sk.is_empty() == empty;
|
49
|
+
if (!thetaOk || !entriesOk || !emptyOk) {
|
50
|
+
std::ostringstream s;
|
51
|
+
s << comment << ": ";
|
52
|
+
if (!thetaOk) { s << "theta: expected " << theta << ", got " << sk.get_theta() << "; "; }
|
53
|
+
if (!entriesOk) { s << "entries: expected " << entries << ", got " << sk.get_num_retained() << "; "; }
|
54
|
+
if (!emptyOk) { s << "empty: expected " << empty << ", got " << sk.is_empty() << "."; }
|
55
|
+
FAIL(s.str());
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
update_theta_sketch build_sketch(SkType skType, float p, uint64_t value) {
|
60
|
+
update_theta_sketch::builder bldr;
|
61
|
+
bldr.set_lg_k(5);
|
62
|
+
|
63
|
+
switch(skType) {
|
64
|
+
case EMPTY: { // { 1.0, 0, T}
|
65
|
+
return bldr.build();
|
66
|
+
}
|
67
|
+
case EXACT: { // { 1.0, >0, F}
|
68
|
+
auto sk = bldr.build();
|
69
|
+
sk.update(value);
|
70
|
+
return sk;
|
71
|
+
}
|
72
|
+
case ESTIMATION: { // {<1.0, >0, F}
|
73
|
+
bldr.set_p(p);
|
74
|
+
auto sk = bldr.build();
|
75
|
+
sk.update(value);
|
76
|
+
return sk;
|
77
|
+
}
|
78
|
+
case DEGENERATE: { // {<1.0, 0, F}
|
79
|
+
bldr.set_p(p);
|
80
|
+
auto sk = bldr.build();
|
81
|
+
sk.update(value); // > theta
|
82
|
+
return sk;
|
83
|
+
}
|
84
|
+
default: throw std::invalid_argument("invalid case");
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
void checks(
|
89
|
+
update_theta_sketch& a,
|
90
|
+
update_theta_sketch& b,
|
91
|
+
double expectedIntersectTheta,
|
92
|
+
uint32_t expectedIntersectCount,
|
93
|
+
bool expectedIntersectEmpty,
|
94
|
+
double expectedAnotbTheta,
|
95
|
+
uint32_t expectedAnotbCount,
|
96
|
+
bool expectedAnotbEmpty,
|
97
|
+
double expectedUnionTheta,
|
98
|
+
uint32_t expectedUnionCount,
|
99
|
+
bool expectedUnionEmpty
|
100
|
+
) {
|
101
|
+
{
|
102
|
+
theta_intersection inter;
|
103
|
+
inter.update(a);
|
104
|
+
inter.update(b);
|
105
|
+
auto csk = inter.get_result();
|
106
|
+
check_result("Intersection update sketches", csk, expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty);
|
107
|
+
}
|
108
|
+
{
|
109
|
+
theta_intersection inter;
|
110
|
+
inter.update(a.compact());
|
111
|
+
inter.update(b.compact());
|
112
|
+
auto csk = inter.get_result();
|
113
|
+
check_result("Intersection compact sketches", csk, expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty);
|
114
|
+
}
|
115
|
+
{
|
116
|
+
theta_a_not_b a_not_b;
|
117
|
+
auto csk = a_not_b.compute(a, b);
|
118
|
+
check_result("AnotB update sketches", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
|
119
|
+
}
|
120
|
+
{
|
121
|
+
theta_a_not_b a_not_b;
|
122
|
+
auto csk = a_not_b.compute(a.compact(), b.compact());
|
123
|
+
check_result("AnotB compact sketches", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
|
124
|
+
}
|
125
|
+
{
|
126
|
+
auto u = theta_union::builder().build();
|
127
|
+
u.update(a);
|
128
|
+
u.update(b);
|
129
|
+
auto csk = u.get_result();
|
130
|
+
check_result("Union update sketches", csk, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
|
135
|
+
TEST_CASE("empty empty") {
|
136
|
+
auto a = build_sketch(SkType::EMPTY, 0, 0);
|
137
|
+
auto b = build_sketch(SkType::EMPTY, 0, 0);
|
138
|
+
const double expectedIntersectTheta = 1.0;
|
139
|
+
const int expectedIntersectCount = 0;
|
140
|
+
const bool expectedIntersectEmpty = true;
|
141
|
+
const double expectedAnotbTheta = 1.0;
|
142
|
+
const int expectedAnotbCount = 0;
|
143
|
+
const bool expectedAnotbEmpty = true;
|
144
|
+
const double expectedUnionTheta = 1.0;
|
145
|
+
const int expectedUnionCount = 0;
|
146
|
+
const bool expectedUnionEmpty = true;
|
147
|
+
|
148
|
+
checks(a, b,
|
149
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
150
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
151
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
152
|
+
}
|
153
|
+
|
154
|
+
TEST_CASE("empty exact") {
|
155
|
+
auto a = build_sketch(SkType::EMPTY, 0, 0);
|
156
|
+
auto b = build_sketch(SkType::EXACT, 0, GT_MIDP_V);
|
157
|
+
const double expectedIntersectTheta = 1.0;
|
158
|
+
const int expectedIntersectCount = 0;
|
159
|
+
const bool expectedIntersectEmpty = true;
|
160
|
+
const double expectedAnotbTheta = 1.0;
|
161
|
+
const int expectedAnotbCount = 0;
|
162
|
+
const bool expectedAnotbEmpty = true;
|
163
|
+
const double expectedUnionTheta = 1.0;
|
164
|
+
const int expectedUnionCount = 1;
|
165
|
+
const bool expectedUnionEmpty = false;
|
166
|
+
|
167
|
+
checks(a, b,
|
168
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
169
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
170
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
171
|
+
}
|
172
|
+
|
173
|
+
TEST_CASE("empty degenerate") {
|
174
|
+
auto a = build_sketch(SkType::EMPTY, 0, 0);
|
175
|
+
auto b = build_sketch(SkType::DEGENERATE, LOWP, GT_LOWP_V);
|
176
|
+
const double expectedIntersectTheta = 1.0;
|
177
|
+
const int expectedIntersectCount = 0;
|
178
|
+
const bool expectedIntersectEmpty = true;
|
179
|
+
const double expectedAnotbTheta = 1.0;
|
180
|
+
const int expectedAnotbCount = 0;
|
181
|
+
const bool expectedAnotbEmpty = true;
|
182
|
+
const double expectedUnionTheta = LOWP_THETA;
|
183
|
+
const int expectedUnionCount = 0;
|
184
|
+
const bool expectedUnionEmpty = false;
|
185
|
+
|
186
|
+
checks(a, b,
|
187
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
188
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
189
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
190
|
+
}
|
191
|
+
|
192
|
+
TEST_CASE("empty estimation") {
|
193
|
+
auto a = build_sketch(SkType::EMPTY, 0, 0);
|
194
|
+
auto b = build_sketch(SkType::ESTIMATION, LOWP, LT_LOWP_V);
|
195
|
+
const double expectedIntersectTheta = 1.0;
|
196
|
+
const int expectedIntersectCount = 0;
|
197
|
+
const bool expectedIntersectEmpty = true;
|
198
|
+
const double expectedAnotbTheta = 1.0;
|
199
|
+
const int expectedAnotbCount = 0;
|
200
|
+
const bool expectedAnotbEmpty = true;
|
201
|
+
const double expectedUnionTheta = LOWP_THETA;
|
202
|
+
const int expectedUnionCount = 1;
|
203
|
+
const bool expectedUnionEmpty = false;
|
204
|
+
|
205
|
+
checks(a, b,
|
206
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
207
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
208
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
209
|
+
}
|
210
|
+
|
211
|
+
// ---
|
212
|
+
|
213
|
+
TEST_CASE("exact empty") {
|
214
|
+
auto a = build_sketch(SkType::EXACT, 0, GT_MIDP_V);
|
215
|
+
auto b = build_sketch(SkType::EMPTY, 0, 0);
|
216
|
+
const double expectedIntersectTheta = 1.0;
|
217
|
+
const int expectedIntersectCount = 0;
|
218
|
+
const bool expectedIntersectEmpty = true;
|
219
|
+
const double expectedAnotbTheta = 1.0;
|
220
|
+
const int expectedAnotbCount = 1;
|
221
|
+
const bool expectedAnotbEmpty = false;
|
222
|
+
const double expectedUnionTheta = 1.0;
|
223
|
+
const int expectedUnionCount = 1;
|
224
|
+
const bool expectedUnionEmpty = false;
|
225
|
+
|
226
|
+
checks(a, b,
|
227
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
228
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
229
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
230
|
+
}
|
231
|
+
|
232
|
+
TEST_CASE("exact exact") {
|
233
|
+
auto a = build_sketch(SkType::EXACT, 0, GT_MIDP_V);
|
234
|
+
auto b = build_sketch(SkType::EXACT, 0, GT_MIDP_V);
|
235
|
+
const double expectedIntersectTheta = 1.0;
|
236
|
+
const int expectedIntersectCount = 1;
|
237
|
+
const bool expectedIntersectEmpty = false;
|
238
|
+
const double expectedAnotbTheta = 1.0;
|
239
|
+
const int expectedAnotbCount = 0;
|
240
|
+
const bool expectedAnotbEmpty = true;
|
241
|
+
const double expectedUnionTheta = 1.0;
|
242
|
+
const int expectedUnionCount = 1;
|
243
|
+
const bool expectedUnionEmpty = false;
|
244
|
+
|
245
|
+
checks(a, b,
|
246
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
247
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
248
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
249
|
+
}
|
250
|
+
|
251
|
+
TEST_CASE("exact degenerate") {
|
252
|
+
auto a = build_sketch(SkType::EXACT, 0, LT_LOWP_V);
|
253
|
+
auto b = build_sketch(SkType::DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
|
254
|
+
const double expectedIntersectTheta = LOWP_THETA;
|
255
|
+
const int expectedIntersectCount = 0;
|
256
|
+
const bool expectedIntersectEmpty = false;
|
257
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
258
|
+
const int expectedAnotbCount = 1;
|
259
|
+
const bool expectedAnotbEmpty = false;
|
260
|
+
const double expectedUnionTheta = LOWP_THETA;
|
261
|
+
const int expectedUnionCount = 1;
|
262
|
+
const bool expectedUnionEmpty = false;
|
263
|
+
|
264
|
+
checks(a, b,
|
265
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
266
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
267
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
268
|
+
}
|
269
|
+
|
270
|
+
TEST_CASE("exact estimation") {
|
271
|
+
auto a = build_sketch(SkType::EXACT, 0, LT_LOWP_V);
|
272
|
+
auto b = build_sketch(SkType::ESTIMATION, LOWP, LT_LOWP_V);
|
273
|
+
const double expectedIntersectTheta = LOWP_THETA;
|
274
|
+
const int expectedIntersectCount = 1;
|
275
|
+
const bool expectedIntersectEmpty = false;
|
276
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
277
|
+
const int expectedAnotbCount = 0;
|
278
|
+
const bool expectedAnotbEmpty = false;
|
279
|
+
const double expectedUnionTheta = LOWP_THETA;
|
280
|
+
const int expectedUnionCount = 1;
|
281
|
+
const bool expectedUnionEmpty = false;
|
282
|
+
|
283
|
+
checks(a, b,
|
284
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
285
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
286
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
287
|
+
}
|
288
|
+
|
289
|
+
// ---
|
290
|
+
|
291
|
+
TEST_CASE("estimation empty") {
|
292
|
+
auto a = build_sketch(SkType::ESTIMATION, LOWP, LT_LOWP_V);
|
293
|
+
auto b = build_sketch(SkType::EMPTY, 0, 0);
|
294
|
+
const double expectedIntersectTheta = 1.0;
|
295
|
+
const int expectedIntersectCount = 0;
|
296
|
+
const bool expectedIntersectEmpty = true;
|
297
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
298
|
+
const int expectedAnotbCount = 1;
|
299
|
+
const bool expectedAnotbEmpty = false;
|
300
|
+
const double expectedUnionTheta = LOWP_THETA;
|
301
|
+
const int expectedUnionCount = 1;
|
302
|
+
const bool expectedUnionEmpty = false;
|
303
|
+
|
304
|
+
checks(a, b,
|
305
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
306
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
307
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
308
|
+
}
|
309
|
+
|
310
|
+
TEST_CASE("estimation exact") {
|
311
|
+
auto a = build_sketch(SkType::ESTIMATION, LOWP, LT_LOWP_V);
|
312
|
+
auto b = build_sketch(SkType::EXACT, 0, LT_LOWP_V);
|
313
|
+
const double expectedIntersectTheta = LOWP_THETA;
|
314
|
+
const int expectedIntersectCount = 1;
|
315
|
+
const bool expectedIntersectEmpty = false;
|
316
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
317
|
+
const int expectedAnotbCount = 0;
|
318
|
+
const bool expectedAnotbEmpty = false;
|
319
|
+
const double expectedUnionTheta = LOWP_THETA;
|
320
|
+
const int expectedUnionCount = 1;
|
321
|
+
const bool expectedUnionEmpty = false;
|
322
|
+
|
323
|
+
checks(a, b,
|
324
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
325
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
326
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
327
|
+
}
|
328
|
+
|
329
|
+
TEST_CASE("estimation degenerate") {
|
330
|
+
auto a = build_sketch(SkType::ESTIMATION, MIDP, LT_LOWP_V);
|
331
|
+
auto b = build_sketch(SkType::DEGENERATE, LOWP, GT_LOWP_V);
|
332
|
+
const double expectedIntersectTheta = LOWP_THETA;
|
333
|
+
const int expectedIntersectCount = 0;
|
334
|
+
const bool expectedIntersectEmpty = false;
|
335
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
336
|
+
const int expectedAnotbCount = 1;
|
337
|
+
const bool expectedAnotbEmpty = false;
|
338
|
+
const double expectedUnionTheta = LOWP_THETA;
|
339
|
+
const int expectedUnionCount = 1;
|
340
|
+
const bool expectedUnionEmpty = false;
|
341
|
+
|
342
|
+
checks(a, b,
|
343
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
344
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
345
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
346
|
+
}
|
347
|
+
|
348
|
+
TEST_CASE("estimation estimation") {
|
349
|
+
auto a = build_sketch(SkType::ESTIMATION, MIDP, LT_LOWP_V);
|
350
|
+
auto b = build_sketch(SkType::ESTIMATION, LOWP, LT_LOWP_V);
|
351
|
+
const double expectedIntersectTheta = LOWP_THETA;
|
352
|
+
const int expectedIntersectCount = 1;
|
353
|
+
const bool expectedIntersectEmpty = false;
|
354
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
355
|
+
const int expectedAnotbCount = 0;
|
356
|
+
const bool expectedAnotbEmpty = false;
|
357
|
+
const double expectedUnionTheta = LOWP_THETA;
|
358
|
+
const int expectedUnionCount = 1;
|
359
|
+
const bool expectedUnionEmpty = false;
|
360
|
+
|
361
|
+
checks(a, b,
|
362
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
363
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
364
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
365
|
+
}
|
366
|
+
|
367
|
+
// ---
|
368
|
+
|
369
|
+
TEST_CASE("degenerate empty") {
|
370
|
+
auto a = build_sketch(SkType::DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
|
371
|
+
auto b = build_sketch(SkType::EMPTY, 0, 0);
|
372
|
+
const double expectedIntersectTheta = 1.0;
|
373
|
+
const int expectedIntersectCount = 0;
|
374
|
+
const bool expectedIntersectEmpty = true;
|
375
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
376
|
+
const int expectedAnotbCount = 0;
|
377
|
+
const bool expectedAnotbEmpty = false;
|
378
|
+
const double expectedUnionTheta = LOWP_THETA;
|
379
|
+
const int expectedUnionCount = 0;
|
380
|
+
const bool expectedUnionEmpty = false;
|
381
|
+
|
382
|
+
checks(a, b,
|
383
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
384
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
385
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
386
|
+
}
|
387
|
+
|
388
|
+
TEST_CASE("degenerate exact") {
|
389
|
+
auto a = build_sketch(SkType::DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
|
390
|
+
auto b = build_sketch(SkType::EXACT, 0, LT_LOWP_V);
|
391
|
+
const double expectedIntersectTheta = LOWP_THETA;
|
392
|
+
const int expectedIntersectCount = 0;
|
393
|
+
const bool expectedIntersectEmpty = false;
|
394
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
395
|
+
const int expectedAnotbCount = 0;
|
396
|
+
const bool expectedAnotbEmpty = false;
|
397
|
+
const double expectedUnionTheta = LOWP_THETA;
|
398
|
+
const int expectedUnionCount = 1;
|
399
|
+
const bool expectedUnionEmpty = false;
|
400
|
+
|
401
|
+
checks(a, b,
|
402
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
403
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
404
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
405
|
+
}
|
406
|
+
|
407
|
+
TEST_CASE("degenerate degenerate") {
|
408
|
+
auto a = build_sketch(SkType::DEGENERATE, MIDP, GT_MIDP_V); //entries = 0
|
409
|
+
auto b = build_sketch(SkType::DEGENERATE, LOWP, GT_LOWP_V);
|
410
|
+
const double expectedIntersectTheta = LOWP_THETA;
|
411
|
+
const int expectedIntersectCount = 0;
|
412
|
+
const bool expectedIntersectEmpty = false;
|
413
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
414
|
+
const int expectedAnotbCount = 0;
|
415
|
+
const bool expectedAnotbEmpty = false;
|
416
|
+
const double expectedUnionTheta = LOWP_THETA;
|
417
|
+
const int expectedUnionCount = 0;
|
418
|
+
const bool expectedUnionEmpty = false;
|
419
|
+
|
420
|
+
checks(a, b,
|
421
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
422
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
423
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
424
|
+
}
|
425
|
+
|
426
|
+
TEST_CASE("degenerate estimation") {
|
427
|
+
auto a = build_sketch(SkType::DEGENERATE, MIDP, GT_MIDP_V); //entries = 0
|
428
|
+
auto b = build_sketch(SkType::ESTIMATION, LOWP, LT_LOWP_V);
|
429
|
+
const double expectedIntersectTheta = LOWP_THETA;
|
430
|
+
const int expectedIntersectCount = 0;
|
431
|
+
const bool expectedIntersectEmpty = false;
|
432
|
+
const double expectedAnotbTheta = LOWP_THETA;
|
433
|
+
const int expectedAnotbCount = 0;
|
434
|
+
const bool expectedAnotbEmpty = false;
|
435
|
+
const double expectedUnionTheta = LOWP_THETA;
|
436
|
+
const int expectedUnionCount = 1;
|
437
|
+
const bool expectedUnionEmpty = false;
|
438
|
+
|
439
|
+
checks(a, b,
|
440
|
+
expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty,
|
441
|
+
expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty,
|
442
|
+
expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
|
443
|
+
}
|
444
|
+
|
445
|
+
} /* namespace datasketches */
|