datasketches-cpp
Loading...
Searching...
No Matches
update_theta_sketch_alloc< Allocator > Class Template Reference

Update Theta sketch. More...

#include <theta_sketch.hpp>

Inheritance diagram for update_theta_sketch_alloc< Allocator >:
theta_sketch_alloc< Allocator > base_theta_sketch_alloc< Allocator >

Classes

class  builder
 Update Theta sketch builder. More...

Public Member Functions

 update_theta_sketch_alloc (const update_theta_sketch_alloc &other)=default
 Copy constructor.
 update_theta_sketch_alloc (update_theta_sketch_alloc &&other) noexcept=default
 Move constructor.
update_theta_sketch_alloc & operator= (const update_theta_sketch_alloc &other)=default
 Copy assignment.
update_theta_sketch_alloc & operator= (update_theta_sketch_alloc &&other)=default
 Move assignment.
virtual Allocator get_allocator () const
virtual bool is_empty () const
virtual bool is_ordered () const
virtual uint16_t get_seed_hash () const
virtual uint64_t get_theta64 () const
virtual uint32_t get_num_retained () const
uint8_t get_lg_k () const
resize_factor get_rf () const
void update (const std::string &value)
 Update this sketch with a given string.
void update (uint64_t value)
 Update this sketch with a given unsigned 64-bit integer.
void update (int64_t value)
 Update this sketch with a given signed 64-bit integer.
void update (uint32_t value)
 Update this sketch with a given unsigned 32-bit integer.
void update (int32_t value)
 Update this sketch with a given signed 32-bit integer.
void update (uint16_t value)
 Update this sketch with a given unsigned 16-bit integer.
void update (int16_t value)
 Update this sketch with a given signed 16-bit integer.
void update (uint8_t value)
 Update this sketch with a given unsigned 8-bit integer.
void update (int8_t value)
 Update this sketch with a given signed 8-bit integer.
void update (double value)
 Update this sketch with a given double-precision floating point value.
void update (float value)
 Update this sketch with a given floating point value.
void update (const void *data, size_t length)
 Update this sketch with given data of any type.
void trim ()
 Remove retained entries in excess of the nominal size k (if any).
void reset ()
 Reset the sketch to the initial empty state.
compact_theta_sketch_alloc< Allocator > compact (bool ordered=true, bool trim=false) const
 Converts this sketch to a compact sketch (ordered or unordered, trimmed or not trimmed).
virtual iterator begin ()
 Iterator over hash values in this sketch.
virtual iterator end ()
 Iterator pointing past the valid range.
virtual const_iterator begin () const
 Const iterator over hash values in this sketch.
virtual const_iterator end () const
 Const iterator pointing past the valid range.
Public Member Functions inherited from base_theta_sketch_alloc< Allocator >
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.
double get_upper_bound (uint8_t num_std_devs) const
 Returns the approximate upper error bound given a number of standard deviations.
bool is_estimation_mode () const
double get_theta () const
virtual string< Allocator > to_string (bool print_items=false) const
 Provides a human-readable summary of this sketch as a string.

Detailed Description

template<typename Allocator = std::allocator<uint64_t>>
class datasketches::update_theta_sketch_alloc< Allocator >

Update Theta sketch.

The purpose of this class is to build a Theta sketch from input data via the update() methods. There is no constructor. Use builder instead.

Constructor & Destructor Documentation

◆ update_theta_sketch_alloc() [1/2]

template<typename Allocator = std::allocator<uint64_t>>
update_theta_sketch_alloc ( const update_theta_sketch_alloc< Allocator > & other)
default

Copy constructor.

Parameters
othersketch to be copied

◆ update_theta_sketch_alloc() [2/2]

template<typename Allocator = std::allocator<uint64_t>>
update_theta_sketch_alloc ( update_theta_sketch_alloc< Allocator > && other)
defaultnoexcept

Move constructor.

Parameters
othersketch to be moved

Member Function Documentation

◆ operator=() [1/2]

template<typename Allocator = std::allocator<uint64_t>>
update_theta_sketch_alloc & operator= ( const update_theta_sketch_alloc< Allocator > & other)
default

Copy assignment.

Parameters
othersketch to be copied
Returns
reference to this sketch

◆ operator=() [2/2]

template<typename Allocator = std::allocator<uint64_t>>
update_theta_sketch_alloc & operator= ( update_theta_sketch_alloc< Allocator > && other)
default

Move assignment.

Parameters
othersketch to be moved
Returns
reference to this sketch

◆ get_allocator()

template<typename A>
A get_allocator ( ) const
virtual
Returns
allocator

Implements base_theta_sketch_alloc< Allocator >.

◆ is_empty()

template<typename A>
bool is_empty ( ) const
virtual
Returns
true if this sketch represents an empty set (not the same as no retained entries!)

Implements base_theta_sketch_alloc< Allocator >.

◆ is_ordered()

template<typename A>
bool is_ordered ( ) const
virtual
Returns
true if retained entries are ordered

Implements base_theta_sketch_alloc< Allocator >.

◆ get_seed_hash()

template<typename A>
uint16_t get_seed_hash ( ) const
virtual
Returns
hash of the seed that was used to hash the input

Implements base_theta_sketch_alloc< Allocator >.

◆ get_theta64()

