compressed hash and displace method added
This commit is contained in:
85
src/cmph.c
85
src/cmph.c
@@ -7,6 +7,7 @@
|
||||
#include "fch.h" /* included -- Fabiano */
|
||||
#include "bdz.h" /* included -- Fabiano */
|
||||
#include "bdz_ph.h" /* included -- Fabiano */
|
||||
#include "chd_ph.h" /* included -- Fabiano */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@@ -14,8 +15,7 @@
|
||||
//#define DEBUG
|
||||
#include "debug.h"
|
||||
|
||||
const char *cmph_names[] = {"bmz", "bmz8", "chm", "brz", "fch", "bdz",
|
||||
"bdz_ph", NULL }; /* included -- Fabiano */
|
||||
const char *cmph_names[] = {"bmz", "bmz8", "chm", "brz", "fch", "bdz", "bdz_ph", "chd_ph", NULL }; /* included -- Fabiano */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -322,6 +322,9 @@ void cmph_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo)
|
||||
case CMPH_BDZ_PH:
|
||||
bdz_ph_config_destroy(mph);
|
||||
break;
|
||||
case CMPH_CHD_PH:
|
||||
chd_ph_config_destroy(mph);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -348,6 +351,9 @@ void cmph_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo)
|
||||
case CMPH_BDZ_PH:
|
||||
mph->data = bdz_ph_config_new();
|
||||
break;
|
||||
case CMPH_CHD_PH:
|
||||
mph->data = chd_ph_config_new();
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -382,6 +388,18 @@ void cmph_config_set_b(cmph_config_t *mph, cmph_uint32 b)
|
||||
{
|
||||
bdz_config_set_b(mph, b);
|
||||
}
|
||||
else if (mph->algo == CMPH_CHD_PH)
|
||||
{
|
||||
chd_ph_config_set_b(mph, b);
|
||||
}
|
||||
}
|
||||
|
||||
void cmph_config_set_keys_per_bin(cmph_config_t *mph, cmph_uint32 keys_per_bin)
|
||||
{
|
||||
if (mph->algo == CMPH_CHD_PH)
|
||||
{
|
||||
chd_ph_config_set_keys_per_bin(mph, keys_per_bin);
|
||||
}
|
||||
}
|
||||
|
||||
void cmph_config_set_memory_availability(cmph_config_t *mph, cmph_uint32 memory_availability)
|
||||
@@ -406,19 +424,22 @@ void cmph_config_destroy(cmph_config_t *mph)
|
||||
bmz_config_destroy(mph);
|
||||
break;
|
||||
case CMPH_BMZ8: /* included -- Fabiano */
|
||||
bmz8_config_destroy(mph);
|
||||
bmz8_config_destroy(mph);
|
||||
break;
|
||||
case CMPH_BRZ: /* included -- Fabiano */
|
||||
brz_config_destroy(mph);
|
||||
brz_config_destroy(mph);
|
||||
break;
|
||||
case CMPH_FCH: /* included -- Fabiano */
|
||||
fch_config_destroy(mph);
|
||||
fch_config_destroy(mph);
|
||||
break;
|
||||
case CMPH_BDZ: /* included -- Fabiano */
|
||||
bdz_config_destroy(mph);
|
||||
bdz_config_destroy(mph);
|
||||
break;
|
||||
case CMPH_BDZ_PH: /* included -- Fabiano */
|
||||
bdz_ph_config_destroy(mph);
|
||||
bdz_ph_config_destroy(mph);
|
||||
break;
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
chd_ph_config_destroy(mph);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
@@ -457,6 +478,9 @@ void cmph_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs)
|
||||
case CMPH_BDZ_PH: /* included -- Fabiano */
|
||||
bdz_ph_config_set_hashfuncs(mph, hashfuncs);
|
||||
break;
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
chd_ph_config_set_hashfuncs(mph, hashfuncs);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -506,6 +530,10 @@ cmph_t *cmph_new(cmph_config_t *mph)
|
||||
DEBUGP("Creating bdz_ph hash\n");
|
||||
mphf = bdz_ph_new(mph, c);
|
||||
break;
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
DEBUGP("Creating chd_ph hash\n");
|
||||
mphf = chd_ph_new(mph, c);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -519,17 +547,19 @@ int cmph_dump(cmph_t *mphf, FILE *f)
|
||||
case CMPH_CHM:
|
||||
return chm_dump(mphf, f);
|
||||
case CMPH_BMZ: /* included -- Fabiano */
|
||||
return bmz_dump(mphf, f);
|
||||
return bmz_dump(mphf, f);
|
||||
case CMPH_BMZ8: /* included -- Fabiano */
|
||||
return bmz8_dump(mphf, f);
|
||||
return bmz8_dump(mphf, f);
|
||||
case CMPH_BRZ: /* included -- Fabiano */
|
||||
return brz_dump(mphf, f);
|
||||
return brz_dump(mphf, f);
|
||||
case CMPH_FCH: /* included -- Fabiano */
|
||||
return fch_dump(mphf, f);
|
||||
return fch_dump(mphf, f);
|
||||
case CMPH_BDZ: /* included -- Fabiano */
|
||||
return bdz_dump(mphf, f);
|
||||
return bdz_dump(mphf, f);
|
||||
case CMPH_BDZ_PH: /* included -- Fabiano */
|
||||
return bdz_ph_dump(mphf, f);
|
||||
return bdz_ph_dump(mphf, f);
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
return chd_ph_dump(mphf, f);
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -573,6 +603,10 @@ cmph_t *cmph_load(FILE *f)
|
||||
DEBUGP("Loading bdz_ph algorithm dependent parts\n");
|
||||
bdz_ph_load(f, mphf);
|
||||
break;
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
DEBUGP("Loading chd_ph algorithm dependent parts\n");
|
||||
chd_ph_load(f, mphf);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -606,6 +640,9 @@ cmph_uint32 cmph_search(cmph_t *mphf, const char *key, cmph_uint32 keylen)
|
||||
case CMPH_BDZ_PH: /* included -- Fabiano */
|
||||
DEBUGP("bdz_ph algorithm search\n");
|
||||
return bdz_ph_search(mphf, key, keylen);
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
DEBUGP("chd_ph algorithm search\n");
|
||||
return chd_ph_search(mphf, key, keylen);
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -626,22 +663,25 @@ void cmph_destroy(cmph_t *mphf)
|
||||
chm_destroy(mphf);
|
||||
return;
|
||||
case CMPH_BMZ: /* included -- Fabiano */
|
||||
bmz_destroy(mphf);
|
||||
bmz_destroy(mphf);
|
||||
return;
|
||||
case CMPH_BMZ8: /* included -- Fabiano */
|
||||
bmz8_destroy(mphf);
|
||||
bmz8_destroy(mphf);
|
||||
return;
|
||||
case CMPH_BRZ: /* included -- Fabiano */
|
||||
brz_destroy(mphf);
|
||||
brz_destroy(mphf);
|
||||
return;
|
||||
case CMPH_FCH: /* included -- Fabiano */
|
||||
fch_destroy(mphf);
|
||||
fch_destroy(mphf);
|
||||
return;
|
||||
case CMPH_BDZ: /* included -- Fabiano */
|
||||
bdz_destroy(mphf);
|
||||
bdz_destroy(mphf);
|
||||
return;
|
||||
case CMPH_BDZ_PH: /* included -- Fabiano */
|
||||
bdz_ph_destroy(mphf);
|
||||
bdz_ph_destroy(mphf);
|
||||
return;
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
chd_ph_destroy(mphf);
|
||||
return;
|
||||
default:
|
||||
assert(0);
|
||||
@@ -685,6 +725,9 @@ void cmph_pack(cmph_t *mphf, void *packed_mphf)
|
||||
case CMPH_BDZ_PH: /* included -- Fabiano */
|
||||
bdz_ph_pack(mphf, ptr);
|
||||
break;
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
chd_ph_pack(mphf, ptr);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -714,6 +757,8 @@ cmph_uint32 cmph_packed_size(cmph_t *mphf)
|
||||
return bdz_packed_size(mphf);
|
||||
case CMPH_BDZ_PH: /* included -- Fabiano */
|
||||
return bdz_ph_packed_size(mphf);
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
return chd_ph_packed_size(mphf);
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -747,6 +792,8 @@ cmph_uint32 cmph_search_packed(void *packed_mphf, const char *key, cmph_uint32 k
|
||||
return bdz_search_packed(++ptr, key, keylen);
|
||||
case CMPH_BDZ_PH: /* included -- Fabiano */
|
||||
return bdz_ph_search_packed(++ptr, key, keylen);
|
||||
case CMPH_CHD_PH: /* included -- Fabiano */
|
||||
return chd_ph_search_packed(++ptr, key, keylen);
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user