Commit 0b0c7639 authored by Yoni Fogel's avatar Yoni Fogel

closes[t:1398] [t:2861] Remove more heaviside code (include straddle hacks) from newbrt

git-svn-id: file:///svn/toku/tokudb@23060 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1bfd207e
...@@ -2160,19 +2160,8 @@ brt_merge_child (BRT t, BRTNODE node, int childnum_to_merge, BOOL *did_io, BOOL ...@@ -2160,19 +2160,8 @@ brt_merge_child (BRT t, BRTNODE node, int childnum_to_merge, BOOL *did_io, BOOL
return r; return r;
} }
// TODO: #1398 Get rid of this entire straddle_callback hack
#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY
int STRADDLE_HACK_INSIDE_CALLBACK = 0;
#endif
static int static int
brt_handle_maybe_reactive_child(BRT t, BRTNODE node, int childnum, enum reactivity re, BOOL *did_io, BOOL *did_react) { brt_handle_maybe_reactive_child(BRT t, BRTNODE node, int childnum, enum reactivity re, BOOL *did_io, BOOL *did_react) {
#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY
if (STRADDLE_HACK_INSIDE_CALLBACK) {
*did_react = FALSE;
return 0;
}
#endif
switch (re) { switch (re) {
case RE_STABLE: case RE_STABLE:
*did_react = FALSE; *did_react = FALSE;
...@@ -2187,11 +2176,6 @@ brt_handle_maybe_reactive_child(BRT t, BRTNODE node, int childnum, enum reactivi ...@@ -2187,11 +2176,6 @@ 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) { brt_handle_maybe_reactive_child_at_root (BRT brt, CACHEKEY *rootp, BRTNODE *nodep, enum reactivity re) {
#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY
if (STRADDLE_HACK_INSIDE_CALLBACK) {
return 0;
}
#endif
BRTNODE node = *nodep; BRTNODE node = *nodep;
switch (re) { switch (re) {
case RE_STABLE: case RE_STABLE:
...@@ -4134,7 +4118,7 @@ is_le_val_empty(LEAFENTRY le, BRT_CURSOR brtcursor) { ...@@ -4134,7 +4118,7 @@ is_le_val_empty(LEAFENTRY le, BRT_CURSOR brtcursor) {
// This is a bottom layer of the search functions. // This is a bottom layer of the search functions.
static int static int
brt_search_leaf_node(BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *re, BOOL *doprefetch, BRT_CURSOR brtcursor) brt_search_leaf_node(BRTNODE node, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *re, BOOL *doprefetch, BRT_CURSOR brtcursor)
{ {
// Now we have to convert from brt_search_t to the heaviside function with a direction. What a pain... // Now we have to convert from brt_search_t to the heaviside function with a direction. What a pain...
...@@ -4204,11 +4188,7 @@ brt_search_leaf_node(BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_CALLBA ...@@ -4204,11 +4188,7 @@ brt_search_leaf_node(BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_CALLBA
assert(brtcursor->current_in_omt == FALSE); assert(brtcursor->current_in_omt == FALSE);
if (r==0) { if (r==0) {
r = getf(keylen, key, r = getf(keylen, key, vallen, val, getf_v);
vallen, val,
0, NULL, //TODO: Put actual values here.
0, NULL, //TODO: Put actual values here.
getf_v);
} }
if (r==0) { if (r==0) {
// Leave the omtcursor alone above (pass NULL to omt_find/fetch) // Leave the omtcursor alone above (pass NULL to omt_find/fetch)
...@@ -4236,7 +4216,7 @@ brt_search_leaf_node(BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_CALLBA ...@@ -4236,7 +4216,7 @@ brt_search_leaf_node(BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_CALLBA
} }
static int static int
brt_search_node (BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *re, BOOL *doprefetch, BRT_CURSOR brtcursor); brt_search_node (BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *re, BOOL *doprefetch, BRT_CURSOR brtcursor);
// the number of nodes to prefetch // the number of nodes to prefetch
#define TOKU_DO_PREFETCH 2 #define TOKU_DO_PREFETCH 2
...@@ -4266,7 +4246,7 @@ brt_node_maybe_prefetch(BRT brt, BRTNODE node, int childnum, BRT_CURSOR brtcurso ...@@ -4266,7 +4246,7 @@ brt_node_maybe_prefetch(BRT brt, BRTNODE node, int childnum, BRT_CURSOR brtcurso
/* search in a node's child */ /* search in a node's child */
static int static int
brt_search_child(BRT brt, BRTNODE node, int childnum, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *parent_re, BOOL *doprefetch, BRT_CURSOR brtcursor, BOOL *did_react) brt_search_child(BRT brt, BRTNODE node, int childnum, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *parent_re, BOOL *doprefetch, BRT_CURSOR brtcursor, BOOL *did_react)
// Effect: Search in a node's child. // Effect: Search in a node's child.
// If we change the shape, set *did_react = TRUE. Else set *did_react = FALSE. // If we change the shape, set *did_react = TRUE. Else set *did_react = FALSE.
{ {
...@@ -4324,7 +4304,7 @@ brt_search_child(BRT brt, BRTNODE node, int childnum, brt_search_t *search, BRT_ ...@@ -4324,7 +4304,7 @@ brt_search_child(BRT brt, BRTNODE node, int childnum, brt_search_t *search, BRT_
} }
static int static int
brt_search_nonleaf_node(BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *re, BOOL *doprefetch, BRT_CURSOR brtcursor) brt_search_nonleaf_node(BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *re, BOOL *doprefetch, BRT_CURSOR brtcursor)
{ {
int count=0; int count=0;
again: again:
...@@ -4365,7 +4345,7 @@ brt_search_nonleaf_node(BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STR ...@@ -4365,7 +4345,7 @@ brt_search_nonleaf_node(BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STR
} }
static int static int
brt_search_node (BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *re, BOOL *doprefetch, BRT_CURSOR brtcursor) brt_search_node (BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, enum reactivity *re, BOOL *doprefetch, BRT_CURSOR brtcursor)
{ {
verify_local_fingerprint_nonleaf(node); verify_local_fingerprint_nonleaf(node);
if (node->height > 0) if (node->height > 0)
...@@ -4376,7 +4356,7 @@ brt_search_node (BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STRADDLE_C ...@@ -4376,7 +4356,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, BRT_CURSOR brtcursor, u_int64_t *root_put_counter) toku_brt_search (BRT brt, brt_search_t *search, BRT_GET_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.
{ {
...@@ -4422,15 +4402,13 @@ toku_brt_search (BRT brt, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTI ...@@ -4422,15 +4402,13 @@ toku_brt_search (BRT brt, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTI
if (r==TOKUDB_FOUND_BUT_REJECTED) r = DB_NOTFOUND; if (r==TOKUDB_FOUND_BUT_REJECTED) r = DB_NOTFOUND;
else if (r==DB_NOTFOUND) { else if (r==DB_NOTFOUND) {
//We truly did not find an answer to the query. //We truly did not find an answer to the query.
//Therefore, the BRT_GET_STRADDLE_CALLBACK_FUNCTION has NOT been called. //Therefore, the BRT_GET_CALLBACK_FUNCTION has NOT been called.
//The contract specifies that the callback function must be called //The contract specifies that the callback function must be called
//for 'r= (0|DB_NOTFOUND|TOKUDB_FOUND_BUT_REJECTED)' //for 'r= (0|DB_NOTFOUND|TOKUDB_FOUND_BUT_REJECTED)'
//TODO: #1378 This is not the ultimate location of this call to the //TODO: #1378 This is not the ultimate location of this call to the
//callback. It is surely wrong for node-level locking, and probably //callback. It is surely wrong for node-level locking, and probably
//wrong for the STRADDLE callback for heaviside function(two sets of key/vals) //wrong for the STRADDLE callback for heaviside function(two sets of key/vals)
int r2 = getf(0,NULL, 0,NULL, int r2 = getf(0,NULL, 0,NULL, getf_v);
0,NULL, 0,NULL,
getf_v);
if (r2!=0) r = r2; if (r2!=0) r = r2;
} }
return r; return r;
...@@ -4443,24 +4421,12 @@ struct brt_cursor_search_struct { ...@@ -4443,24 +4421,12 @@ struct brt_cursor_search_struct {
brt_search_t *search; brt_search_t *search;
}; };
static int
brt_cursor_search_getf(ITEMLEN keylen, bytevec key,
ITEMLEN vallen, bytevec val,
ITEMLEN UU(next_keylen), bytevec UU(next_key),
ITEMLEN UU(next_vallen), bytevec UU(next_val),
void *v) {
struct brt_cursor_search_struct *bcss = v;
int r = bcss->getf(keylen, key, vallen, val, bcss->getf_v);
return r;
}
/* 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) 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}; int r = toku_brt_search(cursor->brt, search, getf, getf_v, 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;
} }
...@@ -4482,8 +4448,6 @@ static int brt_cursor_compare_set(brt_search_t *search, DBT *x) { ...@@ -4482,8 +4448,6 @@ static int brt_cursor_compare_set(brt_search_t *search, DBT *x) {
static int static int
brt_cursor_current_getf(ITEMLEN keylen, bytevec key, brt_cursor_current_getf(ITEMLEN keylen, bytevec key,
ITEMLEN vallen, bytevec val, ITEMLEN vallen, bytevec val,
ITEMLEN UU(next_keylen), bytevec UU(next_key),
ITEMLEN UU(next_vallen), bytevec UU(next_val),
void *v) { void *v) {
struct brt_cursor_search_struct *bcss = v; struct brt_cursor_search_struct *bcss = v;
int r; int r;
...@@ -4693,8 +4657,6 @@ toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *ge ...@@ -4693,8 +4657,6 @@ toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *ge
static int static int
brt_cursor_search_eq_k_x_getf(ITEMLEN keylen, bytevec key, brt_cursor_search_eq_k_x_getf(ITEMLEN keylen, bytevec key,
ITEMLEN vallen, bytevec val, ITEMLEN vallen, bytevec val,
ITEMLEN UU(next_keylen), bytevec UU(next_key),
ITEMLEN UU(next_vallen), bytevec UU(next_val),
void *v) { void *v) {
struct brt_cursor_search_struct *bcss = v; struct brt_cursor_search_struct *bcss = v;
int r; int r;
......
...@@ -27,9 +27,6 @@ C_BEGIN ...@@ -27,9 +27,6 @@ C_BEGIN
//A 'key' bytevec of NULL means that element is not found (effectively infinity or //A 'key' bytevec of NULL means that element is not found (effectively infinity or
//-infinity depending on direction) //-infinity depending on direction)
typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN, bytevec, ITEMLEN, bytevec, void*); typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN, bytevec, ITEMLEN, bytevec, void*);
//Same as BRT_GET_CALLBACK_FUNCTION but returns both the answer to the query and
//the element on the other side of the border (as in heaviside function).
typedef int(*BRT_GET_STRADDLE_CALLBACK_FUNCTION)(ITEMLEN, bytevec, ITEMLEN, bytevec, ITEMLEN, bytevec, ITEMLEN, bytevec, void*);
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*), DB*); int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*), DB*);
int toku_maybe_upgrade_descriptor(BRT t, DESCRIPTOR d, BOOL do_log, TOKUTXN txn); int toku_maybe_upgrade_descriptor(BRT t, DESCRIPTOR d, BOOL do_log, TOKUTXN txn);
......
...@@ -1479,25 +1479,8 @@ int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, u_int32_t ful ...@@ -1479,25 +1479,8 @@ int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, u_int32_t ful
write_pair_for_checkpoint(ct, p, FALSE); write_pair_for_checkpoint(ct, p, FALSE);
} }
// still have the cachetable lock // still have the cachetable lock
// TODO: #1398 kill this hack before it multiplies further get_and_pin_footprint = 7;
// This logic here to prevent deadlock that results when a query pins a node, rwlock_read_lock(&p->rwlock, ct->mutex);
// then the straddle callback creates a cursor that pins it again. If
// toku_cachetable_end_checkpoint() is called between those two calls to pin
// the node, then the checkpoint function waits for the first pin to be released
// while the callback waits for the checkpoint function to release the write
// lock. The work-around is to have an unfair rwlock mechanism that favors the
// reader.
#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY
if (STRADDLE_HACK_INSIDE_CALLBACK) {
get_and_pin_footprint = 6;
rwlock_prefer_read_lock(&p->rwlock, ct->mutex);
}
else
#endif
{
get_and_pin_footprint = 7;
rwlock_read_lock(&p->rwlock, ct->mutex);
}
if (do_wait_time) if (do_wait_time)
cachetable_waittime += get_tnow() - t0; cachetable_waittime += get_tnow() - t0;
get_and_pin_footprint = 8; get_and_pin_footprint = 8;
......
...@@ -15,12 +15,6 @@ ...@@ -15,12 +15,6 @@
extern "C" { extern "C" {
#endif #endif
// TODO: #1398 Get rid of this entire straddle_callback hack
// Man is this ugly.
#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY
extern int STRADDLE_HACK_INSIDE_CALLBACK;
#endif
// Maintain a cache mapping from cachekeys to values (void*) // Maintain a cache mapping from cachekeys to values (void*)
// Some of the keys can be pinned. Don't pin too many or for too long. // Some of the keys can be pinned. Don't pin too many or for too long.
// If the cachetable is too full, it will call the flush_callback() function with the key, the value, and the otherargs // If the cachetable is too full, it will call the flush_callback() function with the key, the value, and the otherargs
......
...@@ -86,9 +86,6 @@ ifeq ($(SYSTEM),sunos) ...@@ -86,9 +86,6 @@ ifeq ($(SYSTEM),sunos)
CPPFLAGS += -DTOKU_ALLOW_DEPRECATED CPPFLAGS += -DTOKU_ALLOW_DEPRECATED
endif endif
# TODO: 1398 Get rid of this hack.
CPPFLAGS+=-DBRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY=1
#CFLAG default options #CFLAG default options
# Add -Wconversion #DISABLED for now. # Add -Wconversion #DISABLED for now.
......
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