datasketches 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE +310 -0
  4. data/NOTICE +11 -0
  5. data/README.md +126 -0
  6. data/ext/datasketches/cpc_wrapper.cpp +50 -0
  7. data/ext/datasketches/ext.cpp +12 -0
  8. data/ext/datasketches/extconf.rb +11 -0
  9. data/ext/datasketches/hll_wrapper.cpp +69 -0
  10. data/lib/datasketches.rb +9 -0
  11. data/lib/datasketches/version.rb +3 -0
  12. data/vendor/datasketches-cpp/CMakeLists.txt +126 -0
  13. data/vendor/datasketches-cpp/LICENSE +311 -0
  14. data/vendor/datasketches-cpp/MANIFEST.in +19 -0
  15. data/vendor/datasketches-cpp/NOTICE +11 -0
  16. data/vendor/datasketches-cpp/README.md +42 -0
  17. data/vendor/datasketches-cpp/common/CMakeLists.txt +45 -0
  18. data/vendor/datasketches-cpp/common/include/MurmurHash3.h +173 -0
  19. data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +458 -0
  20. data/vendor/datasketches-cpp/common/include/bounds_binomial_proportions.hpp +291 -0
  21. data/vendor/datasketches-cpp/common/include/ceiling_power_of_2.hpp +41 -0
  22. data/vendor/datasketches-cpp/common/include/common_defs.hpp +51 -0
  23. data/vendor/datasketches-cpp/common/include/conditional_back_inserter.hpp +68 -0
  24. data/vendor/datasketches-cpp/common/include/conditional_forward.hpp +70 -0
  25. data/vendor/datasketches-cpp/common/include/count_zeros.hpp +114 -0
  26. data/vendor/datasketches-cpp/common/include/inv_pow2_table.hpp +107 -0
  27. data/vendor/datasketches-cpp/common/include/memory_operations.hpp +57 -0
  28. data/vendor/datasketches-cpp/common/include/serde.hpp +196 -0
  29. data/vendor/datasketches-cpp/common/test/CMakeLists.txt +38 -0
  30. data/vendor/datasketches-cpp/common/test/catch.hpp +17618 -0
  31. data/vendor/datasketches-cpp/common/test/catch_runner.cpp +7 -0
  32. data/vendor/datasketches-cpp/common/test/test_allocator.cpp +31 -0
  33. data/vendor/datasketches-cpp/common/test/test_allocator.hpp +108 -0
  34. data/vendor/datasketches-cpp/common/test/test_runner.cpp +29 -0
  35. data/vendor/datasketches-cpp/common/test/test_type.hpp +137 -0
  36. data/vendor/datasketches-cpp/cpc/CMakeLists.txt +74 -0
  37. data/vendor/datasketches-cpp/cpc/include/compression_data.hpp +6022 -0
  38. data/vendor/datasketches-cpp/cpc/include/cpc_common.hpp +62 -0
  39. data/vendor/datasketches-cpp/cpc/include/cpc_compressor.hpp +147 -0
  40. data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +742 -0
  41. data/vendor/datasketches-cpp/cpc/include/cpc_confidence.hpp +167 -0
  42. data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +311 -0
  43. data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +810 -0
  44. data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +102 -0
  45. data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +346 -0
  46. data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +137 -0
  47. data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +274 -0
  48. data/vendor/datasketches-cpp/cpc/include/kxp_byte_lookup.hpp +81 -0
  49. data/vendor/datasketches-cpp/cpc/include/u32_table.hpp +84 -0
  50. data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +266 -0
  51. data/vendor/datasketches-cpp/cpc/test/CMakeLists.txt +44 -0
  52. data/vendor/datasketches-cpp/cpc/test/compression_test.cpp +67 -0
  53. data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +381 -0
  54. data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +149 -0
  55. data/vendor/datasketches-cpp/fi/CMakeLists.txt +54 -0
  56. data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +319 -0
  57. data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +484 -0
  58. data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map.hpp +114 -0
  59. data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map_impl.hpp +345 -0
  60. data/vendor/datasketches-cpp/fi/test/CMakeLists.txt +44 -0
  61. data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_custom_type_test.cpp +84 -0
  62. data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_test.cpp +360 -0
  63. data/vendor/datasketches-cpp/fi/test/items_sketch_string_from_java.sk +0 -0
  64. data/vendor/datasketches-cpp/fi/test/items_sketch_string_utf8_from_java.sk +0 -0
  65. data/vendor/datasketches-cpp/fi/test/longs_sketch_from_java.sk +0 -0
  66. data/vendor/datasketches-cpp/fi/test/reverse_purge_hash_map_test.cpp +47 -0
  67. data/vendor/datasketches-cpp/hll/CMakeLists.txt +92 -0
  68. data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +303 -0
  69. data/vendor/datasketches-cpp/hll/include/AuxHashMap.hpp +83 -0
  70. data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +811 -0
  71. data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable.hpp +40 -0
  72. data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +291 -0
  73. data/vendor/datasketches-cpp/hll/include/CouponHashSet.hpp +59 -0
  74. data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +417 -0
  75. data/vendor/datasketches-cpp/hll/include/CouponList.hpp +91 -0
  76. data/vendor/datasketches-cpp/hll/include/CubicInterpolation-internal.hpp +233 -0
  77. data/vendor/datasketches-cpp/hll/include/CubicInterpolation.hpp +43 -0
  78. data/vendor/datasketches-cpp/hll/include/HarmonicNumbers-internal.hpp +90 -0
  79. data/vendor/datasketches-cpp/hll/include/HarmonicNumbers.hpp +48 -0
  80. data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +335 -0
  81. data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +69 -0
  82. data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +124 -0
  83. data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +55 -0
  84. data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +158 -0
  85. data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +56 -0
  86. data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +706 -0
  87. data/vendor/datasketches-cpp/hll/include/HllArray.hpp +136 -0
  88. data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +462 -0
  89. data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +149 -0
  90. data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +85 -0
  91. data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +170 -0
  92. data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +287 -0
  93. data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +239 -0
  94. data/vendor/datasketches-cpp/hll/include/RelativeErrorTables-internal.hpp +112 -0
  95. data/vendor/datasketches-cpp/hll/include/RelativeErrorTables.hpp +46 -0
  96. data/vendor/datasketches-cpp/hll/include/coupon_iterator-internal.hpp +56 -0
  97. data/vendor/datasketches-cpp/hll/include/coupon_iterator.hpp +43 -0
  98. data/vendor/datasketches-cpp/hll/include/hll.hpp +669 -0
  99. data/vendor/datasketches-cpp/hll/include/hll.private.hpp +32 -0
  100. data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +79 -0
  101. data/vendor/datasketches-cpp/hll/test/CMakeLists.txt +51 -0
  102. data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +130 -0
  103. data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +181 -0
  104. data/vendor/datasketches-cpp/hll/test/CrossCountingTest.cpp +93 -0
  105. data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +191 -0
  106. data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +389 -0
  107. data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +313 -0
  108. data/vendor/datasketches-cpp/hll/test/IsomorphicTest.cpp +141 -0
  109. data/vendor/datasketches-cpp/hll/test/TablesTest.cpp +44 -0
  110. data/vendor/datasketches-cpp/hll/test/ToFromByteArrayTest.cpp +168 -0
  111. data/vendor/datasketches-cpp/hll/test/array6_from_java.sk +0 -0
  112. data/vendor/datasketches-cpp/hll/test/compact_array4_from_java.sk +0 -0
  113. data/vendor/datasketches-cpp/hll/test/compact_set_from_java.sk +0 -0
  114. data/vendor/datasketches-cpp/hll/test/list_from_java.sk +0 -0
  115. data/vendor/datasketches-cpp/hll/test/updatable_array4_from_java.sk +0 -0
  116. data/vendor/datasketches-cpp/hll/test/updatable_set_from_java.sk +0 -0
  117. data/vendor/datasketches-cpp/kll/CMakeLists.txt +58 -0
  118. data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +150 -0
  119. data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +319 -0
  120. data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +67 -0
  121. data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +169 -0
  122. data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +559 -0
  123. data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +1131 -0
  124. data/vendor/datasketches-cpp/kll/test/CMakeLists.txt +44 -0
  125. data/vendor/datasketches-cpp/kll/test/kll_sketch_custom_type_test.cpp +154 -0
  126. data/vendor/datasketches-cpp/kll/test/kll_sketch_float_one_item_v1.sk +0 -0
  127. data/vendor/datasketches-cpp/kll/test/kll_sketch_from_java.sk +0 -0
  128. data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +685 -0
  129. data/vendor/datasketches-cpp/kll/test/kll_sketch_validation.cpp +229 -0
  130. data/vendor/datasketches-cpp/pyproject.toml +17 -0
  131. data/vendor/datasketches-cpp/python/CMakeLists.txt +61 -0
  132. data/vendor/datasketches-cpp/python/README.md +78 -0
  133. data/vendor/datasketches-cpp/python/jupyter/CPCSketch.ipynb +345 -0
  134. data/vendor/datasketches-cpp/python/jupyter/FrequentItemsSketch.ipynb +354 -0
  135. data/vendor/datasketches-cpp/python/jupyter/HLLSketch.ipynb +346 -0
  136. data/vendor/datasketches-cpp/python/jupyter/KLLSketch.ipynb +463 -0
  137. data/vendor/datasketches-cpp/python/jupyter/ThetaSketchNotebook.ipynb +396 -0
  138. data/vendor/datasketches-cpp/python/src/__init__.py +2 -0
  139. data/vendor/datasketches-cpp/python/src/cpc_wrapper.cpp +90 -0
  140. data/vendor/datasketches-cpp/python/src/datasketches.cpp +40 -0
  141. data/vendor/datasketches-cpp/python/src/fi_wrapper.cpp +123 -0
  142. data/vendor/datasketches-cpp/python/src/hll_wrapper.cpp +136 -0
  143. data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +209 -0
  144. data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +162 -0
  145. data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +488 -0
  146. data/vendor/datasketches-cpp/python/src/vo_wrapper.cpp +140 -0
  147. data/vendor/datasketches-cpp/python/tests/__init__.py +0 -0
  148. data/vendor/datasketches-cpp/python/tests/cpc_test.py +64 -0
  149. data/vendor/datasketches-cpp/python/tests/fi_test.py +110 -0
  150. data/vendor/datasketches-cpp/python/tests/hll_test.py +131 -0
  151. data/vendor/datasketches-cpp/python/tests/kll_test.py +119 -0
  152. data/vendor/datasketches-cpp/python/tests/theta_test.py +121 -0
  153. data/vendor/datasketches-cpp/python/tests/vector_of_kll_test.py +148 -0
  154. data/vendor/datasketches-cpp/python/tests/vo_test.py +101 -0
  155. data/vendor/datasketches-cpp/sampling/CMakeLists.txt +48 -0
  156. data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +392 -0
  157. data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +1752 -0
  158. data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +239 -0
  159. data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +645 -0
  160. data/vendor/datasketches-cpp/sampling/test/CMakeLists.txt +43 -0
  161. data/vendor/datasketches-cpp/sampling/test/binaries_from_java.txt +67 -0
  162. data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +509 -0
  163. data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +358 -0
  164. data/vendor/datasketches-cpp/sampling/test/varopt_sketch_long_sampling.sk +0 -0
  165. data/vendor/datasketches-cpp/sampling/test/varopt_sketch_string_exact.sk +0 -0
  166. data/vendor/datasketches-cpp/sampling/test/varopt_union_double_sampling.sk +0 -0
  167. data/vendor/datasketches-cpp/setup.py +94 -0
  168. data/vendor/datasketches-cpp/theta/CMakeLists.txt +57 -0
  169. data/vendor/datasketches-cpp/theta/include/theta_a_not_b.hpp +73 -0
  170. data/vendor/datasketches-cpp/theta/include/theta_a_not_b_impl.hpp +83 -0
  171. data/vendor/datasketches-cpp/theta/include/theta_intersection.hpp +88 -0
  172. data/vendor/datasketches-cpp/theta/include/theta_intersection_impl.hpp +130 -0
  173. data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +533 -0
  174. data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +939 -0
  175. data/vendor/datasketches-cpp/theta/include/theta_union.hpp +122 -0
  176. data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +109 -0
  177. data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +45 -0
  178. data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +244 -0
  179. data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java.sk +0 -0
  180. data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java.sk +0 -0
  181. data/vendor/datasketches-cpp/theta/test/theta_compact_single_item_from_java.sk +0 -0
  182. data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +218 -0
  183. data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +438 -0
  184. data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +97 -0
  185. data/vendor/datasketches-cpp/theta/test/theta_update_empty_from_java.sk +0 -0
  186. data/vendor/datasketches-cpp/theta/test/theta_update_estimation_from_java.sk +0 -0
  187. data/vendor/datasketches-cpp/tuple/CMakeLists.txt +104 -0
  188. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_a_not_b.hpp +52 -0
  189. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_a_not_b_impl.hpp +32 -0
  190. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_intersection.hpp +52 -0
  191. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_intersection_impl.hpp +31 -0
  192. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch.hpp +179 -0
  193. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +238 -0
  194. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union.hpp +81 -0
  195. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union_impl.hpp +43 -0
  196. data/vendor/datasketches-cpp/tuple/include/bounds_on_ratios_in_sampled_sets.hpp +135 -0
  197. data/vendor/datasketches-cpp/tuple/include/bounds_on_ratios_in_theta_sketched_sets.hpp +135 -0
  198. data/vendor/datasketches-cpp/tuple/include/jaccard_similarity.hpp +172 -0
  199. data/vendor/datasketches-cpp/tuple/include/theta_a_not_b_experimental.hpp +53 -0
  200. data/vendor/datasketches-cpp/tuple/include/theta_a_not_b_experimental_impl.hpp +33 -0
  201. data/vendor/datasketches-cpp/tuple/include/theta_comparators.hpp +48 -0
  202. data/vendor/datasketches-cpp/tuple/include/theta_constants.hpp +34 -0
  203. data/vendor/datasketches-cpp/tuple/include/theta_helpers.hpp +54 -0
  204. data/vendor/datasketches-cpp/tuple/include/theta_intersection_base.hpp +59 -0
  205. data/vendor/datasketches-cpp/tuple/include/theta_intersection_base_impl.hpp +121 -0
  206. data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental.hpp +78 -0
  207. data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental_impl.hpp +43 -0
  208. data/vendor/datasketches-cpp/tuple/include/theta_set_difference_base.hpp +54 -0
  209. data/vendor/datasketches-cpp/tuple/include/theta_set_difference_base_impl.hpp +80 -0
  210. data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental.hpp +393 -0
  211. data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental_impl.hpp +481 -0
  212. data/vendor/datasketches-cpp/tuple/include/theta_union_base.hpp +60 -0
  213. data/vendor/datasketches-cpp/tuple/include/theta_union_base_impl.hpp +84 -0
  214. data/vendor/datasketches-cpp/tuple/include/theta_union_experimental.hpp +88 -0
  215. data/vendor/datasketches-cpp/tuple/include/theta_union_experimental_impl.hpp +47 -0
  216. data/vendor/datasketches-cpp/tuple/include/theta_update_sketch_base.hpp +259 -0
  217. data/vendor/datasketches-cpp/tuple/include/theta_update_sketch_base_impl.hpp +389 -0
  218. data/vendor/datasketches-cpp/tuple/include/tuple_a_not_b.hpp +57 -0
  219. data/vendor/datasketches-cpp/tuple/include/tuple_a_not_b_impl.hpp +33 -0
  220. data/vendor/datasketches-cpp/tuple/include/tuple_intersection.hpp +104 -0
  221. data/vendor/datasketches-cpp/tuple/include/tuple_intersection_impl.hpp +43 -0
  222. data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +496 -0
  223. data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +587 -0
  224. data/vendor/datasketches-cpp/tuple/include/tuple_union.hpp +109 -0
  225. data/vendor/datasketches-cpp/tuple/include/tuple_union_impl.hpp +47 -0
  226. data/vendor/datasketches-cpp/tuple/test/CMakeLists.txt +53 -0
  227. data/vendor/datasketches-cpp/tuple/test/aod_1_compact_empty_from_java.sk +1 -0
  228. data/vendor/datasketches-cpp/tuple/test/aod_1_compact_estimation_from_java.sk +0 -0
  229. data/vendor/datasketches-cpp/tuple/test/aod_1_compact_non_empty_no_entries_from_java.sk +0 -0
  230. data/vendor/datasketches-cpp/tuple/test/aod_2_compact_exact_from_java.sk +0 -0
  231. data/vendor/datasketches-cpp/tuple/test/aod_3_compact_empty_from_java.sk +1 -0
  232. data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +298 -0
  233. data/vendor/datasketches-cpp/tuple/test/theta_a_not_b_experimental_test.cpp +250 -0
  234. data/vendor/datasketches-cpp/tuple/test/theta_compact_empty_from_java.sk +0 -0
  235. data/vendor/datasketches-cpp/tuple/test/theta_compact_estimation_from_java.sk +0 -0
  236. data/vendor/datasketches-cpp/tuple/test/theta_compact_single_item_from_java.sk +0 -0
  237. data/vendor/datasketches-cpp/tuple/test/theta_intersection_experimental_test.cpp +224 -0
  238. data/vendor/datasketches-cpp/tuple/test/theta_jaccard_similarity_test.cpp +144 -0
  239. data/vendor/datasketches-cpp/tuple/test/theta_sketch_experimental_test.cpp +247 -0
  240. data/vendor/datasketches-cpp/tuple/test/theta_union_experimental_test.cpp +44 -0
  241. data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +289 -0
  242. data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +235 -0
  243. data/vendor/datasketches-cpp/tuple/test/tuple_jaccard_similarity_test.cpp +98 -0
  244. data/vendor/datasketches-cpp/tuple/test/tuple_sketch_allocation_test.cpp +102 -0
  245. data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +249 -0
  246. data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +187 -0
  247. metadata +302 -0
