Commit d61cd8a3 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #350

Effectively eliminated 'non cursor' gets.
Internally (in brt) all gets were cursor gets already.
To save future locking code, and reduce complexity of ydb,
all DB->get calls use cursor gets as subfunctions.

git-svn-id: file:///svn/tokudb@2195 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4130bbee
...@@ -1344,26 +1344,15 @@ static int toku_c_count(DBC *cursor, db_recno_t *count, u_int32_t flags) { ...@@ -1344,26 +1344,15 @@ static int toku_c_count(DBC *cursor, db_recno_t *count, u_int32_t flags) {
static int toku_db_get_noassociate(DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) { static int toku_db_get_noassociate(DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
int r; int r;
unsigned int brtflags;
if (flags!=0 && flags!=DB_GET_BOTH) return EINVAL; if (flags!=0 && flags!=DB_GET_BOTH) return EINVAL;
toku_brt_get_flags(db->i->brt, &brtflags);
if ((brtflags & TOKU_DB_DUPSORT) || flags == DB_GET_BOTH) {
if (flags != 0 && flags != DB_GET_BOTH) return EINVAL; DBC *dbc;
// We aren't ready to handle flags such as DB_READ_COMMITTED or DB_READ_UNCOMMITTED or DB_RMW r = toku_db_cursor(db, txn, &dbc, 0);
if (r!=0) return r;
DBC *dbc; r = toku_c_get_noassociate(dbc, key, data,
r = toku_db_cursor(db, txn, &dbc, 0); (flags == 0) ? DB_SET : DB_GET_BOTH);
if (r!=0) return r; int r2 = toku_c_close(dbc);
r = toku_c_get_noassociate(dbc, key, data, flags == DB_GET_BOTH ? DB_GET_BOTH : DB_SET); return r ? r : r2;
int r2 = toku_c_close(dbc);
if (r!=0) return r;
return r2;
} else {
if (flags != 0) return EINVAL;
return toku_brt_lookup(db->i->brt, key, data);
}
} }
static int toku_db_del_noassociate(DB * db, DB_TXN * txn, DBT * key, u_int32_t flags) { static int toku_db_del_noassociate(DB * db, DB_TXN * txn, DBT * key, u_int32_t flags) {
...@@ -1679,16 +1668,15 @@ static int toku_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t ...@@ -1679,16 +1668,15 @@ static int toku_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t
if ((db->i->open_flags & DB_THREAD) && db_thread_need_flags(data)) if ((db->i->open_flags & DB_THREAD) && db_thread_need_flags(data))
return EINVAL; return EINVAL;
if (db->i->primary==0) r = toku_db_get_noassociate(db, txn, key, data, flags); if (flags != 0 && flags != DB_GET_BOTH) return EINVAL;
else { // We aren't ready to handle flags such as DB_READ_COMMITTED or DB_READ_UNCOMMITTED or DB_RMW
// It's a get on a secondary.
if (flags == DB_GET_BOTH) return EINVAL; DBC *dbc;
assert(flags == 0); // We aren't ready to handle flags such as DB_READ_COMMITTED or DB_READ_UNCOMMITTED or DB_RMW r = toku_db_cursor(db, txn, &dbc, 0);
DBT primary_key; memset(&primary_key, 0, sizeof(primary_key)); primary_key.flags = DB_DBT_MALLOC; if (r!=0) return r;
r = toku_db_pget(db, txn, key, &primary_key, data, 0); r = toku_c_get(dbc, key, data, (flags == 0) ? DB_SET : DB_GET_BOTH);
if (primary_key.data) toku_free(primary_key.data); int r2 = toku_c_close(dbc);
} return r ? r : r2;
return r;
} }
static int toku_db_pget (DB *db, DB_TXN *txn, DBT *key, DBT *pkey, DBT *data, u_int32_t flags) { static int toku_db_pget (DB *db, DB_TXN *txn, DBT *key, DBT *pkey, DBT *data, u_int32_t flags) {
......
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