Commit e11af557 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@22837 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6e3ae69a
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <sys/time.h> #include <sys/time.h>
const char *pname; const char *pname;
enum run_mode { RUN_HWC, RUN_LWC, RUN_VERIFY, RUN_HEAVI, RUN_RANGE} run_mode = RUN_HWC; enum run_mode { RUN_HWC, RUN_LWC, RUN_VERIFY, RUN_RANGE} run_mode = RUN_HWC;
int do_txns=1, prelock=0, prelockflag=0; int do_txns=1, prelock=0, prelockflag=0;
u_int32_t lock_flag = 0; u_int32_t lock_flag = 0;
long limitcount=-1; long limitcount=-1;
...@@ -35,7 +35,6 @@ static int n_experiments = 2; ...@@ -35,7 +35,6 @@ static int n_experiments = 2;
static int print_usage (const char *argv0) { static int print_usage (const char *argv0) {
fprintf(stderr, "Usage:\n%s [--verify-lwc | --lwc | --nohwc] [--prelock] [--prelockflag] [--prelockwriteflag] [--env DIR]\n", argv0); fprintf(stderr, "Usage:\n%s [--verify-lwc | --lwc | --nohwc] [--prelock] [--prelockflag] [--prelockwriteflag] [--env DIR]\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, " --verify-lwc means to run the light weight cursor and the heavyweight cursor to verify that they get the same answer.\n");
fprintf(stderr, " --lwc run light weight cursors instead of heavy weight cursors\n"); fprintf(stderr, " --lwc run light weight cursors instead of heavy weight cursors\n");
fprintf(stderr, " --prelock acquire a read lock on the entire table before running\n"); fprintf(stderr, " --prelock acquire a read lock on the entire table before running\n");
...@@ -77,10 +76,6 @@ static void parse_args (int argc, const char *argv[]) { ...@@ -77,10 +76,6 @@ static void parse_args (int argc, const char *argv[]) {
run_mode = RUN_HWC; run_mode = RUN_HWC;
} else if (strcmp(*argv, "--prelock")==0) prelock=1; } else if (strcmp(*argv, "--prelock")==0) prelock=1;
#ifdef TOKUDB #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, "--prelockflag")==0) { prelockflag=1; lock_flag = DB_PRELOCKED; }
else if (strcmp(*argv, "--prelockwriteflag")==0) { prelockflag=1; lock_flag = DB_PRELOCKED_WRITE; } else if (strcmp(*argv, "--prelockwriteflag")==0) { prelockflag=1; lock_flag = DB_PRELOCKED_WRITE; }
#endif #endif
...@@ -298,97 +293,6 @@ static void scanscan_range (void) { ...@@ -298,97 +293,6 @@ static void scanscan_range (void) {
} }
#ifdef TOKUDB #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);
}
}
struct extra_verify { struct extra_verify {
long long totalbytes; long long totalbytes;
...@@ -457,7 +361,6 @@ int main (int argc, const char *argv[]) { ...@@ -457,7 +361,6 @@ int main (int argc, const char *argv[]) {
#ifdef TOKUDB #ifdef TOKUDB
case RUN_LWC: scanscan_lwc(); break; case RUN_LWC: scanscan_lwc(); break;
case RUN_VERIFY: scanscan_verify(); break; case RUN_VERIFY: scanscan_verify(); break;
case RUN_HEAVI: scanscan_heaviside(); break;
#endif #endif
case RUN_RANGE: scanscan_range(); break; case RUN_RANGE: scanscan_range(); break;
default: assert(0); break; default: assert(0); break;
......
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