Compiled with -Werror -Wall -O3 and -Wconversion flags
This commit is contained in:
parent
ddf8d74132
commit
17b3299c7c
28
src/bdz.c
28
src/bdz.c
|
@ -11,7 +11,7 @@
|
|||
#include <string.h>
|
||||
//#define DEBUG
|
||||
#include "debug.h"
|
||||
#define UNASSIGNED 3
|
||||
#define UNASSIGNED 3U
|
||||
#define NULL_EDGE 0xffffffff
|
||||
|
||||
//cmph_uint32 ngrafos = 0;
|
||||
|
@ -208,7 +208,7 @@ static int bdz_generate_queue(cmph_uint32 nedges, cmph_uint32 nvertices, bdz_que
|
|||
};
|
||||
};
|
||||
free(marked_edge);
|
||||
return queue_head-nedges;/* returns 0 if successful otherwies return negative number*/
|
||||
return (int)(queue_head-nedges);/* returns 0 if successful otherwies return negative number*/
|
||||
};
|
||||
|
||||
static int bdz_mapping(cmph_config_t *mph, bdz_graph3_t* graph3, bdz_queue_t queue);
|
||||
|
@ -243,7 +243,7 @@ void bdz_config_set_b(cmph_config_t *mph, cmph_uint32 b)
|
|||
{
|
||||
bdz_config_data_t *bdz = (bdz_config_data_t *)mph->data;
|
||||
if (b <= 2 || b > 10) b = 7; // validating restrictions over parameter b.
|
||||
bdz->b = b;
|
||||
bdz->b = (cmph_uint8)b;
|
||||
DEBUGP("b: %u\n", b);
|
||||
|
||||
}
|
||||
|
@ -279,14 +279,14 @@ cmph_t *bdz_new(cmph_config_t *mph, double c)
|
|||
if (c == 0) c = 1.23; // validating restrictions over parameter c.
|
||||
DEBUGP("c: %f\n", c);
|
||||
bdz->m = mph->key_source->nkeys;
|
||||
bdz->r = ceil((c * mph->key_source->nkeys)/3);
|
||||
bdz->r = (cmph_uint32)ceil((c * mph->key_source->nkeys)/3);
|
||||
if ((bdz->r % 2) == 0) bdz->r+=1;
|
||||
bdz->n = 3*bdz->r;
|
||||
|
||||
bdz->k = (1 << bdz->b);
|
||||
bdz->k = (1U << bdz->b);
|
||||
DEBUGP("b: %u -- k: %u\n", bdz->b, bdz->k);
|
||||
|
||||
bdz->ranktablesize = ceil(bdz->n/(double)bdz->k);
|
||||
bdz->ranktablesize = (cmph_uint32)ceil(bdz->n/(double)bdz->k);
|
||||
DEBUGP("ranktablesize: %u\n", bdz->ranktablesize);
|
||||
|
||||
|
||||
|
@ -417,7 +417,7 @@ static void assigning(bdz_config_data_t *bdz, bdz_graph3_t* graph3, bdz_queue_t
|
|||
cmph_uint32 curr_edge;
|
||||
cmph_uint32 v0,v1,v2;
|
||||
cmph_uint8 * marked_vertices =malloc((size_t)(bdz->n >> 3) + 1);
|
||||
cmph_uint32 sizeg = ceil(bdz->n/4.0);
|
||||
cmph_uint32 sizeg = (cmph_uint32)ceil(bdz->n/4.0);
|
||||
bdz->g = (cmph_uint8 *)calloc((size_t)(sizeg), sizeof(cmph_uint8));
|
||||
memset(marked_vertices, 0, (size_t)(bdz->n >> 3) + 1);
|
||||
memset(bdz->g, 0xff, (size_t)(sizeg));
|
||||
|
@ -461,7 +461,7 @@ static void assigning(bdz_config_data_t *bdz, bdz_graph3_t* graph3, bdz_queue_t
|
|||
|
||||
static void ranking(bdz_config_data_t *bdz)
|
||||
{
|
||||
cmph_uint32 i, j, offset = 0, count = 0, size = (bdz->k >> 2), nbytes_total = ceil(bdz->n/4.0), nbytes;
|
||||
cmph_uint32 i, j, offset = 0U, count = 0U, size = (bdz->k >> 2U), nbytes_total = (cmph_uint32)ceil(bdz->n/4.0), nbytes;
|
||||
bdz->ranktable = (cmph_uint32 *)calloc((size_t)bdz->ranktablesize, sizeof(cmph_uint32));
|
||||
// ranktable computation
|
||||
bdz->ranktable[0] = 0;
|
||||
|
@ -486,7 +486,7 @@ int bdz_dump(cmph_t *mphf, FILE *fd)
|
|||
{
|
||||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
bdz_data_t *data = (bdz_data_t *)mphf->data;
|
||||
__cmph_dump(mphf, fd);
|
||||
|
||||
|
@ -500,7 +500,7 @@ int bdz_dump(cmph_t *mphf, FILE *fd)
|
|||
nbytes = fwrite(&(data->m), sizeof(cmph_uint32), (size_t)1, fd);
|
||||
nbytes = fwrite(&(data->r), sizeof(cmph_uint32), (size_t)1, fd);
|
||||
|
||||
cmph_uint32 sizeg = ceil(data->n/4.0);
|
||||
cmph_uint32 sizeg = (cmph_uint32)ceil(data->n/4.0);
|
||||
nbytes = fwrite(data->g, sizeof(cmph_uint8)*sizeg, (size_t)1, fd);
|
||||
|
||||
nbytes = fwrite(&(data->k), sizeof(cmph_uint32), (size_t)1, fd);
|
||||
|
@ -521,7 +521,7 @@ void bdz_load(FILE *f, cmph_t *mphf)
|
|||
{
|
||||
char *buf = NULL;
|
||||
cmph_uint32 buflen, sizeg;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
bdz_data_t *bdz = (bdz_data_t *)malloc(sizeof(bdz_data_t));
|
||||
|
||||
DEBUGP("Loading bdz mphf\n");
|
||||
|
@ -539,7 +539,7 @@ void bdz_load(FILE *f, cmph_t *mphf)
|
|||
nbytes = fread(&(bdz->n), sizeof(cmph_uint32), (size_t)1, f);
|
||||
nbytes = fread(&(bdz->m), sizeof(cmph_uint32), (size_t)1, f);
|
||||
nbytes = fread(&(bdz->r), sizeof(cmph_uint32), (size_t)1, f);
|
||||
sizeg = ceil(bdz->n/4.0);
|
||||
sizeg = (cmph_uint32)ceil(bdz->n/4.0);
|
||||
bdz->g = (cmph_uint8 *)calloc((size_t)(sizeg), sizeof(cmph_uint8));
|
||||
nbytes = fread(bdz->g, sizeg*sizeof(cmph_uint8), (size_t)1, f);
|
||||
|
||||
|
@ -654,7 +654,7 @@ void bdz_pack(cmph_t *mphf, void *packed_mphf)
|
|||
*ptr++ = data->b;
|
||||
|
||||
// packing g
|
||||
cmph_uint32 sizeg = ceil(data->n/4.0);
|
||||
cmph_uint32 sizeg = (cmph_uint32)ceil(data->n/4.0);
|
||||
memcpy(ptr, data->g, sizeof(cmph_uint8)*sizeg);
|
||||
}
|
||||
|
||||
|
@ -669,7 +669,7 @@ cmph_uint32 bdz_packed_size(cmph_t *mphf)
|
|||
|
||||
CMPH_HASH hl_type = hash_get_type(data->hl);
|
||||
|
||||
return (sizeof(CMPH_ALGO) + hash_state_packed_size(hl_type) + 3*sizeof(cmph_uint32) + sizeof(cmph_uint32)*(data->ranktablesize) + sizeof(cmph_uint8) + sizeof(cmph_uint8)*(ceil(data->n/4.0)));
|
||||
return (cmph_uint32)(sizeof(CMPH_ALGO) + hash_state_packed_size(hl_type) + 3*sizeof(cmph_uint32) + sizeof(cmph_uint32)*(data->ranktablesize) + sizeof(cmph_uint8) + sizeof(cmph_uint8)* (cmph_uint32)(ceil(data->n/4.0)));
|
||||
}
|
||||
|
||||
/** cmph_uint32 bdz_search(void *packed_mphf, const char *key, cmph_uint32 keylen);
|
||||
|
|
34
src/bdz_ph.c
34
src/bdz_ph.c
|
@ -15,8 +15,8 @@
|
|||
#define NULL_EDGE 0xffffffff
|
||||
|
||||
|
||||
static int pow3_table[5] = {1,3,9,27,81};
|
||||
static int lookup_table[5][256] = {
|
||||
static cmph_uint8 pow3_table[5] = {1,3,9,27,81};
|
||||
static cmph_uint8 lookup_table[5][256] = {
|
||||
{0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0},
|
||||
{0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1},
|
||||
|
@ -195,7 +195,7 @@ static int bdz_ph_generate_queue(cmph_uint32 nedges, cmph_uint32 nvertices, bdz_
|
|||
};
|
||||
};
|
||||
free(marked_edge);
|
||||
return queue_head-nedges;/* returns 0 if successful otherwies return negative number*/
|
||||
return (int)queue_head - (int)nedges;/* returns 0 if successful otherwies return negative number*/
|
||||
};
|
||||
|
||||
static int bdz_ph_mapping(cmph_config_t *mph, bdz_ph_graph3_t* graph3, bdz_ph_queue_t queue);
|
||||
|
@ -252,7 +252,7 @@ cmph_t *bdz_ph_new(cmph_config_t *mph, double c)
|
|||
if (c == 0) c = 1.23; // validating restrictions over parameter c.
|
||||
DEBUGP("c: %f\n", c);
|
||||
bdz_ph->m = mph->key_source->nkeys;
|
||||
bdz_ph->r = ceil((c * mph->key_source->nkeys)/3);
|
||||
bdz_ph->r = (cmph_uint32)ceil((c * mph->key_source->nkeys)/3);
|
||||
if ((bdz_ph->r % 2) == 0) bdz_ph->r += 1;
|
||||
bdz_ph->n = 3*bdz_ph->r;
|
||||
|
||||
|
@ -382,7 +382,7 @@ static void assigning(bdz_ph_config_data_t *bdz_ph, bdz_ph_graph3_t* graph3, bdz
|
|||
cmph_uint32 curr_edge;
|
||||
cmph_uint32 v0,v1,v2;
|
||||
cmph_uint8 * marked_vertices =malloc((size_t)(bdz_ph->n >> 3) + 1);
|
||||
cmph_uint32 sizeg = ceil(bdz_ph->n/4.0);
|
||||
cmph_uint32 sizeg = (cmph_uint32)ceil(bdz_ph->n/4.0);
|
||||
bdz_ph->g = (cmph_uint8 *)calloc((size_t)sizeg, sizeof(cmph_uint8));
|
||||
memset(marked_vertices, 0, (size_t)(bdz_ph->n >> 3) + 1);
|
||||
//memset(bdz_ph->g, 0xff, sizeg);
|
||||
|
@ -427,7 +427,7 @@ static void bdz_ph_optimization(bdz_ph_config_data_t *bdz_ph)
|
|||
{
|
||||
cmph_uint32 i;
|
||||
cmph_uint8 byte = 0;
|
||||
cmph_uint32 sizeg = ceil(bdz_ph->n/5.0);
|
||||
cmph_uint32 sizeg = (cmph_uint32)ceil(bdz_ph->n/5.0);
|
||||
cmph_uint8 * new_g = (cmph_uint8 *)calloc((size_t)sizeg, sizeof(cmph_uint8));
|
||||
cmph_uint8 value;
|
||||
cmph_uint32 idx;
|
||||
|
@ -436,7 +436,7 @@ static void bdz_ph_optimization(bdz_ph_config_data_t *bdz_ph)
|
|||
idx = i/5;
|
||||
byte = new_g[idx];
|
||||
value = GETVALUE(bdz_ph->g, i);
|
||||
byte += value*pow3_table[i%5];
|
||||
byte = (cmph_uint8) (byte + value*pow3_table[i%5U]);
|
||||
new_g[idx] = byte;
|
||||
}
|
||||
free(bdz_ph->g);
|
||||
|
@ -449,7 +449,7 @@ int bdz_ph_dump(cmph_t *mphf, FILE *fd)
|
|||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
cmph_uint32 sizeg = 0;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
bdz_ph_data_t *data = (bdz_ph_data_t *)mphf->data;
|
||||
__cmph_dump(mphf, fd);
|
||||
|
||||
|
@ -462,7 +462,7 @@ int bdz_ph_dump(cmph_t *mphf, FILE *fd)
|
|||
nbytes = fwrite(&(data->n), sizeof(cmph_uint32), (size_t)1, fd);
|
||||
nbytes = fwrite(&(data->m), sizeof(cmph_uint32), (size_t)1, fd);
|
||||
nbytes = fwrite(&(data->r), sizeof(cmph_uint32), (size_t)1, fd);
|
||||
sizeg = ceil(data->n/5.0);
|
||||
sizeg = (cmph_uint32)ceil(data->n/5.0);
|
||||
nbytes = fwrite(data->g, sizeof(cmph_uint8)*sizeg, (size_t)1, fd);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -479,7 +479,7 @@ void bdz_ph_load(FILE *f, cmph_t *mphf)
|
|||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
cmph_uint32 sizeg = 0;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
bdz_ph_data_t *bdz_ph = (bdz_ph_data_t *)malloc(sizeof(bdz_ph_data_t));
|
||||
|
||||
DEBUGP("Loading bdz_ph mphf\n");
|
||||
|
@ -497,7 +497,7 @@ void bdz_ph_load(FILE *f, cmph_t *mphf)
|
|||
nbytes = fread(&(bdz_ph->n), sizeof(cmph_uint32), (size_t)1, f);
|
||||
nbytes = fread(&(bdz_ph->m), sizeof(cmph_uint32), (size_t)1, f);
|
||||
nbytes = fread(&(bdz_ph->r), sizeof(cmph_uint32), (size_t)1, f);
|
||||
sizeg = ceil(bdz_ph->n/5.0);
|
||||
sizeg = (cmph_uint32)ceil(bdz_ph->n/5.0);
|
||||
bdz_ph->g = (cmph_uint8 *)calloc((size_t)sizeg, sizeof(cmph_uint8));
|
||||
nbytes = fread(bdz_ph->g, sizeg*sizeof(cmph_uint8), (size_t)1, f);
|
||||
|
||||
|
@ -521,9 +521,9 @@ cmph_uint32 bdz_ph_search(cmph_t *mphf, const char *key, cmph_uint32 keylen)
|
|||
byte1 = bdz_ph->g[hl[1]/5];
|
||||
byte2 = bdz_ph->g[hl[2]/5];
|
||||
|
||||
byte0 = lookup_table[hl[0]%5][byte0];
|
||||
byte1 = lookup_table[hl[1]%5][byte1];
|
||||
byte2 = lookup_table[hl[2]%5][byte2];
|
||||
byte0 = lookup_table[hl[0]%5U][byte0];
|
||||
byte1 = lookup_table[hl[1]%5U][byte1];
|
||||
byte2 = lookup_table[hl[2]%5U][byte2];
|
||||
vertex = hl[(byte0 + byte1 + byte2)%3];
|
||||
|
||||
return vertex;
|
||||
|
@ -563,7 +563,7 @@ void bdz_ph_pack(cmph_t *mphf, void *packed_mphf)
|
|||
ptr += sizeof(data->r);
|
||||
|
||||
// packing g
|
||||
cmph_uint32 sizeg = ceil(data->n/5.0);
|
||||
cmph_uint32 sizeg = (cmph_uint32)ceil(data->n/5.0);
|
||||
memcpy(ptr, data->g, sizeof(cmph_uint8)*sizeg);
|
||||
}
|
||||
|
||||
|
@ -576,8 +576,8 @@ cmph_uint32 bdz_ph_packed_size(cmph_t *mphf)
|
|||
{
|
||||
bdz_ph_data_t *data = (bdz_ph_data_t *)mphf->data;
|
||||
CMPH_HASH hl_type = hash_get_type(data->hl);
|
||||
cmph_uint32 sizeg = ceil(data->n/5.0);
|
||||
return (sizeof(CMPH_ALGO) + hash_state_packed_size(hl_type) + 2*sizeof(cmph_uint32) + sizeof(cmph_uint8)*sizeg);
|
||||
cmph_uint32 sizeg = (cmph_uint32)ceil(data->n/5.0);
|
||||
return (cmph_uint32) (sizeof(CMPH_ALGO) + hash_state_packed_size(hl_type) + 2*sizeof(cmph_uint32) + sizeof(cmph_uint8)*sizeg);
|
||||
}
|
||||
|
||||
/** cmph_uint32 bdz_ph_search(void *packed_mphf, const char *key, cmph_uint32 keylen);
|
||||
|
|
|
@ -7,7 +7,7 @@ static const cmph_uint8 bitmask[] = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 <<
|
|||
static const cmph_uint32 bitmask32[] = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7,
|
||||
1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15,
|
||||
1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 21, 1 << 22, 1 << 23,
|
||||
1 << 24, 1 << 25, 1 << 26, 1 << 27, 1 << 28, 1 << 29, 1 << 30, 1 << 31
|
||||
1 << 24, 1 << 25, 1 << 26, 1 << 27, 1 << 28, 1 << 29, 1 << 30, 1U << 31
|
||||
};
|
||||
|
||||
static const cmph_uint8 valuemask[] = { 0xfc, 0xf3, 0xcf, 0x3f};
|
||||
|
@ -55,7 +55,7 @@ static const cmph_uint8 valuemask[] = { 0xfc, 0xf3, 0xcf, 0x3f};
|
|||
* The array should be initialized with all bits set to 1. For example:
|
||||
* memset(array, 0xff, arraySize);
|
||||
*/
|
||||
#define SETVALUE1(array, i, v) (array[i >> 2] &= ((v << ((i & 0x00000003) << 1)) | valuemask[i & 0x00000003]))
|
||||
#define SETVALUE1(array, i, v) (array[i >> 2] &= (cmph_uint8)((v << ((i & 0x00000003) << 1)) | valuemask[i & 0x00000003]))
|
||||
|
||||
/** \def SETVALUE0(array, i, v)
|
||||
* \brief set a value for a 2-bit integer stored in an array initialized with 0s.
|
||||
|
@ -67,7 +67,7 @@ static const cmph_uint8 valuemask[] = { 0xfc, 0xf3, 0xcf, 0x3f};
|
|||
* The array should be initialized with all bits set to 0. For example:
|
||||
* memset(array, 0, arraySize);
|
||||
*/
|
||||
#define SETVALUE0(array, i, v) (array[i >> 2] |= (v << ((i & 0x00000003) << 1)))
|
||||
#define SETVALUE0(array, i, v) (array[i >> 2] |= (cmph_uint8)(v << ((i & 0x00000003) << 1)))
|
||||
|
||||
|
||||
/** \def GETVALUE(array, i)
|
||||
|
@ -77,7 +77,7 @@ static const cmph_uint8 valuemask[] = { 0xfc, 0xf3, 0xcf, 0x3f};
|
|||
*
|
||||
* GETVALUE(array, i) is a macro that get a value for a 2-bit integer stored in an array.
|
||||
*/
|
||||
#define GETVALUE(array, i) ((array[i >> 2] >> ((i & 0x00000003) << 1)) & 0x00000003)
|
||||
#define GETVALUE(array, i) ((cmph_uint8)((array[i >> 2] >> ((i & 0x00000003U) << 1U)) & 0x00000003U))
|
||||
|
||||
|
||||
|
||||
|
@ -149,7 +149,7 @@ static inline void set_bits_at_pos(cmph_uint32 * bits_table, cmph_uint32 pos, cm
|
|||
register cmph_uint32 word_idx = pos >> 5;
|
||||
register cmph_uint32 shift1 = pos & 0x0000001f;
|
||||
register cmph_uint32 shift2 = 32-shift1;
|
||||
register cmph_uint32 string_mask = (1 << string_length) - 1;
|
||||
register cmph_uint32 string_mask = (1U << string_length) - 1;
|
||||
|
||||
bits_table[word_idx] &= ~((string_mask) << shift1);
|
||||
bits_table[word_idx] |= bits_string << shift1;
|
||||
|
@ -165,7 +165,7 @@ static inline cmph_uint32 get_bits_at_pos(cmph_uint32 * bits_table,cmph_uint32 p
|
|||
register cmph_uint32 word_idx = pos >> 5;
|
||||
register cmph_uint32 shift1 = pos & 0x0000001f;
|
||||
register cmph_uint32 shift2 = 32 - shift1;
|
||||
register cmph_uint32 string_mask = (1 << string_length) - 1;
|
||||
register cmph_uint32 string_mask = (1U << string_length) - 1;
|
||||
register cmph_uint32 bits_string;
|
||||
|
||||
bits_string = (bits_table[word_idx] >> shift1) & string_mask;
|
||||
|
|
|
@ -69,7 +69,7 @@ cmph_t *bmz_new(cmph_config_t *mph, double c)
|
|||
if (c == 0) c = 1.15; // validating restrictions over parameter c.
|
||||
DEBUGP("c: %f\n", c);
|
||||
bmz->m = mph->key_source->nkeys;
|
||||
bmz->n = ceil(c * mph->key_source->nkeys);
|
||||
bmz->n = (cmph_uint32)ceil(c * mph->key_source->nkeys);
|
||||
DEBUGP("m (edges): %u n (vertices): %u c: %f\n", bmz->m, bmz->n, c);
|
||||
bmz->graph = graph_new(bmz->n, bmz->m);
|
||||
DEBUGP("Created graph\n");
|
||||
|
@ -448,7 +448,7 @@ int bmz_dump(cmph_t *mphf, FILE *fd)
|
|||
cmph_uint32 buflen;
|
||||
cmph_uint32 two = 2; //number of hash functions
|
||||
bmz_data_t *data = (bmz_data_t *)mphf->data;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
__cmph_dump(mphf, fd);
|
||||
|
||||
nbytes = fwrite(&two, sizeof(cmph_uint32), (size_t)1, fd);
|
||||
|
@ -485,7 +485,7 @@ void bmz_load(FILE *f, cmph_t *mphf)
|
|||
cmph_uint32 buflen;
|
||||
cmph_uint32 i;
|
||||
bmz_data_t *bmz = (bmz_data_t *)malloc(sizeof(bmz_data_t));
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
DEBUGP("Loading bmz mphf\n");
|
||||
mphf->data = bmz;
|
||||
nbytes = fread(&nhashes, sizeof(cmph_uint32), (size_t)1, f);
|
||||
|
@ -588,7 +588,7 @@ cmph_uint32 bmz_packed_size(cmph_t *mphf)
|
|||
CMPH_HASH h1_type = hash_get_type(data->hashes[0]);
|
||||
CMPH_HASH h2_type = hash_get_type(data->hashes[1]);
|
||||
|
||||
return (sizeof(CMPH_ALGO) + hash_state_packed_size(h1_type) + hash_state_packed_size(h2_type) +
|
||||
return (cmph_uint32)(sizeof(CMPH_ALGO) + hash_state_packed_size(h1_type) + hash_state_packed_size(h2_type) +
|
||||
3*sizeof(cmph_uint32) + sizeof(cmph_uint32)*data->n);
|
||||
}
|
||||
|
||||
|
|
55
src/bmz8.c
55
src/bmz8.c
|
@ -72,8 +72,8 @@ cmph_t *bmz8_new(cmph_config_t *mph, double c)
|
|||
}
|
||||
if (c == 0) c = 1.15; // validating restrictions over parameter c.
|
||||
DEBUGP("c: %f\n", c);
|
||||
bmz8->m = mph->key_source->nkeys;
|
||||
bmz8->n = ceil(c * mph->key_source->nkeys);
|
||||
bmz8->m = (cmph_uint8) mph->key_source->nkeys;
|
||||
bmz8->n = (cmph_uint8) ceil(c * mph->key_source->nkeys);
|
||||
DEBUGP("m (edges): %u n (vertices): %u c: %f\n", bmz8->m, bmz8->n, c);
|
||||
bmz8->graph = graph_new(bmz8->n, bmz8->m);
|
||||
DEBUGP("Created graph\n");
|
||||
|
@ -206,7 +206,7 @@ static cmph_uint8 bmz8_traverse_critical_nodes(bmz8_config_data_t *bmz8, cmph_ui
|
|||
graph_iterator_t it, it1;
|
||||
|
||||
DEBUGP("Labelling critical vertices\n");
|
||||
bmz8->g[v] = (cmph_uint8)ceil ((double)(*biggest_edge_value)/2) - 1;
|
||||
bmz8->g[v] = (cmph_uint8)(ceil ((double)(*biggest_edge_value)/2) - 1);
|
||||
SETBIT(visited, v);
|
||||
next_g = (cmph_uint8)floor((double)(*biggest_edge_value/2)); /* next_g is incremented in the do..while statement*/
|
||||
vqueue_insert(q, v);
|
||||
|
@ -221,7 +221,7 @@ static cmph_uint8 bmz8_traverse_critical_nodes(bmz8_config_data_t *bmz8, cmph_ui
|
|||
collision = 1;
|
||||
while(collision) // lookahead to resolve collisions
|
||||
{
|
||||
next_g = *biggest_g_value + 1;
|
||||
next_g = (cmph_uint8)(*biggest_g_value + 1);
|
||||
it1 = graph_neighbors_it(bmz8->graph, u);
|
||||
collision = 0;
|
||||
while((lav = graph_next_neighbor(bmz8->graph, &it1)) != GRAPH_NO_NEIGHBOR)
|
||||
|
@ -249,7 +249,9 @@ static cmph_uint8 bmz8_traverse_critical_nodes(bmz8_config_data_t *bmz8, cmph_ui
|
|||
if (graph_node_is_critical(bmz8->graph, lav) && GETBIT(visited, lav))
|
||||
{
|
||||
SETBIT(used_edges,(next_g + bmz8->g[lav]));
|
||||
if(next_g + bmz8->g[lav] > *biggest_edge_value) *biggest_edge_value = next_g + bmz8->g[lav];
|
||||
|
||||
if(next_g + bmz8->g[lav] > *biggest_edge_value)
|
||||
*biggest_edge_value = (cmph_uint8)(next_g + bmz8->g[lav]);
|
||||
}
|
||||
}
|
||||
bmz8->g[u] = next_g; // Labelling vertex u.
|
||||
|
@ -276,7 +278,7 @@ static cmph_uint8 bmz8_traverse_critical_nodes_heuristic(bmz8_config_data_t *bmz
|
|||
graph_iterator_t it, it1;
|
||||
|
||||
DEBUGP("Labelling critical vertices\n");
|
||||
bmz8->g[v] = (cmph_uint8)ceil ((double)(*biggest_edge_value)/2) - 1;
|
||||
bmz8->g[v] = (cmph_uint8)(ceil ((double)(*biggest_edge_value)/2) - 1);
|
||||
SETBIT(visited, v);
|
||||
next_g = (cmph_uint8)floor((double)(*biggest_edge_value/2));
|
||||
vqueue_insert(q, v);
|
||||
|
@ -298,7 +300,7 @@ static cmph_uint8 bmz8_traverse_critical_nodes_heuristic(bmz8_config_data_t *bmz
|
|||
}
|
||||
else
|
||||
{
|
||||
next_g = *biggest_g_value + 1;
|
||||
next_g = (cmph_uint8)(*biggest_g_value + 1);
|
||||
next_g_index = 255;//UINT_MAX;
|
||||
}
|
||||
it1 = graph_neighbors_it(bmz8->graph, u);
|
||||
|
@ -324,8 +326,8 @@ static cmph_uint8 bmz8_traverse_critical_nodes_heuristic(bmz8_config_data_t *bmz
|
|||
{
|
||||
if(nunused_g_values == unused_g_values_capacity)
|
||||
{
|
||||
unused_g_values = (cmph_uint8*)realloc(unused_g_values, (unused_g_values_capacity + BUFSIZ)*sizeof(cmph_uint8));
|
||||
unused_g_values_capacity += BUFSIZ;
|
||||
unused_g_values = (cmph_uint8*)realloc(unused_g_values, ((size_t)(unused_g_values_capacity + BUFSIZ))*sizeof(cmph_uint8));
|
||||
unused_g_values_capacity += (cmph_uint8)BUFSIZ;
|
||||
}
|
||||
unused_g_values[nunused_g_values++] = next_g;
|
||||
|
||||
|
@ -343,7 +345,8 @@ static cmph_uint8 bmz8_traverse_critical_nodes_heuristic(bmz8_config_data_t *bmz
|
|||
if (graph_node_is_critical(bmz8->graph, lav) && GETBIT(visited, lav))
|
||||
{
|
||||
SETBIT(used_edges,(next_g + bmz8->g[lav]));
|
||||
if(next_g + bmz8->g[lav] > *biggest_edge_value) *biggest_edge_value = next_g + bmz8->g[lav];
|
||||
if(next_g + bmz8->g[lav] > *biggest_edge_value)
|
||||
*biggest_edge_value = (cmph_uint8)(next_g + bmz8->g[lav]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,7 +371,7 @@ static cmph_uint8 next_unused_edge(bmz8_config_data_t *bmz8, cmph_uint8 * used_e
|
|||
if(GETBIT(used_edges, unused_edge_index)) unused_edge_index ++;
|
||||
else break;
|
||||
}
|
||||
return unused_edge_index;
|
||||
return (cmph_uint8)unused_edge_index;
|
||||
}
|
||||
|
||||
static void bmz8_traverse(bmz8_config_data_t *bmz8, cmph_uint8 * used_edges, cmph_uint32 v, cmph_uint8 * unused_edge_index, cmph_uint8 * visited)
|
||||
|
@ -380,7 +383,7 @@ static void bmz8_traverse(bmz8_config_data_t *bmz8, cmph_uint8 * used_edges, cmp
|
|||
if(GETBIT(visited,neighbor)) continue;
|
||||
//DEBUGP("Visiting neighbor %u\n", neighbor);
|
||||
*unused_edge_index = next_unused_edge(bmz8, used_edges, *unused_edge_index);
|
||||
bmz8->g[neighbor] = *unused_edge_index - bmz8->g[v];
|
||||
bmz8->g[neighbor] = (cmph_uint8)(*unused_edge_index - bmz8->g[v]);
|
||||
//if (bmz8->g[neighbor] >= bmz8->m) bmz8->g[neighbor] += bmz8->m;
|
||||
SETBIT(visited, neighbor);
|
||||
(*unused_edge_index)++;
|
||||
|
@ -396,8 +399,8 @@ static void bmz8_traverse_non_critical_nodes(bmz8_config_data_t *bmz8, cmph_uint
|
|||
DEBUGP("Labelling non critical vertices\n");
|
||||
for(i = 0; i < bmz8->m; i++)
|
||||
{
|
||||
v1 = graph_vertex_id(bmz8->graph, i, 0);
|
||||
v2 = graph_vertex_id(bmz8->graph, i, 1);
|
||||
v1 = (cmph_uint8)graph_vertex_id(bmz8->graph, i, 0);
|
||||
v2 = (cmph_uint8)graph_vertex_id(bmz8->graph, i, 1);
|
||||
if((GETBIT(visited,v1) && GETBIT(visited,v2)) || (!GETBIT(visited,v1) && !GETBIT(visited,v2))) continue;
|
||||
if(GETBIT(visited,v1)) bmz8_traverse(bmz8, used_edges, v1, &unused_edge_index, visited);
|
||||
else bmz8_traverse(bmz8, used_edges, v2, &unused_edge_index, visited);
|
||||
|
@ -432,8 +435,8 @@ static int bmz8_gen_edges(cmph_config_t *mph)
|
|||
mph->key_source->read(mph->key_source->data, &key, &keylen);
|
||||
|
||||
// if (key == NULL)fprintf(stderr, "key = %s -- read BMZ\n", key);
|
||||
h1 = hash(bmz8->hashes[0], key, keylen) % bmz8->n;
|
||||
h2 = hash(bmz8->hashes[1], key, keylen) % bmz8->n;
|
||||
h1 = (cmph_uint8)(hash(bmz8->hashes[0], key, keylen) % bmz8->n);
|
||||
h2 = (cmph_uint8)(hash(bmz8->hashes[1], key, keylen) % bmz8->n);
|
||||
if (h1 == h2) if (++h2 >= bmz8->n) h2 = 0;
|
||||
if (h1 == h2)
|
||||
{
|
||||
|
@ -458,7 +461,7 @@ int bmz8_dump(cmph_t *mphf, FILE *fd)
|
|||
cmph_uint32 buflen;
|
||||
cmph_uint8 two = 2; //number of hash functions
|
||||
bmz8_data_t *data = (bmz8_data_t *)mphf->data;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
__cmph_dump(mphf, fd);
|
||||
|
||||
nbytes = fwrite(&two, sizeof(cmph_uint8), (size_t)1, fd);
|
||||
|
@ -493,13 +496,13 @@ void bmz8_load(FILE *f, cmph_t *mphf)
|
|||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
cmph_uint8 i;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
bmz8_data_t *bmz8 = (bmz8_data_t *)malloc(sizeof(bmz8_data_t));
|
||||
|
||||
DEBUGP("Loading bmz8 mphf\n");
|
||||
mphf->data = bmz8;
|
||||
nbytes = fread(&nhashes, sizeof(cmph_uint8), (size_t)1, f);
|
||||
bmz8->hashes = (hash_state_t **)malloc(sizeof(hash_state_t *)*(nhashes + 1));
|
||||
bmz8->hashes = (hash_state_t **)malloc(sizeof(hash_state_t *)*(size_t)(nhashes + 1));
|
||||
bmz8->hashes[nhashes] = NULL;
|
||||
DEBUGP("Reading %u hashes\n", nhashes);
|
||||
for (i = 0; i < nhashes; ++i)
|
||||
|
@ -532,12 +535,12 @@ void bmz8_load(FILE *f, cmph_t *mphf)
|
|||
cmph_uint8 bmz8_search(cmph_t *mphf, const char *key, cmph_uint32 keylen)
|
||||
{
|
||||
bmz8_data_t *bmz8 = mphf->data;
|
||||
cmph_uint8 h1 = hash(bmz8->hashes[0], key, keylen) % bmz8->n;
|
||||
cmph_uint8 h2 = hash(bmz8->hashes[1], key, keylen) % bmz8->n;
|
||||
cmph_uint8 h1 = (cmph_uint8)(hash(bmz8->hashes[0], key, keylen) % bmz8->n);
|
||||
cmph_uint8 h2 = (cmph_uint8)(hash(bmz8->hashes[1], key, keylen) % bmz8->n);
|
||||
DEBUGP("key: %s h1: %u h2: %u\n", key, h1, h2);
|
||||
if (h1 == h2 && ++h2 > bmz8->n) h2 = 0;
|
||||
DEBUGP("key: %s g[h1]: %u g[h2]: %u edges: %u\n", key, bmz8->g[h1], bmz8->g[h2], bmz8->m);
|
||||
return (bmz8->g[h1] + bmz8->g[h2]);
|
||||
return (cmph_uint8)(bmz8->g[h1] + bmz8->g[h2]);
|
||||
}
|
||||
void bmz8_destroy(cmph_t *mphf)
|
||||
{
|
||||
|
@ -596,7 +599,7 @@ cmph_uint32 bmz8_packed_size(cmph_t *mphf)
|
|||
CMPH_HASH h1_type = hash_get_type(data->hashes[0]);
|
||||
CMPH_HASH h2_type = hash_get_type(data->hashes[1]);
|
||||
|
||||
return (sizeof(CMPH_ALGO) + hash_state_packed_size(h1_type) + hash_state_packed_size(h2_type) +
|
||||
return (cmph_uint32)(sizeof(CMPH_ALGO) + hash_state_packed_size(h1_type) + hash_state_packed_size(h2_type) +
|
||||
2*sizeof(cmph_uint32) + sizeof(cmph_uint8) + sizeof(cmph_uint8)*data->n);
|
||||
}
|
||||
|
||||
|
@ -621,9 +624,9 @@ cmph_uint8 bmz8_search_packed(void *packed_mphf, const char *key, cmph_uint32 ke
|
|||
|
||||
register cmph_uint8 n = *g_ptr++;
|
||||
|
||||
register cmph_uint8 h1 = hash_packed(h1_ptr, h1_type, key, keylen) % n;
|
||||
register cmph_uint8 h2 = hash_packed(h2_ptr, h2_type, key, keylen) % n;
|
||||
register cmph_uint8 h1 = (cmph_uint8)(hash_packed(h1_ptr, h1_type, key, keylen) % n);
|
||||
register cmph_uint8 h2 = (cmph_uint8)(hash_packed(h2_ptr, h2_type, key, keylen) % n);
|
||||
DEBUGP("key: %s h1: %u h2: %u\n", key, h1, h2);
|
||||
if (h1 == h2 && ++h2 > n) h2 = 0;
|
||||
return (g_ptr[h1] + g_ptr[h2]);
|
||||
return (cmph_uint8)(g_ptr[h1] + g_ptr[h2]);
|
||||
}
|
||||
|
|
48
src/brz.c
48
src/brz.c
|
@ -79,7 +79,7 @@ void brz_config_set_tmp_dir(cmph_config_t *mph, cmph_uint8 *tmp_dir)
|
|||
brz_config_data_t *brz = (brz_config_data_t *)mph->data;
|
||||
if(tmp_dir)
|
||||
{
|
||||
cmph_uint32 len = strlen((char *)tmp_dir);
|
||||
size_t len = strlen((char *)tmp_dir);
|
||||
free(brz->tmp_dir);
|
||||
if(tmp_dir[len-1] != '/')
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ void brz_config_set_b(cmph_config_t *mph, cmph_uint32 b)
|
|||
{
|
||||
b = 128;
|
||||
}
|
||||
brz->b = b;
|
||||
brz->b = (cmph_uint8)b;
|
||||
}
|
||||
|
||||
void brz_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo)
|
||||
|
@ -231,7 +231,7 @@ static int brz_gen_mphf(cmph_config_t *mph)
|
|||
cmph_uint32 *buffer_h0 = NULL;
|
||||
cmph_uint32 nflushes = 0;
|
||||
cmph_uint32 h0;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
FILE * tmp_fd = NULL;
|
||||
buffer_manager_t * buff_manager = NULL;
|
||||
char *filename = NULL;
|
||||
|
@ -275,7 +275,7 @@ static int brz_gen_mphf(cmph_config_t *mph)
|
|||
h0 = hash(brz->h0, (char *)(buffer + memory_usage + sizeof(keylen1)), keylen1) % brz->k;
|
||||
keys_index[buckets_size[h0]] = memory_usage;
|
||||
buckets_size[h0]++;
|
||||
memory_usage += keylen1 + sizeof(keylen1);
|
||||
memory_usage += keylen1 + (cmph_uint32)sizeof(keylen1);
|
||||
}
|
||||
filename = (char *)calloc(strlen((char *)(brz->tmp_dir)) + 11, sizeof(char));
|
||||
sprintf(filename, "%s%u.cmph",brz->tmp_dir, nflushes);
|
||||
|
@ -296,7 +296,7 @@ static int brz_gen_mphf(cmph_config_t *mph)
|
|||
}
|
||||
memcpy(buffer + memory_usage, &keylen, sizeof(keylen));
|
||||
memcpy(buffer + memory_usage + sizeof(keylen), key, (size_t)keylen);
|
||||
memory_usage += keylen + sizeof(keylen);
|
||||
memory_usage += keylen + (cmph_uint32)sizeof(keylen);
|
||||
h0 = hash(brz->h0, key, keylen) % brz->k;
|
||||
|
||||
if ((brz->size[h0] == MAX_BUCKET_SIZE) || (brz->algo == CMPH_BMZ8 && ((brz->c >= 1.0) && (cmph_uint8)(brz->c * brz->size[h0]) < brz->size[h0])))
|
||||
|
@ -305,7 +305,7 @@ static int brz_gen_mphf(cmph_config_t *mph)
|
|||
free(buckets_size);
|
||||
return 0;
|
||||
}
|
||||
brz->size[h0] = brz->size[h0] + 1;
|
||||
brz->size[h0] = (cmph_uint8)(brz->size[h0] + 1U);
|
||||
buckets_size[h0] ++;
|
||||
nkeys_in_buffer++;
|
||||
mph->key_source->dispose(mph->key_source->data, key, keylen);
|
||||
|
@ -335,7 +335,7 @@ static int brz_gen_mphf(cmph_config_t *mph)
|
|||
h0 = hash(brz->h0, (char *)(buffer + memory_usage + sizeof(keylen1)), keylen1) % brz->k;
|
||||
keys_index[buckets_size[h0]] = memory_usage;
|
||||
buckets_size[h0]++;
|
||||
memory_usage += keylen1 + sizeof(keylen1);
|
||||
memory_usage += keylen1 + (cmph_uint32)sizeof(keylen1);
|
||||
}
|
||||
filename = (char *)calloc(strlen((char *)(brz->tmp_dir)) + 11, sizeof(char));
|
||||
sprintf(filename, "%s%u.cmph",brz->tmp_dir, nflushes);
|
||||
|
@ -523,7 +523,7 @@ static char * brz_copy_partial_fch_mphf(brz_config_data_t *brz, fch_data_t * fch
|
|||
cmph_uint32 n = fchf->b;//brz->size[index];
|
||||
hash_state_dump(fchf->h1, &bufh1, &buflenh1);
|
||||
hash_state_dump(fchf->h2, &bufh2, &buflenh2);
|
||||
*buflen = buflenh1 + buflenh2 + n + 2*sizeof(cmph_uint32);
|
||||
*buflen = buflenh1 + buflenh2 + n + 2U * (cmph_uint32)sizeof(cmph_uint32);
|
||||
buf = (char *)malloc((size_t)(*buflen));
|
||||
memcpy(buf, &buflenh1, sizeof(cmph_uint32));
|
||||
memcpy(buf+sizeof(cmph_uint32), bufh1, (size_t)buflenh1);
|
||||
|
@ -541,10 +541,10 @@ static char * brz_copy_partial_bmz8_mphf(brz_config_data_t *brz, bmz8_data_t * b
|
|||
char * bufh1 = NULL;
|
||||
char * bufh2 = NULL;
|
||||
char * buf = NULL;
|
||||
cmph_uint32 n = ceil(brz->c * brz->size[index]);
|
||||
cmph_uint32 n = (cmph_uint32)ceil(brz->c * brz->size[index]);
|
||||
hash_state_dump(bmzf->hashes[0], &bufh1, &buflenh1);
|
||||
hash_state_dump(bmzf->hashes[1], &bufh2, &buflenh2);
|
||||
*buflen = buflenh1 + buflenh2 + n + 2*sizeof(cmph_uint32);
|
||||
*buflen = buflenh1 + buflenh2 + n + 2U * (cmph_uint32)sizeof(cmph_uint32);
|
||||
buf = (char *)malloc((size_t)(*buflen));
|
||||
memcpy(buf, &buflenh1, sizeof(cmph_uint32));
|
||||
memcpy(buf+sizeof(cmph_uint32), bufh1, (size_t)buflenh1);
|
||||
|
@ -562,7 +562,7 @@ int brz_dump(cmph_t *mphf, FILE *fd)
|
|||
brz_data_t *data = (brz_data_t *)mphf->data;
|
||||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
DEBUGP("Dumping brzf\n");
|
||||
// The initial part of the MPHF have already been dumped to disk during construction
|
||||
// Dumping h0
|
||||
|
@ -581,7 +581,7 @@ void brz_load(FILE *f, cmph_t *mphf)
|
|||
{
|
||||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
cmph_uint32 i, n;
|
||||
brz_data_t *brz = (brz_data_t *)malloc(sizeof(brz_data_t));
|
||||
|
||||
|
@ -619,7 +619,7 @@ void brz_load(FILE *f, cmph_t *mphf)
|
|||
n = fch_calc_b(brz->c, brz->size[i]);
|
||||
break;
|
||||
case CMPH_BMZ8:
|
||||
n = ceil(brz->c * brz->size[i]);
|
||||
n = (cmph_uint32)ceil(brz->c * brz->size[i]);
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
|
@ -650,13 +650,13 @@ static cmph_uint32 brz_bmz8_search(brz_data_t *brz, const char *key, cmph_uint32
|
|||
h0 = fingerprint[2] % brz->k;
|
||||
|
||||
register cmph_uint32 m = brz->size[h0];
|
||||
register cmph_uint32 n = ceil(brz->c * m);
|
||||
register cmph_uint32 n = (cmph_uint32)ceil(brz->c * m);
|
||||
register cmph_uint32 h1 = hash(brz->h1[h0], key, keylen) % n;
|
||||
register cmph_uint32 h2 = hash(brz->h2[h0], key, keylen) % n;
|
||||
register cmph_uint8 mphf_bucket;
|
||||
|
||||
if (h1 == h2 && ++h2 >= n) h2 = 0;
|
||||
mphf_bucket = brz->g[h0][h1] + brz->g[h0][h2];
|
||||
mphf_bucket = (cmph_uint8)(brz->g[h0][h1] + brz->g[h0][h2]);
|
||||
DEBUGP("key: %s h1: %u h2: %u h0: %u\n", key, h1, h2, h0);
|
||||
DEBUGP("key: %s g[h1]: %u g[h2]: %u offset[h0]: %u edges: %u\n", key, brz->g[h0][h1], brz->g[h0][h2], brz->offset[h0], brz->m);
|
||||
DEBUGP("Address: %u\n", mphf_bucket + brz->offset[h0]);
|
||||
|
@ -678,7 +678,7 @@ static cmph_uint32 brz_fch_search(brz_data_t *brz, const char *key, cmph_uint32
|
|||
register cmph_uint32 h2 = hash(brz->h2[h0], key, keylen) % m;
|
||||
register cmph_uint8 mphf_bucket = 0;
|
||||
h1 = mixh10h11h12(b, p1, p2, h1);
|
||||
mphf_bucket = (h2 + brz->g[h0][h1]) % m;
|
||||
mphf_bucket = (cmph_uint8)((h2 + brz->g[h0][h1]) % m);
|
||||
return (mphf_bucket + brz->offset[h0]);
|
||||
}
|
||||
|
||||
|
@ -799,7 +799,7 @@ void brz_pack(cmph_t *mphf, void *packed_mphf)
|
|||
n = fch_calc_b(data->c, data->size[i]);
|
||||
break;
|
||||
case CMPH_BMZ8:
|
||||
n = ceil(data->c * data->size[i]);
|
||||
n = (cmph_uint32)ceil(data->c * data->size[i]);
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
|
@ -823,13 +823,13 @@ cmph_uint32 brz_packed_size(cmph_t *mphf)
|
|||
CMPH_HASH h0_type = hash_get_type(data->h0);
|
||||
CMPH_HASH h1_type = hash_get_type(data->h1[0]);
|
||||
CMPH_HASH h2_type = hash_get_type(data->h2[0]);
|
||||
size = (2*sizeof(CMPH_ALGO) + 3*sizeof(CMPH_HASH) + hash_state_packed_size(h0_type) + sizeof(cmph_uint32) +
|
||||
size = (cmph_uint32)(2*sizeof(CMPH_ALGO) + 3*sizeof(CMPH_HASH) + hash_state_packed_size(h0_type) + sizeof(cmph_uint32) +
|
||||
sizeof(double) + sizeof(cmph_uint8)*data->k + sizeof(cmph_uint32)*data->k);
|
||||
// pointers to g_is
|
||||
#if defined (__ia64) || defined (__x86_64__)
|
||||
size += sizeof(cmph_uint64)*data->k;
|
||||
size += (cmph_uint32) sizeof(cmph_uint64)*data->k;
|
||||
#else
|
||||
size += sizeof(cmph_uint32)*data->k;
|
||||
size += (cmph_uint32) sizeof(cmph_uint32)*data->k;
|
||||
#endif
|
||||
|
||||
size += hash_state_packed_size(h1_type) * data->k;
|
||||
|
@ -844,7 +844,7 @@ cmph_uint32 brz_packed_size(cmph_t *mphf)
|
|||
n = fch_calc_b(data->c, data->size[i]);
|
||||
break;
|
||||
case CMPH_BMZ8:
|
||||
n = ceil(data->c * data->size[i]);
|
||||
n = (cmph_uint32)ceil(data->c * data->size[i]);
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
|
@ -882,7 +882,7 @@ static cmph_uint32 brz_bmz8_search_packed(cmph_uint32 *packed_mphf, const char *
|
|||
h0 = fingerprint[2] % k;
|
||||
|
||||
register cmph_uint32 m = size[h0];
|
||||
register cmph_uint32 n = ceil(c * m);
|
||||
register cmph_uint32 n = (cmph_uint32)ceil(c * m);
|
||||
|
||||
#if defined (__ia64) || defined (__x86_64__)
|
||||
register cmph_uint64 * g_is_ptr = (cmph_uint64 *)packed_mphf;
|
||||
|
@ -902,7 +902,7 @@ static cmph_uint32 brz_bmz8_search_packed(cmph_uint32 *packed_mphf, const char *
|
|||
register cmph_uint8 mphf_bucket;
|
||||
|
||||
if (h1 == h2 && ++h2 >= n) h2 = 0;
|
||||
mphf_bucket = g[h1] + g[h2];
|
||||
mphf_bucket = (cmph_uint8)(g[h1] + g[h2]);
|
||||
DEBUGP("key: %s h1: %u h2: %u h0: %u\n", key, h1, h2, h0);
|
||||
DEBUGP("Address: %u\n", mphf_bucket + offset[h0]);
|
||||
return (mphf_bucket + offset[h0]);
|
||||
|
@ -957,7 +957,7 @@ static cmph_uint32 brz_fch_search_packed(cmph_uint32 *packed_mphf, const char *k
|
|||
|
||||
register cmph_uint8 mphf_bucket = 0;
|
||||
h1 = mixh10h11h12(b, p1, p2, h1);
|
||||
mphf_bucket = (h2 + g[h1]) % m;
|
||||
mphf_bucket = (cmph_uint8)((h2 + g[h1]) % m);
|
||||
return (mphf_bucket + offset[h0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void buffer_entry_load(buffer_entry_t * buffer_entry)
|
|||
{
|
||||
free(buffer_entry->buff);
|
||||
buffer_entry->buff = (cmph_uint8 *)calloc((size_t)buffer_entry->capacity, sizeof(cmph_uint8));
|
||||
buffer_entry->nbytes = fread(buffer_entry->buff, (size_t)1, (size_t)buffer_entry->capacity, buffer_entry->fd);
|
||||
buffer_entry->nbytes = (cmph_uint32)fread(buffer_entry->buff, (size_t)1, (size_t)buffer_entry->capacity, buffer_entry->fd);
|
||||
if (buffer_entry->nbytes != buffer_entry->capacity) buffer_entry->eof = 1;
|
||||
buffer_entry->pos = 0;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ cmph_t *chd_new(cmph_config_t *mph, double c)
|
|||
|
||||
void chd_load(FILE *fd, cmph_t *mphf)
|
||||
{
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
chd_data_t *chd = (chd_data_t *)malloc(sizeof(chd_data_t));
|
||||
|
||||
DEBUGP("Loading chd mphf\n");
|
||||
|
@ -193,7 +193,7 @@ void chd_load(FILE *fd, cmph_t *mphf)
|
|||
|
||||
int chd_dump(cmph_t *mphf, FILE *fd)
|
||||
{
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
chd_data_t *data = (chd_data_t *)mphf->data;
|
||||
|
||||
__cmph_dump(mphf, fd);
|
||||
|
@ -255,7 +255,7 @@ void chd_pack(cmph_t *mphf, void *packed_mphf)
|
|||
cmph_uint32 chd_packed_size(cmph_t *mphf)
|
||||
{
|
||||
register chd_data_t *data = (chd_data_t *)mphf->data;
|
||||
return (sizeof(CMPH_ALGO) + 2*sizeof(cmph_uint32) + data->packed_cr_size + data->packed_chd_phf_size);
|
||||
return (cmph_uint32)(sizeof(CMPH_ALGO) + 2*sizeof(cmph_uint32) + data->packed_cr_size + data->packed_chd_phf_size);
|
||||
|
||||
}
|
||||
|
||||
|
|
20
src/chd_ph.c
20
src/chd_ph.c
|
@ -379,7 +379,7 @@ static inline cmph_uint8 place_bucket_probe(chd_ph_config_data_t *chd_ph, chd_ph
|
|||
{
|
||||
for(i = 0; i < size; i++) // placement
|
||||
{
|
||||
position = (item->f + ((cmph_uint64)item->h)*probe0_num + probe1_num) % chd_ph->n;
|
||||
position = (cmph_uint32)((item->f + ((cmph_uint64)item->h)*probe0_num + probe1_num) % chd_ph->n);
|
||||
if(chd_ph->occup_table[position] >= chd_ph->keys_per_bin)
|
||||
{
|
||||
break;
|
||||
|
@ -391,7 +391,7 @@ static inline cmph_uint8 place_bucket_probe(chd_ph_config_data_t *chd_ph, chd_ph
|
|||
{
|
||||
for(i = 0; i < size; i++) // placement
|
||||
{
|
||||
position = (item->f + ((cmph_uint64)item->h)*probe0_num + probe1_num) % chd_ph->n;
|
||||
position = (cmph_uint32)((item->f + ((cmph_uint64)item->h)*probe0_num + probe1_num) % chd_ph->n);
|
||||
if(GETBIT32(((cmph_uint32 *)chd_ph->occup_table), position))
|
||||
{
|
||||
break;
|
||||
|
@ -411,7 +411,7 @@ static inline cmph_uint8 place_bucket_probe(chd_ph_config_data_t *chd_ph, chd_ph
|
|||
{
|
||||
break;
|
||||
}
|
||||
position = (item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n;
|
||||
position = (cmph_uint32)((item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n);
|
||||
(chd_ph->occup_table[position])--;
|
||||
item++;
|
||||
i--;
|
||||
|
@ -424,7 +424,7 @@ static inline cmph_uint8 place_bucket_probe(chd_ph_config_data_t *chd_ph, chd_ph
|
|||
{
|
||||
break;
|
||||
}
|
||||
position = (item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n;
|
||||
position = (cmph_uint32)((item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n);
|
||||
UNSETBIT32(((cmph_uint32*)chd_ph->occup_table), position);
|
||||
|
||||
// ([position/32]^=(1<<(position%32));
|
||||
|
@ -594,7 +594,7 @@ static inline cmph_uint8 chd_ph_check_bin_hashing(chd_ph_config_data_t *chd_ph,
|
|||
for(; j > 0; j--)
|
||||
{
|
||||
m++;
|
||||
position = (item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n;
|
||||
position = (cmph_uint32)((item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n);
|
||||
if(chd_ph->keys_per_bin > 1)
|
||||
{
|
||||
if(chd_ph->occup_table[position] >= chd_ph->keys_per_bin)
|
||||
|
@ -834,7 +834,7 @@ void chd_ph_load(FILE *fd, cmph_t *mphf)
|
|||
{
|
||||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
chd_ph_data_t *chd_ph = (chd_ph_data_t *)malloc(sizeof(chd_ph_data_t));
|
||||
|
||||
DEBUGP("Loading chd_ph mphf\n");
|
||||
|
@ -865,7 +865,7 @@ int chd_ph_dump(cmph_t *mphf, FILE *fd)
|
|||
{
|
||||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
chd_ph_data_t *data = (chd_ph_data_t *)mphf->data;
|
||||
|
||||
__cmph_dump(mphf, fd);
|
||||
|
@ -914,7 +914,7 @@ cmph_uint32 chd_ph_search(cmph_t *mphf, const char *key, cmph_uint32 keylen)
|
|||
disp = compressed_seq_query(chd_ph->cs, g);
|
||||
probe0_num = disp % chd_ph->n;
|
||||
probe1_num = disp/chd_ph->n;
|
||||
position = (f + ((cmph_uint64 )h)*probe0_num + probe1_num) % chd_ph->n;
|
||||
position = (cmph_uint32)((f + ((cmph_uint64 )h)*probe0_num + probe1_num) % chd_ph->n);
|
||||
return position;
|
||||
}
|
||||
|
||||
|
@ -953,7 +953,7 @@ cmph_uint32 chd_ph_packed_size(cmph_t *mphf)
|
|||
register cmph_uint32 hash_state_pack_size = hash_state_packed_size(hl_type);
|
||||
register cmph_uint32 cs_pack_size = compressed_seq_packed_size(data->cs);
|
||||
|
||||
return (sizeof(CMPH_ALGO) + hash_state_pack_size + cs_pack_size + 3*sizeof(cmph_uint32));
|
||||
return (cmph_uint32)(sizeof(CMPH_ALGO) + hash_state_pack_size + cs_pack_size + 3*sizeof(cmph_uint32));
|
||||
|
||||
}
|
||||
|
||||
|
@ -980,7 +980,7 @@ cmph_uint32 chd_ph_search_packed(void *packed_mphf, const char *key, cmph_uint32
|
|||
disp = compressed_seq_query_packed(ptr, g);
|
||||
probe0_num = disp % n;
|
||||
probe1_num = disp/n;
|
||||
position = (f + ((cmph_uint64 )h)*probe0_num + probe1_num) % n;
|
||||
position = (cmph_uint32)((f + ((cmph_uint64 )h)*probe0_num + probe1_num) % n);
|
||||
return position;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ cmph_t *chm_new(cmph_config_t *mph, double c)
|
|||
chm_config_data_t *chm = (chm_config_data_t *)mph->data;
|
||||
chm->m = mph->key_source->nkeys;
|
||||
if (c == 0) c = 2.09;
|
||||
chm->n = ceil(c * mph->key_source->nkeys);
|
||||
chm->n = (cmph_uint32)ceil(c * mph->key_source->nkeys);
|
||||
DEBUGP("m (edges): %u n (vertices): %u c: %f\n", chm->m, chm->n, c);
|
||||
chm->graph = graph_new(chm->n, chm->m);
|
||||
DEBUGP("Created graph\n");
|
||||
|
@ -204,7 +204,7 @@ int chm_dump(cmph_t *mphf, FILE *fd)
|
|||
cmph_uint32 buflen;
|
||||
cmph_uint32 two = 2; //number of hash functions
|
||||
chm_data_t *data = (chm_data_t *)mphf->data;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
|
||||
__cmph_dump(mphf, fd);
|
||||
|
||||
|
@ -240,7 +240,7 @@ void chm_load(FILE *f, cmph_t *mphf)
|
|||
cmph_uint32 buflen;
|
||||
cmph_uint32 i;
|
||||
chm_data_t *chm = (chm_data_t *)malloc(sizeof(chm_data_t));
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
DEBUGP("Loading chm mphf\n");
|
||||
mphf->data = chm;
|
||||
nbytes = fread(&nhashes, sizeof(cmph_uint32), (size_t)1, f);
|
||||
|
@ -346,7 +346,7 @@ cmph_uint32 chm_packed_size(cmph_t *mphf)
|
|||
CMPH_HASH h1_type = hash_get_type(data->hashes[0]);
|
||||
CMPH_HASH h2_type = hash_get_type(data->hashes[1]);
|
||||
|
||||
return (sizeof(CMPH_ALGO) + hash_state_packed_size(h1_type) + hash_state_packed_size(h2_type) +
|
||||
return (cmph_uint32)(sizeof(CMPH_ALGO) + hash_state_packed_size(h1_type) + hash_state_packed_size(h2_type) +
|
||||
4*sizeof(cmph_uint32) + sizeof(cmph_uint32)*data->n);
|
||||
}
|
||||
|
||||
|
|
10
src/cmph.c
10
src/cmph.c
|
@ -75,7 +75,7 @@ static int key_nlfile_read(void *data, char **key, cmph_uint32 *keylen)
|
|||
(*key)[(*keylen) - 1] = 0;
|
||||
--(*keylen);
|
||||
}
|
||||
return *keylen;
|
||||
return (int)(*keylen);
|
||||
}
|
||||
|
||||
static int key_byte_vector_read(void *data, char **key, cmph_uint32 *keylen)
|
||||
|
@ -88,7 +88,7 @@ static int key_byte_vector_read(void *data, char **key, cmph_uint32 *keylen)
|
|||
*key = (char *)malloc(size);
|
||||
memcpy(*key, keys_vd[cmph_vector->position] + sizeof(*keylen), size);
|
||||
cmph_vector->position = cmph_vector->position + 1;
|
||||
return *keylen;
|
||||
return (int)(*keylen);
|
||||
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ static int key_struct_vector_read(void *data, char **key, cmph_uint32 *keylen)
|
|||
*key = (char *)malloc(size);
|
||||
memcpy(*key, (keys_vd + (cmph_struct_vector->position * cmph_struct_vector->struct_size) + cmph_struct_vector->key_offset), size);
|
||||
cmph_struct_vector->position = cmph_struct_vector->position + 1;
|
||||
return *keylen;
|
||||
return (int)(*keylen);
|
||||
}
|
||||
|
||||
static int key_vector_read(void *data, char **key, cmph_uint32 *keylen)
|
||||
|
@ -110,12 +110,12 @@ static int key_vector_read(void *data, char **key, cmph_uint32 *keylen)
|
|||
cmph_vector_t *cmph_vector = (cmph_vector_t *)data;
|
||||
char **keys_vd = (char **)cmph_vector->vector;
|
||||
size_t size;
|
||||
*keylen = strlen(keys_vd[cmph_vector->position]);
|
||||
*keylen = (cmph_uint32)strlen(keys_vd[cmph_vector->position]);
|
||||
size = *keylen;
|
||||
*key = (char *)malloc(size + 1);
|
||||
strcpy(*key, keys_vd[cmph_vector->position]);
|
||||
cmph_vector->position = cmph_vector->position + 1;
|
||||
return *keylen;
|
||||
return (int)(*keylen);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ void __config_destroy(cmph_config_t *mph)
|
|||
|
||||
void __cmph_dump(cmph_t *mphf, FILE *fd)
|
||||
{
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
nbytes = fwrite(cmph_names[mphf->algo], (size_t)(strlen(cmph_names[mphf->algo]) + 1), (size_t)1, fd);
|
||||
nbytes = fwrite(&(mphf->size), sizeof(mphf->size), (size_t)1, fd);
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ cmph_t *__cmph_load(FILE *f)
|
|||
char algo_name[BUFSIZ];
|
||||
char *ptr = algo_name;
|
||||
CMPH_ALGO algo = CMPH_COUNT;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
|
||||
DEBUGP("Loading mphf\n");
|
||||
while(1)
|
||||
{
|
||||
cmph_uint32 c = fread(ptr, (size_t)1, (size_t)1, f);
|
||||
size_t c = fread(ptr, (size_t)1, (size_t)1, f);
|
||||
if (c != 1) return NULL;
|
||||
if (*ptr == 0) break;
|
||||
++ptr;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
if (gettimeofday(&e_time, NULL) < 0) {
|
||||
return;
|
||||
}
|
||||
*elapsed_time = e_time.tv_sec*1000000 + e_time.tv_usec;
|
||||
*elapsed_time = (cmph_uint64)(e_time.tv_sec*1000000 + e_time.tv_usec);
|
||||
}
|
||||
static inline void dummy_elapsed_time_in_useconds()
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ void compressed_rank_generate(compressed_rank_t * cr, cmph_uint32 * vals_table,
|
|||
}
|
||||
select_vec = (cmph_uint32 *) calloc(cr->max_val >> cr->rem_r, sizeof(cmph_uint32));
|
||||
cr->vals_rems = (cmph_uint32 *) calloc(BITS_TABLE_SIZE(cr->n, cr->rem_r), sizeof(cmph_uint32));
|
||||
rems_mask = (1 << cr->rem_r) - 1;
|
||||
rems_mask = (1U << cr->rem_r) - 1U;
|
||||
|
||||
for(i = 0; i < cr->n; i++)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ cmph_uint32 compressed_rank_query(compressed_rank_t * cr, cmph_uint32 idx)
|
|||
}
|
||||
|
||||
val_quot = idx >> cr->rem_r;
|
||||
rems_mask = (1 << cr->rem_r) - 1;
|
||||
rems_mask = (1U << cr->rem_r) - 1U;
|
||||
val_rem = idx & rems_mask;
|
||||
if(val_quot == 0)
|
||||
{
|
||||
|
@ -116,20 +116,20 @@ cmph_uint32 compressed_rank_query(compressed_rank_t * cr, cmph_uint32 idx)
|
|||
cmph_uint32 compressed_rank_get_space_usage(compressed_rank_t * cr)
|
||||
{
|
||||
register cmph_uint32 space_usage = select_get_space_usage(&cr->sel);
|
||||
space_usage += BITS_TABLE_SIZE(cr->n, cr->rem_r)*sizeof(cmph_uint32)*8;
|
||||
space_usage += 3*sizeof(cmph_uint32)*8;
|
||||
space_usage += BITS_TABLE_SIZE(cr->n, cr->rem_r)*(cmph_uint32)sizeof(cmph_uint32)*8;
|
||||
space_usage += 3*(cmph_uint32)sizeof(cmph_uint32)*8;
|
||||
return space_usage;
|
||||
}
|
||||
|
||||
void compressed_rank_dump(compressed_rank_t * cr, char **buf, cmph_uint32 *buflen)
|
||||
{
|
||||
register cmph_uint32 sel_size = select_packed_size(&(cr->sel));
|
||||
register cmph_uint32 vals_rems_size = BITS_TABLE_SIZE(cr->n, cr->rem_r) * sizeof(cmph_uint32);
|
||||
register cmph_uint32 vals_rems_size = BITS_TABLE_SIZE(cr->n, cr->rem_r) * (cmph_uint32)sizeof(cmph_uint32);
|
||||
register cmph_uint32 pos = 0;
|
||||
char * buf_sel = 0;
|
||||
cmph_uint32 buflen_sel = 0;
|
||||
|
||||
*buflen = 4*sizeof(cmph_uint32) + sel_size + vals_rems_size;
|
||||
*buflen = 4*(cmph_uint32)sizeof(cmph_uint32) + sel_size + vals_rems_size;
|
||||
|
||||
DEBUGP("sel_size = %u\n", sel_size);
|
||||
DEBUGP("vals_rems_size = %u\n", vals_rems_size);
|
||||
|
@ -144,21 +144,21 @@ void compressed_rank_dump(compressed_rank_t * cr, char **buf, cmph_uint32 *bufle
|
|||
|
||||
// dumping max_val, n and rem_r
|
||||
memcpy(*buf, &(cr->max_val), sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("max_val = %u\n", cr->max_val);
|
||||
|
||||
memcpy(*buf + pos, &(cr->n), sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("n = %u\n", cr->n);
|
||||
|
||||
memcpy(*buf + pos, &(cr->rem_r), sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("rem_r = %u\n", cr->rem_r);
|
||||
|
||||
// dumping sel
|
||||
select_dump(&cr->sel, &buf_sel, &buflen_sel);
|
||||
memcpy(*buf + pos, &buflen_sel, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("buflen_sel = %u\n", buflen_sel);
|
||||
|
||||
memcpy(*buf + pos, buf_sel, buflen_sel);
|
||||
|
@ -195,20 +195,20 @@ void compressed_rank_load(compressed_rank_t * cr, const char *buf, cmph_uint32 b
|
|||
|
||||
// loading max_val, n, and rem_r
|
||||
memcpy(&(cr->max_val), buf, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("max_val = %u\n", cr->max_val);
|
||||
|
||||
memcpy(&(cr->n), buf + pos, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("n = %u\n", cr->n);
|
||||
|
||||
memcpy(&(cr->rem_r), buf + pos, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("rem_r = %u\n", cr->rem_r);
|
||||
|
||||
// loading sel
|
||||
memcpy(&buflen_sel, buf + pos, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("buflen_sel = %u\n", buflen_sel);
|
||||
|
||||
select_load(&cr->sel, buf + pos, buflen_sel);
|
||||
|
@ -259,8 +259,8 @@ void compressed_rank_pack(compressed_rank_t *cr, void *cr_packed)
|
|||
cmph_uint32 compressed_rank_packed_size(compressed_rank_t *cr)
|
||||
{
|
||||
register cmph_uint32 sel_size = select_packed_size(&cr->sel);
|
||||
register cmph_uint32 vals_rems_size = BITS_TABLE_SIZE(cr->n, cr->rem_r) * sizeof(cmph_uint32);
|
||||
return 4 * sizeof(cmph_uint32) + sel_size + vals_rems_size;
|
||||
register cmph_uint32 vals_rems_size = BITS_TABLE_SIZE(cr->n, cr->rem_r) * (cmph_uint32)sizeof(cmph_uint32);
|
||||
return 4 * (cmph_uint32)sizeof(cmph_uint32) + sel_size + vals_rems_size;
|
||||
}
|
||||
|
||||
cmph_uint32 compressed_rank_query_packed(void * cr_packed, cmph_uint32 idx)
|
||||
|
@ -288,7 +288,7 @@ cmph_uint32 compressed_rank_query_packed(void * cr_packed, cmph_uint32 idx)
|
|||
}
|
||||
|
||||
val_quot = idx >> rem_r;
|
||||
rems_mask = (1 << rem_r) - 1;
|
||||
rems_mask = (1U << rem_r) - 1U;
|
||||
val_rem = idx & rems_mask;
|
||||
if(val_quot == 0)
|
||||
{
|
||||
|
|
|
@ -77,7 +77,7 @@ void compressed_seq_generate(compressed_seq_t * cs, cmph_uint32 * vals_table, cm
|
|||
{
|
||||
if(vals_table[i] == 0)
|
||||
continue;
|
||||
stored_value = vals_table[i] - ((1 << lengths[i]) - 1);
|
||||
stored_value = vals_table[i] - ((1U << lengths[i]) - 1U);
|
||||
set_bits_at_pos(cs->store_table, cs->total_length, stored_value, lengths[i]);
|
||||
cs->total_length += lengths[i];
|
||||
};
|
||||
|
@ -96,7 +96,7 @@ void compressed_seq_generate(compressed_seq_t * cs, cmph_uint32 * vals_table, cm
|
|||
|
||||
cs->length_rems = (cmph_uint32 *) calloc(BITS_TABLE_SIZE(cs->n, cs->rem_r), sizeof(cmph_uint32));
|
||||
|
||||
rems_mask = (1 << cs->rem_r) - 1;
|
||||
rems_mask = (1U << cs->rem_r) - 1U;
|
||||
cs->total_length = 0;
|
||||
|
||||
for(i = 0; i < cs->n; i++)
|
||||
|
@ -118,9 +118,9 @@ void compressed_seq_generate(compressed_seq_t * cs, cmph_uint32 * vals_table, cm
|
|||
cmph_uint32 compressed_seq_get_space_usage(compressed_seq_t * cs)
|
||||
{
|
||||
register cmph_uint32 space_usage = select_get_space_usage(&cs->sel);
|
||||
space_usage += ((cs->total_length + 31) >> 5) * sizeof(cmph_uint32) * 8;
|
||||
space_usage += BITS_TABLE_SIZE(cs->n, cs->rem_r) * sizeof(cmph_uint32) * 8;
|
||||
return 4 * sizeof(cmph_uint32) * 8 + space_usage;
|
||||
space_usage += ((cs->total_length + 31) >> 5) * (cmph_uint32)sizeof(cmph_uint32) * 8;
|
||||
space_usage += BITS_TABLE_SIZE(cs->n, cs->rem_r) * (cmph_uint32)sizeof(cmph_uint32) * 8;
|
||||
return 4 * (cmph_uint32)sizeof(cmph_uint32) * 8 + space_usage;
|
||||
}
|
||||
|
||||
cmph_uint32 compressed_seq_query(compressed_seq_t * cs, cmph_uint32 idx)
|
||||
|
@ -132,7 +132,7 @@ cmph_uint32 compressed_seq_query(compressed_seq_t * cs, cmph_uint32 idx)
|
|||
|
||||
assert(idx < cs->n); // FABIANO ADDED
|
||||
|
||||
rems_mask = (1 << cs->rem_r) - 1;
|
||||
rems_mask = (1U << cs->rem_r) - 1U;
|
||||
|
||||
if(idx == 0)
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ cmph_uint32 compressed_seq_query(compressed_seq_t * cs, cmph_uint32 idx)
|
|||
return 0;
|
||||
|
||||
stored_value = get_bits_at_pos(cs->store_table, enc_idx, enc_length);
|
||||
return stored_value + ((1 << enc_length) - 1);
|
||||
return stored_value + ((1U << enc_length) - 1U);
|
||||
};
|
||||
|
||||
void compressed_seq_dump(compressed_seq_t * cs, char ** buf, cmph_uint32 * buflen)
|
||||
|
@ -168,7 +168,7 @@ void compressed_seq_dump(compressed_seq_t * cs, char ** buf, cmph_uint32 * bufle
|
|||
char * buf_sel = 0;
|
||||
cmph_uint32 buflen_sel = 0;
|
||||
|
||||
*buflen = 4*sizeof(cmph_uint32) + sel_size + length_rems_size + store_table_size;
|
||||
*buflen = 4*(cmph_uint32)sizeof(cmph_uint32) + sel_size + length_rems_size + store_table_size;
|
||||
|
||||
DEBUGP("sel_size = %u\n", sel_size);
|
||||
DEBUGP("length_rems_size = %u\n", length_rems_size);
|
||||
|
@ -183,22 +183,22 @@ void compressed_seq_dump(compressed_seq_t * cs, char ** buf, cmph_uint32 * bufle
|
|||
|
||||
// dumping n, rem_r and total_length
|
||||
memcpy(*buf, &(cs->n), sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("n = %u\n", cs->n);
|
||||
|
||||
memcpy(*buf + pos, &(cs->rem_r), sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("rem_r = %u\n", cs->rem_r);
|
||||
|
||||
memcpy(*buf + pos, &(cs->total_length), sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("total_length = %u\n", cs->total_length);
|
||||
|
||||
|
||||
// dumping sel
|
||||
select_dump(&cs->sel, &buf_sel, &buflen_sel);
|
||||
memcpy(*buf + pos, &buflen_sel, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("buflen_sel = %u\n", buflen_sel);
|
||||
|
||||
memcpy(*buf + pos, buf_sel, buflen_sel);
|
||||
|
@ -244,20 +244,20 @@ void compressed_seq_load(compressed_seq_t * cs, const char * buf, cmph_uint32 bu
|
|||
|
||||
// loading n, rem_r and total_length
|
||||
memcpy(&(cs->n), buf, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("n = %u\n", cs->n);
|
||||
|
||||
memcpy(&(cs->rem_r), buf + pos, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("rem_r = %u\n", cs->rem_r);
|
||||
|
||||
memcpy(&(cs->total_length), buf + pos, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("total_length = %u\n", cs->total_length);
|
||||
|
||||
// loading sel
|
||||
memcpy(&buflen_sel, buf + pos, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
DEBUGP("buflen_sel = %u\n", buflen_sel);
|
||||
|
||||
select_load(&cs->sel, buf + pos, buflen_sel);
|
||||
|
@ -324,9 +324,9 @@ void compressed_seq_pack(compressed_seq_t *cs, void *cs_packed)
|
|||
cmph_uint32 compressed_seq_packed_size(compressed_seq_t *cs)
|
||||
{
|
||||
register cmph_uint32 sel_size = select_packed_size(&cs->sel);
|
||||
register cmph_uint32 store_table_size = ((cs->total_length + 31) >> 5) * sizeof(cmph_uint32);
|
||||
register cmph_uint32 length_rems_size = BITS_TABLE_SIZE(cs->n, cs->rem_r) * sizeof(cmph_uint32);
|
||||
return 4 * sizeof(cmph_uint32) + sel_size + store_table_size + length_rems_size;
|
||||
register cmph_uint32 store_table_size = ((cs->total_length + 31) >> 5) * (cmph_uint32)sizeof(cmph_uint32);
|
||||
register cmph_uint32 length_rems_size = BITS_TABLE_SIZE(cs->n, cs->rem_r) * (cmph_uint32)sizeof(cmph_uint32);
|
||||
return 4 * (cmph_uint32)sizeof(cmph_uint32) + sel_size + store_table_size + length_rems_size;
|
||||
}
|
||||
|
||||
|
||||
|
@ -350,7 +350,7 @@ cmph_uint32 compressed_seq_query_packed(void * cs_packed, cmph_uint32 idx)
|
|||
register cmph_uint32 stored_value;
|
||||
register cmph_uint32 sel_res;
|
||||
|
||||
rems_mask = (1 << rem_r) - 1;
|
||||
rems_mask = (1U << rem_r) - 1U;
|
||||
|
||||
if(idx == 0)
|
||||
{
|
||||
|
@ -374,5 +374,5 @@ cmph_uint32 compressed_seq_query_packed(void * cs_packed, cmph_uint32 idx)
|
|||
return 0;
|
||||
|
||||
stored_value = get_bits_at_pos(store_table, enc_idx, enc_length);
|
||||
return stored_value + ((1 << enc_length) - 1);
|
||||
return stored_value + ((1U << enc_length) - 1U);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ static void permut(cmph_uint32 * vector, cmph_uint32 n)
|
|||
{
|
||||
cmph_uint32 i, j, b;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = rand() % n;
|
||||
j = (cmph_uint32) rand() % n;
|
||||
b = vector[i];
|
||||
vector[i] = vector[j];
|
||||
vector[j] = b;
|
||||
|
@ -316,7 +316,7 @@ int fch_dump(cmph_t *mphf, FILE *fd)
|
|||
{
|
||||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
|
||||
fch_data_t *data = (fch_data_t *)mphf->data;
|
||||
__cmph_dump(mphf, fd);
|
||||
|
@ -352,7 +352,7 @@ void fch_load(FILE *f, cmph_t *mphf)
|
|||
{
|
||||
char *buf = NULL;
|
||||
cmph_uint32 buflen;
|
||||
register cmph_uint32 nbytes;
|
||||
register size_t nbytes;
|
||||
fch_data_t *fch = (fch_data_t *)malloc(sizeof(fch_data_t));
|
||||
|
||||
//DEBUGP("Loading fch mphf\n");
|
||||
|
@ -474,7 +474,7 @@ cmph_uint32 fch_packed_size(cmph_t *mphf)
|
|||
CMPH_HASH h1_type = hash_get_type(data->h1);
|
||||
CMPH_HASH h2_type = hash_get_type(data->h2);
|
||||
|
||||
return (sizeof(CMPH_ALGO) + hash_state_packed_size(h1_type) + hash_state_packed_size(h2_type) +
|
||||
return (cmph_uint32)(sizeof(CMPH_ALGO) + hash_state_packed_size(h1_type) + hash_state_packed_size(h2_type) +
|
||||
4*sizeof(cmph_uint32) + 2*sizeof(double) + sizeof(cmph_uint32)*(data->b));
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ static void fch_bucket_insert(fch_bucket_t *bucket, char *val, cmph_uint32 val_l
|
|||
static cmph_uint8 fch_bucket_is_empty(fch_bucket_t *bucket)
|
||||
{
|
||||
assert(bucket);
|
||||
return bucket->size == 0;
|
||||
return (cmph_uint8)(bucket->size == 0);
|
||||
}
|
||||
|
||||
static cmph_uint32 fch_bucket_size(fch_bucket_t *bucket)
|
||||
|
@ -183,7 +183,7 @@ cmph_uint32 * fch_buckets_get_indexes_sorted_by_size(fch_buckets_t * buckets)
|
|||
// calculating offset considering a decreasing order of buckets size.
|
||||
value = nbuckets_size[buckets->max_size];
|
||||
nbuckets_size[buckets->max_size] = sum;
|
||||
for(i = buckets->max_size - 1; i >= 0; i--)
|
||||
for(i = (int)buckets->max_size - 1; i >= 0; i--)
|
||||
{
|
||||
sum += value;
|
||||
value = nbuckets_size[i];
|
||||
|
@ -192,7 +192,7 @@ cmph_uint32 * fch_buckets_get_indexes_sorted_by_size(fch_buckets_t * buckets)
|
|||
}
|
||||
for(i = 0; i < buckets->nbuckets; i++)
|
||||
{
|
||||
sorted_indexes[nbuckets_size[fch_bucket_size(buckets->values + i)]] = i;
|
||||
sorted_indexes[nbuckets_size[fch_bucket_size(buckets->values + i)]] = (cmph_uint32)i;
|
||||
nbuckets_size[fch_bucket_size(buckets->values + i)] ++;
|
||||
}
|
||||
free(nbuckets_size);
|
||||
|
|
14
src/graph.c
14
src/graph.c
|
@ -172,10 +172,10 @@ void graph_clear_edges(graph_t *g)
|
|||
g->shrinking = 0;
|
||||
}
|
||||
|
||||
static int find_degree1_edge(graph_t *g, cmph_uint32 v, char *deleted, cmph_uint32 *e)
|
||||
static cmph_uint8 find_degree1_edge(graph_t *g, cmph_uint32 v, cmph_uint8 *deleted, cmph_uint32 *e)
|
||||
{
|
||||
cmph_uint32 edge = g->first[v];
|
||||
char found = 0;
|
||||
cmph_uint8 found = 0;
|
||||
DEBUGP("Checking degree of vertex %u\n", v);
|
||||
if (edge == EMPTY) return 0;
|
||||
else if (!(GETBIT(deleted, abs_edge(edge, 0))))
|
||||
|
@ -196,11 +196,11 @@ static int find_degree1_edge(graph_t *g, cmph_uint32 v, char *deleted, cmph_uint
|
|||
return found;
|
||||
}
|
||||
|
||||
static void cyclic_del_edge(graph_t *g, cmph_uint32 v, char *deleted)
|
||||
static void cyclic_del_edge(graph_t *g, cmph_uint32 v, cmph_uint8 *deleted)
|
||||
{
|
||||
|
||||
cmph_uint32 e = 0;
|
||||
char degree1;
|
||||
cmph_uint8 degree1;
|
||||
cmph_uint32 v1 = v;
|
||||
cmph_uint32 v2 = 0;
|
||||
|
||||
|
@ -229,7 +229,7 @@ int graph_is_cyclic(graph_t *g)
|
|||
{
|
||||
cmph_uint32 i;
|
||||
cmph_uint32 v;
|
||||
char *deleted = (char *)malloc((g->nedges*sizeof(char))/8 + 1);
|
||||
cmph_uint8 *deleted = (cmph_uint8 *)malloc((g->nedges*sizeof(cmph_uint8))/8 + 1);
|
||||
size_t deleted_len = g->nedges/8 + 1;
|
||||
memset(deleted, 0, deleted_len);
|
||||
|
||||
|
@ -253,14 +253,14 @@ int graph_is_cyclic(graph_t *g)
|
|||
|
||||
cmph_uint8 graph_node_is_critical(graph_t * g, cmph_uint32 v) /* included -- Fabiano */
|
||||
{
|
||||
return GETBIT(g->critical_nodes,v);
|
||||
return (cmph_uint8)GETBIT(g->critical_nodes,v);
|
||||
}
|
||||
|
||||
void graph_obtain_critical_nodes(graph_t *g) /* included -- Fabiano*/
|
||||
{
|
||||
cmph_uint32 i;
|
||||
cmph_uint32 v;
|
||||
char *deleted = (char *)malloc((g->nedges*sizeof(char))/8+1);
|
||||
cmph_uint8 *deleted = (cmph_uint8 *)malloc((g->nedges*sizeof(cmph_uint8))/8+1);
|
||||
size_t deleted_len = g->nedges/8 + 1;
|
||||
memset(deleted, 0, deleted_len);
|
||||
free(g->critical_nodes);
|
||||
|
|
|
@ -88,7 +88,7 @@ jenkins_state_t *jenkins_state_new(cmph_uint32 size) //size of hash table
|
|||
{
|
||||
jenkins_state_t *state = (jenkins_state_t *)malloc(sizeof(jenkins_state_t));
|
||||
DEBUGP("Initializing jenkins hash\n");
|
||||
state->seed = rand() % size;
|
||||
state->seed = ((cmph_uint32)rand() % size);
|
||||
return state;
|
||||
}
|
||||
void jenkins_state_destroy(jenkins_state_t *state)
|
||||
|
@ -110,9 +110,9 @@ inline void __jenkins_hash_vector(cmph_uint32 seed, const char *k, cmph_uint32 k
|
|||
/*---------------------------------------- handle most of the key */
|
||||
while (len >= 12)
|
||||
{
|
||||
hashes[0] += (k[0] +((cmph_uint32)k[1]<<8) +((cmph_uint32)k[2]<<16) +((cmph_uint32)k[3]<<24));
|
||||
hashes[1] += (k[4] +((cmph_uint32)k[5]<<8) +((cmph_uint32)k[6]<<16) +((cmph_uint32)k[7]<<24));
|
||||
hashes[2] += (k[8] +((cmph_uint32)k[9]<<8) +((cmph_uint32)k[10]<<16)+((cmph_uint32)k[11]<<24));
|
||||
hashes[0] += ((cmph_uint32)k[0] +((cmph_uint32)k[1]<<8) +((cmph_uint32)k[2]<<16) +((cmph_uint32)k[3]<<24));
|
||||
hashes[1] += ((cmph_uint32)k[4] +((cmph_uint32)k[5]<<8) +((cmph_uint32)k[6]<<16) +((cmph_uint32)k[7]<<24));
|
||||
hashes[2] += ((cmph_uint32)k[8] +((cmph_uint32)k[9]<<8) +((cmph_uint32)k[10]<<16)+((cmph_uint32)k[11]<<24));
|
||||
mix(hashes[0],hashes[1],hashes[2]);
|
||||
k += 12; len -= 12;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ inline void __jenkins_hash_vector(cmph_uint32 seed, const char *k, cmph_uint32 k
|
|||
case 6 :
|
||||
hashes[1] +=((cmph_uint32)k[5]<<8);
|
||||
case 5 :
|
||||
hashes[1] +=k[4];
|
||||
hashes[1] +=(cmph_uint8) k[4];
|
||||
case 4 :
|
||||
hashes[0] +=((cmph_uint32)k[3]<<24);
|
||||
case 3 :
|
||||
|
@ -143,7 +143,7 @@ inline void __jenkins_hash_vector(cmph_uint32 seed, const char *k, cmph_uint32 k
|
|||
case 2 :
|
||||
hashes[0] +=((cmph_uint32)k[1]<<8);
|
||||
case 1 :
|
||||
hashes[0] +=k[0];
|
||||
hashes[0] +=(cmph_uint8)k[0];
|
||||
/* case 0: nothing left to add */
|
||||
}
|
||||
|
||||
|
|
12
src/main.c
12
src/main.c
|
@ -85,14 +85,14 @@ int main(int argc, char **argv)
|
|||
cmph_uint32 keys_per_bin = 1;
|
||||
while (1)
|
||||
{
|
||||
char ch = getopt(argc, argv, "hVvgc:k:a:M:b:t:f:m:d:s:");
|
||||
char ch = (char)getopt(argc, argv, "hVvgc:k:a:M:b:t:f:m:d:s:");
|
||||
if (ch == -1) break;
|
||||
switch (ch)
|
||||
{
|
||||
case 's':
|
||||
{
|
||||
char *cptr;
|
||||
seed = strtoul(optarg, &cptr, 10);
|
||||
seed = (cmph_uint32)strtoul(optarg, &cptr, 10);
|
||||
if(*cptr != 0) {
|
||||
fprintf(stderr, "Invalid seed %s\n", optarg);
|
||||
exit(1);
|
||||
|
@ -115,7 +115,7 @@ int main(int argc, char **argv)
|
|||
case 'k':
|
||||
{
|
||||
char *endptr;
|
||||
nkeys = strtoul(optarg, &endptr, 10);
|
||||
nkeys = (cmph_uint32)strtoul(optarg, &endptr, 10);
|
||||
if(*endptr != 0) {
|
||||
fprintf(stderr, "Invalid number of keys %s\n", optarg);
|
||||
exit(1);
|
||||
|
@ -131,7 +131,7 @@ int main(int argc, char **argv)
|
|||
case 'M':
|
||||
{
|
||||
char *cptr;
|
||||
memory_availability = strtoul(optarg, &cptr, 10);
|
||||
memory_availability = (cmph_uint32)strtoul(optarg, &cptr, 10);
|
||||
if(*cptr != 0) {
|
||||
fprintf(stderr, "Invalid memory availability %s\n", optarg);
|
||||
exit(1);
|
||||
|
@ -141,7 +141,7 @@ int main(int argc, char **argv)
|
|||
case 'b':
|
||||
{
|
||||
char *cptr;
|
||||
b = strtoul(optarg, &cptr, 10);
|
||||
b = (cmph_uint32)strtoul(optarg, &cptr, 10);
|
||||
if(*cptr != 0) {
|
||||
fprintf(stderr, "Parameter b was not found: %s\n", optarg);
|
||||
exit(1);
|
||||
|
@ -151,7 +151,7 @@ int main(int argc, char **argv)
|
|||
case 't':
|
||||
{
|
||||
char *cptr;
|
||||
keys_per_bin = strtoul(optarg, &cptr, 10);
|
||||
keys_per_bin = (cmph_uint32)strtoul(optarg, &cptr, 10);
|
||||
if(*cptr != 0) {
|
||||
fprintf(stderr, "Parameter t was not found: %s\n", optarg);
|
||||
exit(1);
|
||||
|
|
30
src/select.c
30
src/select.c
|
@ -52,8 +52,8 @@ cmph_uint32 select_get_space_usage(select_t * sel)
|
|||
sel_table_size = (sel->n >> NBITS_STEP_SELECT_TABLE) + 1; // (sel->n >> NBITS_STEP_SELECT_TABLE) = (sel->n/STEP_SELECT_TABLE)
|
||||
|
||||
space_usage = 2 * sizeof(cmph_uint32) * 8; // n and m
|
||||
space_usage += vec_size * sizeof(cmph_uint32) * 8;
|
||||
space_usage += sel_table_size * sizeof(cmph_uint32) * 8;
|
||||
space_usage += vec_size * (cmph_uint32) sizeof(cmph_uint32) * 8;
|
||||
space_usage += sel_table_size * (cmph_uint32)sizeof(cmph_uint32) * 8;
|
||||
return space_usage;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ static inline cmph_uint32 _select_next_query(cmph_uint8 * bits_table, cmph_uint3
|
|||
|
||||
vec_byte_idx = vec_bit_idx >> 3;
|
||||
|
||||
one_idx = rank_lookup_table[bits_table[vec_byte_idx] & ((1 << (vec_bit_idx & 0x7)) - 1)] + 1;
|
||||
one_idx = rank_lookup_table[bits_table[vec_byte_idx] & ((1U << (vec_bit_idx & 0x7)) - 1U)] + 1U;
|
||||
part_sum = 0;
|
||||
|
||||
do
|
||||
|
@ -222,11 +222,11 @@ cmph_uint32 select_next_query(select_t * sel, cmph_uint32 vec_bit_idx)
|
|||
void select_dump(select_t *sel, char **buf, cmph_uint32 *buflen)
|
||||
{
|
||||
register cmph_uint32 nbits = sel->n + sel->m;
|
||||
register cmph_uint32 vec_size = ((nbits + 31) >> 5) * sizeof(cmph_uint32); // (nbits + 31) >> 5 = (nbits + 31)/32
|
||||
register cmph_uint32 sel_table_size = ((sel->n >> NBITS_STEP_SELECT_TABLE) + 1) * sizeof(cmph_uint32); // (sel->n >> NBITS_STEP_SELECT_TABLE) = (sel->n/STEP_SELECT_TABLE)
|
||||
register cmph_uint32 vec_size = ((nbits + 31) >> 5) * (cmph_uint32)sizeof(cmph_uint32); // (nbits + 31) >> 5 = (nbits + 31)/32
|
||||
register cmph_uint32 sel_table_size = ((sel->n >> NBITS_STEP_SELECT_TABLE) + 1) * (cmph_uint32)sizeof(cmph_uint32); // (sel->n >> NBITS_STEP_SELECT_TABLE) = (sel->n/STEP_SELECT_TABLE)
|
||||
register cmph_uint32 pos = 0;
|
||||
|
||||
*buflen = 2*sizeof(cmph_uint32) + vec_size + sel_table_size;
|
||||
*buflen = 2*(cmph_uint32)sizeof(cmph_uint32) + vec_size + sel_table_size;
|
||||
|
||||
*buf = (char *)calloc(*buflen, sizeof(char));
|
||||
|
||||
|
@ -237,9 +237,9 @@ void select_dump(select_t *sel, char **buf, cmph_uint32 *buflen)
|
|||
}
|
||||
|
||||
memcpy(*buf, &(sel->n), sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
memcpy(*buf + pos, &(sel->m), sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
memcpy(*buf + pos, sel->bits_vec, vec_size);
|
||||
pos += vec_size;
|
||||
memcpy(*buf + pos, sel->select_table, sel_table_size);
|
||||
|
@ -255,13 +255,13 @@ void select_load(select_t * sel, const char *buf, cmph_uint32 buflen)
|
|||
register cmph_uint32 sel_table_size = 0;
|
||||
|
||||
memcpy(&(sel->n), buf, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
memcpy(&(sel->m), buf + pos, sizeof(cmph_uint32));
|
||||
pos += sizeof(cmph_uint32);
|
||||
pos += (cmph_uint32)sizeof(cmph_uint32);
|
||||
|
||||
nbits = sel->n + sel->m;
|
||||
vec_size = ((nbits + 31) >> 5) * sizeof(cmph_uint32); // (nbits + 31) >> 5 = (nbits + 31)/32
|
||||
sel_table_size = ((sel->n >> NBITS_STEP_SELECT_TABLE) + 1) * sizeof(cmph_uint32); // (sel->n >> NBITS_STEP_SELECT_TABLE) = (sel->n/STEP_SELECT_TABLE)
|
||||
vec_size = ((nbits + 31) >> 5) * (cmph_uint32)sizeof(cmph_uint32); // (nbits + 31) >> 5 = (nbits + 31)/32
|
||||
sel_table_size = ((sel->n >> NBITS_STEP_SELECT_TABLE) + 1) * (cmph_uint32)sizeof(cmph_uint32); // (sel->n >> NBITS_STEP_SELECT_TABLE) = (sel->n/STEP_SELECT_TABLE)
|
||||
|
||||
if(sel->bits_vec)
|
||||
{
|
||||
|
@ -308,9 +308,9 @@ void select_pack(select_t *sel, void *sel_packed)
|
|||
cmph_uint32 select_packed_size(select_t *sel)
|
||||
{
|
||||
register cmph_uint32 nbits = sel->n + sel->m;
|
||||
register cmph_uint32 vec_size = ((nbits + 31) >> 5) * sizeof(cmph_uint32); // (nbits + 31) >> 5 = (nbits + 31)/32
|
||||
register cmph_uint32 sel_table_size = ((sel->n >> NBITS_STEP_SELECT_TABLE) + 1) * sizeof(cmph_uint32); // (sel->n >> NBITS_STEP_SELECT_TABLE) = (sel->n/STEP_SELECT_TABLE)
|
||||
return 2*sizeof(cmph_uint32) + vec_size + sel_table_size;
|
||||
register cmph_uint32 vec_size = ((nbits + 31) >> 5) * (cmph_uint32)sizeof(cmph_uint32); // (nbits + 31) >> 5 = (nbits + 31)/32
|
||||
register cmph_uint32 sel_table_size = ((sel->n >> NBITS_STEP_SELECT_TABLE) + 1) * (cmph_uint32)sizeof(cmph_uint32); // (sel->n >> NBITS_STEP_SELECT_TABLE) = (sel->n/STEP_SELECT_TABLE)
|
||||
return 2*(cmph_uint32)sizeof(cmph_uint32) + vec_size + sel_table_size;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,13 +15,13 @@ vqueue_t * vqueue_new(cmph_uint32 capacity)
|
|||
assert(q);
|
||||
q->values = (cmph_uint32 *)calloc(capacity_plus_one, sizeof(cmph_uint32));
|
||||
q->beg = q->end = 0;
|
||||
q->capacity = capacity_plus_one;
|
||||
q->capacity = (cmph_uint32) capacity_plus_one;
|
||||
return q;
|
||||
}
|
||||
|
||||
cmph_uint8 vqueue_is_empty(vqueue_t * q)
|
||||
{
|
||||
return (q->beg == q->end);
|
||||
return (cmph_uint8)(q->beg == q->end);
|
||||
}
|
||||
|
||||
void vqueue_insert(vqueue_t * q, cmph_uint32 val)
|
||||
|
|
|
@ -48,14 +48,14 @@ int main(int argc, char **argv)
|
|||
cmph_io_adapter_t *source;
|
||||
while (1)
|
||||
{
|
||||
char ch = getopt(argc, argv, "hVvk:m:");
|
||||
char ch = (char)getopt(argc, argv, "hVvk:m:");
|
||||
if (ch == -1) break;
|
||||
switch (ch)
|
||||
{
|
||||
case 'k':
|
||||
{
|
||||
char *endptr;
|
||||
nkeys = strtoul(optarg, &endptr, 10);
|
||||
nkeys = (cmph_uint32) strtoul(optarg, &endptr, 10);
|
||||
if(*endptr != 0) {
|
||||
fprintf(stderr, "Invalid number of keys %s\n", optarg);
|
||||
exit(1);
|
||||
|
|
|
@ -53,14 +53,14 @@ int main(int argc, char **argv)
|
|||
|
||||
while (1)
|
||||
{
|
||||
char ch = getopt(argc, argv, "hVvt:k:m:");
|
||||
char ch = (char)getopt(argc, argv, "hVvt:k:m:");
|
||||
if (ch == -1) break;
|
||||
switch (ch)
|
||||
{
|
||||
case 'k':
|
||||
{
|
||||
char *endptr;
|
||||
nkeys = strtoul(optarg, &endptr, 10);
|
||||
nkeys = (cmph_uint32)strtoul(optarg, &endptr, 10);
|
||||
if(*endptr != 0) {
|
||||
fprintf(stderr, "Invalid number of keys %s\n", optarg);
|
||||
exit(1);
|
||||
|
@ -76,7 +76,7 @@ int main(int argc, char **argv)
|
|||
case 't':
|
||||
{
|
||||
char *cptr;
|
||||
keys_per_bin = strtoul(optarg, &cptr, 10);
|
||||
keys_per_bin = (cmph_uint32)strtoul(optarg, &cptr, 10);
|
||||
if(*cptr != 0) {
|
||||
fprintf(stderr, "Parameter t was not found: %s\n", optarg);
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue