HIBF 1.0.0-rc.1
All Classes Namespaces Files Functions Variables Typedefs Friends Macros Modules Pages Concepts
seqan::hibf::sketch::hyperloglog Class Reference

HyperLogLog estimates. More...

#include <hibf/sketch/hyperloglog.hpp>

Public Member Functions

void add (uint64_t const value)
 Adds a value.
 
uint64_t data_size () const
 Returns size of the internal data.
 
double estimate () const
 Estimates cardinality value.
 
void load (std::istream &is)
 Loads the hyperloglog from a stream.
 
void merge (hyperloglog const &other)
 Merges another hyperloglog into this object.
 
double merge_and_estimate (hyperloglog const &other)
 Merges another hyperloglog and returns the new estimate.
 
void reset ()
 Clears added values. The size is unaffected.
 
void store (std::ostream &os) const
 Write the hyperloglog to a stream.
 
Constructors, destructor and assignment
 hyperloglog (uint8_t const num_bits=5u)
 Default constructor.
 
 hyperloglog (hyperloglog const &)=default
 Defaulted.
 
hyperloglogoperator= (hyperloglog const &)=default
 Defaulted.
 
 hyperloglog (hyperloglog &&)=default
 Defaulted.
 
hyperloglogoperator= (hyperloglog &&)=default
 Defaulted.
 
 ~hyperloglog ()=default
 Defaulted.
 

Friends

class cereal::access
 

Detailed Description

HyperLogLog estimates.

Original work by Hideaki Ohno. Major changes have been applied for bugfixes, 64-bit support, improvements, etc.

See also
https://github.com/hideo55/cpp-HyperLogLog

Constructor & Destructor Documentation

◆ hyperloglog()

seqan::hibf::sketch::hyperloglog::hyperloglog ( uint8_t const num_bits = 5u)

Default constructor.

Parameters
[in]num_bitsThe bit width in [5,32].

Allocates 2^num_bits bytes of memory.

Exceptions
std::invalid_argumentif num_bits is not in [5,32].

Member Function Documentation

◆ add()

void seqan::hibf::sketch::hyperloglog::add ( uint64_t const value)

Adds a value.

Parameters
[in]valueThe value to add.

◆ estimate()

double seqan::hibf::sketch::hyperloglog::estimate ( ) const

Estimates cardinality value.

Returns
Estimated cardinality value.

◆ merge()

void seqan::hibf::sketch::hyperloglog::merge ( hyperloglog const & other)

Merges another hyperloglog into this object.

Parameters
[in]otherThe hyperloglog to be merged.

This has the same effect as adding all values that were added to other.

Warning
Merging a hyperloglog with differing bits is undefined behaviour. In debug mode, this is an assertion instead.

◆ merge_and_estimate()

double seqan::hibf::sketch::hyperloglog::merge_and_estimate ( hyperloglog const & other)

Merges another hyperloglog and returns the new estimate.

Parameters
[in]otherThe hyperloglog to be merged.
Returns
Estimated cardinality value.
Warning
Merging a hyperloglog with differing bits is undefined behaviour. In debug mode, this is an assertion instead.

◆ data_size()

uint64_t seqan::hibf::sketch::hyperloglog::data_size ( ) const
inline

Returns size of the internal data.

Returns
Size in bytes. The returned value is equivalent to 2^bits.

◆ store()

void seqan::hibf::sketch::hyperloglog::store ( std::ostream & os) const

Write the hyperloglog to a stream.

Parameters
[in,out]osThe output stream to write to.
Exceptions
std::runtime_errorif storing failed.

◆ load()

void seqan::hibf::sketch::hyperloglog::load ( std::istream & is)

Loads the hyperloglog from a stream.

Parameters
[in]isThe input stream where to read from.
Exceptions
std::runtime_errorif reading failed.

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