datasketches 0.2.0 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/LICENSE +40 -3
  4. data/NOTICE +1 -1
  5. data/README.md +7 -7
  6. data/ext/datasketches/extconf.rb +1 -1
  7. data/ext/datasketches/theta_wrapper.cpp +20 -4
  8. data/lib/datasketches/version.rb +1 -1
  9. data/vendor/datasketches-cpp/CMakeLists.txt +31 -3
  10. data/vendor/datasketches-cpp/LICENSE +40 -3
  11. data/vendor/datasketches-cpp/MANIFEST.in +3 -0
  12. data/vendor/datasketches-cpp/NOTICE +1 -1
  13. data/vendor/datasketches-cpp/README.md +76 -9
  14. data/vendor/datasketches-cpp/cmake/DataSketchesConfig.cmake.in +10 -0
  15. data/vendor/datasketches-cpp/common/CMakeLists.txt +14 -13
  16. data/vendor/datasketches-cpp/common/include/MurmurHash3.h +11 -7
  17. data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +8 -8
  18. data/vendor/datasketches-cpp/common/include/bounds_binomial_proportions.hpp +12 -15
  19. data/vendor/datasketches-cpp/common/include/common_defs.hpp +26 -0
  20. data/vendor/datasketches-cpp/common/include/conditional_forward.hpp +20 -8
  21. data/vendor/datasketches-cpp/common/include/count_zeros.hpp +2 -2
  22. data/vendor/datasketches-cpp/common/include/serde.hpp +7 -7
  23. data/vendor/datasketches-cpp/cpc/CMakeLists.txt +15 -35
  24. data/vendor/datasketches-cpp/cpc/include/cpc_common.hpp +10 -3
  25. data/vendor/datasketches-cpp/cpc/include/cpc_compressor.hpp +19 -19
  26. data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +91 -89
  27. data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +15 -2
  28. data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +126 -90
  29. data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +1 -1
  30. data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +22 -20
  31. data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +10 -10
  32. data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +4 -4
  33. data/vendor/datasketches-cpp/cpc/include/u32_table.hpp +8 -8
  34. data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +14 -14
  35. data/vendor/datasketches-cpp/cpc/test/compression_test.cpp +10 -10
  36. data/vendor/datasketches-cpp/cpc/test/cpc_sketch_allocation_test.cpp +17 -0
  37. data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +25 -0
  38. data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +1 -1
  39. data/vendor/datasketches-cpp/fi/CMakeLists.txt +5 -15
  40. data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +69 -82
  41. data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map_impl.hpp +10 -10
  42. data/vendor/datasketches-cpp/fi/test/reverse_purge_hash_map_test.cpp +2 -2
  43. data/vendor/datasketches-cpp/hll/CMakeLists.txt +33 -56
  44. data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +60 -63
  45. data/vendor/datasketches-cpp/hll/include/AuxHashMap.hpp +19 -19
  46. data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +15 -15
  47. data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable.hpp +3 -3
  48. data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +74 -76
  49. data/vendor/datasketches-cpp/hll/include/CouponHashSet.hpp +6 -6
  50. data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +110 -113
  51. data/vendor/datasketches-cpp/hll/include/CouponList.hpp +13 -13
  52. data/vendor/datasketches-cpp/hll/include/CubicInterpolation-internal.hpp +2 -4
  53. data/vendor/datasketches-cpp/hll/include/HarmonicNumbers-internal.hpp +1 -1
  54. data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +80 -76
  55. data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +9 -9
  56. data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +26 -26
  57. data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +6 -6
  58. data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +33 -33
  59. data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +6 -6
  60. data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +205 -209
  61. data/vendor/datasketches-cpp/hll/include/HllArray.hpp +36 -36
  62. data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +34 -32
  63. data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +22 -22
  64. data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +13 -13
  65. data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +15 -15
  66. data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +61 -61
  67. data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +120 -127
  68. data/vendor/datasketches-cpp/hll/include/coupon_iterator-internal.hpp +9 -9
  69. data/vendor/datasketches-cpp/hll/include/coupon_iterator.hpp +5 -5
  70. data/vendor/datasketches-cpp/hll/include/hll.hpp +21 -21
  71. data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +1 -1
  72. data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +34 -34
  73. data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +25 -25
  74. data/vendor/datasketches-cpp/hll/test/CrossCountingTest.cpp +2 -2
  75. data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +35 -35
  76. data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +15 -15
  77. data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +10 -14
  78. data/vendor/datasketches-cpp/hll/test/IsomorphicTest.cpp +3 -3
  79. data/vendor/datasketches-cpp/hll/test/ToFromByteArrayTest.cpp +4 -4
  80. data/vendor/datasketches-cpp/kll/CMakeLists.txt +9 -19
  81. data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +5 -4
  82. data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +6 -6
  83. data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +14 -6
  84. data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +39 -24
  85. data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +41 -4
  86. data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +76 -64
  87. data/vendor/datasketches-cpp/kll/include/kolmogorov_smirnov.hpp +67 -0
  88. data/vendor/datasketches-cpp/kll/include/kolmogorov_smirnov_impl.hpp +78 -0
  89. data/vendor/datasketches-cpp/kll/test/CMakeLists.txt +1 -0
  90. data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +133 -46
  91. data/vendor/datasketches-cpp/kll/test/kolmogorov_smirnov_test.cpp +111 -0
  92. data/vendor/datasketches-cpp/pyproject.toml +4 -2
  93. data/vendor/datasketches-cpp/python/CMakeLists.txt +10 -6
  94. data/vendor/datasketches-cpp/python/README.md +50 -50
  95. data/vendor/datasketches-cpp/python/pybind11Path.cmd +3 -0
  96. data/vendor/datasketches-cpp/python/src/cpc_wrapper.cpp +1 -1
  97. data/vendor/datasketches-cpp/python/src/hll_wrapper.cpp +4 -4
  98. data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +1 -1
  99. data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +8 -8
  100. data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +11 -5
  101. data/vendor/datasketches-cpp/python/src/vo_wrapper.cpp +2 -2
  102. data/vendor/datasketches-cpp/python/tests/hll_test.py +1 -1
  103. data/vendor/datasketches-cpp/python/tests/kll_test.py +2 -2
  104. data/vendor/datasketches-cpp/python/tests/req_test.py +2 -2
  105. data/vendor/datasketches-cpp/python/tests/vector_of_kll_test.py +4 -4
  106. data/vendor/datasketches-cpp/python/tests/vo_test.py +3 -3
  107. data/vendor/datasketches-cpp/req/CMakeLists.txt +8 -21
  108. data/vendor/datasketches-cpp/req/include/req_common.hpp +2 -1
  109. data/vendor/datasketches-cpp/req/include/req_compactor.hpp +4 -4
  110. data/vendor/datasketches-cpp/req/include/req_compactor_impl.hpp +26 -39
  111. data/vendor/datasketches-cpp/req/include/req_sketch.hpp +1 -1
  112. data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +13 -11
  113. data/vendor/datasketches-cpp/req/test/req_sketch_test.cpp +52 -52
  114. data/vendor/datasketches-cpp/sampling/CMakeLists.txt +5 -9
  115. data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +10 -5
  116. data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +61 -64
  117. data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +42 -48
  118. data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +6 -6
  119. data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +13 -13
  120. data/vendor/datasketches-cpp/setup.py +10 -7
  121. data/vendor/datasketches-cpp/theta/CMakeLists.txt +26 -45
  122. data/vendor/datasketches-cpp/theta/include/bounds_on_ratios_in_sampled_sets.hpp +1 -1
  123. data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser.hpp +67 -0
  124. data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser_impl.hpp +137 -0
  125. data/vendor/datasketches-cpp/theta/include/theta_constants.hpp +9 -4
  126. data/vendor/datasketches-cpp/theta/include/theta_helpers.hpp +15 -0
  127. data/vendor/datasketches-cpp/theta/include/theta_intersection.hpp +9 -4
  128. data/vendor/datasketches-cpp/theta/include/theta_intersection_base_impl.hpp +6 -6
  129. data/vendor/datasketches-cpp/theta/include/theta_intersection_impl.hpp +1 -1
  130. data/vendor/datasketches-cpp/theta/include/theta_jaccard_similarity_base.hpp +18 -14
  131. data/vendor/datasketches-cpp/theta/include/theta_set_difference_base_impl.hpp +2 -2
  132. data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +73 -15
  133. data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +247 -103
  134. data/vendor/datasketches-cpp/theta/include/theta_union.hpp +10 -5
  135. data/vendor/datasketches-cpp/theta/include/theta_union_base.hpp +3 -1
  136. data/vendor/datasketches-cpp/theta/include/theta_union_base_impl.hpp +9 -3
  137. data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +8 -5
  138. data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base.hpp +11 -5
  139. data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base_impl.hpp +70 -37
  140. data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +1 -0
  141. data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +23 -1
  142. data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v1.sk +0 -0
  143. data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v2.sk +0 -0
  144. data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v1.sk +0 -0
  145. data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v2.sk +0 -0
  146. data/vendor/datasketches-cpp/theta/test/theta_compact_exact_from_java.sk +0 -0
  147. data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +21 -1
  148. data/vendor/datasketches-cpp/theta/test/theta_jaccard_similarity_test.cpp +58 -2
  149. data/vendor/datasketches-cpp/theta/test/theta_setop_test.cpp +445 -0
  150. data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +437 -1
  151. data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +41 -9
  152. data/vendor/datasketches-cpp/tuple/CMakeLists.txt +18 -33
  153. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch.hpp +1 -1
  154. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +50 -63
  155. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union.hpp +1 -1
  156. data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union_impl.hpp +3 -3
  157. data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +13 -9
  158. data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +84 -78
  159. data/vendor/datasketches-cpp/tuple/include/tuple_union.hpp +6 -1
  160. data/vendor/datasketches-cpp/tuple/include/tuple_union_impl.hpp +8 -3
  161. data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +17 -1
  162. data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +17 -17
  163. data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +12 -12
  164. data/vendor/datasketches-cpp/tuple/test/tuple_jaccard_similarity_test.cpp +5 -5
  165. data/vendor/datasketches-cpp/tuple/test/tuple_sketch_allocation_test.cpp +1 -1
  166. data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +66 -28
  167. data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +19 -12
  168. metadata +18 -7
  169. data/vendor/datasketches-cpp/theta/test/theta_update_empty_from_java.sk +0 -0
  170. data/vendor/datasketches-cpp/theta/test/theta_update_estimation_from_java.sk +0 -0