template<typename A>
uint64_t get_theta64 ( ) const
virtual
Returns
theta as a positive integer between 0 and LLONG_MAX

Implements base_theta_sketch_alloc< Allocator >.

◆ get_num_retained()

template<typename A>
uint32_t get_num_retained ( ) const
virtual
Returns
the number of retained entries in the sketch

Implements base_theta_sketch_alloc< Allocator >.

◆ get_lg_k()

template<typename A>
uint8_t get_lg_k ( ) const
Returns
configured nominal number of entries in the sketch

◆ get_rf()

template<typename A>
auto get_rf ( ) const
Returns
configured resize factor of the sketch

◆ update() [1/12]

template<typename A>
void update ( const std::string & value)

Update this sketch with a given string.

Parameters
valuestring to update the sketch with

◆ update() [2/12]

template<typename A>
void update ( uint64_t value)

Update this sketch with a given unsigned 64-bit integer.

Parameters
valueuint64_t to update the sketch with

◆ update() [3/12]

template<typename A>
void update ( int64_t value)

Update this sketch with a given signed 64-bit integer.

Parameters
valueint64_t to update the sketch with

◆ update() [4/12]

template<typename A>
void update ( uint32_t value)

Update this sketch with a given unsigned 32-bit integer.

For compatibility with Java implementation.

Parameters
valueuint32_t to update the sketch with

◆ update() [5/12]

template<typename A>
void update ( int32_t value)

Update this sketch with a given signed 32-bit integer.

For compatibility with Java implementation.

Parameters
valueint32_t to update the sketch with

◆ update() [6/12]

template<typename A>
void update ( uint16_t value)

Update this sketch with a given unsigned 16-bit integer.

For compatibility with Java implementation.

Parameters
valueuint16_t to update the sketch with

◆ update() [7/12]

template<typename A>
void update ( int16_t value)

Update this sketch with a given signed 16-bit integer.

For compatibility with Java implementation.

Parameters
valueint16_t to update the sketch with

◆ update() [8/12]

template<typename A>
void update ( uint8_t value)

Update this sketch with a given unsigned 8-bit integer.

For compatibility with Java implementation.

Parameters
valueuint8_t to update the sketch with

◆ update() [9/12]

template<typename A>
void update ( int8_t value)

Update this sketch with a given signed 8-bit integer.

For compatibility with Java implementation.

Parameters
valueint8_t to update the sketch with

◆ update() [10/12]

template<typename A>
void update ( double value)

Update this sketch with a given double-precision floating point value.

For compatibility with Java implementation.

Parameters
valuedouble to update the sketch with

◆ update() [11/12]

template<typename A>
void update ( float value)

Update this sketch with a given floating point value.

For compatibility with Java implementation.

Parameters
valuefloat to update the sketch with

◆ update() [12/12]

template<typename A>
void update ( const void * data,
size_t length )

Update this sketch with given data of any type.

This is a "universal" update that covers all cases above, but may produce different hashes. Be very careful to hash input values consistently using the same approach both over time and on different platforms and while passing sketches between C++ environment and Java environment. Otherwise two sketches that should represent overlapping sets will be disjoint For instance, for signed 32-bit values call update(int32_t) method above, which does widening conversion to int64_t, if compatibility with Java is expected

Parameters
datapointer to the data
lengthof the data in bytes

◆ compact()

template<typename A>
compact_theta_sketch_alloc< A > compact ( bool ordered = true,
bool trim = false ) const

Converts this sketch to a compact sketch (ordered or unordered, trimmed or not trimmed).

This does not modify the source update sketch.

Parameters
orderedoptional flag to specify if an ordered sketch should be produced
trimoptional flag to reduce the size of the returned sketch to at most the nominal size k, if required. An update sketch retains more than k entries between rebuilds; those extra entries below theta improve the estimate, so the default is to keep them. Trimming is lossy and is never required for correctness. It discards retained entries, and since the relative error scales with 1 / sqrt(retained), it always degrades accuracy and widens the confidence bounds, whatever mode the source is in. Worst case, a sketch grown to just under the rebuild threshold of 15/16 * 2k loses nearly half its entries, widening the bounds by about sqrt(15/8), or roughly 37%. A sketch in exact mode that retains more than k entries loses exactness as well: it is returned in estimation mode, so get_estimate() carries error where it would otherwise have returned an exact count. Only pass true if a bounded result size matters more than that accuracy.
Returns
compact sketch

◆ begin() [1/2]

template<typename A>
auto begin ( )
virtual

Iterator over hash values in this sketch.

Returns
begin iterator

Implements theta_sketch_alloc< Allocator >.

◆ end() [1/2]

template<typename A>
auto end ( )
virtual

Iterator pointing past the valid range.

Not to be incremented or dereferenced.

Returns
end iterator

Implements theta_sketch_alloc< Allocator >.

◆ begin() [2/2]

template<typename A>
auto begin ( ) const
virtual

Const iterator over hash values in this sketch.

Returns
begin iterator

Implements theta_sketch_alloc< Allocator >.

◆ end() [2/2]

template<typename A>
auto end ( ) const
virtual

Const iterator pointing past the valid range.

Not to be incremented or dereferenced.

Returns
end iterator

Implements theta_sketch_alloc< Allocator >.


The documentation for this class was generated from the following files: