biomcmc-lib  0.1
low level library for phylogenetic analysis
hll.h
Go to the documentation of this file.
1 /*
2  * This file is part of biomcmc-lib, a low-level library for phylogenomic analysis.
3  * Copyright (C) 2019-today Leonardo de Oliveira Martins [ leomrtns at gmail.com; http://www.leomartins.org ]
4  *
5  * biomcmc is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6  * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11  * details (file "COPYING" or http://www.gnu.org/copyleft/gpl.html).
12  * The original hyperloglog functions are distributed under the ISC License (ISC) Copyright (c) 2016-2017, Ivan Vitjuk
13  * <virtus@eclipsedminds.org>. The ISC License follows:
14  Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
15  provided that the above copyright notice and this permission notice appear in all copies.
16 
17  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
18  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
19  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
20  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21  PERFORMANCE OF THIS SOFTWARE.
22  */
23 
29 #ifndef _biomcmc_hll_h_
30 #define _biomcmc_hll_h_
31 
32 #include "hashfunctions.h"
33 
34 
35 struct hll_s;
36 typedef struct hll_s hll_t;
37 
41  double alpha;
42  uint16_t n_buckets;
43  uint16_t n_empty_buckets;
44  uint64_t estimate;
45  uint64_t hll_estimate;
48 };
49 
53 
59 typedef uint64_t(*hll_hash_function_t)(const char *, size_t);
60 
69 hll_t *hll_create(size_t bucket_bits);
70 
75 void hll_reset(hll_t *hll);
76 
81 void hll_release(hll_t *hll);
82 
89 void hll_add(const hll_t *hll, const char *data, size_t data_len);
90 
99 int hll_merge(const hll_t *hll1, const hll_t *hll2);
100 
101 /* Change the hash function to be used by the estimator
102  *
103  * @param hll - HLL data type
104  * @param hash_function - A pointer to the hash function (@see hll_hash_function_t)
105  * @return 1 on success, 0 on failure. Fails on NULL arguments
106  */
107 int hll_set_hash_function(hll_t *hll, hll_hash_function_t hash_function);
108 
116 
117 #endif
118 
void hll_release(hll_t *hll)
Definition: hll.c:78
void hll_add(const hll_t *hll, const char *data, size_t data_len)
Definition: hll.c:83
Collections of hash functions for 32 and 64 bits, including one-liners, murmurhash, and xxhash.
hll_t * hll_create(size_t bucket_bits)
Definition: hll.c:32
void hll_reset(hll_t *hll)
Definition: hll.c:69
uint16_t n_empty_buckets
Definition: hll.h:43
Definition: hll.c:21
uint64_t hll_estimate
Definition: hll.h:45
int hll_merge(const hll_t *hll1, const hll_t *hll2)
Definition: hll.c:148
int hll_get_estimate(const hll_t *hll, hll_estimate_t *estimate)
Definition: hll.c:98
Definition: hll.h:40
uint64_t small_range_estimate
Definition: hll.h:46
uint64_t(* hll_hash_function_t)(const char *, size_t)
Definition: hll.h:59
uint64_t large_range_estimate
Definition: hll.h:47
uint64_t estimate
Definition: hll.h:44
uint16_t n_buckets
Definition: hll.h:42