datasketches-cpp
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
compact_tuple_sketch< Summary, Allocator > Class Template Reference

Compact Tuple sketch. More...

#include <tuple_sketch.hpp>

Inheritance diagram for compact_tuple_sketch< Summary, Allocator >:
tuple_sketch< Summary, std::allocator< Summary > >

Public Member Functions

 compact_tuple_sketch (const Base &other, bool ordered)
 Copy constructor. More...
 
 compact_tuple_sketch (const compact_tuple_sketch &other)=default
 Copy constructor. More...
 
 compact_tuple_sketch (compact_tuple_sketch &&) noexcept
 Move constructor. More...
 
compact_tuple_sketchoperator= (const compact_tuple_sketch &other)=default
 Copy assignment. More...
 
compact_tuple_sketchoperator= (compact_tuple_sketch &&other)=default
 Move assignment. More...
 
 compact_tuple_sketch (const theta_sketch_alloc< AllocU64 > &other, const Summary &summary, bool ordered=true)
 Constructor from Theta sketch. 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
 
template<typename Predicate >
compact_tuple_sketch filter (const Predicate &predicate) const
 Produces a Compact Tuple sketch from this sketch by applying a given predicate to each entry. More...
 
template<typename SerDe = serde<Summary>>
void serialize (std::ostream &os, const SerDe &sd=SerDe()) const
 This method serializes the sketch into a given stream in a binary form. More...
 
template<typename SerDe = serde<Summary>>
vector_bytes serialize (unsigned header_size_bytes=0, const SerDe &sd=SerDe()) const
 This method serializes the sketch as a vector of bytes. More...
 
virtual iterator begin ()
 Iterator over entries in this sketch. More...
 
virtual iterator end ()
 Iterator pointing past the valid range. More...
 
virtual const_iterator begin () const
 Const iterator over entries in this sketch. More...
 
virtual const_iterator end () const
 Const iterator pointing past the valid range. More...
 
- Public Member Functions inherited from tuple_sketch< Summary, std::allocator< Summary > >
double get_estimate () const
 
double get_lower_bound (uint8_t num_std_devs, uint32_t num_subset_entries) const
 Returns the approximate lower error bound given a number of standard deviations over an arbitrary number of items stored in the sketch. More...
 
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, uint32_t num_subset_entries) const
 Returns the approximate upper error bound given a number of standard deviations over an arbitrary number of items stored in the sketch. 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
 
string< std::allocator< Summary > > to_string (bool print_items=false) const
 Provides a human-readable summary of this sketch as a string. More...
 

Static Public Member Functions

template<typename Sketch , typename Predicate >
static compact_tuple_sketch filter (const Sketch &sketch, const Predicate &predicate)
 Produces a Compact Tuple sketch from a given sketch (Update or Compact) by applying a given predicate to each entry. More...
 
template<typename SerDe = serde<Summary>>
static compact_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. More...
 
template<typename SerDe = serde<Summary>>
static compact_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. More...
 

Protected Member Functions

template<typename SerDe , typename SS = Summary, typename std::enable_if< std::is_arithmetic< SS >::value, int >::type = 0>
size_t get_serialized_size_summaries_bytes (const SerDe &sd) const
 Computes size needed to serialize summaries in the sketch. More...
 
template<typename SerDe , typename SS = Summary, typename std::enable_if<!std::is_arithmetic< SS >::value, int >::type = 0>
size_t get_serialized_size_summaries_bytes (const SerDe &sd) const
 Computes size needed to serialize summaries in the sketch. More...
 

Detailed Description

template<typename Summary, typename Allocator = std::allocator<Summary>>
class datasketches::compact_tuple_sketch< Summary, Allocator >

Compact Tuple sketch.

This is an immutable form of the Tuple sketch, the form that can be serialized and deserialized.

Constructor & Destructor Documentation

◆ compact_tuple_sketch() [1/4]

compact_tuple_sketch ( const Base other,
bool  ordered 
)

Copy constructor.

Constructs a compact sketch from another sketch (either update or compact)

Parameters
othersketch to be copied
orderedif true make the resulting sketch ordered

◆ compact_tuple_sketch() [2/4]

compact_tuple_sketch ( const compact_tuple_sketch< Summary, Allocator > &  other)
default

Copy constructor.

Parameters
othersketch to be copied

◆ compact_tuple_sketch() [3/4]

compact_tuple_sketch ( compact_tuple_sketch< Summary, Allocator > &&  other)
noexcept

Move constructor.

Parameters
othersketch to be moved

◆ compact_tuple_sketch() [4/4]

compact_tuple_sketch ( const theta_sketch_alloc< AllocU64 > &  other,
const Summary &  summary,
bool  ordered = true 
)

