Commit 357a2ae1 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

[t:5077] add a comparison function that compares 8 byte ints. closes #5077.


git-svn-id: file:///svn/toku/tokudb@44885 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5e21f028
......@@ -44,6 +44,6 @@ test_main(int argc, char *const argv[]) {
struct cli_args args = get_default_args_for_perf();
args.num_elements = 0; // want to start with empty DBs
parse_stress_test_args(argc, argv, &args);
stress_test_main(&args);
stress_test_main_with_cmp(&args, stress_uint64_dbt_cmp);
return 0;
}
......@@ -2063,19 +2063,37 @@ static void
stress_table(DB_ENV *, DB **, struct cli_args *);
static int
stress_int_dbt_cmp (DB *db, const DBT *a, const DBT *b) {
assert(db && a && b);
assert(a->size >= sizeof(int));
assert(b->size >= sizeof(int));
UU() stress_int_dbt_cmp (DB *db, const DBT *a, const DBT *b) {
assert(db && a && b);
assert(a->size >= sizeof(int));
assert(b->size >= sizeof(int));
int x = *(int *) a->data;
int y = *(int *) b->data;
int x = *(int *) a->data;
int y = *(int *) b->data;
if (x<y) return -1;
if (x>y) return 1;
return 0;
}
static int
UU() stress_uint64_dbt_cmp(DB *db, const DBT *a, const DBT *b) {
assert(db && a && b);
assert(a->size >= sizeof(uint64_t));
assert(b->size >= sizeof(uint64_t));
int x = *(uint64_t *) a->data;
int y = *(uint64_t *) b->data;
if (x < y) {
return -1;
}
if (x > y) {
return +1;
}
return 0;
}
static void
do_warm_cache(DB_ENV *env, DB **dbs, struct cli_args *args)
......@@ -2096,7 +2114,7 @@ do_warm_cache(DB_ENV *env, DB **dbs, struct cli_args *args)
}
static void
stress_test_main(struct cli_args *args)
UU() stress_test_main_with_cmp(struct cli_args *args, int (*bt_compare)(DB *, const DBT *, const DBT *))
{
{ char *loc = setlocale(LC_NUMERIC, "en_US.UTF-8"); assert(loc); }
DB_ENV* env = NULL;
......@@ -2107,7 +2125,7 @@ stress_test_main(struct cli_args *args)
&env,
dbs,
args->num_DBs,
stress_int_dbt_cmp,
bt_compare,
args->env_args
);
{ int chk_r = fill_tables_with_zeroes(dbs, args->num_DBs, args->num_elements, args->key_size, args->val_size); CKERR(chk_r); }
......@@ -2117,7 +2135,7 @@ stress_test_main(struct cli_args *args)
{ int chk_r = open_tables(&env,
dbs,
args->num_DBs,
stress_int_dbt_cmp,
bt_compare,
args->env_args); CKERR(chk_r); }
if (args->warm_cache) {
do_warm_cache(env, dbs, args);
......@@ -2127,6 +2145,12 @@ stress_test_main(struct cli_args *args)
}
}
static void
UU() stress_test_main(struct cli_args *args)
{
stress_test_main_with_cmp(args, stress_int_dbt_cmp);
}
static void
UU() stress_recover(struct cli_args *args) {
DB_ENV* env = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment