datasketches 0.1.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/LICENSE +40 -3
- data/NOTICE +1 -1
- data/ext/datasketches/cpc_wrapper.cpp +12 -13
- data/ext/datasketches/ext.cpp +1 -1
- data/ext/datasketches/ext.h +4 -0
- data/ext/datasketches/extconf.rb +1 -1
- data/ext/datasketches/fi_wrapper.cpp +6 -8
- data/ext/datasketches/hll_wrapper.cpp +13 -14
- data/ext/datasketches/kll_wrapper.cpp +28 -76
- data/ext/datasketches/theta_wrapper.cpp +27 -41
- data/ext/datasketches/vo_wrapper.cpp +4 -6
- data/lib/datasketches/version.rb +1 -1
- data/vendor/datasketches-cpp/CMakeLists.txt +10 -0
- data/vendor/datasketches-cpp/LICENSE +40 -3
- data/vendor/datasketches-cpp/NOTICE +1 -1
- data/vendor/datasketches-cpp/README.md +4 -4
- data/vendor/datasketches-cpp/common/include/MurmurHash3.h +18 -7
- data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +8 -8
- data/vendor/datasketches-cpp/common/include/bounds_binomial_proportions.hpp +12 -15
- data/vendor/datasketches-cpp/common/include/common_defs.hpp +26 -0
- data/vendor/datasketches-cpp/common/include/conditional_forward.hpp +20 -8
- data/vendor/datasketches-cpp/common/include/count_zeros.hpp +2 -2
- data/vendor/datasketches-cpp/common/include/memory_operations.hpp +12 -0
- data/vendor/datasketches-cpp/common/include/serde.hpp +7 -7
- data/vendor/datasketches-cpp/common/test/CMakeLists.txt +24 -0
- data/vendor/datasketches-cpp/common/test/integration_test.cpp +77 -0
- data/vendor/datasketches-cpp/common/test/test_allocator.hpp +9 -1
- data/vendor/datasketches-cpp/cpc/include/cpc_common.hpp +13 -3
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor.hpp +20 -20
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +116 -105
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +22 -6
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +140 -101
- data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +2 -2
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +20 -20
- data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +10 -16
- data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +6 -6
- data/vendor/datasketches-cpp/cpc/include/u32_table.hpp +10 -10
- data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +21 -21
- data/vendor/datasketches-cpp/cpc/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/cpc/test/compression_test.cpp +10 -10
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_allocation_test.cpp +237 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +25 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +1 -1
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +15 -10
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +102 -105
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map.hpp +19 -13
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map_impl.hpp +141 -125
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_custom_type_test.cpp +15 -12
- data/vendor/datasketches-cpp/fi/test/reverse_purge_hash_map_test.cpp +5 -5
- data/vendor/datasketches-cpp/hll/CMakeLists.txt +3 -0
- data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +81 -109
- data/vendor/datasketches-cpp/hll/include/AuxHashMap.hpp +25 -24
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +15 -15
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable.hpp +5 -5
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +89 -105
- data/vendor/datasketches-cpp/hll/include/CouponHashSet.hpp +13 -13
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +130 -165
- data/vendor/datasketches-cpp/hll/include/CouponList.hpp +21 -22
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation-internal.hpp +2 -4
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers-internal.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +88 -83
- data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +9 -9
- data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +34 -45
- data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +7 -8
- data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +41 -52
- data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +7 -8
- data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +220 -251
- data/vendor/datasketches-cpp/hll/include/HllArray.hpp +42 -42
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +36 -38
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +22 -22
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +15 -14
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +47 -44
- data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +62 -87
- data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +121 -128
- data/vendor/datasketches-cpp/hll/include/RelativeErrorTables.hpp +1 -1
- data/vendor/datasketches-cpp/hll/include/coupon_iterator-internal.hpp +9 -9
- data/vendor/datasketches-cpp/hll/include/coupon_iterator.hpp +5 -5
- data/vendor/datasketches-cpp/hll/include/hll.hpp +25 -53
- data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +8 -8
- data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +36 -36
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +28 -28
- data/vendor/datasketches-cpp/hll/test/CrossCountingTest.cpp +2 -2
- data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +37 -37
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +57 -61
- data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +10 -14
- data/vendor/datasketches-cpp/hll/test/IsomorphicTest.cpp +3 -3
- data/vendor/datasketches-cpp/hll/test/ToFromByteArrayTest.cpp +4 -4
- data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +5 -4
- data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +6 -6
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +14 -6
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +40 -25
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +50 -6
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +164 -136
- data/vendor/datasketches-cpp/kll/include/kolmogorov_smirnov.hpp +67 -0
- data/vendor/datasketches-cpp/kll/include/kolmogorov_smirnov_impl.hpp +78 -0
- data/vendor/datasketches-cpp/kll/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_custom_type_test.cpp +11 -10
- data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +178 -88
- data/vendor/datasketches-cpp/kll/test/kolmogorov_smirnov_test.cpp +111 -0
- data/vendor/datasketches-cpp/pyproject.toml +4 -2
- data/vendor/datasketches-cpp/python/CMakeLists.txt +12 -6
- data/vendor/datasketches-cpp/python/README.md +52 -49
- data/vendor/datasketches-cpp/python/pybind11Path.cmd +3 -0
- data/vendor/datasketches-cpp/python/src/cpc_wrapper.cpp +1 -1
- data/vendor/datasketches-cpp/python/src/datasketches.cpp +2 -0
- data/vendor/datasketches-cpp/python/src/hll_wrapper.cpp +4 -6
- data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +4 -2
- data/vendor/datasketches-cpp/python/src/req_wrapper.cpp +246 -0
- data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +38 -28
- data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +11 -5
- data/vendor/datasketches-cpp/python/src/vo_wrapper.cpp +2 -2
- data/vendor/datasketches-cpp/python/tests/hll_test.py +1 -2
- data/vendor/datasketches-cpp/python/tests/kll_test.py +5 -5
- data/vendor/datasketches-cpp/python/tests/req_test.py +126 -0
- data/vendor/datasketches-cpp/python/tests/theta_test.py +28 -3
- data/vendor/datasketches-cpp/python/tests/vector_of_kll_test.py +4 -4
- data/vendor/datasketches-cpp/python/tests/vo_test.py +3 -3
- data/vendor/datasketches-cpp/req/CMakeLists.txt +60 -0
- data/vendor/datasketches-cpp/{tuple/include/theta_a_not_b_experimental_impl.hpp → req/include/req_common.hpp} +18 -8
- data/vendor/datasketches-cpp/req/include/req_compactor.hpp +137 -0
- data/vendor/datasketches-cpp/req/include/req_compactor_impl.hpp +488 -0
- data/vendor/datasketches-cpp/req/include/req_quantile_calculator.hpp +69 -0
- data/vendor/datasketches-cpp/req/include/req_quantile_calculator_impl.hpp +60 -0
- data/vendor/datasketches-cpp/req/include/req_sketch.hpp +395 -0
- data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +810 -0
- data/vendor/datasketches-cpp/req/test/CMakeLists.txt +43 -0
- data/vendor/datasketches-cpp/req/test/req_float_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_float_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_float_exact_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_float_raw_items_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_float_single_item_from_java.sk +0 -0
- data/vendor/datasketches-cpp/req/test/req_sketch_custom_type_test.cpp +128 -0
- data/vendor/datasketches-cpp/req/test/req_sketch_test.cpp +494 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +19 -13
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +130 -127
- data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +5 -5
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +41 -49
- data/vendor/datasketches-cpp/sampling/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_allocation_test.cpp +96 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +6 -6
- data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +13 -44
- data/vendor/datasketches-cpp/setup.py +11 -6
- data/vendor/datasketches-cpp/theta/CMakeLists.txt +30 -3
- data/vendor/datasketches-cpp/{tuple → theta}/include/bounds_on_ratios_in_sampled_sets.hpp +3 -2
- data/vendor/datasketches-cpp/{tuple → theta}/include/bounds_on_ratios_in_theta_sketched_sets.hpp +1 -1
- data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser.hpp +67 -0
- data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser_impl.hpp +70 -0
- data/vendor/datasketches-cpp/theta/include/theta_a_not_b.hpp +12 -29
- data/vendor/datasketches-cpp/theta/include/theta_a_not_b_impl.hpp +5 -46
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_comparators.hpp +0 -0
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_constants.hpp +11 -4
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_helpers.hpp +0 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection.hpp +26 -28
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_intersection_base.hpp +0 -0
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_intersection_base_impl.hpp +0 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection_impl.hpp +8 -90
- data/vendor/datasketches-cpp/{tuple/test/theta_union_experimental_test.cpp → theta/include/theta_jaccard_similarity.hpp} +11 -18
- data/vendor/datasketches-cpp/{tuple/include/jaccard_similarity.hpp → theta/include/theta_jaccard_similarity_base.hpp} +24 -36
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_set_difference_base.hpp +0 -0
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_set_difference_base_impl.hpp +5 -0
- data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +163 -256
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +250 -651
- data/vendor/datasketches-cpp/theta/include/theta_union.hpp +27 -60
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_union_base.hpp +1 -1
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_union_base_impl.hpp +6 -1
- data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +13 -69
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_update_sketch_base.hpp +10 -21
- data/vendor/datasketches-cpp/{tuple → theta}/include/theta_update_sketch_base_impl.hpp +44 -30
- data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +23 -1
- data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +21 -1
- data/vendor/datasketches-cpp/{tuple → theta}/test/theta_jaccard_similarity_test.cpp +60 -5
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +74 -235
- data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +22 -2
- data/vendor/datasketches-cpp/tuple/CMakeLists.txt +3 -35
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +47 -60
- data/vendor/datasketches-cpp/tuple/include/tuple_jaccard_similarity.hpp +38 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +28 -13
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +57 -70
- data/vendor/datasketches-cpp/tuple/test/CMakeLists.txt +1 -6
- data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +1 -1
- data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +18 -21
- data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +13 -16
- data/vendor/datasketches-cpp/tuple/test/tuple_jaccard_similarity_test.cpp +7 -6
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_allocation_test.cpp +3 -3
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +20 -20
- data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +13 -16
- metadata +51 -36
- data/vendor/datasketches-cpp/tuple/include/theta_a_not_b_experimental.hpp +0 -53
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental.hpp +0 -78
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental_impl.hpp +0 -43
- data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental.hpp +0 -393
- data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental_impl.hpp +0 -481
- data/vendor/datasketches-cpp/tuple/include/theta_union_experimental.hpp +0 -88
- data/vendor/datasketches-cpp/tuple/include/theta_union_experimental_impl.hpp +0 -47
- data/vendor/datasketches-cpp/tuple/test/theta_a_not_b_experimental_test.cpp +0 -250
- 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 +0 -224
- data/vendor/datasketches-cpp/tuple/test/theta_sketch_experimental_test.cpp +0 -247
@@ -70,33 +70,33 @@ uint8_t compact_array_of_doubles_sketch_alloc<A>::get_num_values() const {
|
|
70
70
|
template<typename A>
|
71
71
|
void compact_array_of_doubles_sketch_alloc<A>::serialize(std::ostream& os) const {
|
72
72
|
const uint8_t preamble_longs = 1;
|
73
|
-
|
73
|
+
write(os, preamble_longs);
|
74
74
|
const uint8_t serial_version = SERIAL_VERSION;
|
75
|
-
|
75
|
+
write(os, serial_version);
|
76
76
|
const uint8_t family = SKETCH_FAMILY;
|
77
|
-
|
77
|
+
write(os, family);
|
78
78
|
const uint8_t type = SKETCH_TYPE;
|
79
|
-
|
79
|
+
write(os, type);
|
80
80
|
const uint8_t flags_byte(
|
81
81
|
(this->is_empty() ? 1 << flags::IS_EMPTY : 0) |
|
82
82
|
(this->get_num_retained() > 0 ? 1 << flags::HAS_ENTRIES : 0) |
|
83
83
|
(this->is_ordered() ? 1 << flags::IS_ORDERED : 0)
|
84
84
|
);
|
85
|
-
|
86
|
-
|
85
|
+
write(os, flags_byte);
|
86
|
+
write(os, num_values_);
|
87
87
|
const uint16_t seed_hash = this->get_seed_hash();
|
88
|
-
|
89
|
-
|
88
|
+
write(os, seed_hash);
|
89
|
+
write(os, this->theta_);
|
90
90
|
if (this->get_num_retained() > 0) {
|
91
|
-
const uint32_t num_entries = this->entries_.size();
|
92
|
-
|
91
|
+
const uint32_t num_entries = static_cast<uint32_t>(this->entries_.size());
|
92
|
+
write(os, num_entries);
|
93
93
|
const uint32_t unused32 = 0;
|
94
|
-
|
94
|
+
write(os, unused32);
|
95
95
|
for (const auto& it: this->entries_) {
|
96
|
-
|
96
|
+
write(os, it.first);
|
97
97
|
}
|
98
98
|
for (const auto& it: this->entries_) {
|
99
|
-
|
99
|
+
write(os, it.second.data(), it.second.size() * sizeof(double));
|
100
100
|
}
|
101
101
|
}
|
102
102
|
}
|
@@ -110,30 +110,29 @@ auto compact_array_of_doubles_sketch_alloc<A>::serialize(unsigned header_size_by
|
|
110
110
|
vector_bytes bytes(size, 0, this->entries_.get_allocator());
|
111
111
|
uint8_t* ptr = bytes.data() + header_size_bytes;
|
112
112
|
|
113
|
-
ptr += copy_to_mem(
|
113
|
+
ptr += copy_to_mem(preamble_longs, ptr);
|
114
114
|
const uint8_t serial_version = SERIAL_VERSION;
|
115
|
-
ptr += copy_to_mem(
|
115
|
+
ptr += copy_to_mem(serial_version, ptr);
|
116
116
|
const uint8_t family = SKETCH_FAMILY;
|
117
|
-
ptr += copy_to_mem(
|
117
|
+
ptr += copy_to_mem(family, ptr);
|
118
118
|
const uint8_t type = SKETCH_TYPE;
|
119
|
-
ptr += copy_to_mem(
|
119
|
+
ptr += copy_to_mem(type, ptr);
|
120
120
|
const uint8_t flags_byte(
|
121
121
|
(this->is_empty() ? 1 << flags::IS_EMPTY : 0) |
|
122
122
|
(this->get_num_retained() ? 1 << flags::HAS_ENTRIES : 0) |
|
123
123
|
(this->is_ordered() ? 1 << flags::IS_ORDERED : 0)
|
124
124
|
);
|
125
|
-
ptr += copy_to_mem(
|
126
|
-
ptr += copy_to_mem(
|
125
|
+
ptr += copy_to_mem(flags_byte, ptr);
|
126
|
+
ptr += copy_to_mem(num_values_, ptr);
|
127
127
|
const uint16_t seed_hash = this->get_seed_hash();
|
128
|
-
ptr += copy_to_mem(
|
129
|
-
ptr += copy_to_mem(
|
128
|
+
ptr += copy_to_mem(seed_hash, ptr);
|
129
|
+
ptr += copy_to_mem((this->theta_), ptr);
|
130
130
|
if (this->get_num_retained() > 0) {
|
131
|
-
const uint32_t num_entries = this->entries_.size();
|
132
|
-
ptr += copy_to_mem(
|
133
|
-
|
134
|
-
ptr += copy_to_mem(&unused32, ptr, sizeof(unused32));
|
131
|
+
const uint32_t num_entries = static_cast<uint32_t>(this->entries_.size());
|
132
|
+
ptr += copy_to_mem(num_entries, ptr);
|
133
|
+
ptr += sizeof(uint32_t); // unused
|
135
134
|
for (const auto& it: this->entries_) {
|
136
|
-
ptr += copy_to_mem(
|
135
|
+
ptr += copy_to_mem(it.first, ptr);
|
137
136
|
}
|
138
137
|
for (const auto& it: this->entries_) {
|
139
138
|
ptr += copy_to_mem(it.second.data(), ptr, it.second.size() * sizeof(double));
|
@@ -144,40 +143,30 @@ auto compact_array_of_doubles_sketch_alloc<A>::serialize(unsigned header_size_by
|
|
144
143
|
|
145
144
|
template<typename A>
|
146
145
|
compact_array_of_doubles_sketch_alloc<A> compact_array_of_doubles_sketch_alloc<A>::deserialize(std::istream& is, uint64_t seed, const A& allocator) {
|
147
|
-
uint8_t
|
148
|
-
|
149
|
-
uint8_t
|
150
|
-
|
151
|
-
uint8_t
|
152
|
-
|
153
|
-
|
154
|
-
is.read(reinterpret_cast<char*>(&type), sizeof(type));
|
155
|
-
uint8_t flags_byte;
|
156
|
-
is.read(reinterpret_cast<char*>(&flags_byte), sizeof(flags_byte));
|
157
|
-
uint8_t num_values;
|
158
|
-
is.read(reinterpret_cast<char*>(&num_values), sizeof(num_values));
|
159
|
-
uint16_t seed_hash;
|
160
|
-
is.read(reinterpret_cast<char*>(&seed_hash), sizeof(seed_hash));
|
146
|
+
read<uint8_t>(is); // unused
|
147
|
+
const auto serial_version = read<uint8_t>(is);
|
148
|
+
const auto family = read<uint8_t>(is);
|
149
|
+
const auto type = read<uint8_t>(is);
|
150
|
+
const auto flags_byte = read<uint8_t>(is);
|
151
|
+
const auto num_values = read<uint8_t>(is);
|
152
|
+
const auto seed_hash = read<uint16_t>(is);
|
161
153
|
checker<true>::check_serial_version(serial_version, SERIAL_VERSION);
|
162
154
|
checker<true>::check_sketch_family(family, SKETCH_FAMILY);
|
163
155
|
checker<true>::check_sketch_type(type, SKETCH_TYPE);
|
164
156
|
const bool has_entries = flags_byte & (1 << flags::HAS_ENTRIES);
|
165
157
|
if (has_entries) checker<true>::check_seed_hash(seed_hash, compute_seed_hash(seed));
|
166
158
|
|
167
|
-
|
168
|
-
is.read(reinterpret_cast<char*>(&theta), sizeof(theta));
|
159
|
+
const auto theta = read<uint64_t>(is);
|
169
160
|
std::vector<Entry, AllocEntry> entries(allocator);
|
170
161
|
if (has_entries) {
|
171
|
-
|
172
|
-
|
173
|
-
uint32_t unused32;
|
174
|
-
is.read(reinterpret_cast<char*>(&unused32), sizeof(unused32));
|
162
|
+
const auto num_entries = read<uint32_t>(is);
|
163
|
+
read<uint32_t>(is); // unused
|
175
164
|
entries.reserve(num_entries);
|
176
165
|
std::vector<uint64_t, AllocU64> keys(num_entries, 0, allocator);
|
177
|
-
|
166
|
+
read(is, keys.data(), num_entries * sizeof(uint64_t));
|
178
167
|
for (size_t i = 0; i < num_entries; ++i) {
|
179
168
|
aod<A> summary(num_values, allocator);
|
180
|
-
|
169
|
+
read(is, summary.data(), num_values * sizeof(double));
|
181
170
|
entries.push_back(Entry(keys[i], std::move(summary)));
|
182
171
|
}
|
183
172
|
}
|
@@ -191,20 +180,19 @@ template<typename A>
|
|
191
180
|
compact_array_of_doubles_sketch_alloc<A> compact_array_of_doubles_sketch_alloc<A>::deserialize(const void* bytes, size_t size, uint64_t seed, const A& allocator) {
|
192
181
|
ensure_minimum_memory(size, 16);
|
193
182
|
const char* ptr = static_cast<const char*>(bytes);
|
194
|
-
uint8_t
|
195
|
-
ptr += copy_from_mem(ptr, &preamble_longs, sizeof(preamble_longs));
|
183
|
+
ptr += sizeof(uint8_t); // unused
|
196
184
|
uint8_t serial_version;
|
197
|
-
ptr += copy_from_mem(ptr,
|
185
|
+
ptr += copy_from_mem(ptr, serial_version);
|
198
186
|
uint8_t family;
|
199
|
-
ptr += copy_from_mem(ptr,
|
187
|
+
ptr += copy_from_mem(ptr, family);
|
200
188
|
uint8_t type;
|
201
|
-
ptr += copy_from_mem(ptr,
|
189
|
+
ptr += copy_from_mem(ptr, type);
|
202
190
|
uint8_t flags_byte;
|
203
|
-
ptr += copy_from_mem(ptr,
|
191
|
+
ptr += copy_from_mem(ptr, flags_byte);
|
204
192
|
uint8_t num_values;
|
205
|
-
ptr += copy_from_mem(ptr,
|
193
|
+
ptr += copy_from_mem(ptr, num_values);
|
206
194
|
uint16_t seed_hash;
|
207
|
-
ptr += copy_from_mem(ptr,
|
195
|
+
ptr += copy_from_mem(ptr, seed_hash);
|
208
196
|
checker<true>::check_serial_version(serial_version, SERIAL_VERSION);
|
209
197
|
checker<true>::check_sketch_family(family, SKETCH_FAMILY);
|
210
198
|
checker<true>::check_sketch_type(type, SKETCH_TYPE);
|
@@ -212,14 +200,13 @@ compact_array_of_doubles_sketch_alloc<A> compact_array_of_doubles_sketch_alloc<A
|
|
212
200
|
if (has_entries) checker<true>::check_seed_hash(seed_hash, compute_seed_hash(seed));
|
213
201
|
|
214
202
|
uint64_t theta;
|
215
|
-
ptr += copy_from_mem(ptr,
|
203
|
+
ptr += copy_from_mem(ptr, theta);
|
216
204
|
std::vector<Entry, AllocEntry> entries(allocator);
|
217
205
|
if (has_entries) {
|
218
206
|
ensure_minimum_memory(size, 24);
|
219
207
|
uint32_t num_entries;
|
220
|
-
ptr += copy_from_mem(ptr,
|
221
|
-
uint32_t
|
222
|
-
ptr += copy_from_mem(ptr, &unused32, sizeof(unused32));
|
208
|
+
ptr += copy_from_mem(ptr, num_entries);
|
209
|
+
ptr += sizeof(uint32_t); // unused
|
223
210
|
ensure_minimum_memory(size, 24 + (sizeof(uint64_t) + sizeof(double) * num_values) * num_entries);
|
224
211
|
entries.reserve(num_entries);
|
225
212
|
std::vector<uint64_t, AllocU64> keys(num_entries, 0, allocator);
|
@@ -0,0 +1,38 @@
|
|
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_JACCARD_SIMILARITY_HPP_
|
21
|
+
#define TUPLE_JACCARD_SIMILARITY_HPP_
|
22
|
+
|
23
|
+
#include "theta_jaccard_similarity_base.hpp"
|
24
|
+
#include "tuple_union.hpp"
|
25
|
+
#include "tuple_intersection.hpp"
|
26
|
+
|
27
|
+
namespace datasketches {
|
28
|
+
|
29
|
+
template<
|
30
|
+
typename Summary,
|
31
|
+
typename IntersectionPolicy,
|
32
|
+
typename UnionPolicy = default_union_policy<Summary>,
|
33
|
+
typename Allocator = std::allocator<Summary>>
|
34
|
+
using tuple_jaccard_similarity = jaccard_similarity_base<tuple_union<Summary, UnionPolicy, Allocator>, tuple_intersection<Summary, IntersectionPolicy, Allocator>, pair_extract_key<uint64_t, Summary>>;
|
35
|
+
|
36
|
+
} /* namespace datasketches */
|
37
|
+
|
38
|
+
# endif
|
@@ -31,7 +31,17 @@ namespace datasketches {
|
|
31
31
|
template<typename S, typename A> class tuple_sketch;
|
32
32
|
template<typename S, typename U, typename P, typename A> class update_tuple_sketch;
|
33
33
|
template<typename S, typename A> class compact_tuple_sketch;
|
34
|
-
template<typename A> class
|
34
|
+
template<typename A> class theta_sketch_alloc;
|
35
|
+
|
36
|
+
template<typename K, typename V>
|
37
|
+
struct pair_extract_key {
|
38
|
+
K& operator()(std::pair<K, V>& entry) const {
|
39
|
+
return entry.first;
|
40
|
+
}
|
41
|
+
const K& operator()(const std::pair<K, V>& entry) const {
|
42
|
+
return entry.first;
|
43
|
+
}
|
44
|
+
};
|
35
45
|
|
36
46
|
template<
|
37
47
|
typename Summary,
|
@@ -143,7 +153,8 @@ public:
|
|
143
153
|
virtual const_iterator end() const = 0;
|
144
154
|
|
145
155
|
protected:
|
146
|
-
|
156
|
+
using ostrstream = std::basic_ostringstream<char, std::char_traits<char>, AllocChar<Allocator>>;
|
157
|
+
virtual void print_specifics(ostrstream& os) const = 0;
|
147
158
|
|
148
159
|
static uint16_t get_seed_hash(uint64_t seed);
|
149
160
|
|
@@ -333,7 +344,8 @@ protected:
|
|
333
344
|
// for builder
|
334
345
|
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
346
|
|
336
|
-
|
347
|
+
using ostrstream = typename Base::ostrstream;
|
348
|
+
virtual void print_specifics(ostrstream& os) const;
|
337
349
|
};
|
338
350
|
|
339
351
|
// compact sketch
|
@@ -372,7 +384,7 @@ public:
|
|
372
384
|
compact_tuple_sketch& operator=(const compact_tuple_sketch&) = default;
|
373
385
|
compact_tuple_sketch& operator=(compact_tuple_sketch&&) = default;
|
374
386
|
|
375
|
-
compact_tuple_sketch(const
|
387
|
+
compact_tuple_sketch(const theta_sketch_alloc<AllocU64>& other, const Summary& summary, bool ordered = true);
|
376
388
|
|
377
389
|
virtual Allocator get_allocator() const;
|
378
390
|
virtual bool is_empty() const;
|
@@ -444,22 +456,25 @@ protected:
|
|
444
456
|
// for deserialize
|
445
457
|
class deleter_of_summaries {
|
446
458
|
public:
|
447
|
-
deleter_of_summaries(uint32_t num, bool destroy
|
448
|
-
|
449
|
-
void
|
459
|
+
deleter_of_summaries(uint32_t num, bool destroy, const Allocator& allocator):
|
460
|
+
allocator_(allocator), num_(num), destroy_(destroy) {}
|
461
|
+
void set_destroy(bool destroy) { destroy_ = destroy; }
|
462
|
+
void operator() (Summary* ptr) {
|
450
463
|
if (ptr != nullptr) {
|
451
|
-
if (
|
452
|
-
for (uint32_t i = 0; i <
|
464
|
+
if (destroy_) {
|
465
|
+
for (uint32_t i = 0; i < num_; ++i) ptr[i].~Summary();
|
453
466
|
}
|
454
|
-
|
467
|
+
allocator_.deallocate(ptr, num_);
|
455
468
|
}
|
456
469
|
}
|
457
470
|
private:
|
458
|
-
|
459
|
-
|
471
|
+
Allocator allocator_;
|
472
|
+
uint32_t num_;
|
473
|
+
bool destroy_;
|
460
474
|
};
|
461
475
|
|
462
|
-
|
476
|
+
using ostrstream = typename Base::ostrstream;
|
477
|
+
virtual void print_specifics(ostrstream& os) const;
|
463
478
|
|
464
479
|
};
|
465
480
|
|
@@ -53,7 +53,7 @@ double tuple_sketch<S, A>::get_upper_bound(uint8_t num_std_devs) const {
|
|
53
53
|
|
54
54
|
template<typename S, typename A>
|
55
55
|
string<A> tuple_sketch<S, A>::to_string(bool detail) const {
|
56
|
-
|
56
|
+
ostrstream os;
|
57
57
|
os << "### Tuple sketch summary:" << std::endl;
|
58
58
|
os << " num retained entries : " << get_num_retained() << std::endl;
|
59
59
|
os << " seed hash : " << get_seed_hash() << std::endl;
|
@@ -238,7 +238,7 @@ compact_tuple_sketch<S, A> update_tuple_sketch<S, U, P, A>::compact(bool ordered
|
|
238
238
|
}
|
239
239
|
|
240
240
|
template<typename S, typename U, typename P, typename A>
|
241
|
-
void update_tuple_sketch<S, U, P, A>::print_specifics(
|
241
|
+
void update_tuple_sketch<S, U, P, A>::print_specifics(ostrstream& os) const {
|
242
242
|
os << " lg nominal size : " << (int) map_.lg_nom_size_ << std::endl;
|
243
243
|
os << " lg current size : " << (int) map_.lg_cur_size_ << std::endl;
|
244
244
|
os << " resize factor : " << (1 << map_.rf_) << std::endl;
|
@@ -279,7 +279,7 @@ entries_(std::move(other.entries_))
|
|
279
279
|
{}
|
280
280
|
|
281
281
|
template<typename S, typename A>
|
282
|
-
compact_tuple_sketch<S, A>::compact_tuple_sketch(const
|
282
|
+
compact_tuple_sketch<S, A>::compact_tuple_sketch(const theta_sketch_alloc<AllocU64>& other, const S& summary, bool ordered):
|
283
283
|
is_empty_(other.is_empty()),
|
284
284
|
is_ordered_(other.is_ordered() || ordered),
|
285
285
|
seed_hash_(other.get_seed_hash()),
|
@@ -315,7 +315,7 @@ uint64_t compact_tuple_sketch<S, A>::get_theta64() const {
|
|
315
315
|
|
316
316
|
template<typename S, typename A>
|
317
317
|
uint32_t compact_tuple_sketch<S, A>::get_num_retained() const {
|
318
|
-
return entries_.size();
|
318
|
+
return static_cast<uint32_t>(entries_.size());
|
319
319
|
}
|
320
320
|
|
321
321
|
template<typename S, typename A>
|
@@ -347,36 +347,36 @@ template<typename SerDe>
|
|
347
347
|
void compact_tuple_sketch<S, A>::serialize(std::ostream& os, const SerDe& sd) const {
|
348
348
|
const bool is_single_item = entries_.size() == 1 && !this->is_estimation_mode();
|
349
349
|
const uint8_t preamble_longs = this->is_empty() || is_single_item ? 1 : this->is_estimation_mode() ? 3 : 2;
|
350
|
-
|
350
|
+
write(os, preamble_longs);
|
351
351
|
const uint8_t serial_version = SERIAL_VERSION;
|
352
|
-
|
352
|
+
write(os, serial_version);
|
353
353
|
const uint8_t family = SKETCH_FAMILY;
|
354
|
-
|
354
|
+
write(os, family);
|
355
355
|
const uint8_t type = SKETCH_TYPE;
|
356
|
-
|
356
|
+
write(os, type);
|
357
357
|
const uint8_t unused8 = 0;
|
358
|
-
|
358
|
+
write(os, unused8);
|
359
359
|
const uint8_t flags_byte(
|
360
360
|
(1 << flags::IS_COMPACT) |
|
361
361
|
(1 << flags::IS_READ_ONLY) |
|
362
362
|
(this->is_empty() ? 1 << flags::IS_EMPTY : 0) |
|
363
363
|
(this->is_ordered() ? 1 << flags::IS_ORDERED : 0)
|
364
364
|
);
|
365
|
-
|
365
|
+
write(os, flags_byte);
|
366
366
|
const uint16_t seed_hash = get_seed_hash();
|
367
|
-
|
367
|
+
write(os, seed_hash);
|
368
368
|
if (!this->is_empty()) {
|
369
369
|
if (!is_single_item) {
|
370
|
-
const uint32_t num_entries = entries_.size();
|
371
|
-
|
370
|
+
const uint32_t num_entries = static_cast<uint32_t>(entries_.size());
|
371
|
+
write(os, num_entries);
|
372
372
|
const uint32_t unused32 = 0;
|
373
|
-
|
373
|
+
write(os, unused32);
|
374
374
|
if (this->is_estimation_mode()) {
|
375
|
-
|
375
|
+
write(os, this->theta_);
|
376
376
|
}
|
377
377
|
}
|
378
378
|
for (const auto& it: entries_) {
|
379
|
-
|
379
|
+
write(os, it.first);
|
380
380
|
sd.serialize(os, &it.second, 1);
|
381
381
|
}
|
382
382
|
}
|
@@ -393,36 +393,34 @@ auto compact_tuple_sketch<S, A>::serialize(unsigned header_size_bytes, const Ser
|
|
393
393
|
uint8_t* ptr = bytes.data() + header_size_bytes;
|
394
394
|
const uint8_t* end_ptr = ptr + size;
|
395
395
|
|
396
|
-
ptr += copy_to_mem(
|
396
|
+
ptr += copy_to_mem(preamble_longs, ptr);
|
397
397
|
const uint8_t serial_version = SERIAL_VERSION;
|
398
|
-
ptr += copy_to_mem(
|
398
|
+
ptr += copy_to_mem(serial_version, ptr);
|
399
399
|
const uint8_t family = SKETCH_FAMILY;
|
400
|
-
ptr += copy_to_mem(
|
400
|
+
ptr += copy_to_mem(family, ptr);
|
401
401
|
const uint8_t type = SKETCH_TYPE;
|
402
|
-
ptr += copy_to_mem(
|
403
|
-
|
404
|
-
ptr += copy_to_mem(&unused8, ptr, sizeof(unused8));
|
402
|
+
ptr += copy_to_mem(type, ptr);
|
403
|
+
ptr += sizeof(uint8_t); // unused
|
405
404
|
const uint8_t flags_byte(
|
406
405
|
(1 << flags::IS_COMPACT) |
|
407
406
|
(1 << flags::IS_READ_ONLY) |
|
408
407
|
(this->is_empty() ? 1 << flags::IS_EMPTY : 0) |
|
409
408
|
(this->is_ordered() ? 1 << flags::IS_ORDERED : 0)
|
410
409
|
);
|
411
|
-
ptr += copy_to_mem(
|
410
|
+
ptr += copy_to_mem(flags_byte, ptr);
|
412
411
|
const uint16_t seed_hash = get_seed_hash();
|
413
|
-
ptr += copy_to_mem(
|
412
|
+
ptr += copy_to_mem(seed_hash, ptr);
|
414
413
|
if (!this->is_empty()) {
|
415
414
|
if (!is_single_item) {
|
416
|
-
const uint32_t num_entries = entries_.size();
|
417
|
-
ptr += copy_to_mem(
|
418
|
-
|
419
|
-
ptr += copy_to_mem(&unused32, ptr, sizeof(unused32));
|
415
|
+
const uint32_t num_entries = static_cast<uint32_t>(entries_.size());
|
416
|
+
ptr += copy_to_mem(num_entries, ptr);
|
417
|
+
ptr += sizeof(uint32_t); // unused
|
420
418
|
if (this->is_estimation_mode()) {
|
421
|
-
ptr += copy_to_mem(
|
419
|
+
ptr += copy_to_mem(theta_, ptr);
|
422
420
|
}
|
423
421
|
}
|
424
422
|
for (const auto& it: entries_) {
|
425
|
-
ptr += copy_to_mem(
|
423
|
+
ptr += copy_to_mem(it.first, ptr);
|
426
424
|
ptr += sd.serialize(ptr, end_ptr - ptr, &it.second, 1);
|
427
425
|
}
|
428
426
|
}
|
@@ -432,20 +430,13 @@ auto compact_tuple_sketch<S, A>::serialize(unsigned header_size_bytes, const Ser
|
|
432
430
|
template<typename S, typename A>
|
433
431
|
template<typename SerDe>
|
434
432
|
compact_tuple_sketch<S, A> compact_tuple_sketch<S, A>::deserialize(std::istream& is, uint64_t seed, const SerDe& sd, const A& allocator) {
|
435
|
-
|
436
|
-
|
437
|
-
uint8_t
|
438
|
-
|
439
|
-
uint8_t
|
440
|
-
|
441
|
-
|
442
|
-
is.read(reinterpret_cast<char*>(&type), sizeof(type));
|
443
|
-
uint8_t unused8;
|
444
|
-
is.read(reinterpret_cast<char*>(&unused8), sizeof(unused8));
|
445
|
-
uint8_t flags_byte;
|
446
|
-
is.read(reinterpret_cast<char*>(&flags_byte), sizeof(flags_byte));
|
447
|
-
uint16_t seed_hash;
|
448
|
-
is.read(reinterpret_cast<char*>(&seed_hash), sizeof(seed_hash));
|
433
|
+
const auto preamble_longs = read<uint8_t>(is);
|
434
|
+
const auto serial_version = read<uint8_t>(is);
|
435
|
+
const auto family = read<uint8_t>(is);
|
436
|
+
const auto type = read<uint8_t>(is);
|
437
|
+
read<uint8_t>(is); // unused
|
438
|
+
const auto flags_byte = read<uint8_t>(is);
|
439
|
+
const auto seed_hash = read<uint16_t>(is);
|
449
440
|
checker<true>::check_serial_version(serial_version, SERIAL_VERSION);
|
450
441
|
checker<true>::check_sketch_family(family, SKETCH_FAMILY);
|
451
442
|
checker<true>::check_sketch_type(type, SKETCH_TYPE);
|
@@ -458,11 +449,10 @@ compact_tuple_sketch<S, A> compact_tuple_sketch<S, A>::deserialize(std::istream&
|
|
458
449
|
if (preamble_longs == 1) {
|
459
450
|
num_entries = 1;
|
460
451
|
} else {
|
461
|
-
|
462
|
-
uint32_t
|
463
|
-
is.read(reinterpret_cast<char*>(&unused32), sizeof(unused32));
|
452
|
+
num_entries = read<uint32_t>(is);
|
453
|
+
read<uint32_t>(is); // unused
|
464
454
|
if (preamble_longs > 2) {
|
465
|
-
|
455
|
+
theta = read<uint64_t>(is);
|
466
456
|
}
|
467
457
|
}
|
468
458
|
}
|
@@ -470,10 +460,9 @@ compact_tuple_sketch<S, A> compact_tuple_sketch<S, A>::deserialize(std::istream&
|
|
470
460
|
std::vector<Entry, AllocEntry> entries(alloc);
|
471
461
|
if (!is_empty) {
|
472
462
|
entries.reserve(num_entries);
|
473
|
-
std::unique_ptr<S, deleter_of_summaries> summary(alloc.allocate(1), deleter_of_summaries(1, false));
|
463
|
+
std::unique_ptr<S, deleter_of_summaries> summary(alloc.allocate(1), deleter_of_summaries(1, false, allocator));
|
474
464
|
for (size_t i = 0; i < num_entries; ++i) {
|
475
|
-
|
476
|
-
is.read(reinterpret_cast<char*>(&key), sizeof(uint64_t));
|
465
|
+
const auto key = read<uint64_t>(is);
|
477
466
|
sd.deserialize(is, summary.get(), 1);
|
478
467
|
entries.push_back(Entry(key, std::move(*summary)));
|
479
468
|
(*summary).~S();
|
@@ -491,19 +480,18 @@ compact_tuple_sketch<S, A> compact_tuple_sketch<S, A>::deserialize(const void* b
|
|
491
480
|
const char* ptr = static_cast<const char*>(bytes);
|
492
481
|
const char* base = ptr;
|
493
482
|
uint8_t preamble_longs;
|
494
|
-
ptr += copy_from_mem(ptr,
|
483
|
+
ptr += copy_from_mem(ptr, preamble_longs);
|
495
484
|
uint8_t serial_version;
|
496
|
-
ptr += copy_from_mem(ptr,
|
485
|
+
ptr += copy_from_mem(ptr, serial_version);
|
497
486
|
uint8_t family;
|
498
|
-
ptr += copy_from_mem(ptr,
|
487
|
+
ptr += copy_from_mem(ptr, family);
|
499
488
|
uint8_t type;
|
500
|
-
ptr += copy_from_mem(ptr,
|
501
|
-
uint8_t
|
502
|
-
ptr += copy_from_mem(ptr, &unused8, sizeof(unused8));
|
489
|
+
ptr += copy_from_mem(ptr, type);
|
490
|
+
ptr += sizeof(uint8_t); // unused
|
503
491
|
uint8_t flags_byte;
|
504
|
-
ptr += copy_from_mem(ptr,
|
492
|
+
ptr += copy_from_mem(ptr, flags_byte);
|
505
493
|
uint16_t seed_hash;
|
506
|
-
ptr += copy_from_mem(ptr,
|
494
|
+
ptr += copy_from_mem(ptr, seed_hash);
|
507
495
|
checker<true>::check_serial_version(serial_version, SERIAL_VERSION);
|
508
496
|
checker<true>::check_sketch_family(family, SKETCH_FAMILY);
|
509
497
|
checker<true>::check_sketch_type(type, SKETCH_TYPE);
|
@@ -518,12 +506,11 @@ compact_tuple_sketch<S, A> compact_tuple_sketch<S, A>::deserialize(const void* b
|
|
518
506
|
num_entries = 1;
|
519
507
|
} else {
|
520
508
|
ensure_minimum_memory(size, 8); // read the first prelong before this method
|
521
|
-
ptr += copy_from_mem(ptr,
|
522
|
-
uint32_t
|
523
|
-
ptr += copy_from_mem(ptr, &unused32, sizeof(unused32));
|
509
|
+
ptr += copy_from_mem(ptr, num_entries);
|
510
|
+
ptr += sizeof(uint32_t); // unused
|
524
511
|
if (preamble_longs > 2) {
|
525
512
|
ensure_minimum_memory(size, (preamble_longs - 1) << 3);
|
526
|
-
ptr += copy_from_mem(ptr,
|
513
|
+
ptr += copy_from_mem(ptr, theta);
|
527
514
|
}
|
528
515
|
}
|
529
516
|
}
|
@@ -533,10 +520,10 @@ compact_tuple_sketch<S, A> compact_tuple_sketch<S, A>::deserialize(const void* b
|
|
533
520
|
std::vector<Entry, AllocEntry> entries(alloc);
|
534
521
|
if (!is_empty) {
|
535
522
|
entries.reserve(num_entries);
|
536
|
-
std::unique_ptr<S, deleter_of_summaries> summary(alloc.allocate(1), deleter_of_summaries(1, false));
|
523
|
+
std::unique_ptr<S, deleter_of_summaries> summary(alloc.allocate(1), deleter_of_summaries(1, false, allocator));
|
537
524
|
for (size_t i = 0; i < num_entries; ++i) {
|
538
525
|
uint64_t key;
|
539
|
-
ptr += copy_from_mem(ptr,
|
526
|
+
ptr += copy_from_mem(ptr, key);
|
540
527
|
ptr += sd.deserialize(ptr, base + size - ptr, summary.get(), 1);
|
541
528
|
entries.push_back(Entry(key, std::move(*summary)));
|
542
529
|
(*summary).~S();
|
@@ -548,26 +535,26 @@ compact_tuple_sketch<S, A> compact_tuple_sketch<S, A>::deserialize(const void* b
|
|
548
535
|
|
549
536
|
template<typename S, typename A>
|
550
537
|
auto compact_tuple_sketch<S, A>::begin() -> iterator {
|
551
|
-
return iterator(entries_.data(), entries_.size(), 0);
|
538
|
+
return iterator(entries_.data(), static_cast<uint32_t>(entries_.size()), 0);
|
552
539
|
}
|
553
540
|
|
554
541
|
template<typename S, typename A>
|
555
542
|
auto compact_tuple_sketch<S, A>::end() -> iterator {
|
556
|
-
return iterator(nullptr, 0, entries_.size());
|
543
|
+
return iterator(nullptr, 0, static_cast<uint32_t>(entries_.size()));
|
557
544
|
}
|
558
545
|
|
559
546
|
template<typename S, typename A>
|
560
547
|
auto compact_tuple_sketch<S, A>::begin() const -> const_iterator {
|
561
|
-
return const_iterator(entries_.data(), entries_.size(), 0);
|
548
|
+
return const_iterator(entries_.data(), static_cast<uint32_t>(entries_.size()), 0);
|
562
549
|
}
|
563
550
|
|
564
551
|
template<typename S, typename A>
|
565
552
|
auto compact_tuple_sketch<S, A>::end() const -> const_iterator {
|
566
|
-
return const_iterator(nullptr, 0, entries_.size());
|
553
|
+
return const_iterator(nullptr, 0, static_cast<uint32_t>(entries_.size()));
|
567
554
|
}
|
568
555
|
|
569
556
|
template<typename S, typename A>
|
570
|
-
void compact_tuple_sketch<S, A>::print_specifics(
|
557
|
+
void compact_tuple_sketch<S, A>::print_specifics(ostrstream&) const {}
|
571
558
|
|
572
559
|
// builder
|
573
560
|
|
@@ -43,11 +43,6 @@ target_sources(tuple_test
|
|
43
43
|
tuple_union_test.cpp
|
44
44
|
tuple_intersection_test.cpp
|
45
45
|
tuple_a_not_b_test.cpp
|
46
|
-
array_of_doubles_sketch_test.cpp
|
47
|
-
theta_sketch_experimental_test.cpp
|
48
|
-
theta_union_experimental_test.cpp
|
49
|
-
theta_intersection_experimental_test.cpp
|
50
|
-
theta_a_not_b_experimental_test.cpp
|
51
|
-
theta_jaccard_similarity_test.cpp
|
52
46
|
tuple_jaccard_similarity_test.cpp
|
47
|
+
array_of_doubles_sketch_test.cpp
|
53
48
|
)
|
@@ -75,7 +75,7 @@ TEST_CASE("aod sketch: serialization compatibility with java - empty configured
|
|
75
75
|
}
|
76
76
|
|
77
77
|
TEST_CASE("aod sketch: serialization compatibility with java - non-empty no entries", "[tuple_sketch]") {
|
78
|
-
auto update_sketch = update_array_of_doubles_sketch::builder().set_p(0.
|
78
|
+
auto update_sketch = update_array_of_doubles_sketch::builder().set_p(0.01f).build();
|
79
79
|
std::vector<double> a = {1};
|
80
80
|
update_sketch.update(1, a);
|
81
81
|
REQUIRE_FALSE(update_sketch.is_empty());
|