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

#4288 port ptquery to bdb refs[t:4288]

git-svn-id: file:///svn/toku/tokudb@39164 c7de825b-a66e-492c-adef-691d508d4ae1
parent caf02a8a
...@@ -74,7 +74,7 @@ else ...@@ -74,7 +74,7 @@ else
build: build.tdb build.bdb; build: build.tdb build.bdb;
endif endif
build.bdb: $(TARGET_BDB) $(SCANSCAN_BDB) $(WINDOWS_BDB_LIB_NAME) $(TXNCOMMIT_BDB) build.bdb: $(TARGET_BDB) $(SCANSCAN_BDB) $(WINDOWS_BDB_LIB_NAME) $(PTQUERY_BDB) $(TXNCOMMIT_BDB)
build.tdb: $(TARGET_TDB) $(SCANSCAN_TDB) $(MULTIBENCH_TDB) $(PTQUERY_TDB) $(TXNCOMMIT_TDB) build.tdb: $(TARGET_TDB) $(SCANSCAN_TDB) $(MULTIBENCH_TDB) $(PTQUERY_TDB) $(TXNCOMMIT_TDB)
check: check-default check-default-small check-rowsize check-xfast check-x check-x-small check-no-rollback check-4G child.benchmark.dir check: check-default check-default-small check-rowsize check-xfast check-x check-x-small check-no-rollback check-4G child.benchmark.dir
...@@ -192,6 +192,8 @@ $(SCANSCAN_BDB): scanscan.c ...@@ -192,6 +192,8 @@ $(SCANSCAN_BDB): scanscan.c
$(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST) $(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
$(TXNCOMMIT_BDB): txncommit.c $(TXNCOMMIT_BDB): txncommit.c
$(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST) $(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
$(PTQUERY_BDB): ptquery.c
$(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
PARGS = PARGS =
ptest%: $(TARGET_TDB) ptest%: $(TARGET_TDB)
......
//#include <stdbool.h>
//#include "test.h"
//#include "toku_pthread.h"
#include <toku_portability.h> #include <toku_portability.h>
#include "tokudb_common_funcs.h" #include "tokudb_common_funcs.h"
#include <toku_pthread.h>
#include <toku_assert.h> #include <toku_assert.h>
#include <db.h> #include <db.h>
#include <errno.h> #include <errno.h>
...@@ -11,20 +8,14 @@ ...@@ -11,20 +8,14 @@
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#ifdef TOKUDB
#include "key.h"
#include "cachetable.h"
#include "trace_mem.h"
#endif
static DB_ENV *env = NULL; static DB_ENV *env = NULL;
static DB *db = NULL; static DB *db = NULL;
static DB_TXN *tid= NULL;
#define STRINGIFY2(s) #s #define STRINGIFY2(s) #s
#define STRINGIFY(s) STRINGIFY2(s) #define STRINGIFY(s) STRINGIFY2(s)
static 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. */
static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK|DB_RECOVER; static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK|DB_RECOVER|DB_THREAD;
// static 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;
static char *dbfilename = "bench.db"; static char *dbfilename = "bench.db";
static u_int64_t cachesize = 127*1024*1024; static u_int64_t cachesize = 127*1024*1024;
...@@ -43,7 +34,7 @@ static void pt_query_setup (void) { ...@@ -43,7 +34,7 @@ static void pt_query_setup (void) {
} }
r = env->open(env, dbdir, env_open_flags_yesx, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); assert(r==0); r = env->open(env, dbdir, env_open_flags_yesx, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); assert(r==0);
r = db_create(&db, env, 0); assert(r==0); r = db_create(&db, env, 0); assert(r==0);
r = db->open(db, tid, dbfilename, NULL, DB_BTREE, 0, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); assert(r==0); r = db->open(db, NULL, dbfilename, NULL, DB_BTREE, DB_THREAD|DB_AUTO_COMMIT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); assert(r==0);
} }
static void pt_query_shutdown (void) { static void pt_query_shutdown (void) {
...@@ -66,24 +57,23 @@ static double gettime (void) { ...@@ -66,24 +57,23 @@ static double gettime (void) {
/* From db-benchmark-test.c */ /* From db-benchmark-test.c */
static void long_long_to_array (unsigned char *a, int array_size, unsigned long long l) { static void long_long_to_array (unsigned char *a, int array_size, unsigned long long l) {
int i; for (int i=0; i<8 && i<array_size; i++)
for (i=0; i<8 && i<array_size; i++)
a[i] = (l>>(56-8*i))&0xff; a[i] = (l>>(56-8*i))&0xff;
} }
static void array_to_long_long (unsigned long long *l, unsigned char *a, int array_size) { static void array_to_long_long (unsigned long long *l, unsigned char *a, int array_size) {
int i;
*l = 0; *l = 0;
unsigned long long tmp; for(int i=0; i<8 && i<array_size; i++) {
for(i=0; i<8 && i<array_size; i++) { unsigned long long tmp = a[i] & 0xff;
tmp = a[i] & 0xff;
*l += tmp << (56-8*i); *l += tmp << (56-8*i);
} }
} }
#if TOKUDB
static int do_nothing (DBT const* UU(key), DBT const* UU(data), void* UU(extrav)) { static int do_nothing (DBT const* UU(key), DBT const* UU(data), void* UU(extrav)) {
return TOKUDB_CURSOR_CONTINUE; return TOKUDB_CURSOR_CONTINUE;
} }
#endif
static void test_begin_commit(int _nqueries) { static void test_begin_commit(int _nqueries) {
int r; int r;
...@@ -99,10 +89,13 @@ static void test_begin_commit(int _nqueries) { ...@@ -99,10 +89,13 @@ static void test_begin_commit(int _nqueries) {
k = ( k / SERIAL_SPACING ) * SERIAL_SPACING; k = ( k / SERIAL_SPACING ) * SERIAL_SPACING;
long_long_to_array(kv, keylen, k); long_long_to_array(kv, keylen, k);
DBT key, val; DBT key = { .data = kv, .size = 8 };
memset(&key, 0, sizeof key); key.data=kv; key.size=8; DBT val = { .data = NULL, .size = 0 };
memset(&val, 0, sizeof val); #if TOKUDB
r = c->c_getf_set(c, 0, &key, do_nothing, NULL); r = c->c_getf_set(c, 0, &key, do_nothing, &val);
#else
r = c->c_get(c, &key, &val, DB_SET);
#endif
assert_zero(r); assert_zero(r);
(void) __sync_fetch_and_add(&set_count, 1); (void) __sync_fetch_and_add(&set_count, 1);
r = c->c_close(c); assert_zero(r); r = c->c_close(c); assert_zero(r);
...@@ -117,17 +110,19 @@ static void warmup(void) { ...@@ -117,17 +110,19 @@ static void warmup(void) {
int r; int r;
DB_TXN *txn=NULL; DB_TXN *txn=NULL;
DBC *c = NULL; DBC *c = NULL;
DBT key, val; DBT key = { .data = NULL };
DBT val = { .data = NULL };
double tstart = gettime(); double tstart = gettime();
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
r = env->txn_begin(env, NULL, &txn, 0); assert_zero(r); r = env->txn_begin(env, NULL, &txn, 0); assert_zero(r);
r = db->cursor(db, txn, &c, 0); assert_zero(r); r = db->cursor(db, txn, &c, 0); assert_zero(r);
r = c->c_get(c, &key, &val, DB_FIRST); assert_zero(r); r = c->c_get(c, &key, &val, DB_FIRST); assert_zero(r);
assert(key.size == 8); assert(key.size == 8);
while ( r != DB_NOTFOUND ) { while ( r != DB_NOTFOUND ) {
#if TOKUDB
r = c->c_getf_next(c, DB_PRELOCKED, do_nothing, NULL); r = c->c_getf_next(c, DB_PRELOCKED, do_nothing, NULL);
#else
r = c->c_get(c, &key, &val, DB_NEXT);
#endif
if ( r != 0 && r != DB_NOTFOUND) assert_zero(r); if ( r != 0 && r != DB_NOTFOUND) assert_zero(r);
} }
memset(&key, 0, sizeof key); memset(&key, 0, sizeof key);
......
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