This counting bloom filter implementation is based on the dablooms of github.
This counting bloom filter can add, delete, and check elements.
-
source code files are
murmur.h,murmur.c,dablooms.h,dablooms.c,test_dablooms.c, andMakefile; -
murmur.h,murmur.c,dablooms.h,dablooms.c, andtest_dablooms.care in a subdirectory namedsrc,Makefileis in the same directory withsrc; -
murmur.handmurmur.care lib for hashing; -
dablooms.handdablooms.care for counting bloom filter; -
test_dablooms.cis for testing, you may program your own test file; -
Makefileis for make, install, clean, or test this filter.
-
put the source code file in a subdirectory named
src; -
the Makefile should be in the same dir with
src, not insidedir; -
get root permission;
-
to test,
make testto make,
maketo clean.
make clean- about the capacity and error rate of this counting bloom filter
the capacity (or the maximum number of elements) is set in
dablooms.hwith macroCAPACITY, the error rate is set indablooms.hwith macroERROR_RATE.
- create the counting bloom filter
the counting bloom filter is created automatically according to arguments
CAPACITYandERROR_RATE.
- the function for adding elements
int counting_bloom_add(counting_bloom_t *bloom, const char *s, size_t len).
bloomis a pointer to the filter which elements are added to;
sis a pointer to the content string of the added element;
lenis the length of s.
- the function for remove elements
int counting_bloom_remove(counting_bloom_t *bloom, const char *s, size_t len)
bloomis a pointer to the filter which elements are to be removed;
sis a pointer to the content string of the removed element;
lenis the length of s.
- the function for checking elements
int counting_bloom_check(counting_bloom_t *bloom, const char *s, size_t len)
bloomis a pointer to the filter which elements are to be removed;
sis a pointer to the content string of the removed element;
lenis the length of s.
- the function for showing statistics
int print_results(bloom_stats *stats)
statsis the pointer to the filter.