@@ -32,151 +32,151 @@
32
32
  namespace datasketches {
33
33
 
34
34
  template<typename A>
35
- hll_union_alloc<A>::hll_union_alloc(const int lg_max_k, const A& allocator):
36
- lg_max_k(HllUtil<A>::checkLgK(lg_max_k)),
37
- gadget(lg_max_k, target_hll_type::HLL_8, false, allocator)
35
+ hll_union_alloc<A>::hll_union_alloc(uint8_t lg_max_k, const A& allocator):
36
+ lg_max_k_(HllUtil<A>::checkLgK(lg_max_k)),
37
+ gadget_(lg_max_k, target_hll_type::HLL_8, false, allocator)
38
38
  {}
39
39
 
40
40
  template<typename A>
41
41
  hll_sketch_alloc<A> hll_union_alloc<A>::get_result(target_hll_type target_type) const {
42
- return hll_sketch_alloc<A>(gadget, target_type);
42
+ return hll_sketch_alloc<A>(gadget_, target_type);
43
43
  }
44
44
 
45
45
  template<typename A>
46
46
  void hll_union_alloc<A>::update(const hll_sketch_alloc<A>& sketch) {
47
47
  if (sketch.is_empty()) return;
48
- union_impl(sketch, lg_max_k);
48
+ union_impl(sketch, lg_max_k_);
49
49
  }
50
50
 
51
51
  template<typename A>
52
52
  void hll_union_alloc<A>::update(hll_sketch_alloc<A>&& sketch) {
53
53
  if (sketch.is_empty()) return;
54
- if (gadget.is_empty() && sketch.get_target_type() == HLL_8 && sketch.get_lg_config_k() <= lg_max_k) {
55
- if (sketch.get_current_mode() == HLL || sketch.get_lg_config_k() == lg_max_k) {
56
- gadget = std::move(sketch);
54
+ if (gadget_.is_empty() && sketch.get_target_type() == HLL_8 && sketch.get_lg_config_k() <= lg_max_k_) {
55
+ if (sketch.get_current_mode() == HLL || sketch.get_lg_config_k() == lg_max_k_) {
56
+ gadget_ = std::move(sketch);
57
57
  }
58
58
  }
59
- union_impl(sketch, lg_max_k);
59
+ union_impl(sketch, lg_max_k_);
60
60
  }
61
61
 
62
62
  template<typename A>
63
63
  void hll_union_alloc<A>::update(const std::string& datum) {
64
- gadget.update(datum);
64
+ gadget_.update(datum);
65
65
  }
66
66
 
67
67
  template<typename A>
68
- void hll_union_alloc<A>::update(const uint64_t datum) {
69
- gadget.update(datum);
68
+ void hll_union_alloc<A>::update(uint64_t datum) {
69
+ gadget_.update(datum);
70
70
  }
71
71
 
72
72
  template<typename A>
73
- void hll_union_alloc<A>::update(const uint32_t datum) {
74
- gadget.update(datum);
73
+ void hll_union_alloc<A>::update(uint32_t datum) {
74
+ gadget_.update(datum);
75
75
  }
76
76
 
77
77
  template<typename A>
78
- void hll_union_alloc<A>::update(const uint16_t datum) {
79
- gadget.update(datum);
78
+ void hll_union_alloc<A>::update(uint16_t datum) {
79
+ gadget_.update(datum);
80
80
  }
81
81
 
82
82
  template<typename A>
83
- void hll_union_alloc<A>::update(const uint8_t datum) {
84
- gadget.update(datum);
83
+ void hll_union_alloc<A>::update(uint8_t datum) {
84
+ gadget_.update(datum);
85
85
  }
86
86
 
87
87
  template<typename A>
88
- void hll_union_alloc<A>::update(const int64_t datum) {
89
- gadget.update(datum);
88
+ void hll_union_alloc<A>::update(int64_t datum) {
89
+ gadget_.update(datum);
90
90
  }
91
91
 
92
92
  template<typename A>
93
- void hll_union_alloc<A>::update(const int32_t datum) {
94
- gadget.update(datum);
93
+ void hll_union_alloc<A>::update(int32_t datum) {
94
+ gadget_.update(datum);
95
95
  }
96
96
 
97
97
  template<typename A>
98
- void hll_union_alloc<A>::update(const int16_t datum) {
99
- gadget.update(datum);
98
+ void hll_union_alloc<A>::update(int16_t datum) {
99
+ gadget_.update(datum);
100
100
  }
101
101
 
102
102
  template<typename A>
103
- void hll_union_alloc<A>::update(const int8_t datum) {
104
- gadget.update(datum);
103
+ void hll_union_alloc<A>::update(int8_t datum) {
104
+ gadget_.update(datum);
105
105
  }
106
106
 
107
107
  template<typename A>
108
- void hll_union_alloc<A>::update(const double datum) {
109
- gadget.update(datum);
108
+ void hll_union_alloc<A>::update(double datum) {
109
+ gadget_.update(datum);
110
110
  }
111
111
 
112
112
  template<typename A>
113
- void hll_union_alloc<A>::update(const float datum) {
114
- gadget.update(datum);
113
+ void hll_union_alloc<A>::update(float datum) {
114
+ gadget_.update(datum);
115
115
  }
116
116
 
117
117
  template<typename A>
118
- void hll_union_alloc<A>::update(const void* data, const size_t length_bytes) {
119
- gadget.update(data, length_bytes);
118
+ void hll_union_alloc<A>::update(const void* data, size_t length_bytes) {
119
+ gadget_.update(data, length_bytes);
120
120
  }
121
121
 
122
122
  template<typename A>
123
- void hll_union_alloc<A>::coupon_update(const int coupon) {
123
+ void hll_union_alloc<A>::coupon_update(uint32_t coupon) {
124
124
  if (coupon == HllUtil<A>::EMPTY) { return; }
125
- HllSketchImpl<A>* result = gadget.sketch_impl->coupon_update(coupon);
126
- if (result != gadget.sketch_impl) {
127
- if (gadget.sketch_impl != nullptr) { gadget.sketch_impl->get_deleter()(gadget.sketch_impl); }
128
- gadget.sketch_impl = result;
125
+ HllSketchImpl<A>* result = gadget_.sketch_impl->coupon_update(coupon);
126
+ if (result != gadget_.sketch_impl) {
127
+ if (gadget_.sketch_impl != nullptr) { gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); }
128
+ gadget_.sketch_impl = result;
129
129
  }
130
130
  }
131
131
 
132
132
  template<typename A>
133
133
  double hll_union_alloc<A>::get_estimate() const {
134
- return gadget.get_estimate();
134
+ return gadget_.get_estimate();
135
135
  }
136
136
 
137
137
  template<typename A>
138
138
  double hll_union_alloc<A>::get_composite_estimate() const {
139
- return gadget.get_composite_estimate();
139
+ return gadget_.get_composite_estimate();
140
140
  }
141
141
 
142
142
  template<typename A>
143
- double hll_union_alloc<A>::get_lower_bound(const int num_std_dev) const {
144
- return gadget.get_lower_bound(num_std_dev);
143
+ double hll_union_alloc<A>::get_lower_bound(uint8_t num_std_dev) const {
144
+ return gadget_.get_lower_bound(num_std_dev);
145
145
  }
146
146
 
147
147
  template<typename A>
148
- double hll_union_alloc<A>::get_upper_bound(const int num_std_dev) const {
149
- return gadget.get_upper_bound(num_std_dev);
148
+ double hll_union_alloc<A>::get_upper_bound(uint8_t num_std_dev) const {
149
+ return gadget_.get_upper_bound(num_std_dev);
150
150
  }
151
151
 
152
152
  template<typename A>
153
- int hll_union_alloc<A>::get_lg_config_k() const {
154
- return gadget.get_lg_config_k();
153
+ uint8_t hll_union_alloc<A>::get_lg_config_k() const {
154
+ return gadget_.get_lg_config_k();
155
155
  }
156
156
 
157
157
  template<typename A>
158
158
  void hll_union_alloc<A>::reset() {
159
- gadget.reset();
159
+ gadget_.reset();
160
160
  }
161
161
 
162
162
  template<typename A>
163
163
  bool hll_union_alloc<A>::is_empty() const {
164
- return gadget.is_empty();
164
+ return gadget_.is_empty();
165
165
  }
166
166
 
167
167
  template<typename A>
168
168
  bool hll_union_alloc<A>::is_out_of_order_flag() const {
169
- return gadget.is_out_of_order_flag();
169
+ return gadget_.is_out_of_order_flag();
170
170
  }
171
171
 
172
172
  template<typename A>
173
173
  hll_mode hll_union_alloc<A>::get_current_mode() const {
174
- return gadget.get_current_mode();
174
+ return gadget_.get_current_mode();
175
175
  }
176
176
 
177
177
  template<typename A>
178
178
  bool hll_union_alloc<A>::is_estimation_mode() const {
179
- return gadget.is_estimation_mode();
179
+ return gadget_.is_estimation_mode();
180
180
  }
181
181
 
182
182
  template<typename A>
@@ -185,13 +185,13 @@ target_hll_type hll_union_alloc<A>::get_target_type() const {
185
185
  }
186
186
 
187
187
  template<typename A>
188
- double hll_union_alloc<A>::get_rel_err(const bool upper_bound, const bool unioned,
189
- const int lg_config_k, const int num_std_dev) {
188
+ double hll_union_alloc<A>::get_rel_err(bool upper_bound, bool unioned,
189
+ uint8_t lg_config_k, uint8_t num_std_dev) {
190
190
  return HllUtil<A>::getRelErr(upper_bound, unioned, lg_config_k, num_std_dev);
191
191
  }
192
192
 
193
193
  template<typename A>
194
- HllSketchImpl<A>* hll_union_alloc<A>::copy_or_downsample(const HllSketchImpl<A>* src_impl, const int tgt_lg_k) {
194
+ HllSketchImpl<A>* hll_union_alloc<A>::copy_or_downsample(const HllSketchImpl<A>* src_impl, uint8_t tgt_lg_k) {
195
195
  if (src_impl->getCurMode() != HLL) {
196
196
  throw std::logic_error("Attempt to downsample non-HLL sketch");
197
197
  }
@@ -210,7 +210,7 @@ HllSketchImpl<A>* hll_union_alloc<A>::copy_or_downsample(const HllSketchImpl<A>*
210
210
  }
211
211
 
212
212
  template<typename A>
213
- inline HllSketchImpl<A>* hll_union_alloc<A>::leak_free_coupon_update(HllSketchImpl<A>* impl, const int coupon) {
213
+ inline HllSketchImpl<A>* hll_union_alloc<A>::leak_free_coupon_update(HllSketchImpl<A>* impl, uint32_t coupon) {
214
214
  HllSketchImpl<A>* result = impl->couponUpdate(coupon);
215
215
  if (result != impl) {
216
216
  impl->get_deleter()(impl);
@@ -219,13 +219,13 @@ inline HllSketchImpl<A>* hll_union_alloc<A>::leak_free_coupon_update(HllSketchIm
219
219
  }
220
220
 
221
221
  template<typename A>
222
- void hll_union_alloc<A>::union_impl(const hll_sketch_alloc<A>& sketch, const int lg_max_k) {
222
+ void hll_union_alloc<A>::union_impl(const hll_sketch_alloc<A>& sketch, uint8_t lg_max_k) {
223
223
  const HllSketchImpl<A>* src_impl = sketch.sketch_impl; //default
224
- HllSketchImpl<A>* dst_impl = gadget.sketch_impl; //default
224
+ HllSketchImpl<A>* dst_impl = gadget_.sketch_impl; //default
225
225
  if (src_impl->getCurMode() == LIST || src_impl->getCurMode() == SET) {
226
226
  if (dst_impl->isEmpty() && src_impl->getLgConfigK() == dst_impl->getLgConfigK()) {
227
227
  dst_impl = src_impl->copyAs(HLL_8);
228
- gadget.sketch_impl->get_deleter()(gadget.sketch_impl); // gadget to be replaced
228
+ gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); // gadget to be replaced
229
229
  } else {
230
230
  const CouponList<A>* src = static_cast<const CouponList<A>*>(src_impl);
231
231
  for (auto coupon: *src) {
@@ -239,11 +239,11 @@ void hll_union_alloc<A>::union_impl(const hll_sketch_alloc<A>& sketch, const int
239
239
  const CouponList<A>* src = static_cast<const CouponList<A>*>(dst_impl);
240
240
  dst_impl = copy_or_downsample(src_impl, lg_max_k);
241
241
  static_cast<Hll8Array<A>*>(dst_impl)->mergeList(*src);
242
- gadget.sketch_impl->get_deleter()(gadget.sketch_impl); // gadget to be replaced
242
+ gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); // gadget to be replaced
243
243
  } else { // gadget is HLL
244
244
  if (src_impl->getLgConfigK() < dst_impl->getLgConfigK()) {
245
245
  dst_impl = copy_or_downsample(dst_impl, sketch.get_lg_config_k());
246
- gadget.sketch_impl->get_deleter()(gadget.sketch_impl); // gadget to be replaced
246
+ gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); // gadget to be replaced
247
247
  }
248
248
  const HllArray<A>* src = static_cast<const HllArray<A>*>(src_impl);
249
249
  static_cast<Hll8Array<A>*>(dst_impl)->mergeHll(*src);
@@ -252,9 +252,9 @@ void hll_union_alloc<A>::union_impl(const hll_sketch_alloc<A>& sketch, const int
252
252
  }
253
253
  } else { // src is HLL, gadget is empty
254
254
  dst_impl = copy_or_downsample(src_impl, lg_max_k);
255
- gadget.sketch_impl->get_deleter()(gadget.sketch_impl); // gadget to be replaced
255
+ gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); // gadget to be replaced
256
256
  }
257
- gadget.sketch_impl = dst_impl; // gadget replaced
257
+ gadget_.sketch_impl = dst_impl; // gadget replaced
258
258
  }
259
259
 
260
260
  }
@@ -34,140 +34,133 @@ namespace datasketches {
34
34
 
35
35
  enum hll_mode { LIST = 0, SET, HLL };
36
36
 
37
+ namespace hll_constants {
38
+
39
+ // preamble stuff
40
+ static const uint8_t SER_VER = 1;
41
+ static const uint8_t FAMILY_ID = 7;
42
+
43
+ static const uint8_t EMPTY_FLAG_MASK = 4;
44
+ static const uint8_t COMPACT_FLAG_MASK = 8;
45
+ static const uint8_t OUT_OF_ORDER_FLAG_MASK = 16;
46
+ static const uint8_t FULL_SIZE_FLAG_MASK = 32;
47
+
48
+ static const uint32_t PREAMBLE_INTS_BYTE = 0;
49
+ static const uint32_t SER_VER_BYTE = 1;
50
+ static const uint32_t FAMILY_BYTE = 2;
51
+ static const uint32_t LG_K_BYTE = 3;
52
+ static const uint32_t LG_ARR_BYTE = 4;
53
+ static const uint32_t FLAGS_BYTE = 5;
54
+ static const uint32_t LIST_COUNT_BYTE = 6;
55
+ static const uint32_t HLL_CUR_MIN_BYTE = 6;
56
+ static const uint32_t MODE_BYTE = 7; // lo2bits = curMode, next 2 bits = tgtHllMode
57
+
58
+ // Coupon List
59
+ static const uint32_t LIST_INT_ARR_START = 8;
60
+ static const uint8_t LIST_PREINTS = 2;
61
+ // Coupon Hash Set
62
+ static const uint32_t HASH_SET_COUNT_INT = 8;
63
+ static const uint32_t HASH_SET_INT_ARR_START = 12;
64
+ static const uint8_t HASH_SET_PREINTS = 3;
65
+ // HLL
66
+ static const uint8_t HLL_PREINTS = 10;
67
+ static const uint32_t HLL_BYTE_ARR_START = 40;
68
+ static const uint32_t HIP_ACCUM_DOUBLE = 8;
69
+ static const uint32_t KXQ0_DOUBLE = 16;
70
+ static const uint32_t KXQ1_DOUBLE = 24;
71
+ static const uint32_t CUR_MIN_COUNT_INT = 32;
72
+ static const uint32_t AUX_COUNT_INT = 36;
73
+
74
+ static const uint32_t EMPTY_SKETCH_SIZE_BYTES = 8;
75
+
76
+ // other HllUtil stuff
77
+ static const uint8_t KEY_BITS_26 = 26;
78
+ static const uint8_t VAL_BITS_6 = 6;
79
+ static const uint32_t KEY_MASK_26 = (1 << KEY_BITS_26) - 1;
80
+ static const uint32_t VAL_MASK_6 = (1 << VAL_BITS_6) - 1;
81
+ static const uint32_t EMPTY = 0;
82
+ static const uint8_t MIN_LOG_K = 4;
83
+ static const uint8_t MAX_LOG_K = 21;
84
+
85
+ static const double HLL_HIP_RSE_FACTOR = 0.8325546; // sqrt(ln(2))
86
+ static const double HLL_NON_HIP_RSE_FACTOR = 1.03896; // sqrt((3 * ln(2)) - 1)
87
+ static const double COUPON_RSE_FACTOR = 0.409; // at transition point not the asymptote
88
+ static const double COUPON_RSE = COUPON_RSE_FACTOR / (1 << 13);
89
+
90
+ static const uint8_t LG_INIT_LIST_SIZE = 3;
91
+ static const uint8_t LG_INIT_SET_SIZE = 5;
92
+ static const uint32_t RESIZE_NUMER = 3;
93
+ static const uint32_t RESIZE_DENOM = 4;
94
+
95
+ static const uint8_t loNibbleMask = 0x0f;
96
+ static const uint8_t hiNibbleMask = 0xf0;
97
+ static const uint8_t AUX_TOKEN = 0xf;
98
+
99
+ /**
100
+ * Log2 table sizes for exceptions based on lgK from 0 to 26.
101
+ * However, only lgK from 4 to 21 are used.
102
+ */
103
+ static const uint8_t LG_AUX_ARR_INTS[] = {
104
+ 0, 2, 2, 2, 2, 2, 2, 3, 3, 3, // 0 - 9
105
+ 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, // 10-19
106
+ 12, 13, 14, 15, 16, 17, 18 // 20-26
107
+ };
108
+
109
+ } // namespace hll_constants
110
+
111
+
37
112
  // template provides internal consistency and allows static float values
38
113
  // but we don't use the template parameter anywhere
39
114
  template<typename A = std::allocator<uint8_t> >
40
115
  class HllUtil final {
41
116
  public:
42
- // preamble stuff
43
- static const int SER_VER = 1;
44
- static const int FAMILY_ID = 7;
45
-
46
- static const int EMPTY_FLAG_MASK = 4;
47
- static const int COMPACT_FLAG_MASK = 8;
48
- static const int OUT_OF_ORDER_FLAG_MASK = 16;
49
- static const int FULL_SIZE_FLAG_MASK = 32;
50
-
51
- static const int PREAMBLE_INTS_BYTE = 0;
52
- static const int SER_VER_BYTE = 1;
53
- static const int FAMILY_BYTE = 2;
54
- static const int LG_K_BYTE = 3;
55
- static const int LG_ARR_BYTE = 4;
56
- static const int FLAGS_BYTE = 5;
57
- static const int LIST_COUNT_BYTE = 6;
58
- static const int HLL_CUR_MIN_BYTE = 6;
59
- static const int MODE_BYTE = 7; // lo2bits = curMode, next 2 bits = tgtHllMode
60
-
61
- // Coupon List
62
- static const int LIST_INT_ARR_START = 8;
63
- static const int LIST_PREINTS = 2;
64
- // Coupon Hash Set
65
- static const int HASH_SET_COUNT_INT = 8;
66
- static const int HASH_SET_INT_ARR_START = 12;
67
- static const int HASH_SET_PREINTS = 3;
68
- // HLL
69
- static const int HLL_PREINTS = 10;
70
- static const int HLL_BYTE_ARR_START = 40;
71
- static const int HIP_ACCUM_DOUBLE = 8;
72
- static const int KXQ0_DOUBLE = 16;
73
- static const int KXQ1_DOUBLE = 24;
74
- static const int CUR_MIN_COUNT_INT = 32;
75
- static const int AUX_COUNT_INT = 36;
76
-
77
- static const int EMPTY_SKETCH_SIZE_BYTES = 8;
78
-
79
- // other HllUtil stuff
80
- static const int KEY_BITS_26 = 26;
81
- static const int VAL_BITS_6 = 6;
82
- static const int KEY_MASK_26 = (1 << KEY_BITS_26) - 1;
83
- static const int VAL_MASK_6 = (1 << VAL_BITS_6) - 1;
84
- static const int EMPTY = 0;
85
- static const int MIN_LOG_K = 4;
86
- static const int MAX_LOG_K = 21;
87
-
88
- static const double HLL_HIP_RSE_FACTOR; // sqrt(log(2.0)) = 0.8325546
89
- static const double HLL_NON_HIP_RSE_FACTOR; // sqrt((3.0 * log(2.0)) - 1.0) = 1.03896
90
- static const double COUPON_RSE_FACTOR; // 0.409 at transition point not the asymptote
91
- static const double COUPON_RSE; // COUPON_RSE_FACTOR / (1 << 13);
92
-
93
- static const int LG_INIT_LIST_SIZE = 3;
94
- static const int LG_INIT_SET_SIZE = 5;
95
- static const int RESIZE_NUMER = 3;
96
- static const int RESIZE_DENOM = 4;
97
-
98
- static const int loNibbleMask = 0x0f;
99
- static const int hiNibbleMask = 0xf0;
100
- static const int AUX_TOKEN = 0xf;
101
-
102
- /**
103
- * Log2 table sizes for exceptions based on lgK from 0 to 26.
104
- * However, only lgK from 4 to 21 are used.
105
- */
106
- static const int LG_AUX_ARR_INTS[];
107
-
108
- static int coupon(const uint64_t hash[]);
109
- static int coupon(const HashState& hashState);
110
- static void hash(const void* key, int keyLen, uint64_t seed, HashState& result);
111
- static int checkLgK(int lgK);
117
+
118
+ static uint32_t coupon(const uint64_t hash[]);
119
+ static uint32_t coupon(const HashState& hashState);
120
+ static void hash(const void* key, size_t keyLen, uint64_t seed, HashState& result);
121
+ static uint8_t checkLgK(uint8_t lgK);
112
122
  static void checkMemSize(uint64_t minBytes, uint64_t capBytes);
113
- static inline void checkNumStdDev(int numStdDev);
114
- static int pair(int slotNo, int value);
115
- static int getLow26(unsigned int coupon);
116
- static int getValue(unsigned int coupon);
117
- static double invPow2(int e);
118
- static unsigned int ceilingPowerOf2(unsigned int n);
119
- static unsigned int simpleIntLog2(unsigned int n); // n must be power of 2
120
- static int computeLgArrInts(hll_mode mode, int count, int lgConfigK);
121
- static double getRelErr(bool upperBound, bool unioned,
122
- int lgConfigK, int numStdDev);
123
+ static inline void checkNumStdDev(uint8_t numStdDev);
124
+ static uint32_t pair(uint32_t slotNo, uint8_t value);
125
+ static uint32_t getLow26(uint32_t coupon);
126
+ static uint8_t getValue(uint32_t coupon);
127
+ static double invPow2(uint8_t e);
128
+ static uint8_t ceilingPowerOf2(uint32_t n);
129
+ static uint8_t simpleIntLog2(uint32_t n); // n must be power of 2
130
+ static uint8_t computeLgArrInts(hll_mode mode, uint32_t count, uint8_t lgConfigK);
131
+ static double getRelErr(bool upperBound, bool unioned, uint8_t lgConfigK, uint8_t numStdDev);
123
132
  };
124
133
 
125
134
  template<typename A>
126
- const double HllUtil<A>::HLL_HIP_RSE_FACTOR = sqrt(log(2.0)); // 0.8325546
127
- template<typename A>
128
- const double HllUtil<A>::HLL_NON_HIP_RSE_FACTOR = sqrt((3.0 * log(2.0)) - 1.0); // 1.03896
129
- template<typename A>
130
- const double HllUtil<A>::COUPON_RSE_FACTOR = 0.409;
131
- template<typename A>
132
- const double HllUtil<A>::COUPON_RSE = COUPON_RSE_FACTOR / (1 << 13);
133
-
134
- template<typename A>
135
- const int HllUtil<A>::LG_AUX_ARR_INTS[] = {
136
- 0, 2, 2, 2, 2, 2, 2, 3, 3, 3, // 0 - 9
137
- 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, // 10-19
138
- 12, 13, 14, 15, 16, 17, 18 // 20-26
139
- };
140
-
141
- template<typename A>
142
- inline int HllUtil<A>::coupon(const uint64_t hash[]) {
143
- int addr26 = (int) (hash[0] & KEY_MASK_26);
144
- int lz = count_leading_zeros_in_u64(hash[1]);
145
- int value = ((lz > 62 ? 62 : lz) + 1);
146
- return (value << KEY_BITS_26) | addr26;
135
+ inline uint32_t HllUtil<A>::coupon(const uint64_t hash[]) {
136
+ uint32_t addr26 = hash[0] & hll_constants::KEY_MASK_26;
137
+ uint8_t lz = count_leading_zeros_in_u64(hash[1]);
138
+ uint8_t value = ((lz > 62 ? 62 : lz) + 1);
139
+ return (value << hll_constants::KEY_BITS_26) | addr26;
147
140
  }
148
141
 
149
142
  template<typename A>
150
- inline int HllUtil<A>::coupon(const HashState& hashState) {
151
- int addr26 = (int) (hashState.h1 & KEY_MASK_26);
152
- int lz = count_leading_zeros_in_u64(hashState.h2);
153
- int value = ((lz > 62 ? 62 : lz) + 1);
154
- return (value << KEY_BITS_26) | addr26;
143
+ inline uint32_t HllUtil<A>::coupon(const HashState& hashState) {
144
+ uint32_t addr26 = (int) (hashState.h1 & hll_constants::KEY_MASK_26);
145
+ uint8_t lz = count_leading_zeros_in_u64(hashState.h2);
146
+ uint8_t value = ((lz > 62 ? 62 : lz) + 1);
147
+ return (value << hll_constants::KEY_BITS_26) | addr26;
155
148
  }
156
149
 
157
150
  template<typename A>
158
- inline void HllUtil<A>::hash(const void* key, const int keyLen, const uint64_t seed, HashState& result) {
151
+ inline void HllUtil<A>::hash(const void* key, size_t keyLen, uint64_t seed, HashState& result) {
159
152
  MurmurHash3_x64_128(key, keyLen, seed, result);
160
153
  }
161
154
 
162
155
  template<typename A>
163
- inline double HllUtil<A>::getRelErr(const bool upperBound, const bool unioned,
164
- const int lgConfigK, const int numStdDev) {
156
+ inline double HllUtil<A>::getRelErr(bool upperBound, bool unioned,
157
+ uint8_t lgConfigK, uint8_t numStdDev) {
165
158
  return RelativeErrorTables<A>::getRelErr(upperBound, unioned, lgConfigK, numStdDev);
166
159
  }
167
160
 
168
161
  template<typename A>
169
- inline int HllUtil<A>::checkLgK(const int lgK) {
170
- if ((lgK >= HllUtil<A>::MIN_LOG_K) && (lgK <= HllUtil<A>::MAX_LOG_K)) {
162
+ inline uint8_t HllUtil<A>::checkLgK(uint8_t lgK) {
163
+ if ((lgK >= hll_constants::MIN_LOG_K) && (lgK <= hll_constants::MAX_LOG_K)) {
171
164
  return lgK;
172
165
  } else {
173
166
  throw std::invalid_argument("Invalid value of k: " + std::to_string(lgK));
@@ -175,36 +168,36 @@ inline int HllUtil<A>::checkLgK(const int lgK) {
175
168
  }
176
169
 
177
170
  template<typename A>
178
- inline void HllUtil<A>::checkMemSize(const uint64_t minBytes, const uint64_t capBytes) {
171
+ inline void HllUtil<A>::checkMemSize(uint64_t minBytes, uint64_t capBytes) {
179
172
  if (capBytes < minBytes) {
180
173
  throw std::invalid_argument("Given destination array is not large enough: " + std::to_string(capBytes));
181
174
  }
182
175
  }
183
176
 
184
177
  template<typename A>
185
- inline void HllUtil<A>::checkNumStdDev(const int numStdDev) {
178
+ inline void HllUtil<A>::checkNumStdDev(uint8_t numStdDev) {
186
179
  if ((numStdDev < 1) || (numStdDev > 3)) {
187
180
  throw std::invalid_argument("NumStdDev may not be less than 1 or greater than 3.");
188
181
  }
189
182
  }
190
183
 
191
184
  template<typename A>
192
- inline int HllUtil<A>::pair(const int slotNo, const int value) {
193
- return (value << HllUtil<A>::KEY_BITS_26) | (slotNo & HllUtil<A>::KEY_MASK_26);
185
+ inline uint32_t HllUtil<A>::pair(uint32_t slotNo, uint8_t value) {
186
+ return (value << hll_constants::KEY_BITS_26) | (slotNo & hll_constants::KEY_MASK_26);
194
187
  }
195
188
 
196
189
  template<typename A>
197
- inline int HllUtil<A>::getLow26(const unsigned int coupon) {
198
- return coupon & HllUtil<A>::KEY_MASK_26;
190
+ inline uint32_t HllUtil<A>::getLow26(uint32_t coupon) {
191
+ return coupon & hll_constants::KEY_MASK_26;
199
192
  }
200
193
 
201
194
  template<typename A>
202
- inline int HllUtil<A>::getValue(const unsigned int coupon) {
203
- return coupon >> HllUtil<A>::KEY_BITS_26;
195
+ inline uint8_t HllUtil<A>::getValue(uint32_t coupon) {
196
+ return coupon >> hll_constants::KEY_BITS_26;
204
197
  }
205
198
 
206
199
  template<typename A>
207
- inline double HllUtil<A>::invPow2(const int e) {
200
+ inline double HllUtil<A>::invPow2(uint8_t e) {
208
201
  union {
209
202
  long long longVal;
210
203
  double doubleVal;
@@ -214,7 +207,7 @@ inline double HllUtil<A>::invPow2(const int e) {
214
207
  }
215
208
 
216
209
  template<typename A>
217
- inline uint32_t HllUtil<A>::simpleIntLog2(uint32_t n) {
210
+ inline uint8_t HllUtil<A>::simpleIntLog2(uint32_t n) {
218
211
  if (n == 0) {
219
212
  throw std::logic_error("cannot take log of 0");
220
213
  }
@@ -222,16 +215,16 @@ inline uint32_t HllUtil<A>::simpleIntLog2(uint32_t n) {
222
215
  }
223
216
 
224
217
  template<typename A>
225
- inline int HllUtil<A>::computeLgArrInts(hll_mode mode, int count, int lgConfigK) {
218
+ inline uint8_t HllUtil<A>::computeLgArrInts(hll_mode mode, uint32_t count, uint8_t lgConfigK) {
226
219
  // assume value missing and recompute
227
- if (mode == LIST) { return HllUtil<A>::LG_INIT_LIST_SIZE; }
228
- int ceilPwr2 = ceiling_power_of_2(count);
229
- if ((HllUtil<A>::RESIZE_DENOM * count) > (HllUtil<A>::RESIZE_NUMER * ceilPwr2)) { ceilPwr2 <<= 1;}
220
+ if (mode == LIST) { return hll_constants::LG_INIT_LIST_SIZE; }
221
+ uint32_t ceilPwr2 = ceiling_power_of_2(count);
222
+ if ((hll_constants::RESIZE_DENOM * count) > (hll_constants::RESIZE_NUMER * ceilPwr2)) { ceilPwr2 <<= 1;}
230
223
  if (mode == SET) {
231
- return fmax(HllUtil<A>::LG_INIT_SET_SIZE, HllUtil<A>::simpleIntLog2(ceilPwr2));
224
+ return std::max(hll_constants::LG_INIT_SET_SIZE, HllUtil<A>::simpleIntLog2(ceilPwr2));
232
225
  }
233
226
  //only used for HLL4
234
- return fmax(HllUtil<A>::LG_AUX_ARR_INTS[lgConfigK], HllUtil<A>::simpleIntLog2(ceilPwr2));
227
+ return std::max(hll_constants::LG_AUX_ARR_INTS[lgConfigK], HllUtil<A>::simpleIntLog2(ceilPwr2));
235
228
  }
236
229
 
237
230
  }
@@ -25,30 +25,30 @@
25
25
  namespace datasketches {
26
26
 
27
27
  template<typename A>
28
- coupon_iterator<A>::coupon_iterator(const int* array, size_t array_size, size_t index, bool all):
29
- array(array), array_size(array_size), index(index), all(all) {
30
- while (this->index < array_size) {
31
- if (all || array[this->index] != HllUtil<A>::EMPTY) break;
32
- this->index++;
28
+ coupon_iterator<A>::coupon_iterator(const uint32_t* array, size_t array_size, size_t index, bool all):
29
+ array_(array), array_size_(array_size), index_(index), all_(all) {
30
+ while (index_ < array_size_) {
31
+ if (all_ || array_[index_] != hll_constants::EMPTY) break;
32
+ ++index_;
33
33
  }
34
34
  }
35
35
 
36
36
  template<typename A>
37
37
  coupon_iterator<A>& coupon_iterator<A>::operator++() {
38
- while (++index < array_size) {
39
- if (all || array[index] != HllUtil<A>::EMPTY) break;
38
+ while (++index_ < array_size_) {
39
+ if (all_ || array_[index_] != hll_constants::EMPTY) break;
40
40
  }
41
41
  return *this;
42
42
  }
43
43
 
44
44
  template<typename A>
45
45
  bool coupon_iterator<A>::operator!=(const coupon_iterator& other) const {
46
- return index != other.index;
46
+ return index_ != other.index_;
47
47
  }
48
48
 
49
49
  template<typename A>
50
50
  uint32_t coupon_iterator<A>::operator*() const {
51
- return array[index];
51
+ return array_[index_];
52
52
  }
53
53
 
54
54
  }
@@ -25,15 +25,15 @@ namespace datasketches {
25
25
  template<typename A>
26
26
  class coupon_iterator: public std::iterator<std::input_iterator_tag, uint32_t> {
27
27
  public:
28
- coupon_iterator(const int* array, size_t array_slze, size_t index, bool all);
28
+ coupon_iterator(const uint32_t* array, size_t array_slze, size_t index, bool all);
29
29
  coupon_iterator& operator++();
30
30
  bool operator!=(const coupon_iterator& other) const;
31
31
  uint32_t operator*() const;
32
32
  private:
33
- const int* array;
34
- size_t array_size;
35
- size_t index;
36
- bool all;
33
+ const uint32_t* array_;
34
+ size_t array_size_;
35
+ size_t index_;
36
+ bool all_;
37
37
  };
38
38
 
39
39
  }