@@ -0,0 +1,104 @@
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 TUPLE_INTERSECTION_HPP_
21
+ #define TUPLE_INTERSECTION_HPP_
22
+
23
+ #include "tuple_sketch.hpp"
24
+ #include "theta_intersection_base.hpp"
25
+
26
+ namespace datasketches {
27
+
28
+ /*
29
+ // for types with defined + operation
30
+ template<typename Summary>
31
+ struct example_intersection_policy {
32
+ void operator()(Summary& summary, const Summary& other) const {
33
+ summary += other;
34
+ }
35
+ void operator()(Summary& summary, Summary&& other) const {
36
+ summary += other;
37
+ }
38
+ };
39
+ */
40
+
41
+ template<
42
+ typename Summary,
43
+ typename Policy,
44
+ typename Allocator = std::allocator<Summary>
45
+ >
46
+ class tuple_intersection {
47
+ public:
48
+ using Entry = std::pair<uint64_t, Summary>;
49
+ using ExtractKey = pair_extract_key<uint64_t, Summary>;
50
+ using Sketch = tuple_sketch<Summary, Allocator>;
51
+ using CompactSketch = compact_tuple_sketch<Summary, Allocator>;
52
+ using AllocEntry = typename std::allocator_traits<Allocator>::template rebind_alloc<Entry>;
53
+
54
+ // reformulate the external policy that operates on Summary
55
+ // in terms of operations on Entry
56
+ struct internal_policy {
57
+ internal_policy(const Policy& policy): policy_(policy) {}
58
+ void operator()(Entry& internal_entry, const Entry& incoming_entry) const {
59
+ policy_(internal_entry.second, incoming_entry.second);
60
+ }
61
+ void operator()(Entry& internal_entry, Entry&& incoming_entry) const {
62
+ policy_(internal_entry.second, std::move(incoming_entry.second));
63
+ }
64
+ const Policy& get_policy() const { return policy_; }
65
+ Policy policy_;
66
+ };
67
+
68
+ using State = theta_intersection_base<Entry, ExtractKey, internal_policy, Sketch, CompactSketch, AllocEntry>;
69
+
70
+ explicit tuple_intersection(uint64_t seed = DEFAULT_SEED, const Policy& policy = Policy(), const Allocator& allocator = Allocator());
71
+
72
+ /**
73
+ * Updates the intersection with a given sketch.
74
+ * The intersection can be viewed as starting from the "universe" set, and every update
75
+ * can reduce the current set to leave the overlapping subset only.
76
+ * @param sketch represents input set for the intersection
77
+ */
78
+ template<typename FwdSketch>
79
+ void update(FwdSketch&& sketch);
80
+
81
+ /**
82
+ * Produces a copy of the current state of the intersection.
83
+ * If update() was not called, the state is the infinite "universe",
84
+ * which is considered an undefined state, and throws an exception.
85
+ * @param ordered optional flag to specify if ordered sketch should be produced
86
+ * @return the result of the intersection
87
+ */
88
+ CompactSketch get_result(bool ordered = true) const;
89
+
90
+ /**
91
+ * Returns true if the state of the intersection is defined (not infinite "universe").
92
+ * @return true if the state is valid
93
+ */
94
+ bool has_result() const;
95
+
96
+ protected:
97
+ State state_;
98
+ };
99
+
100
+ } /* namespace datasketches */
101
+
102
+ #include "tuple_intersection_impl.hpp"
103
+
104
+ #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 S, typename P, typename A>
23
+ tuple_intersection<S, P, A>::tuple_intersection(uint64_t seed, const P& policy, const A& allocator):
24
+ state_(seed, internal_policy(policy), allocator)
25
+ {}
26
+
27
+ template<typename S, typename P, typename A>
28
+ template<typename SS>
29
+ void tuple_intersection<S, P, A>::update(SS&& sketch) {
30
+ state_.update(std::forward<SS>(sketch));
31
+ }
32
+
33
+ template<typename S, typename P, typename A>
34
+ auto tuple_intersection<S, P, A>::get_result(bool ordered) const -> CompactSketch {
35
+ return state_.get_result(ordered);
36
+ }
37
+
38
+ template<typename S, typename P, typename A>
39
+ bool tuple_intersection<S, P, A>::has_result() const {
40
+ return state_.has_result();
41
+ }
42
+
43
+ } /* namespace datasketches */
@@ -0,0 +1,496 @@
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 TUPLE_SKETCH_HPP_
21
+ #define TUPLE_SKETCH_HPP_
22
+
23
+ #include <string>
24
+
25
+ #include "serde.hpp"
26
+ #include "theta_update_sketch_base.hpp"
27
+
28
+ namespace datasketches {
29
+
30
+ // forward-declarations
31
+ template<typename S, typename A> class tuple_sketch;
32
+ template<typename S, typename U, typename P, typename A> class update_tuple_sketch;
33
+ template<typename S, typename A> class compact_tuple_sketch;
34
+ template<typename A> class theta_sketch_experimental;
35
+
36
+ template<
37
+ typename Summary,
38
+ typename Allocator = std::allocator<Summary>
39
+ >
40
+ class tuple_sketch {
41
+ public:
42
+ using Entry = std::pair<uint64_t, Summary>;
43
+ using ExtractKey = pair_extract_key<uint64_t, Summary>;
44
+ using iterator = theta_iterator<Entry, ExtractKey>;
45
+ using const_iterator = theta_const_iterator<Entry, ExtractKey>;
46
+
47
+ virtual ~tuple_sketch() = default;
48
+
49
+ /**
50
+ * @return allocator
51
+ */
52
+ virtual Allocator get_allocator() const = 0;
53
+
54
+ /**
55
+ * @return true if this sketch represents an empty set (not the same as no retained entries!)
56
+ */
57
+ virtual bool is_empty() const = 0;
58
+
59
+ /**
60
+ * @return estimate of the distinct count of the input stream
61
+ */
62
+ double get_estimate() const;
63
+
64
+ /**
65
+ * Returns the approximate lower error bound given a number of standard deviations.
66
+ * This parameter is similar to the number of standard deviations of the normal distribution
67
+ * and corresponds to approximately 67%, 95% and 99% confidence intervals.
68
+ * @param num_std_devs number of Standard Deviations (1, 2 or 3)
69
+ * @return the lower bound
70
+ */
71
+ double get_lower_bound(uint8_t num_std_devs) const;
72
+
73
+ /**
74
+ * Returns the approximate upper error bound given a number of standard deviations.
75
+ * This parameter is similar to the number of standard deviations of the normal distribution
76
+ * and corresponds to approximately 67%, 95% and 99% confidence intervals.
77
+ * @param num_std_devs number of Standard Deviations (1, 2 or 3)
78
+ * @return the upper bound
79
+ */
80
+ double get_upper_bound(uint8_t num_std_devs) const;
81
+
82
+ /**
83
+ * @return true if the sketch is in estimation mode (as opposed to exact mode)
84
+ */
85
+ bool is_estimation_mode() const;
86
+
87
+ /**
88
+ * @return theta as a fraction from 0 to 1 (effective sampling rate)
89
+ */
90
+ double get_theta() const;
91
+
92
+ /**
93
+ * @return theta as a positive integer between 0 and LLONG_MAX
94
+ */
95
+ virtual uint64_t get_theta64() const = 0;
96
+
97
+ /**
98
+ * @return the number of retained entries in the sketch
99
+ */
100
+ virtual uint32_t get_num_retained() const = 0;
101
+
102
+ /**
103
+ * @return hash of the seed that was used to hash the input
104
+ */
105
+ virtual uint16_t get_seed_hash() const = 0;
106
+
107
+ /**
108
+ * @return true if retained entries are ordered
109
+ */
110
+ virtual bool is_ordered() const = 0;
111
+
112
+ /**
113
+ * Provides a human-readable summary of this sketch as a string
114
+ * @param print_items if true include the list of items retained by the sketch
115
+ * @return sketch summary as a string
116
+ */
117
+ string<Allocator> to_string(bool print_items = false) const;
118
+
119
+ /**
120
+ * Iterator over entries in this sketch.
121
+ * @return begin iterator
122
+ */
123
+ virtual iterator begin() = 0;
124
+
125
+ /**
126
+ * Iterator pointing past the valid range.
127
+ * Not to be incremented or dereferenced.
128
+ * @return end iterator
129
+ */
130
+ virtual iterator end() = 0;
131
+
132
+ /**
133
+ * Const iterator over entries in this sketch.
134
+ * @return begin const iterator
135
+ */
136
+ virtual const_iterator begin() const = 0;
137
+
138
+ /**
139
+ * Const iterator pointing past the valid range.
140
+ * Not to be incremented or dereferenced.
141
+ * @return end const iterator
142
+ */
143
+ virtual const_iterator end() const = 0;
144
+
145
+ protected:
146
+ virtual void print_specifics(std::basic_ostream<char>& os) const = 0;
147
+
148
+ static uint16_t get_seed_hash(uint64_t seed);
149
+
150
+ static void check_sketch_type(uint8_t actual, uint8_t expected);
151
+ static void check_serial_version(uint8_t actual, uint8_t expected);
152
+ static void check_seed_hash(uint16_t actual, uint16_t expected);
153
+ };
154
+
155
+ // update sketch
156
+
157
+ // for types with defined default constructor and + operation
158
+ template<typename Summary, typename Update>
159
+ struct default_update_policy {
160
+ Summary create() const {
161
+ return Summary();
162
+ }
163
+ void update(Summary& summary, const Update& update) const {
164
+ summary += update;
165
+ }
166
+ };
167
+
168
+ template<
169
+ typename Summary,
170
+ typename Update = Summary,
171
+ typename Policy = default_update_policy<Summary, Update>,
172
+ typename Allocator = std::allocator<Summary>
173
+ >
174
+ class update_tuple_sketch: public tuple_sketch<Summary, Allocator> {
175
+ public:
176
+ using Base = tuple_sketch<Summary, Allocator>;
177
+ using Entry = typename Base::Entry;
178
+ using ExtractKey = typename Base::ExtractKey;
179
+ using iterator = typename Base::iterator;
180
+ using const_iterator = typename Base::const_iterator;
181
+ using AllocEntry = typename std::allocator_traits<Allocator>::template rebind_alloc<Entry>;
182
+ using tuple_map = theta_update_sketch_base<Entry, ExtractKey, AllocEntry>;
183
+ using resize_factor = typename tuple_map::resize_factor;
184
+
185
+ // No constructor here. Use builder instead.
186
+ class builder;
187
+
188
+ update_tuple_sketch(const update_tuple_sketch&) = default;
189
+ update_tuple_sketch(update_tuple_sketch&&) noexcept = default;
190
+ virtual ~update_tuple_sketch() = default;
191
+ update_tuple_sketch& operator=(const update_tuple_sketch&) = default;
192
+ update_tuple_sketch& operator=(update_tuple_sketch&&) = default;
193
+
194
+ virtual Allocator get_allocator() const;
195
+ virtual bool is_empty() const;
196
+ virtual bool is_ordered() const;
197
+ virtual uint64_t get_theta64() const;
198
+ virtual uint32_t get_num_retained() const;
199
+ virtual uint16_t get_seed_hash() const;
200
+
201
+ /**
202
+ * @return configured nominal number of entries in the sketch
203
+ */
204
+ uint8_t get_lg_k() const;
205
+
206
+ /**
207
+ * @return configured resize factor of the sketch
208
+ */
209
+ resize_factor get_rf() const;
210
+
211
+ /**
212
+ * Update this sketch with a given string.
213
+ * @param value string to update the sketch with
214
+ */
215
+ template<typename FwdUpdate>
216
+ inline void update(const std::string& key, FwdUpdate&& value);
217
+
218
+ /**
219
+ * Update this sketch with a given unsigned 64-bit integer.
220
+ * @param value uint64_t to update the sketch with
221
+ */
222
+ template<typename FwdUpdate>
223
+ inline void update(uint64_t key, FwdUpdate&& value);
224
+
225
+ /**
226
+ * Update this sketch with a given signed 64-bit integer.
227
+ * @param value int64_t to update the sketch with
228
+ */
229
+ template<typename FwdUpdate>
230
+ inline void update(int64_t key, FwdUpdate&& value);
231
+
232
+ /**
233
+ * Update this sketch with a given unsigned 32-bit integer.
234
+ * For compatibility with Java implementation.
235
+ * @param value uint32_t to update the sketch with
236
+ */
237
+ template<typename FwdUpdate>
238
+ inline void update(uint32_t key, FwdUpdate&& value);
239
+
240
+ /**
241
+ * Update this sketch with a given signed 32-bit integer.
242
+ * For compatibility with Java implementation.
243
+ * @param value int32_t to update the sketch with
244
+ */
245
+ template<typename FwdUpdate>
246
+ inline void update(int32_t key, FwdUpdate&& value);
247
+
248
+ /**
249
+ * Update this sketch with a given unsigned 16-bit integer.
250
+ * For compatibility with Java implementation.
251
+ * @param value uint16_t to update the sketch with
252
+ */
253
+ template<typename FwdUpdate>
254
+ inline void update(uint16_t key, FwdUpdate&& value);
255
+
256
+ /**
257
+ * Update this sketch with a given signed 16-bit integer.
258
+ * For compatibility with Java implementation.
259
+ * @param value int16_t to update the sketch with
260
+ */
261
+ template<typename FwdUpdate>
262
+ inline void update(int16_t key, FwdUpdate&& value);
263
+
264
+ /**
265
+ * Update this sketch with a given unsigned 8-bit integer.
266
+ * For compatibility with Java implementation.
267
+ * @param value uint8_t to update the sketch with
268
+ */
269
+ template<typename FwdUpdate>
270
+ inline void update(uint8_t key, FwdUpdate&& value);
271
+
272
+ /**
273
+ * Update this sketch with a given signed 8-bit integer.
274
+ * For compatibility with Java implementation.
275
+ * @param value int8_t to update the sketch with
276
+ */
277
+ template<typename FwdUpdate>
278
+ inline void update(int8_t key, FwdUpdate&& value);
279
+
280
+ /**
281
+ * Update this sketch with a given double-precision floating point value.
282
+ * For compatibility with Java implementation.
283
+ * @param value double to update the sketch with
284
+ */
285
+ template<typename FwdUpdate>
286
+ inline void update(double key, FwdUpdate&& value);
287
+
288
+ /**
289
+ * Update this sketch with a given floating point value.
290
+ * For compatibility with Java implementation.
291
+ * @param value float to update the sketch with
292
+ */
293
+ template<typename FwdUpdate>
294
+ inline void update(float key, FwdUpdate&& value);
295
+
296
+ /**
297
+ * Update this sketch with given data of any type.
298
+ * This is a "universal" update that covers all cases above,
299
+ * but may produce different hashes.
300
+ * Be very careful to hash input values consistently using the same approach
301
+ * both over time and on different platforms
302
+ * and while passing sketches between C++ environment and Java environment.
303
+ * Otherwise two sketches that should represent overlapping sets will be disjoint
304
+ * For instance, for signed 32-bit values call update(int32_t) method above,
305
+ * which does widening conversion to int64_t, if compatibility with Java is expected
306
+ * @param data pointer to the data
307
+ * @param length of the data in bytes
308
+ */
309
+ template<typename FwdUpdate>
310
+ void update(const void* key, size_t length, FwdUpdate&& value);
311
+
312
+ /**
313
+ * Remove retained entries in excess of the nominal size k (if any)
314
+ */
315
+ void trim();
316
+
317
+ /**
318
+ * Converts this sketch to a compact sketch (ordered or unordered).
319
+ * @param ordered optional flag to specify if ordered sketch should be produced
320
+ * @return compact sketch
321
+ */
322
+ compact_tuple_sketch<Summary, Allocator> compact(bool ordered = true) const;
323
+
324
+ virtual iterator begin();
325
+ virtual iterator end();
326
+ virtual const_iterator begin() const;
327
+ virtual const_iterator end() const;
328
+
329
+ protected:
330
+ Policy policy_;
331
+ tuple_map map_;
332
+
333
+ // for builder
334
+ update_tuple_sketch(uint8_t lg_cur_size, uint8_t lg_nom_size, resize_factor rf, uint64_t theta, uint64_t seed, const Policy& policy, const Allocator& allocator);
335
+
336
+ virtual void print_specifics(std::basic_ostream<char>& os) const;
337
+ };
338
+
339
+ // compact sketch
340
+
341
+ template<
342
+ typename Summary,
343
+ typename Allocator = std::allocator<Summary>
344
+ >
345
+ class compact_tuple_sketch: public tuple_sketch<Summary, Allocator> {
346
+ public:
347
+ using Base = tuple_sketch<Summary, Allocator>;
348
+ using Entry = typename Base::Entry;
349
+ using ExtractKey = typename Base::ExtractKey;
350
+ using iterator = typename Base::iterator;
351
+ using const_iterator = typename Base::const_iterator;
352
+ using AllocEntry = typename std::allocator_traits<Allocator>::template rebind_alloc<Entry>;
353
+ using AllocU64 = typename std::allocator_traits<Allocator>::template rebind_alloc<uint64_t>;
354
+ using AllocBytes = typename std::allocator_traits<Allocator>::template rebind_alloc<uint8_t>;
355
+ using vector_bytes = std::vector<uint8_t, AllocBytes>;
356
+ using comparator = compare_by_key<ExtractKey>;
357
+
358
+ static const uint8_t SERIAL_VERSION = 1;
359
+ static const uint8_t SKETCH_FAMILY = 9;
360
+ static const uint8_t SKETCH_TYPE = 5;
361
+ enum flags { IS_BIG_ENDIAN, IS_READ_ONLY, IS_EMPTY, IS_COMPACT, IS_ORDERED };
362
+
363
+ // Instances of this type can be obtained:
364
+ // - by compacting an update_tuple_sketch
365
+ // - as a result of a set operation
366
+ // - by deserializing a previously serialized compact sketch
367
+
368
+ compact_tuple_sketch(const Base& other, bool ordered);
369
+ compact_tuple_sketch(const compact_tuple_sketch&) = default;
370
+ compact_tuple_sketch(compact_tuple_sketch&&) noexcept;
371
+ virtual ~compact_tuple_sketch() = default;
372
+ compact_tuple_sketch& operator=(const compact_tuple_sketch&) = default;
373
+ compact_tuple_sketch& operator=(compact_tuple_sketch&&) = default;
374
+
375
+ compact_tuple_sketch(const theta_sketch_experimental<AllocU64>& other, const Summary& summary, bool ordered = true);
376
+
377
+ virtual Allocator get_allocator() const;
378
+ virtual bool is_empty() const;
379
+ virtual bool is_ordered() const;
380
+ virtual uint64_t get_theta64() const;
381
+ virtual uint32_t get_num_retained() const;
382
+ virtual uint16_t get_seed_hash() const;
383
+
384
+ template<typename SerDe = serde<Summary>>
385
+ void serialize(std::ostream& os, const SerDe& sd = SerDe()) const;
386
+
387
+ template<typename SerDe = serde<Summary>>
388
+ vector_bytes serialize(unsigned header_size_bytes = 0, const SerDe& sd = SerDe()) const;
389
+
390
+ virtual iterator begin();
391
+ virtual iterator end();
392
+ virtual const_iterator begin() const;
393
+ virtual const_iterator end() const;
394
+
395
+ /**
396
+ * This method deserializes a sketch from a given stream.
397
+ * @param is input stream
398
+ * @param seed the seed for the hash function that was used to create the sketch
399
+ * @param instance of a SerDe
400
+ * @return an instance of a sketch
401
+ */
402
+ template<typename SerDe = serde<Summary>>
403
+ static compact_tuple_sketch deserialize(std::istream& is, uint64_t seed = DEFAULT_SEED,
404
+ const SerDe& sd = SerDe(), const Allocator& allocator = Allocator());
405
+
406
+ /**
407
+ * This method deserializes a sketch from a given array of bytes.
408
+ * @param bytes pointer to the array of bytes
409
+ * @param size the size of the array
410
+ * @param seed the seed for the hash function that was used to create the sketch
411
+ * @param instance of a SerDe
412
+ * @return an instance of the sketch
413
+ */
414
+ template<typename SerDe = serde<Summary>>
415
+ static compact_tuple_sketch deserialize(const void* bytes, size_t size, uint64_t seed = DEFAULT_SEED,
416
+ const SerDe& sd = SerDe(), const Allocator& allocator = Allocator());
417
+
418
+ // for internal use
419
+ compact_tuple_sketch(bool is_empty, bool is_ordered, uint16_t seed_hash, uint64_t theta, std::vector<Entry, AllocEntry>&& entries);
420
+
421
+ protected:
422
+ bool is_empty_;
423
+ bool is_ordered_;
424
+ uint16_t seed_hash_;
425
+ uint64_t theta_;
426
+ std::vector<Entry, AllocEntry> entries_;
427
+
428
+ /**
429
+ * Computes size needed to serialize summaries in the sketch.
430
+ * This version is for fixed-size arithmetic types (integral and floating point).
431
+ * @return size in bytes needed to serialize summaries in this sketch
432
+ */
433
+ template<typename SerDe, typename SS = Summary, typename std::enable_if<std::is_arithmetic<SS>::value, int>::type = 0>
434
+ size_t get_serialized_size_summaries_bytes(const SerDe& sd) const;
435
+
436
+ /**
437
+ * Computes size needed to serialize summaries in the sketch.
438
+ * This version is for all other types and can be expensive since every item needs to be looked at.
439
+ * @return size in bytes needed to serialize summaries in this sketch
440
+ */
441
+ template<typename SerDe, typename SS = Summary, typename std::enable_if<!std::is_arithmetic<SS>::value, int>::type = 0>
442
+ size_t get_serialized_size_summaries_bytes(const SerDe& sd) const;
443
+
444
+ // for deserialize
445
+ class deleter_of_summaries {
446
+ public:
447
+ deleter_of_summaries(uint32_t num, bool destroy): num(num), destroy(destroy) {}
448
+ void set_destroy(bool destroy) { this->destroy = destroy; }
449
+ void operator() (Summary* ptr) const {
450
+ if (ptr != nullptr) {
451
+ if (destroy) {
452
+ for (uint32_t i = 0; i < num; ++i) ptr[i].~Summary();
453
+ }
454
+ Allocator().deallocate(ptr, num);
455
+ }
456
+ }
457
+ private:
458
+ uint32_t num;
459
+ bool destroy;
460
+ };
461
+
462
+ virtual void print_specifics(std::basic_ostream<char>& os) const;
463
+
464
+ };
465
+
466
+ // builder
467
+
468
+ template<typename Derived, typename Policy, typename Allocator>
469
+ class tuple_base_builder: public theta_base_builder<Derived, Allocator> {
470
+ public:
471
+ tuple_base_builder(const Policy& policy, const Allocator& allocator);
472
+
473
+ protected:
474
+ Policy policy_;
475
+ };
476
+
477
+ template<typename S, typename U, typename P, typename A>
478
+ class update_tuple_sketch<S, U, P, A>::builder: public tuple_base_builder<builder, P, A> {
479
+ public:
480
+ /**
481
+ * Creates and instance of the builder with default parameters.
482
+ */
483
+ builder(const P& policy = P(), const A& allocator = A());
484
+
485
+ /**
486
+ * This is to create an instance of the sketch with predefined parameters.
487
+ * @return an instance of the sketch
488
+ */
489
+ update_tuple_sketch<S, U, P, A> build() const;
490
+ };
491
+
492
+ } /* namespace datasketches */
493
+
494
+ #include "tuple_sketch_impl.hpp"
495
+
496
+ #endif