Committer: Fabiano C. Botelho <fbotelho@fbotelho-desk.(none)>

On branch master
Changes to be committed:
Fixing bugs reported by Steve Friedman, Kaštil Jan
and a bug that was accidently introduced in file
chd_ph.c in 1.0 release.

	modified:   src/bdz.c
	modified:   src/bitbool.h
	modified:   src/chd_ph.c
	modified:   src/cmph_structs.c
	modified:   src/hash.c
This commit is contained in:
Fabiano C. Botelho 2011-03-27 01:41:28 -07:00
parent 084a940c2a
commit 5315e3a597
5 changed files with 6 additions and 28 deletions

View File

@ -560,21 +560,6 @@ void bdz_load(FILE *f, cmph_t *mphf)
} }
/*
static cmph_uint32 bdz_search_ph(cmph_t *mphf, const char *key, cmph_uint32 keylen)
{
bdz_data_t *bdz = mphf->data;
cmph_uint32 hl[3];
hash_vector(bdz->hl, key, keylen, hl);
cmph_uint32 vertex;
hl[0] = hl[0] % bdz->r;
hl[1] = hl[1] % bdz->r + bdz->r;
hl[2] = hl[2] % bdz->r + (bdz->r << 1);
vertex = hl[(GETVALUE(bdz->g, hl[0]) + GETVALUE(bdz->g, hl[1]) + GETVALUE(bdz->g, hl[2])) % 3];
return vertex;
}
*/
static inline cmph_uint32 rank(cmph_uint32 b, cmph_uint32 * ranktable, cmph_uint8 * g, cmph_uint32 vertex) static inline cmph_uint32 rank(cmph_uint32 b, cmph_uint32 * ranktable, cmph_uint8 * g, cmph_uint32 vertex)
{ {
register cmph_uint32 index = vertex >> b; register cmph_uint32 index = vertex >> b;

View File

@ -31,15 +31,6 @@ static const cmph_uint8 valuemask[] = { 0xfc, 0xf3, 0xcf, 0x3f};
*/ */
#define SETBIT(array, i) (array[i >> 3] |= bitmask[i & 0x00000007]) #define SETBIT(array, i) (array[i >> 3] |= bitmask[i & 0x00000007])
/** \def UNSETBIT(array, i)
* \brief set 0 to an 1-bit integer stored in an array.
* \param array to store 1-bit integer values
* \param i is the index in array to set the the bit to 0
*
* UNSETBIT(array, i) is a macro that sets 0 to an 1-bit integer stored in an array.
*/
#define UNSETBIT(array, i) (array[i >> 3] ^= ((bitmask[i & 0x00000007])))
//#define GETBIT(array, i) (array[(i) / 8] & bitmask[(i) % 8]) //#define GETBIT(array, i) (array[(i) / 8] & bitmask[(i) % 8])
//#define SETBIT(array, i) (array[(i) / 8] |= bitmask[(i) % 8]) //#define SETBIT(array, i) (array[(i) / 8] |= bitmask[(i) % 8])
//#define UNSETBIT(array, i) (array[(i) / 8] ^= ((bitmask[(i) % 8]))) //#define UNSETBIT(array, i) (array[(i) / 8] ^= ((bitmask[(i) % 8])))

View File

@ -625,7 +625,7 @@ cmph_t *chd_ph_new(cmph_config_t *mph, double c)
chd_ph_data_t *chd_phf = NULL; chd_ph_data_t *chd_phf = NULL;
chd_ph_config_data_t *chd_ph = (chd_ph_config_data_t *)mph->data; chd_ph_config_data_t *chd_ph = (chd_ph_config_data_t *)mph->data;
register double load_factor = 0.6; register double load_factor = c;
register cmph_uint8 searching_success = 0; register cmph_uint8 searching_success = 0;
register cmph_uint32 max_probes = 1 << 20; // default value for max_probes register cmph_uint32 max_probes = 1 << 20; // default value for max_probes
register cmph_uint32 iterations = 100; register cmph_uint32 iterations = 100;
@ -641,7 +641,6 @@ cmph_t *chd_ph_new(cmph_config_t *mph, double c)
double construction_time = 0.0; double construction_time = 0.0;
ELAPSED_TIME_IN_SECONDS(&construction_time_begin); ELAPSED_TIME_IN_SECONDS(&construction_time_begin);
#endif #endif
c = load_factor;
chd_ph->m = mph->key_source->nkeys; chd_ph->m = mph->key_source->nkeys;

View File

@ -8,8 +8,8 @@
cmph_config_t *__config_new(cmph_io_adapter_t *key_source) cmph_config_t *__config_new(cmph_io_adapter_t *key_source)
{ {
cmph_config_t *mph = (cmph_config_t *)malloc(sizeof(cmph_config_t)); cmph_config_t *mph = (cmph_config_t *)malloc(sizeof(cmph_config_t));
memset(mph, 0, sizeof(cmph_config_t));
if (mph == NULL) return NULL; if (mph == NULL) return NULL;
memset(mph, 0, sizeof(cmph_config_t));
mph->key_source = key_source; mph->key_source = key_source;
mph->verbosity = 0; mph->verbosity = 0;
mph->data = NULL; mph->data = NULL;

View File

@ -59,7 +59,9 @@ void hash_state_dump(hash_state_t *state, char **buf, cmph_uint32 *buflen)
{ {
case CMPH_HASH_JENKINS: case CMPH_HASH_JENKINS:
jenkins_state_dump((jenkins_state_t *)state, &algobuf, buflen); jenkins_state_dump((jenkins_state_t *)state, &algobuf, buflen);
if (*buflen == UINT_MAX) return; if (*buflen == UINT_MAX) {
goto cmph_cleanup;
}
break; break;
default: default:
assert(0); assert(0);
@ -70,6 +72,7 @@ void hash_state_dump(hash_state_t *state, char **buf, cmph_uint32 *buflen)
len = *buflen; len = *buflen;
memcpy(*buf + strlen(cmph_hash_names[state->hashfunc]) + 1, algobuf, len); memcpy(*buf + strlen(cmph_hash_names[state->hashfunc]) + 1, algobuf, len);
*buflen = (cmph_uint32)strlen(cmph_hash_names[state->hashfunc]) + 1 + *buflen; *buflen = (cmph_uint32)strlen(cmph_hash_names[state->hashfunc]) + 1 + *buflen;
cmph_cleanup:
free(algobuf); free(algobuf);
return; return;
} }