1 #ifndef __CMPH_BMZ_H__
2 #define __CMPH_BMZ_H__
3
4 #include "cmph.h"
5
6 typedef struct __bmz_data_t bmz_data_t;
7 typedef struct __bmz_config_data_t bmz_config_data_t;
8
9 bmz_config_data_t *bmz_config_new(void);
10 void bmz_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs);
11 void bmz_config_destroy(cmph_config_t *mph);
12 cmph_t *bmz_new(cmph_config_t *mph, double c);
13
14 void bmz_load(FILE *f, cmph_t *mphf);
15 int bmz_dump(cmph_t *mphf, FILE *f);
16 void bmz_destroy(cmph_t *mphf);
17 cmph_uint32 bmz_search(cmph_t *mphf, const char *key, cmph_uint32 keylen);
18
19 /** \fn void bmz_pack(cmph_t *mphf, void *packed_mphf);
20 * \brief Support the ability to pack a perfect hash function into a preallocated contiguous memory space pointed by packed_mphf.
21 * \param mphf pointer to the resulting mphf
22 * \param packed_mphf pointer to the contiguous memory area used to store the resulting mphf. The size of packed_mphf must be at least cmph_packed_size()
23 */
24 void bmz_pack(cmph_t *mphf, void *packed_mphf);
25
26 /** \fn cmph_uint32 bmz_packed_size(cmph_t *mphf);
27 * \brief Return the amount of space needed to pack mphf.
28 * \param mphf pointer to a mphf
29 * \return the size of the packed function or zero for failures
30 */
31 cmph_uint32 bmz_packed_size(cmph_t *mphf);
32
33 /** cmph_uint32 bmz_search(void *packed_mphf, const char *key, cmph_uint32 keylen);
34 * \brief Use the packed mphf to do a search.
35 * \param packed_mphf pointer to the packed mphf
36 * \param key key to be hashed
37 * \param keylen key legth in bytes
38 * \return The mphf value
39 */
40 cmph_uint32 bmz_search_packed(void *packed_mphf, const char *key, cmph_uint32 keylen);
41
42 #endif