HyperLogLog functions, based on code by Ivan Vitjuk https://github.com/ivitjuk/libhll under an ISC License.
More...
Go to the source code of this file.
HyperLogLog functions, based on code by Ivan Vitjuk https://github.com/ivitjuk/libhll under an ISC License.
◆ hll_estimate_t
◆ 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.
◆ 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_release()
void hll_release |
( |
hll_t * |
hll | ) |
|
Release HLL type previously allocated with hll_create().
- Parameters
-
◆ 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()
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.