Commit 47d86d3c authored by Christian Rober's avatar Christian Rober Committed by Yoni Fogel

[t:4553] Merging temporary cursor malloc changes into main.

git-svn-id: file:///svn/toku/tokudb@40177 c7de825b-a66e-492c-adef-691d508d4ae1
parent 82921ab1
......@@ -577,6 +577,7 @@ struct brt_cursor {
BOOL is_snapshot_read; // true if query is read_committed, false otherwise
BOOL is_leaf_mode;
BOOL disable_prefetching;
BOOL is_temporary;
TOKUTXN ttxn;
struct brt_cursor_leaf_info leaf_info;
};
......
......@@ -4387,6 +4387,7 @@ int toku_brt_cursor (
cursor->is_leaf_mode = FALSE;
cursor->ttxn = ttxn;
cursor->disable_prefetching = disable_prefetching;
cursor->is_temporary = FALSE;
if (1) {
toku_spin_lock(&brt->cursors_lock);
toku_list_push(&brt->cursors, &cursor->cursors_link);
......@@ -4396,6 +4397,11 @@ int toku_brt_cursor (
return 0;
}
void
toku_brt_cursor_set_temporary(BRT_CURSOR brtcursor) {
brtcursor->is_temporary = TRUE;
}
void
toku_brt_cursor_set_leaf_mode(BRT_CURSOR brtcursor) {
brtcursor->is_leaf_mode = TRUE;
......@@ -5090,10 +5096,12 @@ got_a_good_value:
}
brt_cursor_cleanup_dbts(brtcursor);
if (!brtcursor->is_temporary) {
brtcursor->key.data = toku_memdup(key, keylen);
brtcursor->val.data = toku_memdup(val, vallen);
brtcursor->key.size = keylen;
brtcursor->val.size = vallen;
}
//The search was successful. Prefetching can continue.
*doprefetch = TRUE;
}
......
......@@ -191,6 +191,9 @@ int toku_verify_brt_with_progress (BRT brt, int (*progress_callback)(void *extra
typedef struct brt_cursor *BRT_CURSOR;
int toku_brt_cursor (BRT, BRT_CURSOR*, TOKUTXN, BOOL, BOOL) __attribute__ ((warn_unused_result));
void toku_brt_cursor_set_leaf_mode(BRT_CURSOR);
// Sets a boolean on the brt cursor that prevents uncessary copying of
// the cursor duing a one query.
void toku_brt_cursor_set_temporary(BRT_CURSOR);
int toku_brt_cursor_is_leaf_mode(BRT_CURSOR);
void toku_brt_cursor_set_range_lock(BRT_CURSOR, const DBT *, const DBT *, BOOL, BOOL);
......
......@@ -878,6 +878,13 @@ toku_db_cursor_internal(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags, int is
);
assert(r == 0 || r == TOKUDB_MVCC_DICTIONARY_TOO_NEW);
if (r == 0) {
// Set the is_temporary_cursor boolean inside the brt node so
// that a query only needing one cursor will not perform
// unecessary malloc calls.
if (is_temporary_cursor) {
toku_brt_cursor_set_temporary(dbc_struct_i(result)->c);
}
*c = result;
}
else {
......
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