From 88378bda52a644ffce91bcacfc57948530d06e96 Mon Sep 17 00:00:00 2001 From: Rich Prohaska Date: Sun, 25 Nov 2007 18:17:01 +0000 Subject: [PATCH] search in a BRT with duplicate keys is equivalent to a DB_SET cursor get. Addresses #19 git-svn-id: file:///svn/tokudb@748 c7de825b-a66e-492c-adef-691d508d4ae1 --- newbrt/brt.c | 5 +++++ newbrt/brt.h | 1 + src/ydb.c | 13 ++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/newbrt/brt.c b/newbrt/brt.c index e1fb18be895..733fdafe7d7 100644 --- a/newbrt/brt.c +++ b/newbrt/brt.c @@ -1491,6 +1491,11 @@ int brt_set_flags(BRT brt, int flags) { return 0; } +int brt_get_flags(BRT brt, int *flags) { + *flags = brt->flags; + return 0; +} + int brt_set_nodesize(BRT brt, int nodesize) { brt->nodesize = nodesize; return 0; diff --git a/newbrt/brt.h b/newbrt/brt.h index 40d6836745d..84e1b931216 100644 --- a/newbrt/brt.h +++ b/newbrt/brt.h @@ -13,6 +13,7 @@ int open_brt (const char *fname, const char *dbname, int is_create, BRT *, int n int brt_create(BRT *); int brt_set_flags(BRT, int flags); +int brt_get_flags(BRT, int *flags); int brt_set_nodesize(BRT, int nodesize); int brt_set_bt_compare(BRT, int (*bt_compare)(DB *, const DBT*, const DBT*)); int brt_set_dup_compare(BRT, int (*dup_compare)(DB *, const DBT*, const DBT*)); diff --git a/src/ydb.c b/src/ydb.c index b7b7871a90b..4d75c5662c7 100644 --- a/src/ydb.c +++ b/src/ydb.c @@ -556,7 +556,18 @@ int __toku_db_del(DB * db, DB_TXN * txn __attribute__ ((unused)), DBT * key, u_i int __toku_db_get(DB * db, DB_TXN * txn __attribute__ ((unused)), DBT * key, DBT * data, u_int32_t flags) { assert(flags == 0); - int r = brt_lookup(db->i->brt, key, data, db); + int r; + int brtflags; + brt_get_flags(db->i->brt, &brtflags); + if (brtflags & TOKU_DB_DUPSORT) { + DBC *dbc; + r = db->cursor(db, txn, &dbc, 0); + if (r == 0) { + r = dbc->c_get(dbc, key, data, DB_SET); + dbc->c_close(dbc); + } + } else + r = brt_lookup(db->i->brt, key, data, db); return r; }