20#ifndef ARRAY_OF_STRINGS_SKETCH_HPP_
21#define ARRAY_OF_STRINGS_SKETCH_HPP_
26#include "array_tuple_sketch.hpp"
31using array_of_strings = array<std::string>;
34class default_array_of_strings_update_policy {
36 default_array_of_strings_update_policy() =
default;
38 array_of_strings create()
const;
40 void update(array_of_strings& array,
const array_of_strings& input)
const;
42 void update(array_of_strings& array,
const array_of_strings* input)
const;
53template<
typename Allocator = std::allocator<array_of_
strings>>
54struct default_array_of_strings_serde {
55 using summary_allocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<array_of_strings>;
57 explicit default_array_of_strings_serde(
const Allocator& allocator = Allocator());
59 void serialize(std::ostream& os,
const array_of_strings* items,
unsigned num)
const;
60 void deserialize(std::istream& is, array_of_strings* items,
unsigned num)
const;
61 size_t serialize(
void* ptr,
size_t capacity,
const array_of_strings* items,
unsigned num)
const;
62 size_t deserialize(
const void* ptr,
size_t capacity, array_of_strings* items,
unsigned num)
const;
63 size_t size_of_item(
const array_of_strings& item)
const;
66 summary_allocator summary_allocator_;
67 static void check_num_nodes(uint8_t num_nodes);
68 static uint32_t compute_total_bytes(
const array_of_strings& item);
69 void destroy_items(array_of_strings* items,
unsigned num)
const;
103template<
typename Allocator = std::allocator<array_of_
strings>>
108 using vector_bytes =
typename Base::vector_bytes;
116 template<
typename Sketch>
124 template<
typename SerDe = default_array_of_
strings_serde<Allocator>>
125 void serialize(std::ostream& os,
const SerDe& sd = SerDe())
const;
135 template<
typename SerDe = default_array_of_
strings_serde<Allocator>>
136 vector_bytes
serialize(
unsigned header_size_bytes = 0,
const SerDe& sd = SerDe())
const;
146 template<
typename SerDe = default_array_of_
strings_serde<Allocator>>
148 const SerDe& sd = SerDe(),
const Allocator& allocator = Allocator());
159 template<
typename SerDe = default_array_of_
strings_serde<Allocator>>
161 const SerDe& sd = SerDe(),
const Allocator& allocator = Allocator());
170template<
typename Allocator = std::allocator<array_of_
strings>,
171 typename Policy = default_array_of_
strings_update_policy>
185template<
typename Allocator = std::allocator<array_of_
strings>,
typename Policy = default_array_of_
strings_update_policy>
191#include "array_of_strings_sketch_impl.hpp"
Extended class of compact_tuple_sketch for array of strings.
Definition array_of_strings_sketch.hpp:105
vector_bytes serialize(unsigned header_size_bytes=0, const SerDe &sd=SerDe()) const
This method serializes the sketch as a vector of bytes.
void serialize(std::ostream &os, const SerDe &sd=SerDe()) const
This method serializes the sketch into a given stream in a binary form.
Definition array_of_strings_sketch_impl.hpp:189
static compact_array_of_strings_tuple_sketch deserialize(std::istream &is, uint64_t seed=DEFAULT_SEED, const SerDe &sd=SerDe(), const Allocator &allocator=Allocator())
This method deserializes a sketch from a given stream.
compact_array_of_strings_tuple_sketch(const Sketch &sketch, bool ordered=true)
Copy constructor.
Definition array_of_strings_sketch_impl.hpp:178
static compact_array_of_strings_tuple_sketch deserialize(const void *bytes, size_t size, uint64_t seed=DEFAULT_SEED, const SerDe &sd=SerDe(), const Allocator &allocator=Allocator())
This method deserializes a sketch from a given array of bytes.
compact_tuple_sketch(const Base &other, bool ordered)
Copy constructor.
Definition tuple_sketch_impl.hpp:287
Update Tuple sketch.
Definition tuple_sketch.hpp:222
DataSketches namespace.
Definition binomial_bounds.hpp:38
update_tuple_sketch< array_of_strings, array_of_strings, Policy, Allocator > update_array_of_strings_tuple_sketch
Convenience alias for update_tuple_sketch for array of strings.
Definition array_of_strings_sketch.hpp:172
compact_array_of_strings_tuple_sketch< Allocator > compact_array_of_strings_sketch(const update_array_of_strings_tuple_sketch< Allocator, Policy > &sketch, bool ordered=true)
Converts an array of strings tuple sketch to a compact sketch (ordered or unordered).
Definition array_of_strings_sketch_impl.hpp:170
uint64_t hash_array_of_strings_key(const array_of_strings &key)
Hashes an array of strings key the same way as Java's ArrayOfStringsTupleSketch (org....
Definition array_of_strings_sketch_impl.hpp:157