datasketches 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +7 -7
  4. data/ext/datasketches/theta_wrapper.cpp +20 -4
  5. data/lib/datasketches/version.rb +1 -1
  6. data/vendor/datasketches-cpp/CMakeLists.txt +22 -3
  7. data/vendor/datasketches-cpp/MANIFEST.in +3 -0
  8. data/vendor/datasketches-cpp/README.md +76 -9
  9. data/vendor/datasketches-cpp/cmake/DataSketchesConfig.cmake.in +10 -0
  10. data/vendor/datasketches-cpp/common/CMakeLists.txt +14 -13
  11. data/vendor/datasketches-cpp/cpc/CMakeLists.txt +15 -35
  12. data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +5 -3
  13. data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +8 -6
  14. data/vendor/datasketches-cpp/cpc/test/cpc_sketch_allocation_test.cpp +17 -0
  15. data/vendor/datasketches-cpp/fi/CMakeLists.txt +5 -15
  16. data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +4 -2
  17. data/vendor/datasketches-cpp/hll/CMakeLists.txt +33 -56
  18. data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +6 -4
  19. data/vendor/datasketches-cpp/kll/CMakeLists.txt +9 -19
  20. data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +4 -2
  21. data/vendor/datasketches-cpp/req/CMakeLists.txt +8 -21
  22. data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +4 -2
  23. data/vendor/datasketches-cpp/sampling/CMakeLists.txt +5 -9
  24. data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +13 -7
  25. data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +8 -6
  26. data/vendor/datasketches-cpp/setup.py +1 -1
  27. data/vendor/datasketches-cpp/theta/CMakeLists.txt +26 -45
  28. data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser_impl.hpp +89 -22
  29. data/vendor/datasketches-cpp/theta/include/theta_helpers.hpp +15 -0
  30. data/vendor/datasketches-cpp/theta/include/theta_intersection_base_impl.hpp +6 -6
  31. data/vendor/datasketches-cpp/theta/include/theta_set_difference_base_impl.hpp +2 -2
  32. data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +32 -15
  33. data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +146 -51
  34. data/vendor/datasketches-cpp/theta/include/theta_union.hpp +6 -1
  35. data/vendor/datasketches-cpp/theta/include/theta_union_base.hpp +3 -1
  36. data/vendor/datasketches-cpp/theta/include/theta_union_base_impl.hpp +8 -2
  37. data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +8 -5
  38. data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base.hpp +5 -4
  39. data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base_impl.hpp +33 -9
  40. data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +1 -0
  41. data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v1.sk +0 -0
  42. data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v2.sk +0 -0
  43. data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v1.sk +0 -0
  44. data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v2.sk +0 -0
  45. data/vendor/datasketches-cpp/theta/test/theta_compact_exact_from_java.sk +0 -0
  46. data/vendor/datasketches-cpp/theta/test/theta_setop_test.cpp +445 -0
  47. data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +400 -0
  48. data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +23 -11
  49. data/vendor/datasketches-cpp/tuple/CMakeLists.txt +18 -33
  50. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch.hpp +1 -1
  51. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +3 -3
  52. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union.hpp +1 -1
  53. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union_impl.hpp +3 -3
  54. data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +13 -9
  55. data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +33 -14
  56. data/vendor/datasketches-cpp/tuple/include/tuple_union.hpp +6 -1
  57. data/vendor/datasketches-cpp/tuple/include/tuple_union_impl.hpp +8 -3
  58. data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +16 -0
  59. data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +46 -8
  60. data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +7 -0
  61. metadata +11 -6
  62. data/vendor/datasketches-cpp/theta/test/theta_update_empty_from_java.sk +0 -0
  63. 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 */