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

#3870 add bulk_fetch to the release/examples closes[t:3870]

git-svn-id: file:///svn/toku/tokudb@33961 c7de825b-a66e-492c-adef-691d508d4ae1
parent f2f7d31f
...@@ -16,15 +16,16 @@ ...@@ -16,15 +16,16 @@
#include "trace_mem.h" #include "trace_mem.h"
#endif #endif
const char *pname; static const char *pname;
enum run_mode { RUN_HWC, RUN_LWC, RUN_VERIFY, RUN_RANGE, RUN_FLATTEN} run_mode = RUN_HWC; static 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; static int do_txns=1, prelock=0, prelockflag=0;
u_int32_t lock_flag = 0; static u_int32_t lock_flag = 0;
long limitcount=-1; static long limitcount=-1;
u_int32_t cachesize = 127*1024*1024; static u_int32_t cachesize = 127*1024*1024;
static int do_mysql = 0; static int do_mysql = 0;
static u_int64_t start_range = 0, end_range = 0; static u_int64_t start_range = 0, end_range = 0;
static int n_experiments = 2; static int n_experiments = 2;
static int bulk_fetch = 1;
static int verbose = 0; static int verbose = 0;
static const char *log_dir = NULL; static const char *log_dir = NULL;
...@@ -49,19 +50,20 @@ static int print_usage (const char *argv0) { ...@@ -49,19 +50,20 @@ static int print_usage (const char *argv0) {
fprintf(stderr, " --srandom N srandom(N)\n"); fprintf(stderr, " --srandom N srandom(N)\n");
fprintf(stderr, " --recover run recovery\n"); fprintf(stderr, " --recover run recovery\n");
fprintf(stderr, " --verbose print verbose information\n"); fprintf(stderr, " --verbose print verbose information\n");
fprintf(stderr, " --bulk_fetch 0|1 do bulk fetch on lwc operations (default: 1)\n");
return 1; return 1;
} }
DB_ENV *env; static DB_ENV *env;
DB *db; static DB *db;
DB_TXN *tid=0; static DB_TXN *tid = NULL;
#define STRINGIFY2(s) #s #define STRINGIFY2(s) #s
#define STRINGIFY(s) STRINGIFY2(s) #define STRINGIFY(s) STRINGIFY2(s)
const char *dbdir = "./bench." STRINGIFY(DIRSUF); /* DIRSUF is passed in as a -D argument to the compiler. */ static const char *dbdir = "./bench." STRINGIFY(DIRSUF); /* DIRSUF is passed in as a -D argument to the compiler. */
int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK; static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK;
int env_open_flags_nox = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL; static int env_open_flags_nox = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL;
char *dbfilename = "bench.db"; static char *dbfilename = "bench.db";
static double gettime (void) { static double gettime (void) {
struct timeval tv; struct timeval tv;
...@@ -131,6 +133,9 @@ static void parse_args (int argc, char *const argv[]) { ...@@ -131,6 +133,9 @@ static void parse_args (int argc, char *const argv[]) {
} else if (strcmp(*argv, "--recover") == 0) { } else if (strcmp(*argv, "--recover") == 0) {
env_open_flags_yesx |= DB_RECOVER; env_open_flags_yesx |= DB_RECOVER;
env_open_flags_nox |= DB_RECOVER; env_open_flags_nox |= DB_RECOVER;
} else if (strcmp(*argv, "--bulk_fetch") == 0 && argc > 1) {
argc--; argv++;
bulk_fetch = atoi(*argv);
} else { } else {
exit(print_usage(pname)); exit(print_usage(pname));
} }
...@@ -283,8 +288,7 @@ static int counttotalbytes (DBT const *key, DBT const *data, void *extrav) { ...@@ -283,8 +288,7 @@ static int counttotalbytes (DBT const *key, DBT const *data, void *extrav) {
printf("%s:%d %"PRIu64" %"PRIu64"\n", __FUNCTION__, __LINE__, k, expect_key); printf("%s:%d %"PRIu64" %"PRIu64"\n", __FUNCTION__, __LINE__, k, expect_key);
expect_key = k + 1; expect_key = k + 1;
} }
return TOKUDB_CURSOR_CONTINUE; return bulk_fetch ? TOKUDB_CURSOR_CONTINUE : 0;
//return 0;
} }
static void scanscan_lwc (void) { static void scanscan_lwc (void) {
......
...@@ -24,14 +24,15 @@ ...@@ -24,14 +24,15 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/time.h> #include <sys/time.h>
const char *pname; static const char *pname;
enum run_mode { RUN_HWC, RUN_LWC, RUN_VERIFY, RUN_RANGE} run_mode = RUN_HWC; static enum run_mode { RUN_HWC, RUN_LWC, RUN_VERIFY, RUN_RANGE} run_mode = RUN_HWC;
int do_txns=1, prelock=0, prelockflag=0; static int do_txns=1, prelock=0, prelockflag=0;
u_int32_t lock_flag = 0; static u_int32_t lock_flag = 0;
long limitcount=-1; static long limitcount=-1;
u_int32_t cachesize = 127*1024*1024; static u_int32_t cachesize = 127*1024*1024;
static u_int64_t start_range = 0, end_range = 0; static u_int64_t start_range = 0, end_range = 0;
static int n_experiments = 2; static int n_experiments = 2;
static int bulk_fetch = 1;
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);
...@@ -45,19 +46,20 @@ static int print_usage (const char *argv0) { ...@@ -45,19 +46,20 @@ static int print_usage (const char *argv0) {
fprintf(stderr, " --cachesize N set the env cachesize to N bytes\n"); fprintf(stderr, " --cachesize N set the env cachesize to N bytes\n");
fprintf(stderr, " --srandom N srandom(N)\n"); fprintf(stderr, " --srandom N srandom(N)\n");
fprintf(stderr, " --env DIR put db files in DIR instead of default\n"); fprintf(stderr, " --env DIR put db files in DIR instead of default\n");
fprintf(stderr, " --bulk_fetch 0|1 do bulk fetch on lwc operations (default: 1)\n");
return 1; return 1;
} }
DB_ENV *env; static DB_ENV *env;
DB *db; static DB *db;
DB_TXN *tid=0; static DB_TXN *tid=0;
#define STRINGIFY2(s) #s #define STRINGIFY2(s) #s
#define STRINGIFY(s) STRINGIFY2(s) #define STRINGIFY(s) STRINGIFY2(s)
const char *dbdir = "./bench." STRINGIFY(DIRSUF); /* DIRSUF is passed in as a -D argument to the compiler. */ static const char *dbdir = "./bench." STRINGIFY(DIRSUF); /* DIRSUF is passed in as a -D argument to the compiler. */
int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK; static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK;
int env_open_flags_nox = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL; static int env_open_flags_nox = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL;
char *dbfilename = "bench.db"; static char *dbfilename = "bench.db";
static void parse_args (int argc, const char *argv[]) { static void parse_args (int argc, const char *argv[]) {
...@@ -105,6 +107,9 @@ static void parse_args (int argc, const char *argv[]) { ...@@ -105,6 +107,9 @@ static void parse_args (int argc, const char *argv[]) {
} else if (strcmp(*argv, "--srandom") == 0 && argc > 1) { } else if (strcmp(*argv, "--srandom") == 0 && argc > 1) {
argc--; argv++; argc--; argv++;
srandom(atoi(*argv)); srandom(atoi(*argv));
} else if (strcmp(*argv, "--bulk_fetch") == 0 && argc > 1) {
argc--; argv++;
bulk_fetch = atoi(*argv);
} else { } else {
exit(print_usage(pname)); exit(print_usage(pname));
} }
...@@ -195,7 +200,7 @@ static int counttotalbytes (DBT const *key, DBT const *data, void *extrav) { ...@@ -195,7 +200,7 @@ static int counttotalbytes (DBT const *key, DBT const *data, void *extrav) {
struct extra_count *e=extrav; struct extra_count *e=extrav;
e->totalbytes += key->size + data->size; e->totalbytes += key->size + data->size;
e->rowcounter++; e->rowcounter++;
return 0; return bulk_fetch ? TOKUDB_CURSOR_CONTINUE : 0;
} }
static void scanscan_lwc (void) { static void scanscan_lwc (void) {
......
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