Commit 0860425e authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Addresses #1987 refs[t:1987] API and implementation of broadcast commit (all xids) message.

Cleaned up BRT_CMD vs BRT_MSG, removed logger from query path.

git-svn-id: file:///svn/toku/tokudb@14376 c7de825b-a66e-492c-adef-691d508d4ae1
parent aa5f3c85
...@@ -303,7 +303,7 @@ struct cmd_leafval_heaviside_extra { ...@@ -303,7 +303,7 @@ struct cmd_leafval_heaviside_extra {
}; };
int toku_cmd_leafval_heaviside (OMTVALUE leafentry, void *extra); int toku_cmd_leafval_heaviside (OMTVALUE leafentry, void *extra);
int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd, TOKULOGGER logger); int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd);
void *mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size, void **maybe_free); void *mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size, void **maybe_free);
// Effect: Allocate a new object of size SIZE in MP. If MP runs out of space, allocate new a new mempool space, and copy all the items // Effect: Allocate a new object of size SIZE in MP. If MP runs out of space, allocate new a new mempool space, and copy all the items
......
...@@ -676,7 +676,7 @@ initialize_empty_brtnode (BRT t, BRTNODE n, BLOCKNUM nodename, int height, size_ ...@@ -676,7 +676,7 @@ initialize_empty_brtnode (BRT t, BRTNODE n, BLOCKNUM nodename, int height, size_
} }
static int static int
brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *rootp, TOKULOGGER logger __attribute__((__unused__)), BRTNODE *newrootp) brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *rootp, BRTNODE *newrootp)
// Effect: Create a new root node whose two children are NODEA and NODEB, an dthe pivotkey is SPLITK. // Effect: Create a new root node whose two children are NODEA and NODEB, an dthe pivotkey is SPLITK.
// Store the new root's identity in *ROOTP, and the node in *NEWROOTP. // Store the new root's identity in *ROOTP, and the node in *NEWROOTP.
// Unpin nodea and nodeb. // Unpin nodea and nodeb.
...@@ -1242,6 +1242,7 @@ should_compare_both_keys (BRTNODE node, BRT_MSG cmd) ...@@ -1242,6 +1242,7 @@ should_compare_both_keys (BRTNODE node, BRT_MSG cmd)
case BRT_DELETE_ANY: case BRT_DELETE_ANY:
case BRT_ABORT_ANY: case BRT_ABORT_ANY:
case BRT_COMMIT_ANY: case BRT_COMMIT_ANY:
case BRT_COMMIT_BROADCAST_ALL:
return 0; return 0;
case BRT_NONE: case BRT_NONE:
break; break;
...@@ -1280,7 +1281,7 @@ maybe_bump_nkeys (BRTNODE node, u_int32_t idx, LEAFENTRY le, int direction) { ...@@ -1280,7 +1281,7 @@ maybe_bump_nkeys (BRTNODE node, u_int32_t idx, LEAFENTRY le, int direction) {
assert(node->u.l.leaf_stats.exact); assert(node->u.l.leaf_stats.exact);
} }
static void UU() static void
brt_leaf_apply_full_promotion_once (BRTNODE node, LEAFENTRY le) brt_leaf_apply_full_promotion_once (BRTNODE node, LEAFENTRY le)
// Effect: fully promote leafentry // Effect: fully promote leafentry
// le is old leafentry (and new one) // le is old leafentry (and new one)
...@@ -1362,6 +1363,45 @@ maybe_do_implicit_promotion_on_query (BRT_CURSOR UU(brtcursor), LEAFENTRY UU(le) ...@@ -1362,6 +1363,45 @@ maybe_do_implicit_promotion_on_query (BRT_CURSOR UU(brtcursor), LEAFENTRY UU(le)
#endif #endif
} }
static int
brt_leaf_delete_leafentry (BRTNODE node, u_int32_t idx, LEAFENTRY le)
// Effect: Delete leafentry
// idx is the location where it is
// le is the leafentry to be deleted
{
// brt_leaf_check_leaf_stats(node);
// It was there, note that it's gone and remove it from the mempool
//
// Figure out if one of the other keys is the same key
maybe_bump_nkeys(node, idx, le, -1);
int r;
if ((r = toku_omt_delete_at(node->u.l.buffer, idx))) goto return_r;
node->u.l.n_bytes_in_buffer -= OMT_ITEM_OVERHEAD + leafentry_disksize(le);
node->local_fingerprint -= node->rand4fingerprint * toku_le_crc(le);
{
u_int32_t oldlen = le_innermost_inserted_vallen(le) + le_keylen(le);
assert(node->u.l.leaf_stats.dsize >= oldlen);
node->u.l.leaf_stats.dsize -= oldlen;
}
assert(node->u.l.leaf_stats.dsize < (1U<<31)); // make sure we didn't underflow
node->u.l.leaf_stats.ndata --;
toku_mempool_mfree(&node->u.l.buffer_mempool, 0, leafentry_memsize(le)); // Must pass 0, since le may be no good any more.
r=0;
// printf("%s:%d rand4=%08x local_fingerprint=%08x this=%08x\n", __FILE__, __LINE__, node->rand4fingerprint, node->local_fingerprint, toku_calccrc32_kvpair_struct(kv));
return_r:
// brt_leaf_check_leaf_stats(node);
return r;
}
static int static int
brt_leaf_apply_cmd_once (BRTNODE node, BRT_MSG cmd, brt_leaf_apply_cmd_once (BRTNODE node, BRT_MSG cmd,
u_int32_t idx, LEAFENTRY le) u_int32_t idx, LEAFENTRY le)
...@@ -1421,25 +1461,7 @@ brt_leaf_apply_cmd_once (BRTNODE node, BRT_MSG cmd, ...@@ -1421,25 +1461,7 @@ brt_leaf_apply_cmd_once (BRTNODE node, BRT_MSG cmd,
} else { } else {
if (le) { if (le) {
// It was there, note that it's gone and remove it from the mempool // It was there, note that it's gone and remove it from the mempool
if ((r = brt_leaf_delete_leafentry (node, idx, le))) goto return_r;
// Figure out if one of the other keys is the same key
maybe_bump_nkeys(node, idx, le, -1);
if ((r = toku_omt_delete_at(node->u.l.buffer, idx))) goto return_r;
node->u.l.n_bytes_in_buffer -= OMT_ITEM_OVERHEAD + leafentry_disksize(le);
node->local_fingerprint -= node->rand4fingerprint * toku_le_crc(le);
{
u_int32_t oldlen = le_innermost_inserted_vallen(le) + le_keylen(le);
assert(node->u.l.leaf_stats.dsize >= oldlen);
node->u.l.leaf_stats.dsize -= oldlen;
}
assert(node->u.l.leaf_stats.dsize < (1U<<31)); // make sure we didn't underflow
node->u.l.leaf_stats.ndata --;
toku_mempool_mfree(&node->u.l.buffer_mempool, 0, leafentry_memsize(le)); // Must pass 0, since le may be no good any more.
} }
if (new_le) { if (new_le) {
...@@ -1601,6 +1623,32 @@ brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd, ...@@ -1601,6 +1623,32 @@ brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd,
} }
} }
break;
case BRT_COMMIT_BROADCAST_ALL:
// Apply to all leafentries
idx = 0;
u_int32_t omt_size = toku_omt_size(node->u.l.buffer);
for (idx = 0; idx < omt_size; ) {
r = toku_omt_fetch(node->u.l.buffer, idx, &storeddatav, NULL);
assert(r==0);
storeddata=storeddatav;
int deleted = 0;
if (le_outermost_uncommitted_xid(storeddata) != 0) {
if (le_is_provdel(storeddata)) {
brt_leaf_delete_leafentry(node, idx, storeddata);
deleted = 1;
}
else
brt_leaf_apply_full_promotion_once(node, storeddata);
node->dirty = 1;
}
if (deleted)
omt_size--;
else
idx++;
}
assert(toku_omt_size(node->u.l.buffer) == omt_size);
break; break;
case BRT_NONE: return EINVAL; case BRT_NONE: return EINVAL;
...@@ -1750,6 +1798,24 @@ static int brt_nonleaf_cmd_once (BRT t, BRTNODE node, BRT_MSG cmd, ...@@ -1750,6 +1798,24 @@ static int brt_nonleaf_cmd_once (BRT t, BRTNODE node, BRT_MSG cmd,
return r; return r;
} }
static int
brt_nonleaf_cmd_all (BRT t, BRTNODE node, BRT_MSG cmd,
enum reactivity re_array[], BOOL *did_io)
// Effect: Put the cmd into a nonleaf node. We put it into all children, possibly causing the children to become reactive.
// We don't do the splitting and merging. That's up to the caller after doing all the puts it wants to do.
// The re_array[i] gets set to the reactivity of any modified child i. (And there may be several such children.)
{
int i;
int r;
for (i = 0; i < node->u.n.n_children; i++) {
r = brt_nonleaf_cmd_once_to_child(t, node, i, cmd, re_array, did_io);
if (r!=0) goto return_r;
}
r = 0;
return_r:
return r;
}
static int static int
brt_nonleaf_cmd_many (BRT t, BRTNODE node, BRT_MSG cmd, brt_nonleaf_cmd_many (BRT t, BRTNODE node, BRT_MSG cmd,
enum reactivity re_array[], BOOL *did_io) enum reactivity re_array[], BOOL *did_io)
...@@ -1820,8 +1886,10 @@ brt_nonleaf_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd, ...@@ -1820,8 +1886,10 @@ brt_nonleaf_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd,
case BRT_DELETE_ANY: case BRT_DELETE_ANY:
case BRT_ABORT_ANY: case BRT_ABORT_ANY:
case BRT_COMMIT_ANY: case BRT_COMMIT_ANY:
if (0 == (node->flags & TOKU_DB_DUPSORT)) goto do_once; // nondupsort delete_any is just do once. if (0 == (node->flags & TOKU_DB_DUPSORT)) goto do_once; // for nondupsort brt, delete_any message goes to one child.
return brt_nonleaf_cmd_many(t, node, cmd, re_array, did_io); return brt_nonleaf_cmd_many(t, node, cmd, re_array, did_io); // send message to at least one, possibly all children
case BRT_COMMIT_BROADCAST_ALL:
return brt_nonleaf_cmd_all (t, node, cmd, re_array, did_io); // send message to all children
case BRT_NONE: case BRT_NONE:
break; break;
} }
...@@ -2224,7 +2292,7 @@ brt_handle_maybe_reactive_child(BRT t, BRTNODE node, int childnum, enum reactivi ...@@ -2224,7 +2292,7 @@ brt_handle_maybe_reactive_child(BRT t, BRTNODE node, int childnum, enum reactivi
} }
static int static int
brt_handle_maybe_reactive_child_at_root (BRT brt, CACHEKEY *rootp, BRTNODE *nodep, enum reactivity re, TOKULOGGER logger) { brt_handle_maybe_reactive_child_at_root (BRT brt, CACHEKEY *rootp, BRTNODE *nodep, enum reactivity re) {
#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY #ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY
if (STRADDLE_HACK_INSIDE_CALLBACK) { if (STRADDLE_HACK_INSIDE_CALLBACK) {
return 0; return 0;
...@@ -2248,7 +2316,7 @@ brt_handle_maybe_reactive_child_at_root (BRT brt, CACHEKEY *rootp, BRTNODE *node ...@@ -2248,7 +2316,7 @@ brt_handle_maybe_reactive_child_at_root (BRT brt, CACHEKEY *rootp, BRTNODE *node
} }
//verify_local_fingerprint_nonleaf(nodea); //verify_local_fingerprint_nonleaf(nodea);
//verify_local_fingerprint_nonleaf(nodeb); //verify_local_fingerprint_nonleaf(nodeb);
return brt_init_new_root(brt, nodea, nodeb, splitk, rootp, logger, nodep); return brt_init_new_root(brt, nodea, nodeb, splitk, rootp, nodep);
} }
case RE_FUSIBLE: case RE_FUSIBLE:
return 0; // Cannot merge anything at the root, so return happy. return 0; // Cannot merge anything at the root, so return happy.
...@@ -2405,7 +2473,7 @@ brtnode_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd, enum reactivity *re, BOOL *di ...@@ -2405,7 +2473,7 @@ brtnode_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd, enum reactivity *re, BOOL *di
} }
} }
static int push_something_at_root (BRT brt, BRTNODE *nodep, CACHEKEY *rootp, BRT_MSG cmd, TOKULOGGER logger) static int push_something_at_root (BRT brt, BRTNODE *nodep, CACHEKEY *rootp, BRT_MSG cmd)
// Effect: Put CMD into brt by descending into the tree as deeply as we can // Effect: Put CMD into brt by descending into the tree as deeply as we can
// without performing I/O (but we must fetch the root), // without performing I/O (but we must fetch the root),
// bypassing only empty FIFOs // bypassing only empty FIFOs
...@@ -2435,7 +2503,7 @@ static int push_something_at_root (BRT brt, BRTNODE *nodep, CACHEKEY *rootp, BRT ...@@ -2435,7 +2503,7 @@ static int push_something_at_root (BRT brt, BRTNODE *nodep, CACHEKEY *rootp, BRT
//printf("%s:%d should_split=%d node_size=%" PRIu64 "\n", __FILE__, __LINE__, should_split, brtnode_memory_size(node)); //printf("%s:%d should_split=%d node_size=%" PRIu64 "\n", __FILE__, __LINE__, should_split, brtnode_memory_size(node));
{ {
int r = brt_handle_maybe_reactive_child_at_root(brt, rootp, nodep, re, logger); int r = brt_handle_maybe_reactive_child_at_root(brt, rootp, nodep, re);
verify_local_fingerprint_nonleaf(*nodep); verify_local_fingerprint_nonleaf(*nodep);
return r; return r;
} }
...@@ -2472,8 +2540,8 @@ CACHEKEY* toku_calculate_root_offset_pointer (BRT brt, u_int32_t *roothash) { ...@@ -2472,8 +2540,8 @@ CACHEKEY* toku_calculate_root_offset_pointer (BRT brt, u_int32_t *roothash) {
return &brt->h->root; return &brt->h->root;
} }
int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd, TOKULOGGER logger) int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd)
// Effect: Flush the root fifo into the brt, and then push the cmd into the brt. // Effect: push the cmd into the brt.
{ {
void *node_v; void *node_v;
BRTNODE node; BRTNODE node;
...@@ -2498,7 +2566,7 @@ int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd, TOKULOGGER logger) ...@@ -2498,7 +2566,7 @@ int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd, TOKULOGGER logger)
brt_verify_flags(brt, node); brt_verify_flags(brt, node);
verify_local_fingerprint_nonleaf(node); verify_local_fingerprint_nonleaf(node);
if ((r = push_something_at_root(brt, &node, rootp, cmd, logger))) { if ((r = push_something_at_root(brt, &node, rootp, cmd))) {
toku_unpin_brtnode(brt, node); // ignore any error code on the unpin. toku_unpin_brtnode(brt, node); // ignore any error code on the unpin.
return r; return r;
} }
...@@ -2508,6 +2576,23 @@ int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd, TOKULOGGER logger) ...@@ -2508,6 +2576,23 @@ int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd, TOKULOGGER logger)
return 0; return 0;
} }
//If this function is ever used for anything other than format upgrade,
//you MAY need to add a log entry. If this log entry causes you to re-do the broadcast on
//recovery, you must NOT log it for the purpose of format upgrade, or it will be sent multiple times.
int
toku_brt_broadcast_commit_all (BRT brt)
// Effect: Commit all leafentries in the brt.
{
int r;
XIDS message_xids = xids_get_root_xids();
static DBT zero; //Want a zeroed DBT for key, val. Never changes so can be re-used.
BRT_MSG_S brtcmd = { BRT_INSERT, message_xids, .u.id={&zero,&zero}};
r = toku_brt_root_put_cmd(brt, &brtcmd);
if (r!=0) return r;
return r;
}
int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn) int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn)
// Effect: Insert the key-val pair into brt. // Effect: Insert the key-val pair into brt.
{ {
...@@ -2542,7 +2627,7 @@ int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn) ...@@ -2542,7 +2627,7 @@ int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn)
} }
BRT_MSG_S brtcmd = { BRT_INSERT, message_xids, .u.id={key,val}}; BRT_MSG_S brtcmd = { BRT_INSERT, message_xids, .u.id={key,val}};
r = toku_brt_root_put_cmd(brt, &brtcmd, logger); r = toku_brt_root_put_cmd(brt, &brtcmd);
if (r!=0) return r; if (r!=0) return r;
return r; return r;
} }
...@@ -2572,7 +2657,7 @@ int toku_brt_delete(BRT brt, DBT *key, TOKUTXN txn) { ...@@ -2572,7 +2657,7 @@ int toku_brt_delete(BRT brt, DBT *key, TOKUTXN txn) {
} }
DBT val; DBT val;
BRT_MSG_S brtcmd = { BRT_DELETE_ANY, message_xids, .u.id={key, toku_init_dbt(&val)}}; BRT_MSG_S brtcmd = { BRT_DELETE_ANY, message_xids, .u.id={key, toku_init_dbt(&val)}};
r = toku_brt_root_put_cmd(brt, &brtcmd, logger); r = toku_brt_root_put_cmd(brt, &brtcmd);
return r; return r;
} }
...@@ -3650,7 +3735,7 @@ brt_search_node (BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_C ...@@ -3650,7 +3735,7 @@ brt_search_node (BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_C
} }
static int static int
toku_brt_search (BRT brt, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger, BRT_CURSOR brtcursor, u_int64_t *root_put_counter) toku_brt_search (BRT brt, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, BRT_CURSOR brtcursor, u_int64_t *root_put_counter)
// Effect: Perform a search. Associate cursor with a leaf if possible. // Effect: Perform a search. Associate cursor with a leaf if possible.
// All searches are performed through this function. // All searches are performed through this function.
{ {
...@@ -3679,7 +3764,7 @@ toku_brt_search (BRT brt, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTI ...@@ -3679,7 +3764,7 @@ toku_brt_search (BRT brt, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTI
r = brt_search_node(brt, node, search, getf, getf_v, &re, &doprefetch, brtcursor); r = brt_search_node(brt, node, search, getf, getf_v, &re, &doprefetch, brtcursor);
if (r!=0) goto return_r; if (r!=0) goto return_r;
r = brt_handle_maybe_reactive_child_at_root(brt, rootp, &node, re, logger); r = brt_handle_maybe_reactive_child_at_root(brt, rootp, &node, re);
} }
return_r: return_r:
...@@ -3730,11 +3815,11 @@ brt_cursor_search_getf(ITEMLEN keylen, bytevec key, ...@@ -3730,11 +3815,11 @@ brt_cursor_search_getf(ITEMLEN keylen, bytevec key,
/* search for the first kv pair that matches the search object */ /* search for the first kv pair that matches the search object */
static int static int
brt_cursor_search(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) brt_cursor_search(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_cursor_invalidate(cursor); brt_cursor_invalidate(cursor);
struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, search}; struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, search};
int r = toku_brt_search(cursor->brt, search, brt_cursor_search_getf, &bcss, logger, cursor, &cursor->root_put_counter); int r = toku_brt_search(cursor->brt, search, brt_cursor_search_getf, &bcss, cursor, &cursor->root_put_counter);
return r; return r;
} }
...@@ -3787,11 +3872,11 @@ brt_cursor_search_eq_kv_xy_getf(ITEMLEN keylen, bytevec key, ...@@ -3787,11 +3872,11 @@ brt_cursor_search_eq_kv_xy_getf(ITEMLEN keylen, bytevec key,
/* search for the kv pair that matches the search object and is equal to kv */ /* search for the kv pair that matches the search object and is equal to kv */
static int static int
brt_cursor_search_eq_kv_xy(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) brt_cursor_search_eq_kv_xy(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_cursor_invalidate(cursor); brt_cursor_invalidate(cursor);
struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, search}; struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, search};
int r = toku_brt_search(cursor->brt, search, brt_cursor_search_eq_kv_xy_getf, &bcss, logger, cursor, &cursor->root_put_counter); int r = toku_brt_search(cursor->brt, search, brt_cursor_search_eq_kv_xy_getf, &bcss, cursor, &cursor->root_put_counter);
return r; return r;
} }
...@@ -3826,7 +3911,7 @@ brt_cursor_current_getf(ITEMLEN keylen, bytevec key, ...@@ -3826,7 +3911,7 @@ brt_cursor_current_getf(ITEMLEN keylen, bytevec key,
} }
int int
toku_brt_cursor_current(BRT_CURSOR cursor, int op, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_current(BRT_CURSOR cursor, int op, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return EINVAL; return EINVAL;
...@@ -3834,7 +3919,7 @@ toku_brt_cursor_current(BRT_CURSOR cursor, int op, BRT_GET_CALLBACK_FUNCTION get ...@@ -3834,7 +3919,7 @@ toku_brt_cursor_current(BRT_CURSOR cursor, int op, BRT_GET_CALLBACK_FUNCTION get
brt_cursor_invalidate(cursor); brt_cursor_invalidate(cursor);
struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, 0}; struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, 0};
brt_search_t search; brt_search_init(&search, brt_cursor_compare_set, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_set, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt);
return toku_brt_search(cursor->brt, &search, brt_cursor_current_getf, &bcss, logger, cursor, &cursor->root_put_counter); return toku_brt_search(cursor->brt, &search, brt_cursor_current_getf, &bcss, cursor, &cursor->root_put_counter);
} }
brt_cursor_invalidate(cursor); brt_cursor_invalidate(cursor);
return getf(cursor->key.size, cursor->key.data, cursor->val.size, cursor->val.data, getf_v); // brt_cursor_copyout(cursor, outkey, outval); return getf(cursor->key.size, cursor->key.data, cursor->val.size, cursor->val.data, getf_v); // brt_cursor_copyout(cursor, outkey, outval);
...@@ -3854,7 +3939,7 @@ toku_brt_flatten(BRT brt, TOKULOGGER logger) ...@@ -3854,7 +3939,7 @@ toku_brt_flatten(BRT brt, TOKULOGGER logger)
int r = toku_brt_cursor(brt, &tmp_cursor, logger); int r = toku_brt_cursor(brt, &tmp_cursor, logger);
if (r!=0) return r; if (r!=0) return r;
brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_LEFT, 0, 0, tmp_cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_LEFT, 0, 0, tmp_cursor->brt);
r = brt_cursor_search(tmp_cursor, &search, brt_flatten_getf, NULL, logger); r = brt_cursor_search(tmp_cursor, &search, brt_flatten_getf, NULL);
if (r==DB_NOTFOUND) r = 0; if (r==DB_NOTFOUND) r = 0;
{ {
//Cleanup temporary cursor //Cleanup temporary cursor
...@@ -3865,17 +3950,17 @@ toku_brt_flatten(BRT brt, TOKULOGGER logger) ...@@ -3865,17 +3950,17 @@ toku_brt_flatten(BRT brt, TOKULOGGER logger)
} }
int int
toku_brt_cursor_first(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_first(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_LEFT, 0, 0, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_LEFT, 0, 0, cursor->brt);
return brt_cursor_search(cursor, &search, getf, getf_v, logger); return brt_cursor_search(cursor, &search, getf, getf_v);
} }
int int
toku_brt_cursor_last(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_last(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_RIGHT, 0, 0, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_RIGHT, 0, 0, cursor->brt);
return brt_cursor_search(cursor, &search, getf, getf_v, logger); return brt_cursor_search(cursor, &search, getf, getf_v);
} }
static int brt_cursor_compare_next(brt_search_t *search, DBT *x, DBT *y) { static int brt_cursor_compare_next(brt_search_t *search, DBT *x, DBT *y) {
...@@ -3990,7 +4075,7 @@ brt_cursor_next_shortcut (BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, voi ...@@ -3990,7 +4075,7 @@ brt_cursor_next_shortcut (BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, voi
} }
int int
toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
int r; int r;
...@@ -3999,7 +4084,7 @@ toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *ge ...@@ -3999,7 +4084,7 @@ toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *ge
} }
else { else {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_next, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_next, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt);
r = brt_cursor_search(cursor, &search, getf, getf_v, logger); r = brt_cursor_search(cursor, &search, getf, getf_v);
} }
if (r == 0) brt_cursor_set_prefetching(cursor); if (r == 0) brt_cursor_set_prefetching(cursor);
return r; return r;
...@@ -4011,7 +4096,7 @@ static int brt_cursor_compare_next_nodup(brt_search_t *search, DBT *x, DBT *y) { ...@@ -4011,7 +4096,7 @@ static int brt_cursor_compare_next_nodup(brt_search_t *search, DBT *x, DBT *y) {
} }
int int
toku_brt_cursor_next_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_next_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
int r; int r;
...@@ -4020,7 +4105,7 @@ toku_brt_cursor_next_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, vo ...@@ -4020,7 +4105,7 @@ toku_brt_cursor_next_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, vo
} }
else { else {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_next_nodup, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_next_nodup, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt);
r = brt_cursor_search(cursor, &search, getf, getf_v, logger); r = brt_cursor_search(cursor, &search, getf, getf_v);
} }
if (r == 0) brt_cursor_set_prefetching(cursor); if (r == 0) brt_cursor_set_prefetching(cursor);
return r; return r;
...@@ -4060,20 +4145,20 @@ brt_cursor_search_eq_k_x_getf(ITEMLEN keylen, bytevec key, ...@@ -4060,20 +4145,20 @@ brt_cursor_search_eq_k_x_getf(ITEMLEN keylen, bytevec key,
/* search for the kv pair that matches the search object and is equal to k */ /* search for the kv pair that matches the search object and is equal to k */
static int static int
brt_cursor_search_eq_k_x(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) brt_cursor_search_eq_k_x(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_cursor_invalidate(cursor); brt_cursor_invalidate(cursor);
struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, search}; struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, search};
int r = toku_brt_search(cursor->brt, search, brt_cursor_search_eq_k_x_getf, &bcss, logger, cursor, &cursor->root_put_counter); int r = toku_brt_search(cursor->brt, search, brt_cursor_search_eq_k_x_getf, &bcss, cursor, &cursor->root_put_counter);
return r; return r;
} }
int int
toku_brt_cursor_next_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_next_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
int r; int r;
brt_search_t search; brt_search_init(&search, brt_cursor_compare_next_dup, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_next_dup, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt);
r = brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v, logger); r = brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v);
if (r == 0) brt_cursor_set_prefetching(cursor); if (r == 0) brt_cursor_set_prefetching(cursor);
return r; return r;
} }
...@@ -4088,10 +4173,10 @@ static int brt_cursor_compare_get_both_range(brt_search_t *search, DBT *x, DBT * ...@@ -4088,10 +4173,10 @@ static int brt_cursor_compare_get_both_range(brt_search_t *search, DBT *x, DBT *
} }
int int
toku_brt_cursor_get_both_range(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_get_both_range(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_get_both_range, BRT_SEARCH_LEFT, key, val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_get_both_range, BRT_SEARCH_LEFT, key, val, cursor->brt);
return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v, logger); return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v);
} }
static int brt_cursor_compare_get_both_range_reverse(brt_search_t *search, DBT *x, DBT *y) { static int brt_cursor_compare_get_both_range_reverse(brt_search_t *search, DBT *x, DBT *y) {
...@@ -4104,10 +4189,10 @@ static int brt_cursor_compare_get_both_range_reverse(brt_search_t *search, DBT * ...@@ -4104,10 +4189,10 @@ static int brt_cursor_compare_get_both_range_reverse(brt_search_t *search, DBT *
} }
int int
toku_brt_cursor_get_both_range_reverse(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_get_both_range_reverse(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_get_both_range_reverse, BRT_SEARCH_RIGHT, key, val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_get_both_range_reverse, BRT_SEARCH_RIGHT, key, val, cursor->brt);
return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v, logger); return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v);
} }
static int static int
...@@ -4138,13 +4223,13 @@ static int brt_cursor_compare_prev(brt_search_t *search, DBT *x, DBT *y) { ...@@ -4138,13 +4223,13 @@ static int brt_cursor_compare_prev(brt_search_t *search, DBT *x, DBT *y) {
} }
int int
toku_brt_cursor_prev(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_prev(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
if (0!=(cursor->brt->flags & TOKU_DB_DUP) && if (0!=(cursor->brt->flags & TOKU_DB_DUP) &&
brt_cursor_prev_shortcut(cursor, getf, getf_v)==0) brt_cursor_prev_shortcut(cursor, getf, getf_v)==0)
return 0; return 0;
brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt);
return brt_cursor_search(cursor, &search, getf, getf_v, logger); return brt_cursor_search(cursor, &search, getf, getf_v);
} }
static int brt_cursor_compare_prev_nodup(brt_search_t *search, DBT *x, DBT *y) { static int brt_cursor_compare_prev_nodup(brt_search_t *search, DBT *x, DBT *y) {
...@@ -4153,13 +4238,13 @@ static int brt_cursor_compare_prev_nodup(brt_search_t *search, DBT *x, DBT *y) { ...@@ -4153,13 +4238,13 @@ static int brt_cursor_compare_prev_nodup(brt_search_t *search, DBT *x, DBT *y) {
} }
int int
toku_brt_cursor_prev_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_prev_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
if (0==(cursor->brt->flags & TOKU_DB_DUP) && if (0==(cursor->brt->flags & TOKU_DB_DUP) &&
brt_cursor_prev_shortcut(cursor, getf, getf_v)==0) brt_cursor_prev_shortcut(cursor, getf, getf_v)==0)
return 0; return 0;
brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev_nodup, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev_nodup, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt);
return brt_cursor_search(cursor, &search, getf, getf_v, logger); return brt_cursor_search(cursor, &search, getf, getf_v);
} }
static int brt_cursor_compare_prev_dup(brt_search_t *search, DBT *x, DBT *y) { static int brt_cursor_compare_prev_dup(brt_search_t *search, DBT *x, DBT *y) {
...@@ -4172,10 +4257,10 @@ static int brt_cursor_compare_prev_dup(brt_search_t *search, DBT *x, DBT *y) { ...@@ -4172,10 +4257,10 @@ static int brt_cursor_compare_prev_dup(brt_search_t *search, DBT *x, DBT *y) {
} }
int int
toku_brt_cursor_prev_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_prev_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev_dup, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev_dup, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt);
return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v, logger); return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v);
} }
...@@ -4185,17 +4270,17 @@ static int brt_cursor_compare_set_range(brt_search_t *search, DBT *x, DBT *y) { ...@@ -4185,17 +4270,17 @@ static int brt_cursor_compare_set_range(brt_search_t *search, DBT *x, DBT *y) {
} }
int int
toku_brt_cursor_set(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_set(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range, BRT_SEARCH_LEFT, key, val, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range, BRT_SEARCH_LEFT, key, val, cursor->brt);
return brt_cursor_search_eq_kv_xy(cursor, &search, getf, getf_v, logger); return brt_cursor_search_eq_kv_xy(cursor, &search, getf, getf_v);
} }
int int
toku_brt_cursor_set_range(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_set_range(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range, BRT_SEARCH_LEFT, key, NULL, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range, BRT_SEARCH_LEFT, key, NULL, cursor->brt);
return brt_cursor_search(cursor, &search, getf, getf_v, logger); return brt_cursor_search(cursor, &search, getf, getf_v);
} }
static int brt_cursor_compare_set_range_reverse(brt_search_t *search, DBT *x, DBT *y) { static int brt_cursor_compare_set_range_reverse(brt_search_t *search, DBT *x, DBT *y) {
...@@ -4204,71 +4289,70 @@ static int brt_cursor_compare_set_range_reverse(brt_search_t *search, DBT *x, DB ...@@ -4204,71 +4289,70 @@ static int brt_cursor_compare_set_range_reverse(brt_search_t *search, DBT *x, DB
} }
int int
toku_brt_cursor_set_range_reverse(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) toku_brt_cursor_set_range_reverse(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range_reverse, BRT_SEARCH_RIGHT, key, NULL, cursor->brt); brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range_reverse, BRT_SEARCH_RIGHT, key, NULL, cursor->brt);
return brt_cursor_search(cursor, &search, getf, getf_v, logger); return brt_cursor_search(cursor, &search, getf, getf_v);
} }
//TODO: When tests have been rewritten, get rid of this function. //TODO: When tests have been rewritten, get rid of this function.
//Only used by tests. //Only used by tests.
int int
toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, int get_flags, TOKUTXN txn) toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, int get_flags)
{ {
int op = get_flags & DB_OPFLAGS_MASK; int op = get_flags & DB_OPFLAGS_MASK;
TOKULOGGER logger = toku_txn_logger(txn);
if (get_flags & ~DB_OPFLAGS_MASK) if (get_flags & ~DB_OPFLAGS_MASK)
return EINVAL; return EINVAL;
switch (op) { switch (op) {
case DB_CURRENT: case DB_CURRENT:
case DB_CURRENT_BINDING: case DB_CURRENT_BINDING:
return toku_brt_cursor_current(cursor, op, getf, getf_v, logger); return toku_brt_cursor_current(cursor, op, getf, getf_v);
case DB_FIRST: case DB_FIRST:
return toku_brt_cursor_first(cursor, getf, getf_v, logger); return toku_brt_cursor_first(cursor, getf, getf_v);
case DB_LAST: case DB_LAST:
return toku_brt_cursor_last(cursor, getf, getf_v, logger); return toku_brt_cursor_last(cursor, getf, getf_v);
case DB_NEXT: case DB_NEXT:
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return toku_brt_cursor_first(cursor, getf, getf_v, logger); return toku_brt_cursor_first(cursor, getf, getf_v);
else else
return toku_brt_cursor_next(cursor, getf, getf_v, logger); return toku_brt_cursor_next(cursor, getf, getf_v);
case DB_NEXT_DUP: case DB_NEXT_DUP:
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return EINVAL; return EINVAL;
else else
return toku_brt_cursor_next_dup(cursor, getf, getf_v, logger); return toku_brt_cursor_next_dup(cursor, getf, getf_v);
case DB_NEXT_NODUP: case DB_NEXT_NODUP:
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return toku_brt_cursor_first(cursor, getf, getf_v, logger); return toku_brt_cursor_first(cursor, getf, getf_v);
else else
return toku_brt_cursor_next_nodup(cursor, getf, getf_v, logger); return toku_brt_cursor_next_nodup(cursor, getf, getf_v);
case DB_PREV: case DB_PREV:
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return toku_brt_cursor_last(cursor, getf, getf_v, logger); return toku_brt_cursor_last(cursor, getf, getf_v);
else else
return toku_brt_cursor_prev(cursor, getf, getf_v, logger); return toku_brt_cursor_prev(cursor, getf, getf_v);
#if defined(DB_PREV_DUP) #if defined(DB_PREV_DUP)
case DB_PREV_DUP: case DB_PREV_DUP:
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return EINVAL; return EINVAL;
else else
return toku_brt_cursor_prev_dup(cursor, getf, getf_v, logger); return toku_brt_cursor_prev_dup(cursor, getf, getf_v);
#endif #endif
case DB_PREV_NODUP: case DB_PREV_NODUP:
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return toku_brt_cursor_last(cursor, getf, getf_v, logger); return toku_brt_cursor_last(cursor, getf, getf_v);
else else
return toku_brt_cursor_prev_nodup(cursor, getf, getf_v, logger); return toku_brt_cursor_prev_nodup(cursor, getf, getf_v);
case DB_SET: case DB_SET:
return toku_brt_cursor_set(cursor, key, 0, getf, getf_v, logger); return toku_brt_cursor_set(cursor, key, 0, getf, getf_v);
case DB_SET_RANGE: case DB_SET_RANGE:
return toku_brt_cursor_set_range(cursor, key, getf, getf_v, logger); return toku_brt_cursor_set_range(cursor, key, getf, getf_v);
case DB_GET_BOTH: case DB_GET_BOTH:
return toku_brt_cursor_set(cursor, key, val, getf, getf_v, logger); return toku_brt_cursor_set(cursor, key, val, getf, getf_v);
case DB_GET_BOTH_RANGE: case DB_GET_BOTH_RANGE:
return toku_brt_cursor_get_both_range(cursor, key, val, getf, getf_v, logger); return toku_brt_cursor_get_both_range(cursor, key, val, getf, getf_v);
default: ;// Fall through default: ;// Fall through
} }
return EINVAL; return EINVAL;
...@@ -4330,12 +4414,12 @@ straddle_hack_getf(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, ...@@ -4330,12 +4414,12 @@ straddle_hack_getf(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val,
/* search for the first kv pair that matches the search object */ /* search for the first kv pair that matches the search object */
static int static int
brt_cursor_straddle_search(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) brt_cursor_straddle_search(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v)
{ {
brt_cursor_invalidate(cursor); brt_cursor_invalidate(cursor);
#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY #ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY
struct brt_cursor_straddle_search_struct bcsss = {getf, getf_v, cursor, search}; struct brt_cursor_straddle_search_struct bcsss = {getf, getf_v, cursor, search};
int r = toku_brt_search(cursor->brt, search, straddle_hack_getf, &bcsss, logger, cursor, &cursor->root_put_counter); int r = toku_brt_search(cursor->brt, search, straddle_hack_getf, &bcsss, cursor, &cursor->root_put_counter);
#else #else
int r = toku_brt_search(cursor->brt, search, getf, getf_v, logger, cursor, &cursor->root_put_counter); int r = toku_brt_search(cursor->brt, search, getf, getf_v, logger, cursor, &cursor->root_put_counter);
#endif #endif
...@@ -4366,7 +4450,7 @@ heaviside_getf(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, ...@@ -4366,7 +4450,7 @@ heaviside_getf(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val,
} }
int int
toku_brt_cursor_heaviside(BRT_CURSOR cursor, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger, HEAVI_WRAPPER wrapper) toku_brt_cursor_heaviside(BRT_CURSOR cursor, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, HEAVI_WRAPPER wrapper)
{ {
brt_search_t search; brt_search_init(&search, brt_cursor_compare_heaviside, brt_search_t search; brt_search_init(&search, brt_cursor_compare_heaviside,
wrapper->direction < 0 ? BRT_SEARCH_RIGHT : BRT_SEARCH_LEFT, wrapper->direction < 0 ? BRT_SEARCH_RIGHT : BRT_SEARCH_LEFT,
...@@ -4377,7 +4461,7 @@ toku_brt_cursor_heaviside(BRT_CURSOR cursor, BRT_GET_STRADDLE_CALLBACK_FUNCTION ...@@ -4377,7 +4461,7 @@ toku_brt_cursor_heaviside(BRT_CURSOR cursor, BRT_GET_STRADDLE_CALLBACK_FUNCTION
struct brt_cursor_heaviside_struct bchs = {getf, getf_v, wrapper}; struct brt_cursor_heaviside_struct bchs = {getf, getf_v, wrapper};
return brt_cursor_straddle_search(cursor, &search, heaviside_getf, &bchs, logger); return brt_cursor_straddle_search(cursor, &search, heaviside_getf, &bchs);
} }
BOOL toku_brt_cursor_uninitialized(BRT_CURSOR c) { BOOL toku_brt_cursor_uninitialized(BRT_CURSOR c) {
...@@ -4410,7 +4494,7 @@ toku_brt_lookup (BRT brt, DBT *k, DBT *v, BRT_GET_CALLBACK_FUNCTION getf, void * ...@@ -4410,7 +4494,7 @@ toku_brt_lookup (BRT brt, DBT *k, DBT *v, BRT_GET_CALLBACK_FUNCTION getf, void *
if (rr != 0) return rr; if (rr != 0) return rr;
int op = brt->flags & TOKU_DB_DUPSORT ? DB_GET_BOTH : DB_SET; int op = brt->flags & TOKU_DB_DUPSORT ? DB_GET_BOTH : DB_SET;
r = toku_brt_cursor_get(cursor, k, v, getf, getf_v, op, 0); r = toku_brt_cursor_get(cursor, k, v, getf, getf_v, op);
rr = toku_brt_cursor_close(cursor); assert(rr == 0); rr = toku_brt_cursor_close(cursor); assert(rr == 0);
...@@ -4447,7 +4531,7 @@ int toku_brt_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn) { ...@@ -4447,7 +4531,7 @@ int toku_brt_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn) {
} }
BRT_MSG_S brtcmd = { BRT_DELETE_BOTH, message_xids, .u.id={key,val}}; BRT_MSG_S brtcmd = { BRT_DELETE_BOTH, message_xids, .u.id={key,val}};
r = toku_brt_root_put_cmd(brt, &brtcmd, logger); r = toku_brt_root_put_cmd(brt, &brtcmd);
return r; return r;
} }
...@@ -4468,7 +4552,7 @@ toku_brt_cursor_delete(BRT_CURSOR cursor, int flags, TOKUTXN txn) { ...@@ -4468,7 +4552,7 @@ toku_brt_cursor_delete(BRT_CURSOR cursor, int flags, TOKUTXN txn) {
else { else {
r = 0; r = 0;
if (error_if_missing) { if (error_if_missing) {
r = toku_brt_cursor_current(cursor, DB_CURRENT, getf_nothing, NULL, toku_txn_logger(txn)); r = toku_brt_cursor_current(cursor, DB_CURRENT, getf_nothing, NULL);
} }
if (r == 0) { if (r == 0) {
//We need to have access to the (key,val) that the cursor points to. //We need to have access to the (key,val) that the cursor points to.
...@@ -4768,13 +4852,13 @@ int toku_brt_destroy(void) { ...@@ -4768,13 +4852,13 @@ int toku_brt_destroy(void) {
//Return TRUE if empty, FALSE if not empty. //Return TRUE if empty, FALSE if not empty.
static BOOL static BOOL
brt_is_empty (BRT brt, TOKULOGGER logger) { brt_is_empty (BRT brt) {
BRT_CURSOR cursor; BRT_CURSOR cursor;
int r, r2; int r, r2;
BOOL is_empty; BOOL is_empty;
r = toku_brt_cursor(brt, &cursor, NULL); r = toku_brt_cursor(brt, &cursor, NULL);
if (r == 0) { if (r == 0) {
r = toku_brt_cursor_first(cursor, getf_nothing, NULL, logger); r = toku_brt_cursor_first(cursor, getf_nothing, NULL);
r2 = toku_brt_cursor_close(cursor); r2 = toku_brt_cursor_close(cursor);
is_empty = (BOOL)(r2==0 && r==DB_NOTFOUND); is_empty = (BOOL)(r2==0 && r==DB_NOTFOUND);
} }
...@@ -4786,7 +4870,7 @@ int ...@@ -4786,7 +4870,7 @@ int
toku_brt_note_table_lock (BRT brt, TOKUTXN txn) toku_brt_note_table_lock (BRT brt, TOKUTXN txn)
{ {
if (brt->h->txnid_that_created_or_locked_when_empty != toku_txn_get_txnid(txn) && if (brt->h->txnid_that_created_or_locked_when_empty != toku_txn_get_txnid(txn) &&
brt_is_empty(brt, toku_txn_logger(txn)) && brt_is_empty(brt) &&
brt->h->txnid_that_created_or_locked_when_empty == 0) { brt->h->txnid_that_created_or_locked_when_empty == 0) {
brt->h->txnid_that_created_or_locked_when_empty = toku_txn_get_txnid(txn); brt->h->txnid_that_created_or_locked_when_empty = toku_txn_get_txnid(txn);
int r = toku_txn_note_brt(txn, brt); int r = toku_txn_note_brt(txn, brt);
......
...@@ -50,6 +50,7 @@ int toku_brt_open(BRT, const char *fname, const char *fname_in_env, int is_creat ...@@ -50,6 +50,7 @@ int toku_brt_open(BRT, const char *fname, const char *fname_in_env, int is_creat
int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags); int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags);
int toku_brt_broadcast_commit_all (BRT brt);
int toku_brt_insert (BRT, DBT *, DBT *, TOKUTXN); int toku_brt_insert (BRT, DBT *, DBT *, TOKUTXN);
int toku_brt_lookup (BRT brt, DBT *k, DBT *v, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_lookup (BRT brt, DBT *k, DBT *v, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_delete (BRT brt, DBT *k, TOKUTXN); int toku_brt_delete (BRT brt, DBT *k, TOKUTXN);
...@@ -89,23 +90,23 @@ typedef struct brt_cursor *BRT_CURSOR; ...@@ -89,23 +90,23 @@ typedef struct brt_cursor *BRT_CURSOR;
int toku_brt_cursor (BRT, BRT_CURSOR*, TOKULOGGER); int toku_brt_cursor (BRT, BRT_CURSOR*, TOKULOGGER);
// get is deprecated in favor of the individual functions below // get is deprecated in favor of the individual functions below
int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, int get_flags, TOKUTXN txn); int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, int get_flags);
int toku_brt_flatten(BRT, TOKULOGGER logger); int toku_brt_flatten(BRT, TOKULOGGER logger);
int toku_brt_cursor_first(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_first(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_last(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_last(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_next_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_next_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_next_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_next_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_prev(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_prev(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_prev_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_prev_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_prev_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_prev_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_current(BRT_CURSOR cursor, int op, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_current(BRT_CURSOR cursor, int op, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_set(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_set(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_set_range(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_set_range(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_set_range_reverse(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_set_range_reverse(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_get_both_range(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_get_both_range(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
int toku_brt_cursor_get_both_range_reverse(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger); int toku_brt_cursor_get_both_range_reverse(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v);
typedef struct { typedef struct {
...@@ -114,7 +115,7 @@ typedef struct { ...@@ -114,7 +115,7 @@ typedef struct {
int r_h; int r_h;
int direction; int direction;
} *HEAVI_WRAPPER, HEAVI_WRAPPER_S; } *HEAVI_WRAPPER, HEAVI_WRAPPER_S;
int toku_brt_cursor_heaviside(BRT_CURSOR cursor, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger, HEAVI_WRAPPER wrapper); int toku_brt_cursor_heaviside(BRT_CURSOR cursor, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, HEAVI_WRAPPER wrapper);
int toku_brt_cursor_delete(BRT_CURSOR cursor, int flags, TOKUTXN); int toku_brt_cursor_delete(BRT_CURSOR cursor, int flags, TOKUTXN);
int toku_brt_cursor_close (BRT_CURSOR curs); int toku_brt_cursor_close (BRT_CURSOR curs);
BOOL toku_brt_cursor_uninitialized(BRT_CURSOR c); BOOL toku_brt_cursor_uninitialized(BRT_CURSOR c);
......
...@@ -112,6 +112,7 @@ dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) { ...@@ -112,6 +112,7 @@ dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) {
case BRT_ABORT_BOTH: printf("ABORT_BOTH"); goto ok; case BRT_ABORT_BOTH: printf("ABORT_BOTH"); goto ok;
case BRT_COMMIT_ANY: printf("COMMIT_ANY"); goto ok; case BRT_COMMIT_ANY: printf("COMMIT_ANY"); goto ok;
case BRT_COMMIT_BOTH: printf("COMMIT_BOTH"); goto ok; case BRT_COMMIT_BOTH: printf("COMMIT_BOTH"); goto ok;
case BRT_COMMIT_BROADCAST_ALL: printf("COMMIT_BROADCAST_ALL"); goto ok;
} }
printf("HUH?"); printf("HUH?");
ok: ok:
......
...@@ -90,7 +90,8 @@ enum brt_msg_type { ...@@ -90,7 +90,8 @@ enum brt_msg_type {
BRT_ABORT_ANY = 4, // Abort any commands on any matching key. BRT_ABORT_ANY = 4, // Abort any commands on any matching key.
BRT_ABORT_BOTH = 5, // Abort commands that match both the key and the value BRT_ABORT_BOTH = 5, // Abort commands that match both the key and the value
BRT_COMMIT_ANY = 6, BRT_COMMIT_ANY = 6,
BRT_COMMIT_BOTH = 7 BRT_COMMIT_BOTH = 7,
BRT_COMMIT_BROADCAST_ALL = 8 // Broadcast to all leafentries, (commit all transactions).
}; };
typedef struct xids_t *XIDS; typedef struct xids_t *XIDS;
......
...@@ -77,7 +77,7 @@ static int do_insertion (enum brt_msg_type type, FILENUM filenum, BYTESTRING key ...@@ -77,7 +77,7 @@ static int do_insertion (enum brt_msg_type type, FILENUM filenum, BYTESTRING key
assert(r==0); assert(r==0);
BRT brt = brtv; BRT brt = brtv;
r = toku_brt_root_put_cmd(brt, &brtcmd, txn->logger); r = toku_brt_root_put_cmd(brt, &brtcmd);
return r; return r;
} }
......
...@@ -57,7 +57,7 @@ static void test_sub_block(int n) { ...@@ -57,7 +57,7 @@ static void test_sub_block(int n) {
int k = htonl(i); int k = htonl(i);
int v = i; int v = i;
struct check_pair pair = {sizeof k, &k, sizeof v, &v, 0}; struct check_pair pair = {sizeof k, &k, sizeof v, &v, 0};
error = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); error = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
if (error != 0) { if (error != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
......
...@@ -65,8 +65,7 @@ static void test_multiple_brt_cursor_dbts(int n, DB *db) { ...@@ -65,8 +65,7 @@ static void test_multiple_brt_cursor_dbts(int n, DB *db) {
toku_init_dbt(&vbt), toku_init_dbt(&vbt),
save_data, save_data,
&ptrs[i], &ptrs[i],
DB_SET, DB_SET);
null_txn);
assert(r == 0); assert(r == 0);
} }
......
...@@ -23,7 +23,7 @@ static void assert_cursor_notfound(BRT brt, int position) { ...@@ -23,7 +23,7 @@ static void assert_cursor_notfound(BRT brt, int position) {
assert(r==0); assert(r==0);
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, position, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, position);
assert(r == DB_NOTFOUND); assert(r == DB_NOTFOUND);
assert(pair.call_count==0); assert(pair.call_count==0);
...@@ -40,7 +40,7 @@ static void assert_cursor_value(BRT brt, int position, long long value) { ...@@ -40,7 +40,7 @@ static void assert_cursor_value(BRT brt, int position, long long value) {
if (test_cursor_debug && verbose) printf("key: "); if (test_cursor_debug && verbose) printf("key: ");
struct check_pair pair = {len_ignore, 0, sizeof(value), &value, 0}; struct check_pair pair = {len_ignore, 0, sizeof(value), &value, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, position, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, position);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
...@@ -58,7 +58,7 @@ static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv) ...@@ -58,7 +58,7 @@ static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv)
if (test_cursor_debug && verbose) printf("first key: "); if (test_cursor_debug && verbose) printf("first key: ");
{ {
struct check_pair pair = {len_ignore, 0, sizeof(firstv), &firstv, 0}; struct check_pair pair = {len_ignore, 0, sizeof(firstv), &firstv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -66,7 +66,7 @@ static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv) ...@@ -66,7 +66,7 @@ static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv)
if (test_cursor_debug && verbose) printf("last key:"); if (test_cursor_debug && verbose) printf("last key:");
{ {
struct check_pair pair = {len_ignore, 0, sizeof(lastv), &lastv, 0}; struct check_pair pair = {len_ignore, 0, sizeof(lastv), &lastv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -257,7 +257,7 @@ static void assert_cursor_walk(BRT brt, int n) { ...@@ -257,7 +257,7 @@ static void assert_cursor_walk(BRT brt, int n) {
for (i=0; ; i++) { for (i=0; ; i++) {
long long v = i; long long v = i;
struct check_pair pair = {len_ignore, 0, sizeof(v), &v, 0}; struct check_pair pair = {len_ignore, 0, sizeof(v), &v, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
if (r != 0) { if (r != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -323,7 +323,7 @@ static void assert_cursor_rwalk(BRT brt, int n) { ...@@ -323,7 +323,7 @@ static void assert_cursor_rwalk(BRT brt, int n) {
for (i=n-1; ; i--) { for (i=n-1; ; i--) {
long long v = i; long long v = i;
struct check_pair pair = {len_ignore, 0, sizeof v, &v, 0}; struct check_pair pair = {len_ignore, 0, sizeof v, &v, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_PREV, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_PREV);
if (r != 0) { if (r != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -407,7 +407,7 @@ static void assert_cursor_walk_inorder(BRT brt, int n) { ...@@ -407,7 +407,7 @@ static void assert_cursor_walk_inorder(BRT brt, int n) {
if (test_cursor_debug && verbose) printf("key: "); if (test_cursor_debug && verbose) printf("key: ");
for (i=0; ; i++) { for (i=0; ; i++) {
r = toku_brt_cursor_get(cursor, NULL, NULL, ascending_key_string_checkf, &prevkey, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, ascending_key_string_checkf, &prevkey, DB_NEXT);
if (r != 0) { if (r != 0) {
break; break;
} }
...@@ -510,7 +510,7 @@ static void test_brt_cursor_split(int n, DB *db) { ...@@ -510,7 +510,7 @@ static void test_brt_cursor_split(int n, DB *db) {
if (test_cursor_debug && verbose) printf("key: "); if (test_cursor_debug && verbose) printf("key: ");
for (i=0; i<n/2; i++) { for (i=0; i<n/2; i++) {
struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0}; struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
assert(r==0); assert(r==0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -532,7 +532,7 @@ static void test_brt_cursor_split(int n, DB *db) { ...@@ -532,7 +532,7 @@ static void test_brt_cursor_split(int n, DB *db) {
// Just loop through the cursor // Just loop through the cursor
for (;;) { for (;;) {
struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0}; struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
if (r != 0) { if (r != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -642,7 +642,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) { ...@@ -642,7 +642,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) {
if ((i % cursor_gap) == 0) { if ((i % cursor_gap) == 0) {
c = i / cursor_gap; c = i / cursor_gap;
struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0}; struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0};
r = toku_brt_cursor_get(cursors[c], NULL, NULL, lookup_checkf, &pair, DB_LAST, null_txn); r = toku_brt_cursor_get(cursors[c], NULL, NULL, lookup_checkf, &pair, DB_LAST);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -653,7 +653,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) { ...@@ -653,7 +653,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) {
for (c=0; c<ncursors; c++) { for (c=0; c<ncursors; c++) {
int vv = c*cursor_gap + i + 1; int vv = c*cursor_gap + i + 1;
struct check_pair pair = {len_ignore, 0, sizeof vv, &vv, 0}; struct check_pair pair = {len_ignore, 0, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursors[c], NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursors[c], NULL, NULL, lookup_checkf, &pair, DB_NEXT);
if (r == DB_NOTFOUND) { if (r == DB_NOTFOUND) {
/* we already consumed 1 previously */ /* we already consumed 1 previously */
assert(pair.call_count==0); assert(pair.call_count==0);
...@@ -719,7 +719,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -719,7 +719,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
struct check_pair pair = {sizeof k, 0, sizeof vv, &v, 0}; struct check_pair pair = {sizeof k, 0, sizeof vv, &v, 0};
if (cursor_op == DB_SET) pair.key = &k; // if it is a set operation, make sure that the result we get is the right one. if (cursor_op == DB_SET) pair.key = &k; // if it is a set operation, make sure that the result we get is the right one.
r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, cursor_op, null_txn); r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, cursor_op);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -732,7 +732,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -732,7 +732,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
DBT key; DBT key;
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
struct check_pair pair = {0, 0, 0, 0, 0}; struct check_pair pair = {0, 0, 0, 0, 0};
r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, DB_SET, null_txn); r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, DB_SET);
CKERR2(r,DB_NOTFOUND); CKERR2(r,DB_NOTFOUND);
assert(pair.call_count==0); assert(pair.call_count==0);
assert(key.data == &k); // make sure that no side effect happened on key assert(key.data == &k); // make sure that no side effect happened on key
...@@ -792,7 +792,7 @@ static void test_brt_cursor_set_range(int n, DB *db) { ...@@ -792,7 +792,7 @@ static void test_brt_cursor_set_range(int n, DB *db) {
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
int vv = ((v+9)/10)*10; int vv = ((v+9)/10)*10;
struct check_pair pair = {sizeof k, 0, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof k, 0, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, DB_SET_RANGE, null_txn); r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, DB_SET_RANGE);
if (v > max_key) { if (v > max_key) {
/* there is no smallest key if v > the max key */ /* there is no smallest key if v > the max key */
assert(r == DB_NOTFOUND); assert(r == DB_NOTFOUND);
...@@ -849,7 +849,7 @@ static void test_brt_cursor_delete(int n, DB *db) { ...@@ -849,7 +849,7 @@ static void test_brt_cursor_delete(int n, DB *db) {
/* walk the tree and delete under the cursor */ /* walk the tree and delete under the cursor */
for (;;) { for (;;) {
struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0}; struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0};
error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_NEXT, null_txn); error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_NEXT);
if (error == DB_NOTFOUND) { if (error == DB_NOTFOUND) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -901,7 +901,7 @@ static void test_brt_cursor_get_both(int n, DB *db) { ...@@ -901,7 +901,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v); toku_fill_dbt(&val, &v, sizeof v);
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH, null_txn); error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH);
assert(error == DB_NOTFOUND); assert(error == DB_NOTFOUND);
assert(pair.call_count==0); assert(pair.call_count==0);
} }
...@@ -927,7 +927,7 @@ static void test_brt_cursor_get_both(int n, DB *db) { ...@@ -927,7 +927,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v); toku_fill_dbt(&val, &v, sizeof v);
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH, null_txn); error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH);
assert(error == DB_NOTFOUND); assert(error == DB_NOTFOUND);
assert(pair.call_count==0); assert(pair.call_count==0);
} }
...@@ -940,7 +940,7 @@ static void test_brt_cursor_get_both(int n, DB *db) { ...@@ -940,7 +940,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v); toku_fill_dbt(&val, &v, sizeof v);
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH, null_txn); error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH);
assert(error == DB_NOTFOUND); assert(error == DB_NOTFOUND);
assert(pair.call_count==0); assert(pair.call_count==0);
} }
...@@ -954,7 +954,7 @@ static void test_brt_cursor_get_both(int n, DB *db) { ...@@ -954,7 +954,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v); toku_fill_dbt(&val, &v, sizeof v);
struct check_pair pair = {len_ignore,0,len_ignore,0,0}; struct check_pair pair = {len_ignore,0,len_ignore,0,0};
error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH, null_txn); error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH);
assert(error == 0); assert(error == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -962,7 +962,7 @@ static void test_brt_cursor_get_both(int n, DB *db) { ...@@ -962,7 +962,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
{ {
int vv = i; int vv = i;
struct check_pair pair = {len_ignore, 0, sizeof vv, &vv, 0}; struct check_pair pair = {len_ignore, 0, sizeof vv, &vv, 0};
error = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT, 0); error = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT);
assert(error == 0); assert(error == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -976,7 +976,7 @@ static void test_brt_cursor_get_both(int n, DB *db) { ...@@ -976,7 +976,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v); toku_fill_dbt(&val, &v, sizeof v);
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH, null_txn); error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH);
assert(error == DB_NOTFOUND); assert(error == DB_NOTFOUND);
assert(pair.call_count==0); assert(pair.call_count==0);
} }
......
...@@ -258,13 +258,13 @@ static void test_cursor_last_empty(void) { ...@@ -258,13 +258,13 @@ static void test_cursor_last_empty(void) {
r = toku_brt_cursor(brt, &cursor, NULL); assert(r==0); r = toku_brt_cursor(brt, &cursor, NULL); assert(r==0);
{ {
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST);
assert(pair.call_count==0); assert(pair.call_count==0);
assert(r==DB_NOTFOUND); assert(r==DB_NOTFOUND);
} }
{ {
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST);
assert(pair.call_count==0); assert(pair.call_count==0);
assert(r==DB_NOTFOUND); assert(r==DB_NOTFOUND);
} }
...@@ -300,7 +300,7 @@ static void test_cursor_next (void) { ...@@ -300,7 +300,7 @@ static void test_cursor_next (void) {
if (verbose) printf("%s:%d calling toku_brt_cursor_get(...)\n", __FILE__, __LINE__); if (verbose) printf("%s:%d calling toku_brt_cursor_get(...)\n", __FILE__, __LINE__);
{ {
struct check_pair pair = {7, "byebye", 7, "byenow", 0}; struct check_pair pair = {7, "byebye", 7, "byenow", 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
if (verbose) printf("%s:%d called toku_brt_cursor_get(...)\n", __FILE__, __LINE__); if (verbose) printf("%s:%d called toku_brt_cursor_get(...)\n", __FILE__, __LINE__);
assert(r==0); assert(r==0);
assert(pair.call_count==1); assert(pair.call_count==1);
...@@ -308,13 +308,13 @@ static void test_cursor_next (void) { ...@@ -308,13 +308,13 @@ static void test_cursor_next (void) {
{ {
struct check_pair pair = {6, "hello", 6, "there", 0}; struct check_pair pair = {6, "hello", 6, "there", 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
assert(r==0); assert(r==0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
{ {
struct check_pair pair = {0, 0, 0, 0, 0}; struct check_pair pair = {0, 0, 0, 0, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
assert(r==DB_NOTFOUND); assert(r==DB_NOTFOUND);
assert(pair.call_count==0); assert(pair.call_count==0);
} }
...@@ -392,7 +392,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -392,7 +392,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
b[2] = a[1] = (unsigned char)((i>>8)&255); b[2] = a[1] = (unsigned char)((i>>8)&255);
b[1] = a[2] = (unsigned char)((i>>16)&255); b[1] = a[2] = (unsigned char)((i>>16)&255);
b[0] = a[3] = (unsigned char)((i>>24)&255); b[0] = a[3] = (unsigned char)((i>>24)&255);
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
assert(r==0); assert(r==0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -432,7 +432,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -432,7 +432,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
b[2] = a[1] = (unsigned char)((i>>8)&255); b[2] = a[1] = (unsigned char)((i>>8)&255);
b[1] = a[2] = (unsigned char)((i>>16)&255); b[1] = a[2] = (unsigned char)((i>>16)&255);
b[0] = a[3] = (unsigned char)((i>>24)&255); b[0] = a[3] = (unsigned char)((i>>24)&255);
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
assert(r==0); assert(r==0);
assert(pair.call_count==1); assert(pair.call_count==1);
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
...@@ -572,7 +572,7 @@ static void test_brt_delete_present(int n) { ...@@ -572,7 +572,7 @@ static void test_brt_delete_present(int n) {
{ {
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST);
assert(r != 0); assert(r != 0);
assert(pair.call_count==0); assert(pair.call_count==0);
} }
...@@ -705,7 +705,7 @@ static void test_brt_delete_cursor_first(int n) { ...@@ -705,7 +705,7 @@ static void test_brt_delete_cursor_first(int n) {
int kv = toku_htonl(n-1); int kv = toku_htonl(n-1);
int vv = n-1; int vv = n-1;
struct check_pair pair = {sizeof kv, &kv, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kv, &kv, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -826,7 +826,7 @@ static void test_brt_delete_both(int n) { ...@@ -826,7 +826,7 @@ static void test_brt_delete_both(int n) {
int kv = toku_htonl(0); int kv = toku_htonl(0);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kv, &kv, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kv, &kv, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
if (r != 0) { if (r != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -910,7 +910,7 @@ static void test_new_brt_cursor_first(int n, int dup_mode) { ...@@ -910,7 +910,7 @@ static void test_new_brt_cursor_first(int n, int dup_mode) {
int kv = toku_htonl(i); int kv = toku_htonl(i);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kv, &kv, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kv, &kv, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST);
if (r != 0) { if (r != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -963,7 +963,7 @@ static void test_new_brt_cursor_last(int n, int dup_mode) { ...@@ -963,7 +963,7 @@ static void test_new_brt_cursor_last(int n, int dup_mode) {
int kk = toku_htonl(i); int kk = toku_htonl(i);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST);
if (r != 0) { if (r != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -1013,7 +1013,7 @@ static void test_new_brt_cursor_next(int n, int dup_mode) { ...@@ -1013,7 +1013,7 @@ static void test_new_brt_cursor_next(int n, int dup_mode) {
int kk = toku_htonl(i); int kk = toku_htonl(i);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
if (r != 0) { if (r != 0) {
assert(pair.call_count ==0); assert(pair.call_count ==0);
break; break;
...@@ -1057,7 +1057,7 @@ static void test_new_brt_cursor_prev(int n, int dup_mode) { ...@@ -1057,7 +1057,7 @@ static void test_new_brt_cursor_prev(int n, int dup_mode) {
int kk = toku_htonl(i); int kk = toku_htonl(i);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_PREV, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_PREV);
if (r != 0) { if (r != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -1102,7 +1102,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) { ...@@ -1102,7 +1102,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk = toku_htonl(i); int kk = toku_htonl(i);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST);
if (r != 0) { if (r != 0) {
assert(pair.call_count==0); assert(pair.call_count==0);
break; break;
...@@ -1113,7 +1113,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) { ...@@ -1113,7 +1113,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk = toku_htonl(i); int kk = toku_htonl(i);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -1122,7 +1122,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) { ...@@ -1122,7 +1122,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk = toku_htonl(i); int kk = toku_htonl(i);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT_BINDING, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT_BINDING);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -1133,7 +1133,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) { ...@@ -1133,7 +1133,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
static int count=0; static int count=0;
count++; count++;
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT);
CKERR2(r,DB_NOTFOUND); // previous DB_KEYEMPTY CKERR2(r,DB_NOTFOUND); // previous DB_KEYEMPTY
assert(pair.call_count==0); assert(pair.call_count==0);
} }
...@@ -1142,7 +1142,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) { ...@@ -1142,7 +1142,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk = toku_htonl(i); int kk = toku_htonl(i);
int vv = toku_htonl(i); int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0}; struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT_BINDING, null_txn); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT_BINDING);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
} }
...@@ -1196,7 +1196,7 @@ static void test_new_brt_cursor_set_range(int n, int dup_mode) { ...@@ -1196,7 +1196,7 @@ static void test_new_brt_cursor_set_range(int n, int dup_mode) {
struct check_pair pair = {sizeof k, NULL, // NULL data means don't check it struct check_pair pair = {sizeof k, NULL, // NULL data means don't check it
sizeof vv, &vv, sizeof vv, &vv,
0}; 0};
r = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_SET_RANGE, null_txn); r = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_SET_RANGE);
if (v > max_key) { if (v > max_key) {
/* there is no smallest key if v > the max key */ /* there is no smallest key if v > the max key */
assert(r == DB_NOTFOUND); assert(r == DB_NOTFOUND);
...@@ -1247,7 +1247,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -1247,7 +1247,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) {
int k = toku_htonl(v); int k = toku_htonl(v);
DBT key = {.size=sizeof k, .data=&k}; DBT key = {.size=sizeof k, .data=&k};
struct check_pair pair = {sizeof k, &k, sizeof v, &v, 0}; struct check_pair pair = {sizeof k, &k, sizeof v, &v, 0};
r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, cursor_op, null_txn); r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, cursor_op);
assert(r == 0); assert(r == 0);
assert(pair.call_count==1); assert(pair.call_count==1);
if (cursor_op == DB_SET) assert(key.data == &k); if (cursor_op == DB_SET) assert(key.data == &k);
...@@ -1260,7 +1260,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -1260,7 +1260,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) {
int k = toku_htonl(i); int k = toku_htonl(i);
DBT key = {.size=sizeof k, .data=&k}; DBT key = {.size=sizeof k, .data=&k};
struct check_pair pair = {0,0,0,0,0}; struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, DB_SET, null_txn); r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, DB_SET);
assert(r == DB_NOTFOUND); assert(r == DB_NOTFOUND);
assert(pair.call_count==0); assert(pair.call_count==0);
assert(key.data == &k); assert(key.data == &k);
......
...@@ -34,11 +34,11 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute ...@@ -34,11 +34,11 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute
{ {
struct check_pair pair = {5, "0000", 5, "0000", 0}; struct check_pair pair = {5, "0000", 5, "0000", 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); assert(r==0); assert(pair.call_count==1); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
} }
{ {
struct check_pair pair = {5, "0001", 5, "0001", 0}; struct check_pair pair = {5, "0001", 5, "0001", 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); assert(r==0); assert(pair.call_count==1); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
} }
// This will invalidate due to the root counter bumping, but the OMT itself will still be valid. // This will invalidate due to the root counter bumping, but the OMT itself will still be valid.
...@@ -49,7 +49,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute ...@@ -49,7 +49,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute
{ {
struct check_pair pair = {5, "0002", 5, "0002", 0}; struct check_pair pair = {5, "0002", 5, "0002", 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT, null_txn); assert(r==0); assert(pair.call_count==1); r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
} }
r = toku_brt_cursor_close(cursor); assert(r==0); r = toku_brt_cursor_close(cursor); assert(r==0);
......
...@@ -1351,13 +1351,6 @@ c_get_wrapper_callback(DBT const *key, DBT const *val, void *extra) { ...@@ -1351,13 +1351,6 @@ c_get_wrapper_callback(DBT const *key, DBT const *val, void *extra) {
return r; return r;
} }
static TOKULOGGER
c_get_logger(DBC *c) {
TOKUTXN txn = dbc_struct_i(c)->txn ? db_txn_struct_i(dbc_struct_i(c)->txn)->tokutxn : NULL;
TOKULOGGER logger = toku_txn_logger(txn);
return logger;
}
static int toku_c_get_current_unconditional(DBC* c, u_int32_t flags, DBT* key, DBT* val) { static int toku_c_get_current_unconditional(DBC* c, u_int32_t flags, DBT* key, DBT* val) {
int r; int r;
QUERY_CONTEXT_WRAPPED_S context; QUERY_CONTEXT_WRAPPED_S context;
...@@ -1793,9 +1786,8 @@ toku_c_getf_first(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) ...@@ -1793,9 +1786,8 @@ toku_c_getf_first(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra)
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_first will call c_getf_first_callback(..., context) (if query is successful) //toku_brt_cursor_first will call c_getf_first_callback(..., context) (if query is successful)
int r = toku_brt_cursor_first(dbc_struct_i(c)->c, c_getf_first_callback, &context, logger); int r = toku_brt_cursor_first(dbc_struct_i(c)->c, c_getf_first_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -1848,9 +1840,8 @@ toku_c_getf_last(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { ...@@ -1848,9 +1840,8 @@ toku_c_getf_last(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) {
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_last will call c_getf_last_callback(..., context) (if query is successful) //toku_brt_cursor_last will call c_getf_last_callback(..., context) (if query is successful)
int r = toku_brt_cursor_last(dbc_struct_i(c)->c, c_getf_last_callback, &context, logger); int r = toku_brt_cursor_last(dbc_struct_i(c)->c, c_getf_last_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -1906,9 +1897,8 @@ toku_c_getf_next(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { ...@@ -1906,9 +1897,8 @@ toku_c_getf_next(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) {
else { else {
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful) //toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful)
r = toku_brt_cursor_next(dbc_struct_i(c)->c, c_getf_next_callback, &context, logger); r = toku_brt_cursor_next(dbc_struct_i(c)->c, c_getf_next_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
} }
return r; return r;
...@@ -1961,9 +1951,8 @@ toku_c_getf_next_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *ex ...@@ -1961,9 +1951,8 @@ toku_c_getf_next_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *ex
else { else {
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful) //toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful)
r = toku_brt_cursor_next_nodup(dbc_struct_i(c)->c, c_getf_next_callback, &context, logger); r = toku_brt_cursor_next_nodup(dbc_struct_i(c)->c, c_getf_next_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
} }
return r; return r;
...@@ -1979,9 +1968,8 @@ toku_c_getf_next_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extr ...@@ -1979,9 +1968,8 @@ toku_c_getf_next_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extr
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_next_dup will call c_getf_next_dup_callback(..., context) (if query is successful) //toku_brt_cursor_next_dup will call c_getf_next_dup_callback(..., context) (if query is successful)
int r = toku_brt_cursor_next_dup(dbc_struct_i(c)->c, c_getf_next_dup_callback, &context, logger); int r = toku_brt_cursor_next_dup(dbc_struct_i(c)->c, c_getf_next_dup_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -2035,9 +2023,8 @@ toku_c_getf_prev(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { ...@@ -2035,9 +2023,8 @@ toku_c_getf_prev(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) {
else { else {
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful) //toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful)
r = toku_brt_cursor_prev(dbc_struct_i(c)->c, c_getf_prev_callback, &context, logger); r = toku_brt_cursor_prev(dbc_struct_i(c)->c, c_getf_prev_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
} }
return r; return r;
...@@ -2090,9 +2077,8 @@ toku_c_getf_prev_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *ex ...@@ -2090,9 +2077,8 @@ toku_c_getf_prev_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *ex
else { else {
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful) //toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful)
r = toku_brt_cursor_prev_nodup(dbc_struct_i(c)->c, c_getf_prev_callback, &context, logger); r = toku_brt_cursor_prev_nodup(dbc_struct_i(c)->c, c_getf_prev_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
} }
return r; return r;
...@@ -2108,9 +2094,8 @@ toku_c_getf_prev_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extr ...@@ -2108,9 +2094,8 @@ toku_c_getf_prev_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extr
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_prev_dup will call c_getf_prev_dup_callback(..., context) (if query is successful) //toku_brt_cursor_prev_dup will call c_getf_prev_dup_callback(..., context) (if query is successful)
int r = toku_brt_cursor_prev_dup(dbc_struct_i(c)->c, c_getf_prev_dup_callback, &context, logger); int r = toku_brt_cursor_prev_dup(dbc_struct_i(c)->c, c_getf_prev_dup_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -2161,9 +2146,8 @@ toku_c_getf_current(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra ...@@ -2161,9 +2146,8 @@ toku_c_getf_current(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_current will call c_getf_current_callback(..., context) (if query is successful) //toku_brt_cursor_current will call c_getf_current_callback(..., context) (if query is successful)
int r = toku_brt_cursor_current(dbc_struct_i(c)->c, DB_CURRENT, c_getf_current_callback, &context, logger); int r = toku_brt_cursor_current(dbc_struct_i(c)->c, DB_CURRENT, c_getf_current_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -2197,9 +2181,8 @@ toku_c_getf_current_binding(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, voi ...@@ -2197,9 +2181,8 @@ toku_c_getf_current_binding(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, voi
QUERY_CONTEXT_S context; //Describes the context of this query. QUERY_CONTEXT_S context; //Describes the context of this query.
query_context_init(&context, c, flag, f, extra); query_context_init(&context, c, flag, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_current will call c_getf_current_callback(..., context) (if query is successful) //toku_brt_cursor_current will call c_getf_current_callback(..., context) (if query is successful)
int r = toku_brt_cursor_current(dbc_struct_i(c)->c, DB_CURRENT_BINDING, c_getf_current_callback, &context, logger); int r = toku_brt_cursor_current(dbc_struct_i(c)->c, DB_CURRENT_BINDING, c_getf_current_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -2213,9 +2196,8 @@ toku_c_getf_set(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, void ...@@ -2213,9 +2196,8 @@ toku_c_getf_set(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, void
QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query.
query_context_with_input_init(&context, c, flag, key, NULL, f, extra); query_context_with_input_init(&context, c, flag, key, NULL, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_set will call c_getf_set_callback(..., context) (if query is successful) //toku_brt_cursor_set will call c_getf_set_callback(..., context) (if query is successful)
int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, NULL, c_getf_set_callback, &context, logger); int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, NULL, c_getf_set_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -2271,9 +2253,8 @@ toku_c_getf_set_range(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, ...@@ -2271,9 +2253,8 @@ toku_c_getf_set_range(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f,
QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query.
query_context_with_input_init(&context, c, flag, key, NULL, f, extra); query_context_with_input_init(&context, c, flag, key, NULL, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_set_range will call c_getf_set_range_callback(..., context) (if query is successful) //toku_brt_cursor_set_range will call c_getf_set_range_callback(..., context) (if query is successful)
int r = toku_brt_cursor_set_range(dbc_struct_i(c)->c, key, c_getf_set_range_callback, &context, logger); int r = toku_brt_cursor_set_range(dbc_struct_i(c)->c, key, c_getf_set_range_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -2330,9 +2311,8 @@ toku_c_getf_set_range_reverse(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUN ...@@ -2330,9 +2311,8 @@ toku_c_getf_set_range_reverse(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUN
QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query.
query_context_with_input_init(&context, c, flag, key, NULL, f, extra); query_context_with_input_init(&context, c, flag, key, NULL, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_set_range_reverse will call c_getf_set_range_reverse_callback(..., context) (if query is successful) //toku_brt_cursor_set_range_reverse will call c_getf_set_range_reverse_callback(..., context) (if query is successful)
int r = toku_brt_cursor_set_range_reverse(dbc_struct_i(c)->c, key, c_getf_set_range_reverse_callback, &context, logger); int r = toku_brt_cursor_set_range_reverse(dbc_struct_i(c)->c, key, c_getf_set_range_reverse_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -2389,9 +2369,8 @@ toku_c_getf_get_both(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FU ...@@ -2389,9 +2369,8 @@ toku_c_getf_get_both(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FU
QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query.
query_context_with_input_init(&context, c, flag, key, val, f, extra); query_context_with_input_init(&context, c, flag, key, val, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_get_both will call c_getf_get_both_callback(..., context) (if query is successful) //toku_brt_cursor_get_both will call c_getf_get_both_callback(..., context) (if query is successful)
int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, val, c_getf_get_both_callback, &context, logger); int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, val, c_getf_get_both_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
...@@ -2442,9 +2421,8 @@ toku_c_getf_get_both_range(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLB ...@@ -2442,9 +2421,8 @@ toku_c_getf_get_both_range(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLB
else { else {
QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query.
query_context_with_input_init(&context, c, flag, key, val, f, extra); query_context_with_input_init(&context, c, flag, key, val, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_get_both_range will call c_getf_get_both_range_callback(..., context) (if query is successful) //toku_brt_cursor_get_both_range will call c_getf_get_both_range_callback(..., context) (if query is successful)
r = toku_brt_cursor_get_both_range(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_callback, &context, logger); r = toku_brt_cursor_get_both_range(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
} }
return r; return r;
...@@ -2503,9 +2481,8 @@ toku_c_getf_get_both_range_reverse(DBC *c, u_int32_t flag, DBT *key, DBT *val, Y ...@@ -2503,9 +2481,8 @@ toku_c_getf_get_both_range_reverse(DBC *c, u_int32_t flag, DBT *key, DBT *val, Y
else { else {
QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query.
query_context_with_input_init(&context, c, flag, key, val, f, extra); query_context_with_input_init(&context, c, flag, key, val, f, extra);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_get_both_range_reverse will call c_getf_get_both_range_reverse_callback(..., context) (if query is successful) //toku_brt_cursor_get_both_range_reverse will call c_getf_get_both_range_reverse_callback(..., context) (if query is successful)
r = toku_brt_cursor_get_both_range_reverse(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_reverse_callback, &context, logger); r = toku_brt_cursor_get_both_range_reverse(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_reverse_callback, &context);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
} }
return r; return r;
...@@ -2596,9 +2573,8 @@ toku_c_getf_heaviside(DBC *c, u_int32_t flag, ...@@ -2596,9 +2573,8 @@ toku_c_getf_heaviside(DBC *c, u_int32_t flag,
heavi_wrapper_init(&wrapper, h, extra_h, direction); heavi_wrapper_init(&wrapper, h, extra_h, direction);
QUERY_CONTEXT_HEAVISIDE_S context; //Describes the context of this query. QUERY_CONTEXT_HEAVISIDE_S context; //Describes the context of this query.
query_context_heaviside_init(&context, c, flag, f, extra_f, &wrapper); query_context_heaviside_init(&context, c, flag, f, extra_f, &wrapper);
TOKULOGGER logger = c_get_logger(c);
//toku_brt_cursor_heaviside will call c_getf_heaviside_callback(..., context) (if query is successful) //toku_brt_cursor_heaviside will call c_getf_heaviside_callback(..., context) (if query is successful)
r = toku_brt_cursor_heaviside(dbc_struct_i(c)->c, c_getf_heaviside_callback, &context, logger, &wrapper); r = toku_brt_cursor_heaviside(dbc_struct_i(c)->c, c_getf_heaviside_callback, &context, &wrapper);
if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback;
return r; return r;
} }
......
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