datasketches 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE +310 -0
- data/NOTICE +11 -0
- data/README.md +126 -0
- data/ext/datasketches/cpc_wrapper.cpp +50 -0
- data/ext/datasketches/ext.cpp +12 -0
- data/ext/datasketches/extconf.rb +11 -0
- data/ext/datasketches/hll_wrapper.cpp +69 -0
- data/lib/datasketches.rb +9 -0
- data/lib/datasketches/version.rb +3 -0
- data/vendor/datasketches-cpp/CMakeLists.txt +126 -0
- data/vendor/datasketches-cpp/LICENSE +311 -0
- data/vendor/datasketches-cpp/MANIFEST.in +19 -0
- data/vendor/datasketches-cpp/NOTICE +11 -0
- data/vendor/datasketches-cpp/README.md +42 -0
- data/vendor/datasketches-cpp/common/CMakeLists.txt +45 -0
- data/vendor/datasketches-cpp/common/include/MurmurHash3.h +173 -0
- data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +458 -0
- data/vendor/datasketches-cpp/common/include/bounds_binomial_proportions.hpp +291 -0
- data/vendor/datasketches-cpp/common/include/ceiling_power_of_2.hpp +41 -0
- data/vendor/datasketches-cpp/common/include/common_defs.hpp +51 -0
- data/vendor/datasketches-cpp/common/include/conditional_back_inserter.hpp +68 -0
- data/vendor/datasketches-cpp/common/include/conditional_forward.hpp +70 -0
- data/vendor/datasketches-cpp/common/include/count_zeros.hpp +114 -0
- data/vendor/datasketches-cpp/common/include/inv_pow2_table.hpp +107 -0
- data/vendor/datasketches-cpp/common/include/memory_operations.hpp +57 -0
- data/vendor/datasketches-cpp/common/include/serde.hpp +196 -0
- data/vendor/datasketches-cpp/common/test/CMakeLists.txt +38 -0
- data/vendor/datasketches-cpp/common/test/catch.hpp +17618 -0
- data/vendor/datasketches-cpp/common/test/catch_runner.cpp +7 -0
- data/vendor/datasketches-cpp/common/test/test_allocator.cpp +31 -0
- data/vendor/datasketches-cpp/common/test/test_allocator.hpp +108 -0
- data/vendor/datasketches-cpp/common/test/test_runner.cpp +29 -0
- data/vendor/datasketches-cpp/common/test/test_type.hpp +137 -0
- data/vendor/datasketches-cpp/cpc/CMakeLists.txt +74 -0
- data/vendor/datasketches-cpp/cpc/include/compression_data.hpp +6022 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_common.hpp +62 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor.hpp +147 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +742 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_confidence.hpp +167 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +311 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +810 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +102 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +346 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +137 -0
- data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +274 -0
- data/vendor/datasketches-cpp/cpc/include/kxp_byte_lookup.hpp +81 -0
- data/vendor/datasketches-cpp/cpc/include/u32_table.hpp +84 -0
- data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +266 -0
- data/vendor/datasketches-cpp/cpc/test/CMakeLists.txt +44 -0
- data/vendor/datasketches-cpp/cpc/test/compression_test.cpp +67 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +381 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +149 -0
- data/vendor/datasketches-cpp/fi/CMakeLists.txt +54 -0
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +319 -0
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +484 -0
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map.hpp +114 -0
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map_impl.hpp +345 -0
- data/vendor/datasketches-cpp/fi/test/CMakeLists.txt +44 -0
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_custom_type_test.cpp +84 -0
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_test.cpp +360 -0
- data/vendor/datasketches-cpp/fi/test/items_sketch_string_from_java.sk +0 -0
- data/vendor/datasketches-cpp/fi/test/items_sketch_string_utf8_from_java.sk +0 -0
- data/vendor/datasketches-cpp/fi/test/longs_sketch_from_java.sk +0 -0
- data/vendor/datasketches-cpp/fi/test/reverse_purge_hash_map_test.cpp +47 -0
- data/vendor/datasketches-cpp/hll/CMakeLists.txt +92 -0
- data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +303 -0
- data/vendor/datasketches-cpp/hll/include/AuxHashMap.hpp +83 -0
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +811 -0
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable.hpp +40 -0
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +291 -0
- data/vendor/datasketches-cpp/hll/include/CouponHashSet.hpp +59 -0
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +417 -0
- data/vendor/datasketches-cpp/hll/include/CouponList.hpp +91 -0
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation-internal.hpp +233 -0
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation.hpp +43 -0
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers-internal.hpp +90 -0
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers.hpp +48 -0
- data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +335 -0
- data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +69 -0
- data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +124 -0
- data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +55 -0
- data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +158 -0
- data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +56 -0
- data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +706 -0
- data/vendor/datasketches-cpp/hll/include/HllArray.hpp +136 -0
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +462 -0
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +149 -0
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +85 -0
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +170 -0
- data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +287 -0
- data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +239 -0
- data/vendor/datasketches-cpp/hll/include/RelativeErrorTables-internal.hpp +112 -0
- data/vendor/datasketches-cpp/hll/include/RelativeErrorTables.hpp +46 -0
- data/vendor/datasketches-cpp/hll/include/coupon_iterator-internal.hpp +56 -0
- data/vendor/datasketches-cpp/hll/include/coupon_iterator.hpp +43 -0
- data/vendor/datasketches-cpp/hll/include/hll.hpp +669 -0
- data/vendor/datasketches-cpp/hll/include/hll.private.hpp +32 -0
- data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +79 -0
- data/vendor/datasketches-cpp/hll/test/CMakeLists.txt +51 -0
- data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +130 -0
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +181 -0
- data/vendor/datasketches-cpp/hll/test/CrossCountingTest.cpp +93 -0
- data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +191 -0
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +389 -0
- data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +313 -0
- data/vendor/datasketches-cpp/hll/test/IsomorphicTest.cpp +141 -0
- data/vendor/datasketches-cpp/hll/test/TablesTest.cpp +44 -0
- data/vendor/datasketches-cpp/hll/test/ToFromByteArrayTest.cpp +168 -0
- data/vendor/datasketches-cpp/hll/test/array6_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/compact_array4_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/compact_set_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/list_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/updatable_array4_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/updatable_set_from_java.sk +0 -0
- data/vendor/datasketches-cpp/kll/CMakeLists.txt +58 -0
- data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +150 -0
- data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +319 -0
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +67 -0
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +169 -0
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +559 -0
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +1131 -0
- data/vendor/datasketches-cpp/kll/test/CMakeLists.txt +44 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_custom_type_test.cpp +154 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_float_one_item_v1.sk +0 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_from_java.sk +0 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +685 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_validation.cpp +229 -0
- data/vendor/datasketches-cpp/pyproject.toml +17 -0
- data/vendor/datasketches-cpp/python/CMakeLists.txt +61 -0
- data/vendor/datasketches-cpp/python/README.md +78 -0
- data/vendor/datasketches-cpp/python/jupyter/CPCSketch.ipynb +345 -0
- data/vendor/datasketches-cpp/python/jupyter/FrequentItemsSketch.ipynb +354 -0
- data/vendor/datasketches-cpp/python/jupyter/HLLSketch.ipynb +346 -0
- data/vendor/datasketches-cpp/python/jupyter/KLLSketch.ipynb +463 -0
- data/vendor/datasketches-cpp/python/jupyter/ThetaSketchNotebook.ipynb +396 -0
- data/vendor/datasketches-cpp/python/src/__init__.py +2 -0
- data/vendor/datasketches-cpp/python/src/cpc_wrapper.cpp +90 -0
- data/vendor/datasketches-cpp/python/src/datasketches.cpp +40 -0
- data/vendor/datasketches-cpp/python/src/fi_wrapper.cpp +123 -0
- data/vendor/datasketches-cpp/python/src/hll_wrapper.cpp +136 -0
- data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +209 -0
- data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +162 -0
- data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +488 -0
- data/vendor/datasketches-cpp/python/src/vo_wrapper.cpp +140 -0
- data/vendor/datasketches-cpp/python/tests/__init__.py +0 -0
- data/vendor/datasketches-cpp/python/tests/cpc_test.py +64 -0
- data/vendor/datasketches-cpp/python/tests/fi_test.py +110 -0
- data/vendor/datasketches-cpp/python/tests/hll_test.py +131 -0
- data/vendor/datasketches-cpp/python/tests/kll_test.py +119 -0
- data/vendor/datasketches-cpp/python/tests/theta_test.py +121 -0
- data/vendor/datasketches-cpp/python/tests/vector_of_kll_test.py +148 -0
- data/vendor/datasketches-cpp/python/tests/vo_test.py +101 -0
- data/vendor/datasketches-cpp/sampling/CMakeLists.txt +48 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +392 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +1752 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +239 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +645 -0
- data/vendor/datasketches-cpp/sampling/test/CMakeLists.txt +43 -0
- data/vendor/datasketches-cpp/sampling/test/binaries_from_java.txt +67 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +509 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +358 -0
- data/vendor/datasketches-cpp/sampling/test/varopt_sketch_long_sampling.sk +0 -0
- data/vendor/datasketches-cpp/sampling/test/varopt_sketch_string_exact.sk +0 -0
- data/vendor/datasketches-cpp/sampling/test/varopt_union_double_sampling.sk +0 -0
- data/vendor/datasketches-cpp/setup.py +94 -0
- data/vendor/datasketches-cpp/theta/CMakeLists.txt +57 -0
- data/vendor/datasketches-cpp/theta/include/theta_a_not_b.hpp +73 -0
- data/vendor/datasketches-cpp/theta/include/theta_a_not_b_impl.hpp +83 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection.hpp +88 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection_impl.hpp +130 -0
- data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +533 -0
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +939 -0
- data/vendor/datasketches-cpp/theta/include/theta_union.hpp +122 -0
- data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +109 -0
- data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +45 -0
- data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +244 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_single_item_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +218 -0
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +438 -0
- data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +97 -0
- 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
- data/vendor/datasketches-cpp/tuple/CMakeLists.txt +104 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_a_not_b.hpp +52 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_a_not_b_impl.hpp +32 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_intersection.hpp +52 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_intersection_impl.hpp +31 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch.hpp +179 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +238 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union.hpp +81 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union_impl.hpp +43 -0
- data/vendor/datasketches-cpp/tuple/include/bounds_on_ratios_in_sampled_sets.hpp +135 -0
- data/vendor/datasketches-cpp/tuple/include/bounds_on_ratios_in_theta_sketched_sets.hpp +135 -0
- data/vendor/datasketches-cpp/tuple/include/jaccard_similarity.hpp +172 -0
- data/vendor/datasketches-cpp/tuple/include/theta_a_not_b_experimental.hpp +53 -0
- data/vendor/datasketches-cpp/tuple/include/theta_a_not_b_experimental_impl.hpp +33 -0
- data/vendor/datasketches-cpp/tuple/include/theta_comparators.hpp +48 -0
- data/vendor/datasketches-cpp/tuple/include/theta_constants.hpp +34 -0
- data/vendor/datasketches-cpp/tuple/include/theta_helpers.hpp +54 -0
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_base.hpp +59 -0
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_base_impl.hpp +121 -0
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental.hpp +78 -0
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental_impl.hpp +43 -0
- data/vendor/datasketches-cpp/tuple/include/theta_set_difference_base.hpp +54 -0
- data/vendor/datasketches-cpp/tuple/include/theta_set_difference_base_impl.hpp +80 -0
- data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental.hpp +393 -0
- data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental_impl.hpp +481 -0
- data/vendor/datasketches-cpp/tuple/include/theta_union_base.hpp +60 -0
- data/vendor/datasketches-cpp/tuple/include/theta_union_base_impl.hpp +84 -0
- data/vendor/datasketches-cpp/tuple/include/theta_union_experimental.hpp +88 -0
- data/vendor/datasketches-cpp/tuple/include/theta_union_experimental_impl.hpp +47 -0
- data/vendor/datasketches-cpp/tuple/include/theta_update_sketch_base.hpp +259 -0
- data/vendor/datasketches-cpp/tuple/include/theta_update_sketch_base_impl.hpp +389 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_a_not_b.hpp +57 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_a_not_b_impl.hpp +33 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_intersection.hpp +104 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_intersection_impl.hpp +43 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +496 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +587 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_union.hpp +109 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_union_impl.hpp +47 -0
- data/vendor/datasketches-cpp/tuple/test/CMakeLists.txt +53 -0
- data/vendor/datasketches-cpp/tuple/test/aod_1_compact_empty_from_java.sk +1 -0
- data/vendor/datasketches-cpp/tuple/test/aod_1_compact_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/aod_1_compact_non_empty_no_entries_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/aod_2_compact_exact_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/aod_3_compact_empty_from_java.sk +1 -0
- data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +298 -0
- data/vendor/datasketches-cpp/tuple/test/theta_a_not_b_experimental_test.cpp +250 -0
- data/vendor/datasketches-cpp/tuple/test/theta_compact_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_compact_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_compact_single_item_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_intersection_experimental_test.cpp +224 -0
- data/vendor/datasketches-cpp/tuple/test/theta_jaccard_similarity_test.cpp +144 -0
- data/vendor/datasketches-cpp/tuple/test/theta_sketch_experimental_test.cpp +247 -0
- data/vendor/datasketches-cpp/tuple/test/theta_union_experimental_test.cpp +44 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +289 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +235 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_jaccard_similarity_test.cpp +98 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_allocation_test.cpp +102 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +249 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +187 -0
- metadata +302 -0
@@ -0,0 +1,54 @@
|
|
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
|
+
#ifndef THETA_HELPERS_HPP_
|
21
|
+
#define THETA_HELPERS_HPP_
|
22
|
+
|
23
|
+
#include <string>
|
24
|
+
#include <stdexcept>
|
25
|
+
|
26
|
+
namespace datasketches {
|
27
|
+
|
28
|
+
template<typename T>
|
29
|
+
static void check_value(T actual, T expected, const char* description) {
|
30
|
+
if (actual != expected) {
|
31
|
+
throw std::invalid_argument(std::string(description) + " mismatch: expected " + std::to_string(expected) + ", actual " + std::to_string(actual));
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
template<bool dummy>
|
36
|
+
class checker {
|
37
|
+
public:
|
38
|
+
static void check_serial_version(uint8_t actual, uint8_t expected) {
|
39
|
+
check_value(actual, expected, "serial version");
|
40
|
+
}
|
41
|
+
static void check_sketch_family(uint8_t actual, uint8_t expected) {
|
42
|
+
check_value(actual, expected, "sketch family");
|
43
|
+
}
|
44
|
+
static void check_sketch_type(uint8_t actual, uint8_t expected) {
|
45
|
+
check_value(actual, expected, "sketch type");
|
46
|
+
}
|
47
|
+
static void check_seed_hash(uint16_t actual, uint16_t expected) {
|
48
|
+
check_value(actual, expected, "seed hash");
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
} /* namespace datasketches */
|
53
|
+
|
54
|
+
#endif
|
@@ -0,0 +1,59 @@
|
|
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
|
+
#ifndef THETA_INTERSECTION_BASE_HPP_
|
21
|
+
#define THETA_INTERSECTION_BASE_HPP_
|
22
|
+
|
23
|
+
namespace datasketches {
|
24
|
+
|
25
|
+
template<
|
26
|
+
typename Entry,
|
27
|
+
typename ExtractKey,
|
28
|
+
typename Policy,
|
29
|
+
typename Sketch,
|
30
|
+
typename CompactSketch,
|
31
|
+
typename Allocator
|
32
|
+
>
|
33
|
+
class theta_intersection_base {
|
34
|
+
public:
|
35
|
+
using hash_table = theta_update_sketch_base<Entry, ExtractKey, Allocator>;
|
36
|
+
using resize_factor = typename hash_table::resize_factor;
|
37
|
+
using comparator = compare_by_key<ExtractKey>;
|
38
|
+
theta_intersection_base(uint64_t seed, const Policy& policy, const Allocator& allocator);
|
39
|
+
|
40
|
+
template<typename FwdSketch>
|
41
|
+
void update(FwdSketch&& sketch);
|
42
|
+
|
43
|
+
CompactSketch get_result(bool ordered = true) const;
|
44
|
+
|
45
|
+
bool has_result() const;
|
46
|
+
|
47
|
+
const Policy& get_policy() const;
|
48
|
+
|
49
|
+
private:
|
50
|
+
Policy policy_;
|
51
|
+
bool is_valid_;
|
52
|
+
hash_table table_;
|
53
|
+
};
|
54
|
+
|
55
|
+
} /* namespace datasketches */
|
56
|
+
|
57
|
+
#include "theta_intersection_base_impl.hpp"
|
58
|
+
|
59
|
+
#endif
|
@@ -0,0 +1,121 @@
|
|
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 <iostream>
|
21
|
+
#include <sstream>
|
22
|
+
#include <algorithm>
|
23
|
+
|
24
|
+
#include "conditional_forward.hpp"
|
25
|
+
|
26
|
+
namespace datasketches {
|
27
|
+
|
28
|
+
template<typename EN, typename EK, typename P, typename S, typename CS, typename A>
|
29
|
+
theta_intersection_base<EN, EK, P, S, CS, A>::theta_intersection_base(uint64_t seed, const P& policy, const A& allocator):
|
30
|
+
policy_(policy),
|
31
|
+
is_valid_(false),
|
32
|
+
table_(0, 0, resize_factor::X1, theta_constants::MAX_THETA, seed, allocator, false)
|
33
|
+
{}
|
34
|
+
|
35
|
+
template<typename EN, typename EK, typename P, typename S, typename CS, typename A>
|
36
|
+
template<typename SS>
|
37
|
+
void theta_intersection_base<EN, EK, P, S, CS, A>::update(SS&& sketch) {
|
38
|
+
if (table_.is_empty_) return;
|
39
|
+
if (!sketch.is_empty() && sketch.get_seed_hash() != compute_seed_hash(table_.seed_)) throw std::invalid_argument("seed hash mismatch");
|
40
|
+
table_.is_empty_ |= sketch.is_empty();
|
41
|
+
table_.theta_ = std::min(table_.theta_, sketch.get_theta64());
|
42
|
+
if (is_valid_ && table_.num_entries_ == 0) return;
|
43
|
+
if (sketch.get_num_retained() == 0) {
|
44
|
+
is_valid_ = true;
|
45
|
+
table_ = hash_table(0, 0, resize_factor::X1, table_.theta_, table_.seed_, table_.allocator_, table_.is_empty_);
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
if (!is_valid_) { // first update, copy or move incoming sketch
|
49
|
+
is_valid_ = true;
|
50
|
+
const uint8_t lg_size = lg_size_from_count(sketch.get_num_retained(), theta_update_sketch_base<EN, EK, A>::REBUILD_THRESHOLD);
|
51
|
+
table_ = hash_table(lg_size, lg_size, resize_factor::X1, table_.theta_, table_.seed_, table_.allocator_, table_.is_empty_);
|
52
|
+
for (auto& entry: sketch) {
|
53
|
+
auto result = table_.find(EK()(entry));
|
54
|
+
if (result.second) {
|
55
|
+
throw std::invalid_argument("duplicate key, possibly corrupted input sketch");
|
56
|
+
}
|
57
|
+
table_.insert(result.first, conditional_forward<SS>(entry));
|
58
|
+
}
|
59
|
+
if (table_.num_entries_ != sketch.get_num_retained()) throw std::invalid_argument("num entries mismatch, possibly corrupted input sketch");
|
60
|
+
} else { // intersection
|
61
|
+
const uint32_t max_matches = std::min(table_.num_entries_, sketch.get_num_retained());
|
62
|
+
std::vector<EN, A> matched_entries(table_.allocator_);
|
63
|
+
matched_entries.reserve(max_matches);
|
64
|
+
uint32_t match_count = 0;
|
65
|
+
uint32_t count = 0;
|
66
|
+
for (auto& entry: sketch) {
|
67
|
+
if (EK()(entry) < table_.theta_) {
|
68
|
+
auto result = table_.find(EK()(entry));
|
69
|
+
if (result.second) {
|
70
|
+
if (match_count == max_matches) throw std::invalid_argument("max matches exceeded, possibly corrupted input sketch");
|
71
|
+
policy_(*result.first, conditional_forward<SS>(entry));
|
72
|
+
matched_entries.push_back(std::move(*result.first));
|
73
|
+
++match_count;
|
74
|
+
}
|
75
|
+
} else if (sketch.is_ordered()) {
|
76
|
+
break; // early stop
|
77
|
+
}
|
78
|
+
++count;
|
79
|
+
}
|
80
|
+
if (count > sketch.get_num_retained()) {
|
81
|
+
throw std::invalid_argument(" more keys than expected, possibly corrupted input sketch");
|
82
|
+
} else if (!sketch.is_ordered() && count < sketch.get_num_retained()) {
|
83
|
+
throw std::invalid_argument(" fewer keys than expected, possibly corrupted input sketch");
|
84
|
+
}
|
85
|
+
if (match_count == 0) {
|
86
|
+
table_ = hash_table(0, 0, resize_factor::X1, table_.theta_, table_.seed_, table_.allocator_, table_.is_empty_);
|
87
|
+
if (table_.theta_ == theta_constants::MAX_THETA) table_.is_empty_ = true;
|
88
|
+
} else {
|
89
|
+
const uint8_t lg_size = lg_size_from_count(match_count, theta_update_sketch_base<EN, EK, A>::REBUILD_THRESHOLD);
|
90
|
+
table_ = hash_table(lg_size, lg_size, resize_factor::X1, table_.theta_, table_.seed_, table_.allocator_, table_.is_empty_);
|
91
|
+
for (uint32_t i = 0; i < match_count; i++) {
|
92
|
+
auto result = table_.find(EK()(matched_entries[i]));
|
93
|
+
table_.insert(result.first, std::move(matched_entries[i]));
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
template<typename EN, typename EK, typename P, typename S, typename CS, typename A>
|
100
|
+
CS theta_intersection_base<EN, EK, P, S, CS, A>::get_result(bool ordered) const {
|
101
|
+
if (!is_valid_) throw std::invalid_argument("calling get_result() before calling update() is undefined");
|
102
|
+
std::vector<EN, A> entries(table_.allocator_);
|
103
|
+
if (table_.num_entries_ > 0) {
|
104
|
+
entries.reserve(table_.num_entries_);
|
105
|
+
std::copy_if(table_.begin(), table_.end(), std::back_inserter(entries), key_not_zero<EN, EK>());
|
106
|
+
if (ordered) std::sort(entries.begin(), entries.end(), comparator());
|
107
|
+
}
|
108
|
+
return CS(table_.is_empty_, ordered, compute_seed_hash(table_.seed_), table_.theta_, std::move(entries));
|
109
|
+
}
|
110
|
+
|
111
|
+
template<typename EN, typename EK, typename P, typename S, typename CS, typename A>
|
112
|
+
bool theta_intersection_base<EN, EK, P, S, CS, A>::has_result() const {
|
113
|
+
return is_valid_;
|
114
|
+
}
|
115
|
+
|
116
|
+
template<typename EN, typename EK, typename P, typename S, typename CS, typename A>
|
117
|
+
const P& theta_intersection_base<EN, EK, P, S, CS, A>::get_policy() const {
|
118
|
+
return policy_;
|
119
|
+
}
|
120
|
+
|
121
|
+
} /* namespace datasketches */
|
@@ -0,0 +1,78 @@
|
|
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
|
+
#ifndef THETA_INTERSECTION_EXPERIMENTAL_HPP_
|
21
|
+
#define THETA_INTERSECTION_EXPERIMENTAL_HPP_
|
22
|
+
|
23
|
+
#include "theta_sketch_experimental.hpp"
|
24
|
+
#include "theta_intersection_base.hpp"
|
25
|
+
|
26
|
+
namespace datasketches {
|
27
|
+
|
28
|
+
template<typename Allocator = std::allocator<uint64_t>>
|
29
|
+
class theta_intersection_experimental {
|
30
|
+
public:
|
31
|
+
using Entry = uint64_t;
|
32
|
+
using ExtractKey = trivial_extract_key;
|
33
|
+
using Sketch = theta_sketch_experimental<Allocator>;
|
34
|
+
using CompactSketch = compact_theta_sketch_experimental<Allocator>;
|
35
|
+
|
36
|
+
struct pass_through_policy {
|
37
|
+
uint64_t operator()(uint64_t internal_entry, uint64_t incoming_entry) const {
|
38
|
+
unused(incoming_entry);
|
39
|
+
return internal_entry;
|
40
|
+
}
|
41
|
+
};
|
42
|
+
using State = theta_intersection_base<Entry, ExtractKey, pass_through_policy, Sketch, CompactSketch, Allocator>;
|
43
|
+
|
44
|
+
explicit theta_intersection_experimental(uint64_t seed = DEFAULT_SEED, const Allocator& allocator = Allocator());
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Updates the intersection with a given sketch.
|
48
|
+
* The intersection can be viewed as starting from the "universe" set, and every update
|
49
|
+
* can reduce the current set to leave the overlapping subset only.
|
50
|
+
* @param sketch represents input set for the intersection
|
51
|
+
*/
|
52
|
+
template<typename FwdSketch>
|
53
|
+
void update(FwdSketch&& sketch);
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Produces a copy of the current state of the intersection.
|
57
|
+
* If update() was not called, the state is the infinite "universe",
|
58
|
+
* which is considered an undefined state, and throws an exception.
|
59
|
+
* @param ordered optional flag to specify if ordered sketch should be produced
|
60
|
+
* @return the result of the intersection
|
61
|
+
*/
|
62
|
+
CompactSketch get_result(bool ordered = true) const;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Returns true if the state of the intersection is defined (not infinite "universe").
|
66
|
+
* @return true if the state is valid
|
67
|
+
*/
|
68
|
+
bool has_result() const;
|
69
|
+
|
70
|
+
private:
|
71
|
+
State state_;
|
72
|
+
};
|
73
|
+
|
74
|
+
} /* namespace datasketches */
|
75
|
+
|
76
|
+
#include "theta_intersection_experimental_impl.hpp"
|
77
|
+
|
78
|
+
#endif
|
@@ -0,0 +1,43 @@
|
|
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
|
+
namespace datasketches {
|
21
|
+
|
22
|
+
template<typename A>
|
23
|
+
theta_intersection_experimental<A>::theta_intersection_experimental(uint64_t seed, const A& allocator):
|
24
|
+
state_(seed, pass_through_policy(), allocator)
|
25
|
+
{}
|
26
|
+
|
27
|
+
template<typename A>
|
28
|
+
template<typename SS>
|
29
|
+
void theta_intersection_experimental<A>::update(SS&& sketch) {
|
30
|
+
state_.update(std::forward<SS>(sketch));
|
31
|
+
}
|
32
|
+
|
33
|
+
template<typename A>
|
34
|
+
auto theta_intersection_experimental<A>::get_result(bool ordered) const -> CompactSketch {
|
35
|
+
return state_.get_result(ordered);
|
36
|
+
}
|
37
|
+
|
38
|
+
template<typename A>
|
39
|
+
bool theta_intersection_experimental<A>::has_result() const {
|
40
|
+
return state_.has_result();
|
41
|
+
}
|
42
|
+
|
43
|
+
} /* namespace datasketches */
|
@@ -0,0 +1,54 @@
|
|
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
|
+
#ifndef THETA_SET_DIFFERENCE_BASE_HPP_
|
21
|
+
#define THETA_SET_DIFFERENCE_BASE_HPP_
|
22
|
+
|
23
|
+
#include "theta_comparators.hpp"
|
24
|
+
#include "theta_update_sketch_base.hpp"
|
25
|
+
|
26
|
+
namespace datasketches {
|
27
|
+
|
28
|
+
template<
|
29
|
+
typename Entry,
|
30
|
+
typename ExtractKey,
|
31
|
+
typename CompactSketch,
|
32
|
+
typename Allocator
|
33
|
+
>
|
34
|
+
class theta_set_difference_base {
|
35
|
+
public:
|
36
|
+
using comparator = compare_by_key<ExtractKey>;
|
37
|
+
using AllocU64 = typename std::allocator_traits<Allocator>::template rebind_alloc<uint64_t>;
|
38
|
+
using hash_table = theta_update_sketch_base<uint64_t, trivial_extract_key, AllocU64>;
|
39
|
+
|
40
|
+
theta_set_difference_base(uint64_t seed, const Allocator& allocator = Allocator());
|
41
|
+
|
42
|
+
template<typename FwdSketch, typename Sketch>
|
43
|
+
CompactSketch compute(FwdSketch&& a, const Sketch& b, bool ordered) const;
|
44
|
+
|
45
|
+
private:
|
46
|
+
Allocator allocator_;
|
47
|
+
uint16_t seed_hash_;
|
48
|
+
};
|
49
|
+
|
50
|
+
} /* namespace datasketches */
|
51
|
+
|
52
|
+
#include "theta_set_difference_base_impl.hpp"
|
53
|
+
|
54
|
+
#endif
|
@@ -0,0 +1,80 @@
|
|
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 <algorithm>
|
21
|
+
|
22
|
+
#include "conditional_back_inserter.hpp"
|
23
|
+
#include "conditional_forward.hpp"
|
24
|
+
|
25
|
+
namespace datasketches {
|
26
|
+
|
27
|
+
template<typename EN, typename EK, typename CS, typename A>
|
28
|
+
theta_set_difference_base<EN, EK, CS, A>::theta_set_difference_base(uint64_t seed, const A& allocator):
|
29
|
+
allocator_(allocator),
|
30
|
+
seed_hash_(compute_seed_hash(seed))
|
31
|
+
{}
|
32
|
+
|
33
|
+
template<typename EN, typename EK, typename CS, typename A>
|
34
|
+
template<typename FwdSketch, typename Sketch>
|
35
|
+
CS theta_set_difference_base<EN, EK, CS, A>::compute(FwdSketch&& a, const Sketch& b, bool ordered) const {
|
36
|
+
if (a.is_empty() || a.get_num_retained() == 0 || b.is_empty()) return CS(a, ordered);
|
37
|
+
if (a.get_seed_hash() != seed_hash_) throw std::invalid_argument("A seed hash mismatch");
|
38
|
+
if (b.get_seed_hash() != seed_hash_) throw std::invalid_argument("B seed hash mismatch");
|
39
|
+
|
40
|
+
const uint64_t theta = std::min(a.get_theta64(), b.get_theta64());
|
41
|
+
std::vector<EN, A> entries(allocator_);
|
42
|
+
bool is_empty = a.is_empty();
|
43
|
+
|
44
|
+
if (b.get_num_retained() == 0) {
|
45
|
+
std::copy_if(forward_begin(std::forward<FwdSketch>(a)), forward_end(std::forward<FwdSketch>(a)), std::back_inserter(entries),
|
46
|
+
key_less_than<uint64_t, EN, EK>(theta));
|
47
|
+
} else {
|
48
|
+
if (a.is_ordered() && b.is_ordered()) { // sort-based
|
49
|
+
std::set_difference(forward_begin(std::forward<FwdSketch>(a)), forward_end(std::forward<FwdSketch>(a)), b.begin(), b.end(),
|
50
|
+
conditional_back_inserter(entries, key_less_than<uint64_t, EN, EK>(theta)), comparator());
|
51
|
+
} else { // hash-based
|
52
|
+
const uint8_t lg_size = lg_size_from_count(b.get_num_retained(), hash_table::REBUILD_THRESHOLD);
|
53
|
+
hash_table table(lg_size, lg_size, hash_table::resize_factor::X1, 0, 0, allocator_); // theta and seed are not used here
|
54
|
+
for (const auto& entry: b) {
|
55
|
+
const uint64_t hash = EK()(entry);
|
56
|
+
if (hash < theta) {
|
57
|
+
table.insert(table.find(hash).first, hash);
|
58
|
+
} else if (b.is_ordered()) {
|
59
|
+
break; // early stop
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
// scan A lookup B
|
64
|
+
for (auto& entry: a) {
|
65
|
+
const uint64_t hash = EK()(entry);
|
66
|
+
if (hash < theta) {
|
67
|
+
auto result = table.find(hash);
|
68
|
+
if (!result.second) entries.push_back(conditional_forward<FwdSketch>(entry));
|
69
|
+
} else if (a.is_ordered()) {
|
70
|
+
break; // early stop
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
if (entries.empty() && theta == theta_constants::MAX_THETA) is_empty = true;
|
76
|
+
if (ordered && !a.is_ordered()) std::sort(entries.begin(), entries.end(), comparator());
|
77
|
+
return CS(is_empty, a.is_ordered() || ordered, seed_hash_, theta, std::move(entries));
|
78
|
+
}
|
79
|
+
|
80
|
+
} /* namespace datasketches */
|