Commit 0604d770 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#3046 use the brt compare function for le cursor key comparisons refs[t:3046]

git-svn-id: file:///svn/toku/tokudb@25729 c7de825b-a66e-492c-adef-691d508d4ae1
parent da5110ec
......@@ -10,8 +10,10 @@
struct le_cursor {
BRT_CURSOR brt_cursor;
BRT brt;
DBT key;
BOOL neg_infinity, pos_infinity;
BOOL neg_infinity;
BOOL pos_infinity;
};
int
......@@ -24,7 +26,9 @@ le_cursor_create(LE_CURSOR *le_cursor_result, BRT brt, TOKUTXN txn) {
result = toku_brt_cursor(brt, &le_cursor->brt_cursor, txn, FALSE);
if (result == 0) {
toku_brt_cursor_set_leaf_mode(le_cursor->brt_cursor);
toku_init_dbt(&le_cursor->key); le_cursor->key.flags = DB_DBT_REALLOC;
le_cursor->brt = brt;
toku_init_dbt(&le_cursor->key);
le_cursor->key.flags = DB_DBT_REALLOC;
le_cursor->neg_infinity = TRUE;
le_cursor->pos_infinity = FALSE;
}
......@@ -71,14 +75,15 @@ le_cursor_next(LE_CURSOR le_cursor, DBT *key, DBT *val) {
}
int
is_key_right_of_le_cursor(LE_CURSOR le_cursor, const DBT *key, int (*keycompare)(DB *, const DBT *, const DBT *), DB *db) {
is_key_right_of_le_cursor(LE_CURSOR le_cursor, const DBT *key, DB *keycompare_db) {
int result;
if (le_cursor->neg_infinity)
result = TRUE;
else if (le_cursor->pos_infinity)
result = FALSE;
else {
int r = keycompare(db, &le_cursor->key, key);
brt_compare_func keycompare = toku_brt_get_bt_compare(le_cursor->brt);
int r = keycompare(keycompare_db, &le_cursor->key, key);
if (r < 0)
result = TRUE;
else
......
......@@ -35,6 +35,6 @@ int le_cursor_next(LE_CURSOR le_cursor, DBT *key, DBT *val);
// The LE_CURSOR position is intialized to -infinity. Any key comparision with -infinity returns TRUE.
// When the cursor runs off the right edge of the tree, the LE_CURSOR position is set to +infinity. Any key comparision with +infinity
// returns FALSE.
int is_key_right_of_le_cursor(LE_CURSOR le_cursor, const DBT *key, int (*keycompare)(DB *extra, const DBT *, const DBT *), DB *extra);
int is_key_right_of_le_cursor(LE_CURSOR le_cursor, const DBT *key, DB *keycompare_db);
#endif
......@@ -112,7 +112,7 @@ test_neg_infinity(const char *fname, int n) {
int k = toku_htonl(i);
DBT key;
toku_fill_dbt(&key, &k, sizeof k);
int right = is_key_right_of_le_cursor(cursor, &key, test_keycompare, null_db);
int right = is_key_right_of_le_cursor(cursor, &key, null_db);
assert(right == TRUE);
}
......@@ -172,7 +172,7 @@ test_pos_infinity(const char *fname, int n) {
int k = toku_htonl(i);
DBT key2;
toku_fill_dbt(&key2, &k, sizeof k);
int right = is_key_right_of_le_cursor(cursor, &key2, test_keycompare, null_db);
int right = is_key_right_of_le_cursor(cursor, &key2, null_db);
assert(right == FALSE);
}
......@@ -229,7 +229,7 @@ test_between(const char *fname, int n) {
int k = toku_htonl(j);
DBT key2;
toku_fill_dbt(&key2, &k, sizeof k);
int right = is_key_right_of_le_cursor(cursor, &key2, test_keycompare, null_db);
int right = is_key_right_of_le_cursor(cursor, &key2, null_db);
assert(right == FALSE);
}
......@@ -238,7 +238,7 @@ test_between(const char *fname, int n) {
int k = toku_htonl(j);
DBT key2;
toku_fill_dbt(&key2, &k, sizeof k);
int right = is_key_right_of_le_cursor(cursor, &key2, test_keycompare, null_db);
int right = is_key_right_of_le_cursor(cursor, &key2, null_db);
assert(right == TRUE);
}
......
......@@ -216,8 +216,7 @@ toku_indexer_set_error_callback(DB_INDEXER *indexer,
int
toku_indexer_is_key_right_of_le_cursor(DB_INDEXER *indexer, DB *db, const DBT *key) {
DB_ENV *env = indexer->i->env;
return is_key_right_of_le_cursor(indexer->i->lec, key, env->i->bt_compare, db);
return is_key_right_of_le_cursor(indexer->i->lec, key, db);
}
static int
......
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