Constructor from Theta sketch.

Parameters
otherTheta sketch to be constructed from
summarySummary instance to be associated with each entry
orderedif true make the resulting sketch ordered

Member Function Documentation

◆ operator=() [1/2]

compact_tuple_sketch& operator= ( const compact_tuple_sketch< Summary, Allocator > &  other)
default

Copy assignment.

Parameters
othersketch to be copied
Returns
reference to this sketch

◆ operator=() [2/2]

compact_tuple_sketch& operator= ( compact_tuple_sketch< Summary, Allocator > &&  other)
default

Move assignment.

Parameters
othersketch to be moved
Returns
reference to this sketch

◆ get_allocator()

A get_allocator
virtual

◆ is_empty()

bool is_empty
virtual
Returns
true if this sketch represents an empty set (not the same as no retained entries!)

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ is_ordered()

bool is_ordered
virtual
Returns
true if retained entries are ordered

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ get_theta64()

uint64_t get_theta64
virtual
Returns
theta as a positive integer between 0 and LLONG_MAX

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ get_num_retained()

uint32_t get_num_retained
virtual
Returns
the number of retained entries in the sketch

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ get_seed_hash()

uint16_t get_seed_hash
virtual
Returns
hash of the seed that was used to hash the input

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ filter() [1/2]

compact_tuple_sketch filter ( const Predicate &  predicate) const

Produces a Compact Tuple sketch from this sketch by applying a given predicate to each entry.

Parameters
predicateshould return true for the entries to keep
Returns
compact sketch with the entries retained according to the predicate

◆ filter() [2/2]

static compact_tuple_sketch filter ( const Sketch &  sketch,
const Predicate &  predicate 
)
static

Produces a Compact Tuple sketch from a given sketch (Update or Compact) by applying a given predicate to each entry.

Parameters
sketchinput sketch
predicateshould return true for the entries to keep
Returns
compact sketch with the entries retained according to the predicate

◆ serialize() [1/2]

void serialize ( std::ostream &  os,
const SerDe &  sd = SerDe() 
) const

This method serializes the sketch into a given stream in a binary form.

Parameters
osoutput stream
sdinstance of a SerDe

◆ serialize() [2/2]

vector_bytes serialize ( unsigned  header_size_bytes = 0,
const SerDe &  sd = SerDe() 
) const

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.

Parameters
header_size_bytesspace to reserve in front of the sketch
sdinstance of a SerDe
Returns
serialized sketch as a vector of bytes

◆ begin() [1/2]

auto begin
virtual

Iterator over entries in this sketch.

Returns
begin iterator

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ end() [1/2]

auto end
virtual

Iterator pointing past the valid range.

Not to be incremented or dereferenced.

Returns
end iterator

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ begin() [2/2]

auto begin
virtual

Const iterator over entries in this sketch.

Returns
begin const iterator

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ end() [2/2]

auto end
virtual

Const iterator pointing past the valid range.

Not to be incremented or dereferenced.

Returns
end const iterator

Implements tuple_sketch< Summary, std::allocator< Summary > >.

◆ deserialize() [1/2]

static compact_tuple_sketch deserialize ( std::istream &  is,
uint64_t  seed = DEFAULT_SEED,
const SerDe &  sd = SerDe(),
const Allocator &  allocator = Allocator() 
)
static

This method deserializes a sketch from a given stream.

Parameters
isinput stream
seedthe seed for the hash function that was used to create the sketch
sdinstance of a SerDe
allocatorinstance of an Allocator
Returns
an instance of a sketch

◆ deserialize() [2/2]

static compact_tuple_sketch deserialize ( const void *  bytes,
size_t  size,
uint64_t  seed = DEFAULT_SEED,
const SerDe &  sd = SerDe(),
const Allocator &  allocator = Allocator() 
)
static

This method deserializes a sketch from a given array of bytes.

Parameters
bytespointer to the array of bytes
sizethe size of the array
seedthe seed for the hash function that was used to create the sketch
sdinstance of a SerDe
allocatorinstance of an Allocator
Returns
an instance of the sketch

◆ get_serialized_size_summaries_bytes() [1/2]

size_t get_serialized_size_summaries_bytes ( const SerDe &  sd) const
protected

Computes size needed to serialize summaries in the sketch.

This version is for fixed-size arithmetic types (integral and floating point).

Returns
size in bytes needed to serialize summaries in this sketch

◆ get_serialized_size_summaries_bytes() [2/2]

size_t get_serialized_size_summaries_bytes ( const SerDe &  sd) const
protected

Computes size needed to serialize summaries in the sketch.

This version is for all other types and can be expensive since every item needs to be looked at.

Returns
size in bytes needed to serialize summaries in this sketch

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