Remaining part of the fix for bug 3465649. This one fixes both BRZ and
CHD_PH for small key sets.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
noinst_PROGRAMS = vector_adapter_ex1 file_adapter_ex2 struct_vector_adapter_ex3 small_set_test
|
||||
noinst_PROGRAMS = vector_adapter_ex1 file_adapter_ex2 struct_vector_adapter_ex3 small_set_ex4
|
||||
|
||||
INCLUDES = -I../src/
|
||||
|
||||
@@ -11,5 +11,5 @@ file_adapter_ex2_SOURCES = file_adapter_ex2.c
|
||||
struct_vector_adapter_ex3_LDADD = ../src/libcmph.la
|
||||
struct_vector_adapter_ex3_SOURCES = struct_vector_adapter_ex3.c
|
||||
|
||||
small_set_test_LDADD = ../src/libcmph.la
|
||||
small_set_test_SOURCES = small_set_test.c
|
||||
small_set_ex4_LDADD = ../src/libcmph.la
|
||||
small_set_ex4_SOURCES = small_set_ex4.c
|
||||
|
||||
@@ -6,6 +6,8 @@ int test(cmph_uint32* items_to_hash, cmph_uint32 items_len, CMPH_ALGO alg_n)
|
||||
cmph_config_t *config;
|
||||
cmph_io_adapter_t *source;
|
||||
cmph_uint32 i;
|
||||
char filename[256];
|
||||
FILE* mphf_fd = NULL;
|
||||
|
||||
printf("%s (%u)\n", cmph_names[alg_n], alg_n);
|
||||
|
||||
@@ -16,9 +18,21 @@ int test(cmph_uint32* items_to_hash, cmph_uint32 items_len, CMPH_ALGO alg_n)
|
||||
items_len);
|
||||
config = cmph_config_new(source);
|
||||
cmph_config_set_algo(config, alg_n);
|
||||
if (alg_n == CMPH_BRZ) {
|
||||
sprintf(filename, "%s_%u.mph", cmph_names[alg_n], items_len);
|
||||
mphf_fd = fopen(filename, "w");
|
||||
cmph_config_set_mphf_fd(config, mphf_fd);
|
||||
}
|
||||
hash = cmph_new(config);
|
||||
cmph_config_destroy(config);
|
||||
|
||||
if (alg_n == CMPH_BRZ) {
|
||||
cmph_dump(hash, mphf_fd);
|
||||
cmph_destroy(hash);
|
||||
fclose(mphf_fd);
|
||||
mphf_fd = fopen(filename, "r");
|
||||
hash = cmph_load(mphf_fd);
|
||||
}
|
||||
printf("packed_size %u\n",cmph_packed_size(hash));
|
||||
|
||||
for (i=0; i<items_len; ++i)
|
||||
@@ -30,7 +44,11 @@ int test(cmph_uint32* items_to_hash, cmph_uint32 items_len, CMPH_ALGO alg_n)
|
||||
printf("\n");
|
||||
|
||||
cmph_io_vector_adapter_destroy(source);
|
||||
cmph_destroy(hash);
|
||||
cmph_destroy(hash);
|
||||
|
||||
if (alg_n == CMPH_BRZ) {
|
||||
fclose(mphf_fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -43,6 +61,8 @@ int main (void)
|
||||
cmph_uint32 vec2_len = 2;
|
||||
cmph_uint32 vec3[] = {2184764, 1882984, 1170551}; // CMPH_CHD_PH, CMPH_CHD (7,8)
|
||||
cmph_uint32 vec3_len = 3;
|
||||
cmph_uint32 vec4[] = {2184764}; // CMPH_CHD_PH, CMPH_CHD (7,8)
|
||||
cmph_uint32 vec4_len = 1;
|
||||
cmph_uint32 i;
|
||||
|
||||
// Testing with vec1
|
||||
@@ -63,7 +83,7 @@ int main (void)
|
||||
test(values, length, i);
|
||||
}
|
||||
|
||||
// Testing with vec2
|
||||
// Testing with vec3
|
||||
values = (cmph_uint32*)vec3;
|
||||
length = vec3_len;
|
||||
printf("TESTING VECTOR WITH %u INTEGERS\n", length);
|
||||
@@ -72,5 +92,14 @@ int main (void)
|
||||
test(values, length, i);
|
||||
}
|
||||
|
||||
// Testing with vec4
|
||||
values = (cmph_uint32*)vec4;
|
||||
length = vec4_len;
|
||||
printf("TESTING VECTOR WITH %u INTEGERS\n", length);
|
||||
for (i = 0; i < CMPH_COUNT; i++)
|
||||
{
|
||||
test(values, length, i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user