Commit d6249b26 authored by Rich Prohaska's avatar Rich Prohaska

implement DB_CURRENT_BINDING, an operation that returns the current cursor kv...

implement DB_CURRENT_BINDING, an operation that returns the current cursor kv binding even if deleted.  closes #274

git-svn-id: file:///svn/tokudb@2063 c7de825b-a66e-492c-adef-691d508d4ae1
parent 30a66896
...@@ -89,6 +89,7 @@ typedef enum { ...@@ -89,6 +89,7 @@ typedef enum {
#define DB_PREV_NODUP 28 #define DB_PREV_NODUP 28
#define DB_SET 30 #define DB_SET 30
#define DB_SET_RANGE 32 #define DB_SET_RANGE 32
#define DB_CURRENT_BINDING 253
#define DB_RMW 1073741824 #define DB_RMW 1073741824
#define DB_DBT_APPMALLOC 1 #define DB_DBT_APPMALLOC 1
#define DB_TXN_WRITE_NOSYNC 524288 #define DB_TXN_WRITE_NOSYNC 524288
......
...@@ -90,6 +90,7 @@ typedef enum { ...@@ -90,6 +90,7 @@ typedef enum {
#define DB_PREV_NODUP 26 #define DB_PREV_NODUP 26
#define DB_SET 28 #define DB_SET 28
#define DB_SET_RANGE 30 #define DB_SET_RANGE 30
#define DB_CURRENT_BINDING 253
#define DB_RMW 536870912 #define DB_RMW 536870912
#define DB_DBT_APPMALLOC 1 #define DB_DBT_APPMALLOC 1
#define DB_LOG_AUTOREMOVE 65536 #define DB_LOG_AUTOREMOVE 65536
......
...@@ -90,6 +90,7 @@ typedef enum { ...@@ -90,6 +90,7 @@ typedef enum {
#define DB_PREV_NODUP 26 #define DB_PREV_NODUP 26
#define DB_SET 28 #define DB_SET 28
#define DB_SET_RANGE 30 #define DB_SET_RANGE 30
#define DB_CURRENT_BINDING 253
#define DB_RMW 536870912 #define DB_RMW 536870912
#define DB_DBT_APPMALLOC 1 #define DB_DBT_APPMALLOC 1
#define DB_LOG_AUTOREMOVE 262144 #define DB_LOG_AUTOREMOVE 262144
......
...@@ -90,6 +90,7 @@ typedef enum { ...@@ -90,6 +90,7 @@ typedef enum {
#define DB_PREV_NODUP 24 #define DB_PREV_NODUP 24
#define DB_SET 25 #define DB_SET 25
#define DB_SET_RANGE 27 #define DB_SET_RANGE 27
#define DB_CURRENT_BINDING 253
#define DB_RMW 1073741824 #define DB_RMW 1073741824
#define DB_DBT_APPMALLOC 1 #define DB_DBT_APPMALLOC 1
#define DB_LOG_AUTOREMOVE 524288 #define DB_LOG_AUTOREMOVE 524288
......
...@@ -91,6 +91,7 @@ typedef enum { ...@@ -91,6 +91,7 @@ typedef enum {
#define DB_PREV_NODUP 25 #define DB_PREV_NODUP 25
#define DB_SET 26 #define DB_SET 26
#define DB_SET_RANGE 27 #define DB_SET_RANGE 27
#define DB_CURRENT_BINDING 253
#define DB_RMW 1073741824 #define DB_RMW 1073741824
#define DB_DBT_APPMALLOC 1 #define DB_DBT_APPMALLOC 1
#define DB_DBT_MULTIPLE 16 #define DB_DBT_MULTIPLE 16
......
...@@ -101,6 +101,7 @@ void print_defines (void) { ...@@ -101,6 +101,7 @@ void print_defines (void) {
dodefine(DB_PREV_NODUP); dodefine(DB_PREV_NODUP);
dodefine(DB_SET); dodefine(DB_SET);
dodefine(DB_SET_RANGE); dodefine(DB_SET_RANGE);
printf("#define DB_CURRENT_BINDING 253\n"); // private tokudb
dodefine(DB_RMW); dodefine(DB_RMW);
dodefine(DB_DBT_APPMALLOC); dodefine(DB_DBT_APPMALLOC);
......
...@@ -90,6 +90,7 @@ typedef enum { ...@@ -90,6 +90,7 @@ typedef enum {
#define DB_PREV_NODUP 26 #define DB_PREV_NODUP 26
#define DB_SET 28 #define DB_SET 28
#define DB_SET_RANGE 30 #define DB_SET_RANGE 30
#define DB_CURRENT_BINDING 253
#define DB_RMW 536870912 #define DB_RMW 536870912
#define DB_DBT_APPMALLOC 1 #define DB_DBT_APPMALLOC 1
#define DB_LOG_AUTOREMOVE 262144 #define DB_LOG_AUTOREMOVE 262144
......
...@@ -2577,7 +2577,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) { ...@@ -2577,7 +2577,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i)); assert(vv == (int) htonl(i));
r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT+256, null_txn); assert(r == 0); r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT_BINDING, null_txn); assert(r == 0);
assert(key.size == sizeof kk); assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size); memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i)); assert(kk == (int) htonl(i));
...@@ -2589,7 +2589,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) { ...@@ -2589,7 +2589,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT, null_txn); assert(r == DB_KEYEMPTY); r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT, null_txn); assert(r == DB_KEYEMPTY);
r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT+256, null_txn); assert(r == 0); r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT_BINDING, null_txn); assert(r == 0);
assert(key.size == sizeof kk); assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size); memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i)); assert(kk == (int) htonl(i));
......
...@@ -2053,10 +2053,10 @@ static int brt_cursor_compare_set(brt_search_t *search, DBT *x, DBT *y) { ...@@ -2053,10 +2053,10 @@ static int brt_cursor_compare_set(brt_search_t *search, DBT *x, DBT *y) {
return compare_kv_xy(brt, search->k, search->v, x, y) <= 0; /* return min xy: kv <= xy */ return compare_kv_xy(brt, search->k, search->v, x, y) <= 0; /* return min xy: kv <= xy */
} }
static int brt_cursor_current(BRT_CURSOR cursor, int get_flags, DBT *outkey, DBT *outval, TOKUTXN txn) { static int brt_cursor_current(BRT_CURSOR cursor, int op, DBT *outkey, DBT *outval, TOKUTXN txn) {
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return EINVAL; return EINVAL;
if ((get_flags & 256) == 0) { if (op == DB_CURRENT) {
DBT newkey; toku_init_dbt(&newkey); DBT newkey; toku_init_dbt(&newkey);
DBT newval; toku_init_dbt(&newval); DBT newval; toku_init_dbt(&newval);
...@@ -2236,17 +2236,16 @@ static int brt_cursor_set_range(BRT_CURSOR cursor, DBT *key, DBT *outkey, DBT *o ...@@ -2236,17 +2236,16 @@ static int brt_cursor_set_range(BRT_CURSOR cursor, DBT *key, DBT *outkey, DBT *o
} }
int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, int get_flags, TOKUTXN txn) { int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, int get_flags, TOKUTXN txn) {
assert(txn == 0);
int r; int r;
if ((get_flags & ~(DB_OPFLAGS_MASK+256))) int op = get_flags & DB_OPFLAGS_MASK;
if (get_flags & ~DB_OPFLAGS_MASK)
return EINVAL; return EINVAL;
switch (get_flags) { switch (op) {
case DB_CURRENT: case DB_CURRENT:
case DB_CURRENT+256: case DB_CURRENT_BINDING:
r = brt_cursor_current(cursor, get_flags, key, val, txn); r = brt_cursor_current(cursor, op, key, val, txn);
break; break;
case DB_FIRST: case DB_FIRST:
r = brt_cursor_first(cursor, key, val, txn); r = brt_cursor_first(cursor, key, val, txn);
......
...@@ -1135,7 +1135,7 @@ static int toku_c_count(DBC *cursor, db_recno_t *count, u_int32_t flags) { ...@@ -1135,7 +1135,7 @@ static int toku_c_count(DBC *cursor, db_recno_t *count, u_int32_t flags) {
r = EINVAL; goto finish; r = EINVAL; goto finish;
} }
r = toku_c_get(cursor, &currentkey, &currentval, DB_CURRENT+256); r = toku_c_get(cursor, &currentkey, &currentval, DB_CURRENT_BINDING);
if (r != 0) goto finish; if (r != 0) goto finish;
r = toku_db_cursor(cursor->dbp, 0, &count_cursor, 0); r = toku_db_cursor(cursor->dbp, 0, &count_cursor, 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