FCH algorithm added but not tested...
This commit is contained in:
parent
9352564651
commit
3825c0a511
@ -367,7 +367,7 @@ static void bmz_traverse(bmz_config_data_t *bmz, cmph_uint8 * used_edges, cmph_u
|
|||||||
while((neighbor = graph_next_neighbor(bmz->graph, &it)) != GRAPH_NO_NEIGHBOR)
|
while((neighbor = graph_next_neighbor(bmz->graph, &it)) != GRAPH_NO_NEIGHBOR)
|
||||||
{
|
{
|
||||||
if(GETBIT(visited,neighbor)) continue;
|
if(GETBIT(visited,neighbor)) continue;
|
||||||
DEBUGP("Visiting neighbor %u\n", neighbor);
|
//DEBUGP("Visiting neighbor %u\n", neighbor);
|
||||||
*unused_edge_index = next_unused_edge(bmz, used_edges, *unused_edge_index);
|
*unused_edge_index = next_unused_edge(bmz, used_edges, *unused_edge_index);
|
||||||
bmz->g[neighbor] = *unused_edge_index - bmz->g[v];
|
bmz->g[neighbor] = *unused_edge_index - bmz->g[v];
|
||||||
//if (bmz->g[neighbor] >= bmz->m) bmz->g[neighbor] += bmz->m;
|
//if (bmz->g[neighbor] >= bmz->m) bmz->g[neighbor] += bmz->m;
|
||||||
@ -430,7 +430,7 @@ static int bmz_gen_edges(cmph_config_t *mph)
|
|||||||
mph->key_source->dispose(mph->key_source->data, key, keylen);
|
mph->key_source->dispose(mph->key_source->data, key, keylen);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DEBUGP("Adding edge: %u -> %u for key %s\n", h1, h2, key);
|
//DEBUGP("Adding edge: %u -> %u for key %s\n", h1, h2, key);
|
||||||
mph->key_source->dispose(mph->key_source->data, key, keylen);
|
mph->key_source->dispose(mph->key_source->data, key, keylen);
|
||||||
// fprintf(stderr, "key = %s -- dispose BMZ\n", key);
|
// fprintf(stderr, "key = %s -- dispose BMZ\n", key);
|
||||||
multiple_edges = graph_contains_edge(bmz->graph, h1, h2);
|
multiple_edges = graph_contains_edge(bmz->graph, h1, h2);
|
||||||
|
89
src/cmph.c
89
src/cmph.c
@ -4,6 +4,7 @@
|
|||||||
#include "bmz.h"
|
#include "bmz.h"
|
||||||
#include "bmz8.h" /* included -- Fabiano */
|
#include "bmz8.h" /* included -- Fabiano */
|
||||||
#include "brz.h" /* included -- Fabiano */
|
#include "brz.h" /* included -- Fabiano */
|
||||||
|
#include "fch.h" /* included -- Fabiano */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -11,7 +12,7 @@
|
|||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
const char *cmph_names[] = { "bmz", "bmz8", "chm", "brz", NULL }; /* included -- Fabiano */
|
const char *cmph_names[] = { "bmz", "bmz8", "chm", "brz", "fch", NULL }; /* included -- Fabiano */
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -219,6 +220,9 @@ void cmph_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo)
|
|||||||
case CMPH_BRZ:
|
case CMPH_BRZ:
|
||||||
brz_config_destroy(mph);
|
brz_config_destroy(mph);
|
||||||
break;
|
break;
|
||||||
|
case CMPH_FCH:
|
||||||
|
fch_config_destroy(mph);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -236,6 +240,9 @@ void cmph_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo)
|
|||||||
case CMPH_BRZ:
|
case CMPH_BRZ:
|
||||||
mph->data = brz_config_new();
|
mph->data = brz_config_new();
|
||||||
break;
|
break;
|
||||||
|
case CMPH_FCH:
|
||||||
|
mph->data = fch_config_new();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -245,76 +252,35 @@ void cmph_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo)
|
|||||||
|
|
||||||
void cmph_config_set_tmp_dir(cmph_config_t *mph, cmph_uint8 *tmp_dir)
|
void cmph_config_set_tmp_dir(cmph_config_t *mph, cmph_uint8 *tmp_dir)
|
||||||
{
|
{
|
||||||
switch (mph->algo)
|
if (mph->algo == CMPH_BRZ)
|
||||||
{
|
{
|
||||||
case CMPH_CHM:
|
brz_config_set_tmp_dir(mph, tmp_dir);
|
||||||
break;
|
|
||||||
case CMPH_BMZ: /* included -- Fabiano */
|
|
||||||
break;
|
|
||||||
case CMPH_BMZ8: /* included -- Fabiano */
|
|
||||||
break;
|
|
||||||
case CMPH_BRZ: /* included -- Fabiano */
|
|
||||||
brz_config_set_tmp_dir(mph, tmp_dir);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmph_config_set_mphf_fd(cmph_config_t *mph, FILE *mphf_fd)
|
void cmph_config_set_mphf_fd(cmph_config_t *mph, FILE *mphf_fd)
|
||||||
{
|
{
|
||||||
switch (mph->algo)
|
if (mph->algo == CMPH_BRZ)
|
||||||
{
|
{
|
||||||
case CMPH_CHM:
|
brz_config_set_mphf_fd(mph, mphf_fd);
|
||||||
break;
|
|
||||||
case CMPH_BMZ: /* included -- Fabiano */
|
|
||||||
break;
|
|
||||||
case CMPH_BMZ8: /* included -- Fabiano */
|
|
||||||
break;
|
|
||||||
case CMPH_BRZ: /* included -- Fabiano */
|
|
||||||
brz_config_set_mphf_fd(mph, mphf_fd);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmph_config_set_b(cmph_config_t *mph, cmph_uint8 b)
|
void cmph_config_set_b(cmph_config_t *mph, cmph_uint8 b)
|
||||||
{
|
{
|
||||||
switch (mph->algo)
|
if (mph->algo == CMPH_BRZ)
|
||||||
{
|
{
|
||||||
case CMPH_CHM:
|
brz_config_set_b(mph, b);
|
||||||
break;
|
|
||||||
case CMPH_BMZ: /* included -- Fabiano */
|
|
||||||
break;
|
|
||||||
case CMPH_BMZ8: /* included -- Fabiano */
|
|
||||||
break;
|
|
||||||
case CMPH_BRZ: /* included -- Fabiano */
|
|
||||||
brz_config_set_b(mph, b);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmph_config_set_memory_availability(cmph_config_t *mph, cmph_uint32 memory_availability)
|
void cmph_config_set_memory_availability(cmph_config_t *mph, cmph_uint32 memory_availability)
|
||||||
{
|
{
|
||||||
switch (mph->algo)
|
if (mph->algo == CMPH_BRZ)
|
||||||
{
|
{
|
||||||
case CMPH_CHM:
|
brz_config_set_memory_availability(mph, memory_availability);
|
||||||
break;
|
|
||||||
case CMPH_BMZ: /* included -- Fabiano */
|
|
||||||
break;
|
|
||||||
case CMPH_BMZ8: /* included -- Fabiano */
|
|
||||||
break;
|
|
||||||
case CMPH_BRZ: /* included -- Fabiano */
|
|
||||||
brz_config_set_memory_availability(mph, memory_availability);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmph_config_destroy(cmph_config_t *mph)
|
void cmph_config_destroy(cmph_config_t *mph)
|
||||||
@ -334,6 +300,9 @@ void cmph_config_destroy(cmph_config_t *mph)
|
|||||||
case CMPH_BRZ: /* included -- Fabiano */
|
case CMPH_BRZ: /* included -- Fabiano */
|
||||||
brz_config_destroy(mph);
|
brz_config_destroy(mph);
|
||||||
break;
|
break;
|
||||||
|
case CMPH_FCH: /* included -- Fabiano */
|
||||||
|
fch_config_destroy(mph);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -361,6 +330,9 @@ void cmph_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs)
|
|||||||
case CMPH_BRZ: /* included -- Fabiano */
|
case CMPH_BRZ: /* included -- Fabiano */
|
||||||
brz_config_set_hashfuncs(mph, hashfuncs);
|
brz_config_set_hashfuncs(mph, hashfuncs);
|
||||||
break;
|
break;
|
||||||
|
case CMPH_FCH: /* included -- Fabiano */
|
||||||
|
fch_config_set_hashfuncs(mph, hashfuncs);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -400,6 +372,11 @@ cmph_t *cmph_new(cmph_config_t *mph)
|
|||||||
if (c == 0) c = 1.15;
|
if (c == 0) c = 1.15;
|
||||||
mphf = brz_new(mph, c);
|
mphf = brz_new(mph, c);
|
||||||
break;
|
break;
|
||||||
|
case CMPH_FCH: /* included -- Fabiano */
|
||||||
|
DEBUGP("Creating fch hash\n");
|
||||||
|
if (c <= 2) c = 2.1;
|
||||||
|
mphf = fch_new(mph, c);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -418,6 +395,8 @@ int cmph_dump(cmph_t *mphf, FILE *f)
|
|||||||
return bmz8_dump(mphf, f);
|
return bmz8_dump(mphf, f);
|
||||||
case CMPH_BRZ: /* included -- Fabiano */
|
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);
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -449,6 +428,10 @@ cmph_t *cmph_load(FILE *f)
|
|||||||
DEBUGP("Loading brz algorithm dependent parts\n");
|
DEBUGP("Loading brz algorithm dependent parts\n");
|
||||||
brz_load(f, mphf);
|
brz_load(f, mphf);
|
||||||
break;
|
break;
|
||||||
|
case CMPH_FCH: /* included -- Fabiano */
|
||||||
|
DEBUGP("Loading fch algorithm dependent parts\n");
|
||||||
|
fch_load(f, mphf);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -473,6 +456,9 @@ cmph_uint32 cmph_search(cmph_t *mphf, const char *key, cmph_uint32 keylen)
|
|||||||
case CMPH_BRZ: /* included -- Fabiano */
|
case CMPH_BRZ: /* included -- Fabiano */
|
||||||
DEBUGP("brz algorithm search\n");
|
DEBUGP("brz algorithm search\n");
|
||||||
return brz_search(mphf, key, keylen);
|
return brz_search(mphf, key, keylen);
|
||||||
|
case CMPH_FCH: /* included -- Fabiano */
|
||||||
|
DEBUGP("fch algorithm search\n");
|
||||||
|
return fch_search(mphf, key, keylen);
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -501,6 +487,9 @@ void cmph_destroy(cmph_t *mphf)
|
|||||||
case CMPH_BRZ: /* included -- Fabiano */
|
case CMPH_BRZ: /* included -- Fabiano */
|
||||||
brz_destroy(mphf);
|
brz_destroy(mphf);
|
||||||
return;
|
return;
|
||||||
|
case CMPH_FCH: /* included -- Fabiano */
|
||||||
|
fch_destroy(mphf);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ typedef float cmph_float32;
|
|||||||
typedef enum { CMPH_HASH_DJB2, CMPH_HASH_FNV, CMPH_HASH_JENKINS,
|
typedef enum { CMPH_HASH_DJB2, CMPH_HASH_FNV, CMPH_HASH_JENKINS,
|
||||||
CMPH_HASH_SDBM, CMPH_HASH_COUNT } CMPH_HASH;
|
CMPH_HASH_SDBM, CMPH_HASH_COUNT } CMPH_HASH;
|
||||||
extern const char *cmph_hash_names[];
|
extern const char *cmph_hash_names[];
|
||||||
typedef enum { CMPH_BMZ, CMPH_BMZ8, CMPH_CHM, CMPH_BRZ, CMPH_COUNT } CMPH_ALGO; /* included -- Fabiano */
|
typedef enum { CMPH_BMZ, CMPH_BMZ8, CMPH_CHM, CMPH_BRZ, CMPH_FCH, CMPH_COUNT } CMPH_ALGO; /* included -- Fabiano */
|
||||||
extern const char *cmph_names[];
|
extern const char *cmph_names[];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#define INDEX 0 /* alignment index within a bucket */
|
#define INDEX 0 /* alignment index within a bucket */
|
||||||
//#define DEBUG
|
#define DEBUG
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
static cmph_uint32 mixh10h11h12(cmph_uint32 b, cmph_float32 p1, cmph_float32 p2, cmph_uint32 initial_index);
|
static cmph_uint32 mixh10h11h12(cmph_uint32 b, cmph_float32 p1, cmph_float32 p2, cmph_uint32 initial_index);
|
||||||
|
@ -61,7 +61,7 @@ int main(int argc, char **argv)
|
|||||||
cmph_uint32 nhashes = 0;
|
cmph_uint32 nhashes = 0;
|
||||||
cmph_uint32 i;
|
cmph_uint32 i;
|
||||||
CMPH_ALGO mph_algo = CMPH_CHM;
|
CMPH_ALGO mph_algo = CMPH_CHM;
|
||||||
float c = 2.09;
|
float c = 0;
|
||||||
cmph_config_t *config = NULL;
|
cmph_config_t *config = NULL;
|
||||||
cmph_t *mphf = NULL;
|
cmph_t *mphf = NULL;
|
||||||
char * tmp_dir = NULL;
|
char * tmp_dir = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user