1 | //===----------------------------------------------------------------------===// |
2 | // DuckDB |
3 | // |
4 | // third_party/hyperloglog/hyperloglog.h |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #ifdef __cplusplus |
12 | extern "C" { |
13 | #endif |
14 | |
15 | #include <string.h> |
16 | |
17 | /* Error codes */ |
18 | #define C_OK 0 |
19 | #define C_ERR -1 |
20 | |
21 | typedef struct { |
22 | void *ptr; |
23 | } robj; |
24 | |
25 | //! Create a new empty HyperLogLog object |
26 | robj *hll_create(void); |
27 | //! Destroy the specified HyperLogLog object |
28 | void hll_destroy(robj *obj); |
29 | //! Add an element with the specified amount of bytes to the HyperLogLog. Returns C_ERR on failure, otherwise returns 0 if the cardinality did not change, and 1 otherwise. |
30 | int hll_add(robj *o, unsigned char *ele, size_t elesize); |
31 | //! Returns the estimated amount of unique elements seen by the HyperLogLog. Returns C_OK on success, or C_ERR on failure. |
32 | int hll_count(robj *o, size_t *result); |
33 | //! Merge hll_count HyperLogLog objects into a single one. Returns NULL on failure, or the new HLL object on success. |
34 | robj *hll_merge(robj **hlls, size_t hll_count); |
35 | |
36 | #ifdef __cplusplus |
37 | } |
38 | #endif |
39 | |