datasketches-cpp
|
Compact Theta sketch. More...
#include <theta_sketch.hpp>
Public Member Functions | |
template<typename Other > | |
compact_theta_sketch_alloc (const Other &other, bool ordered) | |
Copy constructor. More... | |
compact_theta_sketch_alloc (const compact_theta_sketch_alloc &other)=default | |
Copy constructor. More... | |
compact_theta_sketch_alloc (compact_theta_sketch_alloc &&other) noexcept=default | |
Move constructor. More... | |
compact_theta_sketch_alloc & | operator= (const compact_theta_sketch_alloc &other)=default |
Copy assignment. More... | |
compact_theta_sketch_alloc & | operator= (compact_theta_sketch_alloc &&other)=default |
Move assignment. More... | |
virtual Allocator | get_allocator () const |
virtual bool | is_empty () const |
virtual bool | is_ordered () const |
virtual uint64_t | get_theta64 () const |
virtual uint32_t | get_num_retained () const |
virtual uint16_t | get_seed_hash () const |
size_t | get_serialized_size_bytes (bool compressed=false) const |
Computes size in bytes required to serialize the current state of the sketch. More... | |
void | serialize (std::ostream &os) const |
This method serializes the sketch into a given stream in a binary form. More... | |
vector_bytes | serialize (unsigned header_size_bytes=0) const |
This method serializes the sketch as a vector of bytes. More... | |
void | serialize_compressed (std::ostream &os) const |
This method serializes the sketch into a given stream in a compressed binary form. More... | |
vector_bytes | serialize_compressed (unsigned header_size_bytes=0) const |
This method serializes the sketch as a vector of bytes. More... | |
virtual iterator | begin () |
Iterator over hash values in this sketch. More... | |
virtual iterator | end () |
Iterator pointing past the valid range. More... | |
virtual const_iterator | begin () const |
Const iterator over hash values in this sketch. More... | |
virtual const_iterator | end () const |
Const iterator pointing past the valid range. More... | |
Public Member Functions inherited from base_theta_sketch_alloc< std::allocator< uint64_t > > | |
double | get_estimate () const |
double | get_lower_bound (uint8_t num_std_devs) const |
Returns the approximate lower error bound given a number of standard deviations. More... | |
double | get_upper_bound (uint8_t num_std_devs) const |
Returns the approximate upper error bound given a number of standard deviations. More... | |
bool | is_estimation_mode () const |
double | get_theta () const |
virtual string< std::allocator< uint64_t > > | to_string (bool print_items=false) const |
Provides a human-readable summary of this sketch as a string. More... | |
Static Public Member Functions | |
static size_t | get_max_serialized_size_bytes (uint8_t lg_k) |
Computes maximum serialized size in bytes. More... | |
static compact_theta_sketch_alloc | deserialize (std::istream &is, uint64_t seed=DEFAULT_SEED, const Allocator &allocator=Allocator()) |
This method deserializes a sketch from a given stream. More... | |
static compact_theta_sketch_alloc | deserialize (const void *bytes, size_t size, uint64_t seed=DEFAULT_SEED, const Allocator &allocator=Allocator()) |
This method deserializes a sketch from a given array of bytes. More... | |
Compact Theta sketch.
This is an immutable form of the Theta sketch, the form that can be serialized and deserialized.
compact_theta_sketch_alloc | ( | const Other & | other, |
bool | ordered | ||
) |
Copy constructor.
Constructs a compact sketch from any other type of Theta sketch
other | sketch to be constructed from |
ordered | if true make the resulting sketch ordered |
|
default |
Copy constructor.
other | sketch to be copied |
|
defaultnoexcept |
Move constructor.
other | sketch to be moved |
|
default |
Copy assignment.
other | sketch to be copied |
|
default |
Move assignment.
other | sketch to be moved |
|
virtual |
Implements base_theta_sketch_alloc< std::allocator< uint64_t > >.
|
virtual |
Implements base_theta_sketch_alloc< std::allocator< uint64_t > >.
|
virtual |
Implements base_theta_sketch_alloc< std::allocator< uint64_t > >.
|
virtual |
Implements base_theta_sketch_alloc< std::allocator< uint64_t > >.
|
virtual |
Implements base_theta_sketch_alloc< std::allocator< uint64_t > >.
|
virtual |
Implements base_theta_sketch_alloc< std::allocator< uint64_t > >.
|
static |
Computes maximum serialized size in bytes.
lg_k | nominal number of entries in the sketch |
size_t get_serialized_size_bytes | ( | bool | compressed = false | ) | const |
Computes size in bytes required to serialize the current state of the sketch.
Computing compressed size is expensive. It takes iterating over all retained hashes, and the actual serialization will have to look at them again.
compressed | if true compressed size is returned (if applicable) |
void serialize | ( | std::ostream & | os | ) | const |
This method serializes the sketch into a given stream in a binary form.
os | output stream |
auto serialize | ( | unsigned | header_size_bytes = 0 | ) | const |
This method serializes the sketch as a vector of bytes.
An optional header can be reserved in front of the sketch. It is an uninitialized space of a given size. This header is used in Datasketches PostgreSQL extension.
header_size_bytes | space to reserve in front of the sketch |
void serialize_compressed | ( | std::ostream & | os | ) | const |
This method serializes the sketch into a given stream in a compressed binary form.
Compression is applied to ordered sketches except empty and single item. For unordered, empty and single item sketches this method is equivalent to serialize()
os | output stream |
auto serialize_compressed | ( | unsigned | header_size_bytes = 0 | ) | const |
This method serializes the sketch as a vector of bytes.
An optional header can be reserved in front of the sketch. It is an uninitialized space of a given size. This header is used in Datasketches PostgreSQL extension. Compression is applied to ordered sketches except empty and single item. For unordered, empty and single item sketches this method is equivalent to serialize()
header_size_bytes | space to reserve in front of the sketch |
|
virtual |
Iterator over hash values in this sketch.
Implements theta_sketch_alloc< std::allocator< uint64_t > >.
|
virtual |
Iterator pointing past the valid range.
Not to be incremented or dereferenced.
Implements theta_sketch_alloc< std::allocator< uint64_t > >.
|
virtual |
Const iterator over hash values in this sketch.
Implements theta_sketch_alloc< std::allocator< uint64_t > >.
|
virtual |
Const iterator pointing past the valid range.
Not to be incremented or dereferenced.
Implements theta_sketch_alloc< std::allocator< uint64_t > >.
|
static |
This method deserializes a sketch from a given stream.
is | input stream |
seed | the seed for the hash function that was used to create the sketch |
allocator | instance of an Allocator |
|
static |
This method deserializes a sketch from a given array of bytes.
bytes | pointer to the array of bytes |
size | the size of the array |
seed | the seed for the hash function that was used to create the sketch |
allocator | instance of an Allocator |