libbloom.so

NAME
libbloom.so - a library providing routines used for bloom filters.

SYNOPSIS
#include <bloom.h>

int bloom_init(bloom *bloom,BIGNUM size,int hashes);

int bloom_test (bloom *bloom,char *str,int mode);

int bloom_add (bloom *bloom,char *str);

int bloom_check (bloom *bloom,char *str);

int bloom_suggestion(struct bloomstat *stats, BIGNUM n,double e);

DESCRIPTION
The function bloom_init initializes the bloom structure pointed to by bloom with a bit vector containing size elements. BIGNUM is a macro which by default resolves to the "long long" datatype. On systems not supporting this datatype, BIGNUM can be changed to "long" and the bloom library recompiled. At insertion, the candidate key will be hashed hashes times.

The function bloom_test tests for the existence of the key str in the bit vector, returning 1 if the key exists. if mode is set to RO, nothing else is done, but if set to SET, the key will be inserted into the vector.

The function bloom_add calls bloom_test in SET mode, returning 1 if the key is a duplicate and setting the key otherwisee.

The function bloom_check calls bloom_test in RO mode, returning 1 if the key is a duplicate.

The function bloom_suggestions takes a pointer to a bloomstat struct and sets the values of that struct appropriately for m (size) and k (hashes). Its input value n represents the expected number of elements to check for duplicates, while e represents the appropriate probability of error. Because in most cases we are more likely to know our data size and acceptable error rate than to know the ideal bloom internals, common practice is to call bloom_suggestions and then call bloom init with the resulting values.

RETURN VALUE
bloom_init returns 0 on success and nonzero on failure. test_all returns 1 if the key exists in the vector and 0 otherwise. get_suggestion returns 0 on success and nonzero on failure.