From 690dc3ee82a4a171fcfc3c62de3e7ec2efa35cd9 Mon Sep 17 00:00:00 2001 From: fc_botelho Date: Mon, 7 Aug 2006 16:37:49 +0000 Subject: [PATCH] BRZ is working with FCH or BMZ8. BMZ8 is faster but the MPHFs for each bucket are larger --- src/brz.c | 11 ++++++++++- src/brz.h | 1 + src/cmph.c | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/brz.c b/src/brz.c index 83df9e1..1ccec1e 100755 --- a/src/brz.c +++ b/src/brz.c @@ -28,7 +28,7 @@ brz_config_data_t *brz_config_new() { brz_config_data_t *brz = NULL; brz = (brz_config_data_t *)malloc(sizeof(brz_config_data_t)); - brz->algo = CMPH_BMZ8; + brz->algo = CMPH_FCH; brz->b = 128; brz->hashfuncs[0] = CMPH_HASH_JENKINS; brz->hashfuncs[1] = CMPH_HASH_JENKINS; @@ -108,6 +108,15 @@ void brz_config_set_b(cmph_config_t *mph, cmph_uint8 b) brz->b = b; } +void brz_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo) +{ + if (algo == CMPH_BMZ8 || algo == CMPH_FCH) // supported algorithms + { + brz_config_data_t *brz = (brz_config_data_t *)mph->data; + brz->algo = algo; + } +} + cmph_t *brz_new(cmph_config_t *mph, float c) { cmph_t *mphf = NULL; diff --git a/src/brz.h b/src/brz.h index 88b9487..1f128dd 100644 --- a/src/brz.h +++ b/src/brz.h @@ -11,6 +11,7 @@ void brz_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs); void brz_config_set_tmp_dir(cmph_config_t *mph, cmph_uint8 *tmp_dir); void brz_config_set_mphf_fd(cmph_config_t *mph, FILE *mphf_fd); void brz_config_set_b(cmph_config_t *mph, cmph_uint8 b); +void brz_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo); void brz_config_set_memory_availability(cmph_config_t *mph, cmph_uint32 memory_availability); void brz_config_destroy(cmph_config_t *mph); cmph_t *brz_new(cmph_config_t *mph, float c); diff --git a/src/cmph.c b/src/cmph.c index 1d7badd..6d753d4 100644 --- a/src/cmph.c +++ b/src/cmph.c @@ -366,6 +366,8 @@ cmph_t *cmph_new(cmph_config_t *mph) break; case CMPH_BRZ: /* included -- Fabiano */ DEBUGP("Creating brz hash\n"); + if (c >= 2.0) brz_config_set_algo(mph, CMPH_FCH); + else brz_config_set_algo(mph, CMPH_BMZ8); mphf = brz_new(mph, c); break; case CMPH_FCH: /* included -- Fabiano */