Commit ebde8ef4 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#2865 refs[t:2865] remove heaviside from scanscan.c

git-svn-id: file:///svn/toku/tokudb@22836 c7de825b-a66e-492c-adef-691d508d4ae1
parent 37fbff8b
......@@ -17,7 +17,7 @@
#endif
const char *pname;
enum run_mode { RUN_HWC, RUN_LWC, RUN_VERIFY, RUN_HEAVI, RUN_RANGE, RUN_FLATTEN} run_mode = RUN_HWC;
enum run_mode { RUN_HWC, RUN_LWC, RUN_VERIFY, RUN_RANGE, RUN_FLATTEN} run_mode = RUN_HWC;
int do_txns=1, prelock=0, prelockflag=0;
u_int32_t lock_flag = 0;
long limitcount=-1;
......@@ -32,7 +32,6 @@ static const char *log_dir = NULL;
static int print_usage (const char *argv0) {
fprintf(stderr, "Usage:\n%s [--verify-lwc | --lwc | --nohwc] [--prelock] [--prelockflag] [--prelockwriteflag] [--env DIR] [--verbose]\n", argv0);
fprintf(stderr, " --hwc run heavy weight cursors (this is the default)\n");
fprintf(stderr, " --verify-lwc means to run the light weight cursor and the heavyweight cursor to verify that they get the same answer.\n");
fprintf(stderr, " --flatten Flatten only using special flatten function\n");
fprintf(stderr, " --lwc run light weight cursors instead of heavy weight cursors\n");
......@@ -92,10 +91,6 @@ static void parse_args (int argc, char *const argv[]) {
run_mode = RUN_HWC;
} else if (strcmp(*argv, "--prelock")==0) prelock=1;
#ifdef TOKUDB
else if (strcmp(*argv, "--heavi")==0) {
if (specified_run_mode && run_mode!=RUN_HEAVI) goto two_modes;
run_mode = RUN_HEAVI;
}
else if (strcmp(*argv, "--prelockflag")==0) { prelockflag=1; lock_flag = DB_PRELOCKED; }
else if (strcmp(*argv, "--prelockwriteflag")==0) { prelockflag=1; lock_flag = DB_PRELOCKED_WRITE; }
#endif
......@@ -390,99 +385,9 @@ static void scanscan_range (void) {
}
#ifdef TOKUDB
struct extra_heavi {
long long totalbytes;
int rowcounter;
DBT key;
DBT val;
};
static int
copy_dbt(DBT *target, DBT const *source) {
int r;
if (target->ulen < source->size) {
target->data = realloc(target->data, source->size);
target->ulen = source->size;
}
if (!target->data) r = ENOMEM;
else {
target->size = source->size;
memcpy(target->data, source->data, target->size);
r = 0;
}
return r;
}
typedef struct foo{int a; } FOO;
static int
heaviside_next(const DBT *key, const DBT *val, void *extra_h) {
struct extra_heavi *e=extra_h;
int cmp;
cmp = toku_builtin_compare_fun(db, key, &e->key);
if (cmp != 0) return cmp;
if (val) cmp = toku_builtin_compare_fun(db, val, &e->val);
if (cmp != 0) return cmp;
return -1; //Return negative on <=, positive on >
}
static int copy_and_counttotalbytes (DBT const *key, DBT const *val, void *extrav, int r_h) {
assert(r_h>0);
struct extra_heavi *e=extrav;
e->totalbytes += key->size + val->size;
e->rowcounter++;
int r;
r = copy_dbt(&e->key, key);
if (r==0) r = copy_dbt(&e->val, val);
return r;
}
static void scanscan_heaviside (void) {
int r;
int counter=0;
for (counter=0; counter<n_experiments; counter++) {
struct extra_heavi e;
memset(&e, 0, sizeof(e));
e.key.flags = DB_DBT_REALLOC;
e.val.flags = DB_DBT_REALLOC;
double prevtime = gettime();
DBC *dbc;
r = db->cursor(db, tid, &dbc, 0); assert(r==0);
u_int32_t f_flags = 0;
if (prelockflag && (counter || prelock)) {
f_flags |= lock_flag;
}
//Get first manually.
long rowcounter=1;
r = dbc->c_get(dbc, &e.key, &e.val, DB_FIRST | f_flags); assert(r==0);
e.rowcounter = 1;
e.totalbytes = e.key.size + e.val.size;
while (0 == (r = dbc->c_getf_heaviside(dbc, f_flags,
copy_and_counttotalbytes, &e,
heaviside_next, &e,
1))) {
rowcounter++;
if (limitcount>0 && rowcounter>=limitcount) break;
}
assert(rowcounter==e.rowcounter);
if (e.key.data) {
free(e.key.data);
e.key.data = NULL;
}
if (e.val.data) {
free(e.val.data);
e.val.data = NULL;
}
r = dbc->c_close(dbc); assert(r==0);
double thistime = gettime();
double tdiff = thistime-prevtime;
printf("LWC Scan %lld bytes (%d rows) in %9.6fs at %9fMB/s\n", e.totalbytes, e.rowcounter, tdiff, 1e-6*e.totalbytes/tdiff);
print_engine_status();
}
}
struct extra_verify {
long long totalbytes;
int rowcounter;
......@@ -552,7 +457,6 @@ static int test_main (int argc, char *const argv[]) {
case RUN_LWC: scanscan_lwc(); break;
case RUN_FLATTEN: scanscan_flatten(); break;
case RUN_VERIFY: scanscan_verify(); break;
case RUN_HEAVI: scanscan_heaviside(); break;
#endif
case RUN_RANGE: scanscan_range(); break;
default: assert(0); break;
......@@ -560,10 +464,6 @@ static int test_main (int argc, char *const argv[]) {
scanscan_shutdown();
#if defined(TOKUDB)
if (verbose) {
toku_cachetable_print_hash_histogram();
}
// if tokudb has tracing enabled (see trace_mem.h) then this will dump
// the trace data
if (0) {
......
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