Stable version of BRZ algorithm with option -M (memory_availability)
This commit is contained in:
20
src/main.c
20
src/main.c
@@ -22,12 +22,12 @@
|
||||
|
||||
void usage(const char *prg)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-v] [-h] [-V] [-k nkeys] [-f hash_function] [-g [-c value][-s seed] ] [-a algorithm] [-d tmp_dir] [-m file.mph] keysfile\n", prg);
|
||||
fprintf(stderr, "usage: %s [-v] [-h] [-V] [-k nkeys] [-f hash_function] [-g [-c value][-s seed] ] [-a algorithm] [-M memory_in_MB] [-d tmp_dir] [-m file.mph] keysfile\n", prg);
|
||||
}
|
||||
void usage_long(const char *prg)
|
||||
{
|
||||
cmph_uint32 i;
|
||||
fprintf(stderr, "usage: %s [-v] [-h] [-V] [-k nkeys] [-f hash_function] [-g [-c value][-s seed] ] [-a algorithm] [-d tmp_dir] [-m file.mph] keysfile\n", prg);
|
||||
fprintf(stderr, "usage: %s [-v] [-h] [-V] [-k nkeys] [-f hash_function] [-g [-c value][-s seed] ] [-a algorithm] [-M memory_in_MB] [-d tmp_dir] [-m file.mph] keysfile\n", prg);
|
||||
fprintf(stderr, "Minimum perfect hashing tool\n\n");
|
||||
fprintf(stderr, " -h\t print this help message\n");
|
||||
fprintf(stderr, " -c\t c value that determines the number of vertices in the graph\n");
|
||||
@@ -41,6 +41,7 @@ void usage_long(const char *prg)
|
||||
fprintf(stderr, " -g\t generation mode\n");
|
||||
fprintf(stderr, " -s\t random seed\n");
|
||||
fprintf(stderr, " -m\t minimum perfect hash function file \n");
|
||||
fprintf(stderr, " -M\t main memory availability (in MB)\n");
|
||||
fprintf(stderr, " -d\t temporary directory used in brz algorithm \n");
|
||||
fprintf(stderr, " keysfile\t line separated file with keys\n");
|
||||
}
|
||||
@@ -65,10 +66,10 @@ int main(int argc, char **argv)
|
||||
cmph_t *mphf = NULL;
|
||||
cmph_uint8 * tmp_dir = NULL;
|
||||
cmph_io_adapter_t *source;
|
||||
|
||||
cmph_uint32 memory_availability = 0;
|
||||
while (1)
|
||||
{
|
||||
char ch = getopt(argc, argv, "hVvgc:k:a:f:m:d:s:");
|
||||
char ch = getopt(argc, argv, "hVvgc:k:a:M:f:m:d:s:");
|
||||
if (ch == -1) break;
|
||||
switch (ch)
|
||||
{
|
||||
@@ -111,6 +112,16 @@ int main(int argc, char **argv)
|
||||
case 'd':
|
||||
tmp_dir = strdup(optarg);
|
||||
break;
|
||||
case 'M':
|
||||
{
|
||||
char *cptr;
|
||||
memory_availability = strtoul(optarg, &cptr, 10);
|
||||
if(*cptr != 0) {
|
||||
fprintf(stderr, "Invalid memory availability %s\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
++verbosity;
|
||||
break;
|
||||
@@ -202,6 +213,7 @@ int main(int argc, char **argv)
|
||||
if (nhashes) cmph_config_set_hashfuncs(config, hashes);
|
||||
cmph_config_set_verbosity(config, verbosity);
|
||||
cmph_config_set_tmp_dir(config, tmp_dir);
|
||||
cmph_config_set_memory_availability(config, memory_availability);
|
||||
if(mph_algo == CMPH_BMZ && c >= 2.0) c=1.15;
|
||||
if (c != 0) cmph_config_set_graphsize(config, c);
|
||||
mphf = cmph_new(config);
|
||||
|
||||
Reference in New Issue
Block a user