diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-02-18 18:39:07 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-02-18 18:39:07 +0000 |
commit | 20b70f7ade43a74b4790e503ec1dff33798f2cb0 (patch) | |
tree | e3795769d1297b4d7d98e661eed93c8f72dd0a14 /src/bloom.h | |
parent | 29962c678ab36050ffce1b2849d49eaa54aef921 (diff) | |
download | rspamd-20b70f7ade43a74b4790e503ec1dff33798f2cb0.tar.gz rspamd-20b70f7ade43a74b4790e503ec1dff33798f2cb0.zip |
Rework bloom hash library to use XXHash.
Diffstat (limited to 'src/bloom.h')
-rw-r--r-- | src/bloom.h | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/bloom.h b/src/bloom.h index eb3d538ba..380143c80 100644 --- a/src/bloom.h +++ b/src/bloom.h @@ -3,26 +3,19 @@ #include "config.h" -typedef guint (*hashfunc_t) (const gchar *); - -typedef struct bloom_filter_s { +typedef struct rspamd_bloom_filter_s { size_t asize; gchar *a; size_t nfuncs; - hashfunc_t *funcs; -} bloom_filter_t; + guint32 *seeds; +} rspamd_bloom_filter_t; -/* Hash functions */ -guint bloom_sax_hash (const gchar *key); -guint bloom_sdbm_hash (const gchar *key); -guint bloom_fnv_hash (const gchar *key); -guint bloom_rs_hash (const gchar *key); -guint bloom_js_hash (const gchar *key); -guint bloom_elf_hash (const gchar *key); -guint bloom_bkdr_hash (const gchar *key); -guint bloom_ap_hash (const gchar *key); -#define DEFAULT_BLOOM_HASHES 8, bloom_sax_hash, bloom_sdbm_hash, bloom_fnv_hash, bloom_rs_hash, bloom_js_hash, bloom_elf_hash, bloom_bkdr_hash, bloom_ap_hash +/* + * Some random uint32 seeds for hashing + */ +#define RSPAMD_DEFAULT_BLOOM_HASHES 8, 0x61782caaU, 0x79ab8141U, 0xe45ee2d1U, \ + 0xf97542d1U, 0x1e2623edU, 0xf5a23cfeU, 0xa41b2508U, 0x85abdce8U /* * Create new bloom filter @@ -30,26 +23,26 @@ guint bloom_ap_hash (const gchar *key); * @param nfuncs number of hash functions * @param ... hash functions list */ -bloom_filter_t* bloom_create (size_t size, size_t nfuncs, ...); +rspamd_bloom_filter_t* rspamd_bloom_create (size_t size, size_t nfuncs, ...); /* * Destroy bloom filter */ -void bloom_destroy (bloom_filter_t * bloom); +void rspamd_bloom_destroy (rspamd_bloom_filter_t * bloom); /* * Add a string to bloom filter */ -gboolean bloom_add (bloom_filter_t * bloom, const gchar *s); +gboolean rspamd_bloom_add (rspamd_bloom_filter_t * bloom, const gchar *s); /* * Delete a string from bloom filter */ -gboolean bloom_del (bloom_filter_t * bloom, const gchar *s); +gboolean rspamd_bloom_del (rspamd_bloom_filter_t * bloom, const gchar *s); /* * Check whether this string is in bloom filter (algorithm produces FALSE-POSITIVES, so result must be checked if it is positive) */ -gboolean bloom_check (bloom_filter_t * bloom, const gchar *s); +gboolean rspamd_bloom_check (rspamd_bloom_filter_t * bloom, const gchar *s); #endif |