datasketches-cpp
|
Provides a unioning operation over var_opt_sketch objects. More...
#include <var_opt_union.hpp>
Public Member Functions | |
void | update (const var_opt_sketch< T, A > &sk) |
Updates this union with the given sketch This method takes an lvalue. More... | |
void | update (var_opt_sketch< T, A > &&sk) |
Updates this union with the given sketch This method takes an rvalue. More... | |
var_opt_sketch< T, A > | get_result () const |
Gets the varopt sketch resulting from the union of any input sketches. More... | |
void | reset () |
Resets the union to its default, empty state. | |
template<typename SerDe = serde<T>> | |
size_t | get_serialized_size_bytes (const SerDe &sd=SerDe()) const |
Computes size needed to serialize the current state of the union. More... | |
template<typename SerDe = serde<T>> | |
vector_bytes | serialize (unsigned header_size_bytes=0, const SerDe &sd=SerDe()) const |
NOTE: This method may be deprecated in a future version. More... | |
template<typename SerDe = serde<T>> | |
void | serialize (std::ostream &os, const SerDe &sd=SerDe()) const |
NOTE: This method may be deprecated in a future version. More... | |
string< A > | to_string () const |
Prints a summary of the union as a string. More... | |
Static Public Member Functions | |
template<typename SerDe = serde<T>> | |
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. More... | |
template<typename SerDe = serde<T>> | |
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. More... | |
Provides a unioning operation over var_opt_sketch objects.
This union allows the sample size k to float, possibly increasing or decreasing as warranted by the available data.
The union currently allows serialization and deserialization, even though transporting union objects seems to be an anti-pattern with most sketches. We currently provide it here because the get_result() call may need to discard samples and decrease k in order to return a valid sketch, even if future calls to update() would allow k to remain larger.
The (de)serialization methods may be deprecated and subsequently removed in future versions.
author Kevin Lang author Jon Malkin
void update | ( | const var_opt_sketch< T, A > & | sk | ) |
Updates this union with the given sketch This method takes an lvalue.
sk | a sketch to add to the union |
void update | ( | var_opt_sketch< T, A > && | sk | ) |
Updates this union with the given sketch This method takes an rvalue.
sk | a sketch to add to the union |
var_opt_sketch< T, A > get_result |
Gets the varopt sketch resulting from the union of any input sketches.
size_t get_serialized_size_bytes | ( | const SerDe & | sd = SerDe() | ) | const |
Computes size needed to serialize the current state of the union.
This version is for all other types and can be expensive since every item needs to be looked at.
sd | instance of a SerDe |
vector_bytes serialize | ( | unsigned | header_size_bytes = 0 , |
const SerDe & | sd = SerDe() |
||
) | const |
NOTE: This method may be deprecated in a future version.
This method serializes the sketch as a vector of bytes. An optional header can be reserved in front of the sketch. It is a blank space of a given size. This header is used in Datasketches PostgreSQL extension.
header_size_bytes | space to reserve in front of the sketch |
sd | instance of a SerDe |
void serialize | ( | std::ostream & | os, |
const SerDe & | sd = SerDe() |
||
) | const |
NOTE: This method may be deprecated in a future version.
This method serializes the sketch into a given stream in a binary form
os | output stream |
sd | instance of a SerDe |
|
static |
NOTE: This method may be deprecated in a future version.
This method deserializes a union from a given stream.
is | input stream |
sd | instance of a SerDe |
allocator | instance of an Allocator |
|
static |
NOTE: This method may be deprecated in a future version.
This method deserializes a union from a given array of bytes.
bytes | pointer to the array of bytes |
size | the size of the array |
sd | instance of a SerDe |
allocator | instance of an Allocator |
string< A > to_string |
Prints a summary of the union as a string.