biomcmc-lib  0.1
low level library for phylogenetic analysis
Data Structures | Typedefs | Functions
hll.h File Reference

HyperLogLog functions, based on code by Ivan Vitjuk https://github.com/ivitjuk/libhll under an ISC License. More...

#include "hashfunctions.h"
Include dependency graph for hll.h:

Go to the source code of this file.

Data Structures

struct  hll_estimate_s
 

Typedefs

typedef struct hll_s hll_t
 
typedef struct hll_estimate_s hll_estimate_t
 
typedef uint64_t(* hll_hash_function_t) (const char *, size_t)
 

Functions

hll_thll_create (size_t bucket_bits)
 
void hll_reset (hll_t *hll)
 
void hll_release (hll_t *hll)
 
void hll_add (const hll_t *hll, const char *data, size_t data_len)
 
int hll_merge (const hll_t *hll1, const hll_t *hll2)
 
int hll_set_hash_function (hll_t *hll, hll_hash_function_t hash_function)
 
int hll_get_estimate (const hll_t *hll, hll_estimate_t *estimate)
 

Detailed Description

HyperLogLog functions, based on code by Ivan Vitjuk https://github.com/ivitjuk/libhll under an ISC License.

Typedef Documentation

◆ hll_estimate_t

Estimation result type

◆ hll_hash_function_t

typedef uint64_t(* hll_hash_function_t) (const char *, size_t)

Hash function type

Even though hash funtion is expected to return a 64bit value, only 32 bits of entropy will be used.

Function Documentation

◆ hll_create()

hll_t* hll_create ( size_t  bucket_bits)

Create HLL data structure

Parameters
bucket_bits- Number of bits to use for the buckets. Actual number of buckets will be 2^bucket_bits. Must be 4 <= bucket_bits <= 16.
Returns
HLL data type or 0 on error. Error can be memory allocation failure or invalid bucket_bits value.

◆ hll_reset()

void hll_reset ( hll_t hll)

Reset state of the estimator

Parameters
hll- HLL data type

◆ hll_release()

void hll_release ( hll_t hll)

Release HLL type previously allocated with hll_create().

Parameters
hll- HLL data type

◆ hll_add()

void hll_add ( const hll_t hll,
const char *  data,
size_t  data_len 
)

Add a sample to the HLL estimator

Parameters
hll- HLL data type
data- Sample to be added to the estimator (underlying data type is not important)
data_len- Lenght of the data sample in bytes

◆ hll_merge()

int hll_merge ( const hll_t hll1,
const hll_t hll2 
)

Merge data from two HLLs

Data from hll2 will be merged into hll2

Parameters
hll1- First HLL data type
hll2- Second HLL data type
Returns
1 on success, 0 on failure. Fails when number of buckets are not compatible.

◆ hll_get_estimate()

int hll_get_estimate ( const hll_t hll,
hll_estimate_t estimate 
)

Get the estimated cardinality based on the data added to the estimator

Parameters
hll- HLL data type
estimate- Result of the estimation
Returns
1 on success, 0 on failure. Fails only on NULL input parameters.