2222
2323#include < stdexcept>
2424
25+ #include " array_of_strings_sketch.hpp"
2526#include " common_defs.hpp"
2627#include " third_party/utf8cpp/utf8.h"
2728
2829namespace datasketches {
2930
30- template <typename Allocator>
31- default_array_of_strings_update_policy<Allocator>::default_array_of_strings_update_policy(const Allocator& allocator):
32- allocator_ (allocator) {}
33-
34- template <typename Allocator>
35- auto default_array_of_strings_update_policy<Allocator>::create() const -> array_of_strings {
36- return array_of_strings (0 , " " , allocator_);
31+ inline array_of_strings default_array_of_strings_update_policy::create () const {
32+ return array_of_strings (0 , " " );
3733}
3834
39- template <typename Allocator>
40- void default_array_of_strings_update_policy<Allocator>::update(
35+ inline void default_array_of_strings_update_policy::update (
4136 array_of_strings& array, const array_of_strings& input
4237) const {
4338 const auto length = static_cast <size_t >(input.size ());
44- array = array_of_strings (static_cast <uint8_t >(length), " " , allocator_ );
39+ array = array_of_strings (static_cast <uint8_t >(length), " " );
4540 for (size_t i = 0 ; i < length; ++i) array[i] = input[i];
4641}
4742
48- template <typename Allocator>
49- void default_array_of_strings_update_policy<Allocator>::update(
43+ inline void default_array_of_strings_update_policy::update (
5044 array_of_strings& array, const array_of_strings* input
5145) const {
5246 if (input == nullptr ) {
53- array = array_of_strings (0 , " " , allocator_ );
47+ array = array_of_strings (0 , " " );
5448 return ;
5549 }
5650 const auto length = static_cast <size_t >(input->size ());
57- array = array_of_strings (static_cast <uint8_t >(length), " " , allocator_ );
51+ array = array_of_strings (static_cast <uint8_t >(length), " " );
5852 for (size_t i = 0 ; i < length; ++i) array[i] = (*input)[i];
5953}
6054
61- template <typename Allocator>
62- uint64_t hash_array_of_strings_key (const array<std::string, Allocator>& key) {
55+ inline uint64_t hash_array_of_strings_key (const array_of_strings& key) {
6356 // Matches Java Util.PRIME for ArrayOfStrings key hashing.
6457 static constexpr uint64_t STRING_ARR_HASH_SEED = 0x7A3CCA71ULL ;
6558 XXHash64 hasher (STRING_ARR_HASH_SEED );
@@ -95,8 +88,7 @@ template<typename SerDe>
9588auto compact_array_of_strings_tuple_sketch<Allocator>::deserialize(
9689 std::istream& is, uint64_t seed, const SerDe& sd, const Allocator& allocator
9790) -> compact_array_of_strings_tuple_sketch {
98- summary_allocator alloc (allocator);
99- auto base = Base::deserialize (is, seed, sd, alloc);
91+ auto base = Base::deserialize (is, seed, sd, allocator);
10092 return compact_array_of_strings_tuple_sketch (std::move (base));
10193}
10294
@@ -105,14 +97,12 @@ template<typename SerDe>
10597auto compact_array_of_strings_tuple_sketch<Allocator>::deserialize(
10698 const void * bytes, size_t size, uint64_t seed, const SerDe& sd, const Allocator& allocator
10799) -> compact_array_of_strings_tuple_sketch {
108- summary_allocator alloc (allocator);
109- auto base = Base::deserialize (bytes, size, seed, sd, alloc);
100+ auto base = Base::deserialize (bytes, size, seed, sd, allocator);
110101 return compact_array_of_strings_tuple_sketch (std::move (base));
111102}
112103
113104template <typename Allocator>
114105default_array_of_strings_serde<Allocator>::default_array_of_strings_serde(const Allocator& allocator):
115- allocator_ (allocator),
116106 summary_allocator_ (allocator) {}
117107
118108template <typename Allocator>
@@ -144,7 +134,7 @@ void default_array_of_strings_serde<Allocator>::deserialize(
144134 const uint8_t num_nodes = read<uint8_t >(is);
145135 if (!is) throw std::runtime_error (" array_of_strings stream read failed" );
146136 check_num_nodes (num_nodes);
147- array_of_strings array (num_nodes, " " , allocator_ );
137+ array_of_strings array (num_nodes, " " );
148138 for (uint8_t j = 0 ; j < num_nodes; ++j) {
149139 const uint32_t length = read<uint32_t >(is);
150140 if (!is) throw std::runtime_error (" array_of_strings stream read failed" );
@@ -202,7 +192,7 @@ size_t default_array_of_strings_serde<Allocator>::deserialize(
202192 uint8_t num_nodes;
203193 bytes_read += copy_from_mem (ptr8 + bytes_read, num_nodes);
204194 check_num_nodes (num_nodes);
205- array_of_strings array (num_nodes, " " , allocator_ );
195+ array_of_strings array (num_nodes, " " );
206196 for (uint8_t j = 0 ; j < num_nodes; ++j) {
207197 uint32_t length;
208198 bytes_read += copy_from_mem (ptr8 + bytes_read, length);
@@ -252,4 +242,4 @@ void default_array_of_strings_serde<Allocator>::check_utf8(const std::string& va
252242
253243} /* namespace datasketches */
254244
255- #endif
245+ #endif
0 commit comments