20#ifndef _VAR_OPT_UNION_HPP_
21#define _VAR_OPT_UNION_HPP_
23#include "var_opt_sketch.hpp"
24#include "common_defs.hpp"
31template<
typename A>
using AllocU8 =
typename std::allocator_traits<A>::template rebind_alloc<uint8_t>;
50 typename A = std::allocator<T>
56 explicit var_opt_union(uint32_t max_k,
const A& allocator = A());
57 var_opt_union(
const var_opt_union& other);
58 var_opt_union(var_opt_union&& other)
noexcept;
62 var_opt_union& operator=(
const var_opt_union& other);
63 var_opt_union& operator=(var_opt_union&& other);
100 template<
typename SerDe = serde<T>>
105 typedef vector_u8<A> vector_bytes;
116 template<
typename SerDe = serde<T>>
117 vector_bytes
serialize(
unsigned header_size_bytes = 0,
const SerDe& sd = SerDe())
const;
125 template<
typename SerDe = serde<T>>
126 void serialize(std::ostream& os,
const SerDe& sd = SerDe())
const;
136 template<
typename SerDe = serde<T>>
137 static var_opt_union
deserialize(std::istream& is,
const SerDe& sd = SerDe(),
const A& allocator = A());
148 template<
typename SerDe = serde<T>>
149 static var_opt_union
deserialize(
const void* bytes,
size_t size,
const SerDe& sd = SerDe(),
const A& allocator = A());
158 using AllocSketch =
typename std::allocator_traits<A>::template rebind_alloc<var_opt_sketch<T, A>>;
159 using AllocDouble =
typename std::allocator_traits<A>::template rebind_alloc<double>;
160 using AllocBool =
typename std::allocator_traits<A>::template rebind_alloc<bool>;
162 static const uint8_t PREAMBLE_LONGS_EMPTY = 1;
163 static const uint8_t PREAMBLE_LONGS_NON_EMPTY = 4;
164 static const uint8_t SER_VER = 2;
165 static const uint8_t FAMILY_ID = 14;
166 static const uint8_t EMPTY_FLAG_MASK = 4;
171 double outer_tau_numer_;
174 uint64_t outer_tau_denom_;
182 var_opt_union(uint64_t n,
double outer_tau_numer, uint64_t outer_tau_denom,
243 double get_outer_tau()
const;
247 bool there_exist_unmarked_h_items_lighter_than_target(
double threshold)
const;
252 static void check_preamble_longs(uint8_t preamble_longs, uint8_t flags);
253 static void check_family_and_serialization_version(uint8_t family_id, uint8_t ser_ver);
258#include "var_opt_union_impl.hpp"
This sketch samples data from a stream of items.
Definition var_opt_sketch.hpp:72
vector_bytes serialize(unsigned header_size_bytes=0, const SerDe &sd=SerDe()) const
NOTE: This method may be deprecated in a future version.
var_opt_sketch< T, A > get_result() const
Gets the varopt sketch resulting from the union of any input sketches.
Definition var_opt_union_impl.hpp:426
void update(const var_opt_sketch< T, A > &sk)
Updates this union with the given sketch This method takes an lvalue.
Definition var_opt_union_impl.hpp:324
static var_opt_union deserialize(const void *bytes, size_t size, const SerDe &sd=SerDe(), const A &allocator=A())
NOTE: This method may be deprecated in a future version.
size_t get_serialized_size_bytes(const SerDe &sd=SerDe()) const
Computes size needed to serialize the current state of the union.
Definition var_opt_union_impl.hpp:219
void reset()
Resets the union to its default, empty state.
Definition var_opt_union_impl.hpp:302
string< A > to_string() const
Prints a summary of the union as a string.
Definition var_opt_union_impl.hpp:310
static var_opt_union deserialize(std::istream &is, const SerDe &sd=SerDe(), const A &allocator=A())
NOTE: This method may be deprecated in a future version.
DataSketches namespace.
Definition binomial_bounds.hpp:38