Commit 18b6bfaa authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Implement {{{DBC->c_getf_next}}}, with a simple test. Addresses #902.

git-svn-id: file:///svn/tokudb@4452 c7de825b-a66e-492c-adef-691d508d4ae1
parent 8f641a56
......@@ -92,6 +92,7 @@ typedef enum {
#define DB_SET_RANGE 32
#define DB_CURRENT_BINDING 253
#define DB_RMW 1073741824
#define DB_PRELOCKED 0x00800000
#define DB_DBT_APPMALLOC 1
#define DB_TXN_WRITE_NOSYNC 524288
#define DB_TXN_NOWAIT 2048
......@@ -176,13 +177,13 @@ struct __toku_db {
void* __toku_dummy1[28];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=236 size=4, 64=bit offset=376 size=8 */
const DBT* (*dbt_pos_infty)(void);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=260 size=4, 64=bit offset=424 size=8 */
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=264 size=4, 64=bit offset=432 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
const DBT* (*dbt_neg_infty)(void);
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
void* __toku_dummy4[1];
int (*fd) (DB *, int *); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=284 size=4, 64=bit offset=472 size=8 */
......@@ -239,16 +240,17 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
void* __toku_dummy0[19];
int (*c_getf_next)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
void* __toku_dummy0[18];
char __toku_dummy1[104];
int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=272 size=8 */
int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=280 size=8 */
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=196 size=4, 64=bit offset=288 size=8 */
void* __toku_dummy2[1];
int (*c_getf_next_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */
int (*c_pget) (DBC *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=208 size=4, 64=bit offset=312 size=8 */
int (*c_put) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=212 size=4, 64=bit offset=320 size=8 */
void* __toku_dummy3[9]; /* Padding at the end */
void* __toku_dummy2[9]; /* Padding at the end */
};
struct __toku_dbt {
void*data; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
......
......@@ -93,6 +93,7 @@ typedef enum {
#define DB_SET_RANGE 30
#define DB_CURRENT_BINDING 253
#define DB_RMW 536870912
#define DB_PRELOCKED 0x00800000
#define DB_DBT_APPMALLOC 1
#define DB_LOG_AUTOREMOVE 65536
#define DB_TXN_WRITE_NOSYNC 268435456
......@@ -186,13 +187,13 @@ struct __toku_db {
void* __toku_dummy1[31];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=248 size=4, 64=bit offset=400 size=8 */
const DBT* (*dbt_pos_infty)(void);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=272 size=4, 64=bit offset=448 size=8 */
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=276 size=4, 64=bit offset=456 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
const DBT* (*dbt_neg_infty)(void);
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
void* __toku_dummy4[2];
int (*fd) (DB *, int *); /* 32-bit offset=296 size=4, 64=bit offset=496 size=8 */
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t); /* 32-bit offset=300 size=4, 64=bit offset=504 size=8 */
......@@ -255,16 +256,17 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
void* __toku_dummy0[17];
int (*c_getf_next)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
void* __toku_dummy0[16];
char __toku_dummy1[112];
int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=264 size=8 */
int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=272 size=8 */
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=196 size=4, 64=bit offset=280 size=8 */
void* __toku_dummy2[1];
int (*c_getf_next_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=296 size=8 */
int (*c_pget) (DBC *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=208 size=4, 64=bit offset=304 size=8 */
int (*c_put) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=212 size=4, 64=bit offset=312 size=8 */
void* __toku_dummy3[8]; /* Padding at the end */
void* __toku_dummy2[8]; /* Padding at the end */
};
struct __toku_dbt {
void*data; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
......
......@@ -93,6 +93,7 @@ typedef enum {
#define DB_SET_RANGE 30
#define DB_CURRENT_BINDING 253
#define DB_RMW 536870912
#define DB_PRELOCKED 0x00800000
#define DB_DBT_APPMALLOC 1
#define DB_LOG_AUTOREMOVE 262144
#define DB_TXN_WRITE_NOSYNC 1024
......@@ -188,11 +189,11 @@ struct __toku_db {
void* __toku_dummy1[33];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */
const DBT* (*dbt_pos_infty)(void);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=276 size=4, 64=bit offset=456 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
const DBT* (*dbt_neg_infty)(void);
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=288 size=4, 64=bit offset=480 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=292 size=4, 64=bit offset=488 size=8 */
void* __toku_dummy4[2];
......@@ -258,16 +259,17 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
void* __toku_dummy0[19];
int (*c_getf_next)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
void* __toku_dummy0[18];
char __toku_dummy1[104];
int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=272 size=8 */
int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=280 size=8 */
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=196 size=4, 64=bit offset=288 size=8 */
void* __toku_dummy2[1];
int (*c_getf_next_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */
int (*c_pget) (DBC *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=208 size=4, 64=bit offset=312 size=8 */
int (*c_put) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=212 size=4, 64=bit offset=320 size=8 */
void* __toku_dummy3[8]; /* Padding at the end */
void* __toku_dummy2[8]; /* Padding at the end */
};
struct __toku_dbt {
void*data; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
......
......@@ -93,6 +93,7 @@ typedef enum {
#define DB_SET_RANGE 27
#define DB_CURRENT_BINDING 253
#define DB_RMW 1073741824
#define DB_PRELOCKED 0x00800000
#define DB_DBT_APPMALLOC 1
#define DB_LOG_AUTOREMOVE 524288
#define DB_TXN_WRITE_NOSYNC 2048
......@@ -187,11 +188,11 @@ struct __toku_db {
void* __toku_dummy1[36];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
const DBT* (*dbt_pos_infty)(void);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=288 size=4, 64=bit offset=480 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=292 size=4, 64=bit offset=488 size=8 */
const DBT* (*dbt_neg_infty)(void);
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=300 size=4, 64=bit offset=504 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=304 size=4, 64=bit offset=512 size=8 */
void* __toku_dummy4[2];
......@@ -257,16 +258,17 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
void* __toku_dummy0[23];
int (*c_getf_next)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
void* __toku_dummy0[22];
char __toku_dummy1[104];
int (*c_close) (DBC *); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */
int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=208 size=4, 64=bit offset=312 size=8 */
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=212 size=4, 64=bit offset=320 size=8 */
void* __toku_dummy2[1];
int (*c_getf_next_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=220 size=4, 64=bit offset=336 size=8 */
int (*c_pget) (DBC *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=224 size=4, 64=bit offset=344 size=8 */
int (*c_put) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=228 size=4, 64=bit offset=352 size=8 */
void* __toku_dummy3[8]; /* Padding at the end */
void* __toku_dummy2[8]; /* Padding at the end */
};
struct __toku_dbt {
void*data; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
......
......@@ -11,9 +11,9 @@ extern "C" {
#define TOKUDB 1
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 6
#define DB_VERSION_PATCH 19
#define DB_VERSION_PATCH 21
#ifndef _TOKUDB_WRAP_H
#define DB_VERSION_STRING "Tokutek: TokuDB 4.6.19"
#define DB_VERSION_STRING "Tokutek: TokuDB 4.6.21"
#else
#define DB_VERSION_STRING_ydb "Tokutek: TokuDB (wrapped bdb)"
#endif
......@@ -94,6 +94,7 @@ typedef enum {
#define DB_SET_RANGE 27
#define DB_CURRENT_BINDING 253
#define DB_RMW 1073741824
#define DB_PRELOCKED 0x00800000
#define DB_DBT_APPMALLOC 1
#define DB_DBT_MULTIPLE 16
#define DB_LOG_AUTOREMOVE 524288
......@@ -191,11 +192,11 @@ struct __toku_db {
void* __toku_dummy2[41];
char __toku_dummy3[80];
void *api_internal; /* 32-bit offset=276 size=4, 64=bit offset=464 size=8 */
const DBT* (*dbt_pos_infty)(void);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
void* __toku_dummy4[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=296 size=4, 64=bit offset=504 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=300 size=4, 64=bit offset=512 size=8 */
const DBT* (*dbt_neg_infty)(void);
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=308 size=4, 64=bit offset=528 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=312 size=4, 64=bit offset=536 size=8 */
void* __toku_dummy5[3];
......@@ -262,16 +263,17 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
void* __toku_dummy0[33];
int (*c_getf_next)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
void* __toku_dummy0[32];
char __toku_dummy1[104];
int (*c_close) (DBC *); /* 32-bit offset=244 size=4, 64=bit offset=384 size=8 */
int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=248 size=4, 64=bit offset=392 size=8 */
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=252 size=4, 64=bit offset=400 size=8 */
void* __toku_dummy2[1];
int (*c_getf_next_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=260 size=4, 64=bit offset=416 size=8 */
int (*c_pget) (DBC *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=264 size=4, 64=bit offset=424 size=8 */
int (*c_put) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=268 size=4, 64=bit offset=432 size=8 */
void* __toku_dummy3[8]; /* Padding at the end */
void* __toku_dummy2[8]; /* Padding at the end */
};
struct __toku_dbt {
void*data; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
......
......@@ -111,6 +111,7 @@ void print_defines (void) {
dodefine(DB_SET_RANGE);
printf("#define DB_CURRENT_BINDING 253\n"); // private tokudb
dodefine(DB_RMW);
printf("#define DB_PRELOCKED 0x00800000\n"); // private tokudb
dodefine(DB_DBT_APPMALLOC);
#ifdef DB_DBT_MULTIPLE
......@@ -301,12 +302,14 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
print_struct("db_lsn", 0, db_lsn_fields32, db_lsn_fields64, sizeof(db_lsn_fields32)/sizeof(db_lsn_fields32[0]), 0);
assert(sizeof(db_fields32)==sizeof(db_fields64));
const char *extra[]={"int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact)",
"int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*)",
"const DBT* (*dbt_pos_infty)(void)",
"const DBT* (*dbt_neg_infty)(void)",
NULL};
print_struct("db", 1, db_fields32, db_fields64, sizeof(db_fields32)/sizeof(db_fields32[0]), extra);
{
const char *extra[]={"int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact)",
"int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*)",
"const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/",
"const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/",
NULL};
print_struct("db", 1, db_fields32, db_fields64, sizeof(db_fields32)/sizeof(db_fields32[0]), extra);
}
assert(sizeof(db_txn_active_fields32)==sizeof(db_txn_active_fields64));
print_struct("db_txn_active", 0, db_txn_active_fields32, db_txn_active_fields64, sizeof(db_txn_active_fields32)/sizeof(db_txn_active_fields32[0]), 0);
......@@ -316,8 +319,20 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
assert(sizeof(db_txn_stat_fields32)==sizeof(db_txn_stat_fields64));
print_struct("db_txn_stat", 0, db_txn_stat_fields32, db_txn_stat_fields64, sizeof(db_txn_stat_fields32)/sizeof(db_txn_stat_fields32[0]), 0);
assert(sizeof(dbc_fields32)==sizeof(dbc_fields64));
print_struct("dbc", 1, dbc_fields32, dbc_fields64, sizeof(dbc_fields32)/sizeof(dbc_fields32[0]), 0);
{
const char *extra[]={"int (*c_getf_next)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
"int (*c_getf_next_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
"int (*c_getf_next_no_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
"int (*c_getf_prev)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
"int (*c_getf_prev_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
"int (*c_getf_prev_no_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
"int (*c_getf_current)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
"int (*c_getf_first)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
"int (*c_getf_last)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *)",
NULL};
assert(sizeof(dbc_fields32)==sizeof(dbc_fields64));
print_struct("dbc", 1, dbc_fields32, dbc_fields64, sizeof(dbc_fields32)/sizeof(dbc_fields32[0]), extra);
}
assert(sizeof(dbt_fields32)==sizeof(dbt_fields64));
print_struct("dbt", 0, dbt_fields32, dbt_fields64, sizeof(dbt_fields32)/sizeof(dbt_fields32[0]), 0);
......
......@@ -5,12 +5,12 @@
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <unistd.h>
DB_ENV *env;
DB *db;
DB_TXN *tid=0;
DBC *dbc;
#define STRINGIFY2(s) #s
#define STRINGIFY(s) STRINGIFY2(s)
......@@ -33,12 +33,10 @@ void setup (void) {
r = env->txn_begin(env, 0, &tid, 0); assert(r==0);
#endif
r = db->open(db, tid, dbfilename, NULL, DB_BTREE, 0, 0644); assert(r==0);
r = db->cursor(db, tid, &dbc, 0); assert(r==0);
}
void shutdown (void) {
int r;
r = dbc->c_close(dbc); assert(r==0);
r = db->close(db, 0); assert(r==0);
#ifdef TXNS
r = tid->commit(tid, 0); assert(r==0);
......@@ -65,34 +63,136 @@ void scanscan (void) {
int rowcounter=0;
double prevtime = gettime();
DBT k,v;
DBC *dbc;
r = db->cursor(db, tid, &dbc, 0); assert(r==0);
memset(&k, 0, sizeof(k));
memset(&v, 0, sizeof(v));
r = dbc->c_get(dbc, &k, &v, DB_FIRST);
if (r!=DB_NOTFOUND) {
while (0 == (r = dbc->c_get(dbc, &k, &v, DB_NEXT))) {
totalbytes += k.size + v.size;
rowcounter++;
assert(r==0);
while (1) {
r = dbc->c_get(dbc, &k, &v, DB_NEXT);
if (r==DB_NOTFOUND) {
break;
}
assert(r==0);
totalbytes += k.size + v.size;
rowcounter++;
}
}
r = dbc->c_close(dbc); assert(r==0);
double thistime = gettime();
double tdiff = thistime-prevtime;
printf("Scan %lld bytes (%d rows) in %9.6fs at %9fMB/s\n", totalbytes, rowcounter, tdiff, 1e-6*totalbytes/tdiff);
printf("Scan %lld bytes (%d rows) in %9.6fs at %9fMB/s\n", totalbytes, rowcounter, tdiff, 1e-6*totalbytes/tdiff);
}
}
int main (int argc, char *argv[]) {
argc=argc;
argv=argv;
setup();
scanscan();
shutdown();
struct extra_count {
long long totalbytes;
int rowcounter;
};
void counttotalbytes (DBT const *key, DBT const *data, void *extrav) {
struct extra_count *e=extrav;
e->totalbytes += key->size + data->size;
e->rowcounter++;
}
void scanscan_lwc (void) {
int r;
int counter=0;
for (counter=0; counter<2; counter++) {
struct extra_count e = {0,0};
double prevtime = gettime();
DBC *dbc;
r = db->cursor(db, tid, &dbc, 0); assert(r==0);
while (0 == (r = dbc->c_getf_next(dbc, 0, counttotalbytes, &e)));
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 {
long long totalbytes;
int rowcounter;
DBT k,v; // the k and v are gotten using the old cursor
};
void checkbytes (DBT const *key, DBT const *data, void *extrav) {
struct extra_verify *e=extrav;
e->totalbytes += key->size + data->size;
e->rowcounter++;
assert(e->k.size == key->size);
assert(e->v.size == data->size);
assert(memcmp(e->k.data, key->data, key->size)==0);
assert(memcmp(e->v.data, data->data, data->size)==0);
assert(e->k.data != key->data);
assert(e->v.data != data->data);
}
void scanscan_verify (void) {
int r;
int counter=0;
for (counter=0; counter<2; counter++) {
struct extra_verify v;
v.totalbytes=0;
v.rowcounter=0;
double prevtime = gettime();
DBC *dbc1, *dbc2;
r = db->cursor(db, tid, &dbc1, 0); assert(r==0);
r = db->cursor(db, tid, &dbc2, 0); assert(r==0);
memset(&v.k, 0, sizeof(v.k));
memset(&v.v, 0, sizeof(v.v));
while (1) {
int r1,r2;
r2 = dbc1->c_get(dbc1, &v.k, &v.v, DB_NEXT);
r1 = dbc2->c_getf_next(dbc2, 0, checkbytes, &v);
assert(r1==r2);
if (r1) break;
}
r = dbc1->c_close(dbc1); assert(r==0);
r = dbc2->c_close(dbc2); assert(r==0);
double thistime = gettime();
double tdiff = thistime-prevtime;
printf("verify %lld bytes (%d rows) in %9.6fs at %9fMB/s\n", v.totalbytes, v.rowcounter, tdiff, 1e-6*v.totalbytes/tdiff);
}
}
const char *pname;
int verify_lwc=0, lwc=0, hwc=1;
void parse_args (int argc, const char *argv[]) {
pname=argv[0];
argc--;
argv++;
while (argc>0) {
if (strcmp(*argv,"--verify-lwc")==0) verify_lwc=1;
else if (strcmp(*argv, "--lwc")==0) lwc=1;
else if (strcmp(*argv, "--nohwc")==0) hwc=0;
else {
printf("Usage:\n%s [--verify-lwc] [--lwc] [--nohwc]\n", pname);
exit(1);
}
argc--;
argv++;
}
}
int main (int argc, const char *argv[]) {
parse_args(argc,argv);
if (hwc) {
setup();
scanscan();
shutdown();
}
if (lwc) {
setup();
scanscan_lwc();
shutdown();
}
if (verify_lwc) {
setup();
scanscan_verify();
shutdown();
}
return 0;
}
......@@ -93,6 +93,7 @@ typedef enum {
#define DB_SET_RANGE 30
#define DB_CURRENT_BINDING 253
#define DB_RMW 536870912
#define DB_PRELOCKED 0x00800000
#define DB_DBT_APPMALLOC 1
#define DB_LOG_AUTOREMOVE 262144
#define DB_TXN_WRITE_NOSYNC 1024
......@@ -188,11 +189,11 @@ struct __toku_db {
void* __toku_dummy1[33];
char __toku_dummy2[96];
void *api_internal; /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */
const DBT* (*dbt_pos_infty)(void);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
void* __toku_dummy3[3];
int (*associate) (DB*, DB_TXN*, DB*, int(*)(DB*, const DBT*, const DBT*, DBT*), u_int32_t); /* 32-bit offset=276 size=4, 64=bit offset=456 size=8 */
int (*close) (DB*, u_int32_t); /* 32-bit offset=280 size=4, 64=bit offset=464 size=8 */
const DBT* (*dbt_neg_infty)(void);
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t); /* 32-bit offset=288 size=4, 64=bit offset=480 size=8 */
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t); /* 32-bit offset=292 size=4, 64=bit offset=488 size=8 */
void* __toku_dummy4[2];
......@@ -258,16 +259,17 @@ struct __toku_db_txn_stat {
struct __toku_dbc {
DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
struct __toku_dbc_internal *i;
void* __toku_dummy0[19];
int (*c_getf_next)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
void* __toku_dummy0[18];
char __toku_dummy1[104];
int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=272 size=8 */
int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=280 size=8 */
int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=196 size=4, 64=bit offset=288 size=8 */
void* __toku_dummy2[1];
int (*c_getf_next_dup)(DBC *, u_int32_t, void(*)(DBT const *, DBT const *, void *), void *);
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */
int (*c_pget) (DBC *, DBT *, DBT *, DBT *, u_int32_t); /* 32-bit offset=208 size=4, 64=bit offset=312 size=8 */
int (*c_put) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=212 size=4, 64=bit offset=320 size=8 */
void* __toku_dummy3[8]; /* Padding at the end */
void* __toku_dummy2[8]; /* Padding at the end */
};
struct __toku_dbt {
void*data; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */
......
......@@ -89,6 +89,9 @@ static int toku_db_cursor(DB *db, DB_TXN * txn, DBC **c, u_int32_t flags, int is
/* txn methods */
/* lightweight cursor methods. */
static int toku_c_getf_next(DBC *c, u_int32_t flag, void(*f)(DBT const *key, DBT const *data, void *extra), void *extra);
/* cursor methods */
static int toku_c_get(DBC * c, DBT * key, DBT * data, u_int32_t flag);
static int toku_c_get_noassociate(DBC * c, DBT * key, DBT * data, u_int32_t flag);
......@@ -1662,6 +1665,22 @@ static int toku_c_get(DBC * c, DBT * key, DBT * data, u_int32_t flag) {
return r;
}
static int locked_c_getf_next(DBC *c, u_int32_t flag, void(*f)(DBT const *key, DBT const *data, void *extra), void *extra) {
return toku_c_getf_next(c, flag, f, extra); // flags are grabbed inside.
}
static int toku_c_getf_next(DBC *c, u_int32_t flag, void(*f)(DBT const *key, DBT const *data, void *extra), void *extra) {
DBT key,val;
memset(&key, 0, sizeof(key));
memset(&val, 0, sizeof(val));
flag &= ~DB_PRELOCKED; // Get rid of the prelock flag, because c_get doesn't know about it.
assert(flag==0);
int r = c->c_get(c, &key, &val, DB_NEXT);
if (r==0) f(&key, &val, extra);
return r;
}
static int toku_c_close(DBC * c) {
int r = toku_brt_cursor_close(c->i->c);
toku_free(c->i);
......@@ -1967,6 +1986,7 @@ static int toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags, int
result->c_close = locked_c_close;
result->c_del = locked_c_del;
result->c_count = locked_c_count;
result->c_getf_next = locked_c_getf_next; // Don't need loc
MALLOC(result->i);
assert(result->i);
result->dbp = db;
......
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