From 1bfd207e32a7834d08236e7ea5550201d793992c Mon Sep 17 00:00:00 2001 From: "Bradley C. Kuszmaul" Date: Tue, 16 Apr 2013 23:59:21 -0400 Subject: [PATCH] Merge the fixes for #2862, #2861, and #2269 onto main. Fixes #2269, #2861, #2862. close[t:2269] close[t:2861] close[t:2862] {{{ svn merge -r 23006:23042 https://svn.tokutek.com/tokudb/toku/tokudb.2862b }}} . git-svn-id: file:///svn/toku/tokudb@23046 c7de825b-a66e-492c-adef-691d508d4ae1 --- buildheader/db.h_4_1 | 42 +- buildheader/db.h_4_3 | 44 +- buildheader/db.h_4_4 | 44 +- buildheader/db.h_4_5 | 44 +- buildheader/db.h_4_6 | 45 +- buildheader/make_db_h.c | 26 +- buildheader/sample_offsets.c | 1 - buildheader/sample_offsets_32_4_1.h | 1 - buildheader/sample_offsets_32_4_3.h | 1 - buildheader/sample_offsets_32_4_4.h | 1 - buildheader/sample_offsets_32_4_5.h | 1 - buildheader/sample_offsets_32_4_6.h | 1 - buildheader/sample_offsets_64_4_1.h | 1 - buildheader/sample_offsets_64_4_3.h | 1 - buildheader/sample_offsets_64_4_4.h | 1 - buildheader/sample_offsets_64_4_5.h | 1 - buildheader/sample_offsets_64_4_6.h | 1 - buildheader/sample_offsets_64_4_7.h | 1 - buildheader/tdb.h | 22 +- cxx/db.cpp | 11 - cxx/tests/Makefile | 5 - cxx/tests/db_create.cpp | 10 +- cxx/tests/db_dump.cpp | 2 + cxx/tests/test_cursor_count.cpp | 54 +- cxx/tests/test_reverse_compare_fun.cpp | 21 +- db-benchmark-test/Makefile | 9 +- db-benchmark-test/db-benchmark-test.c | 3 - db-benchmark-test/scanscan.c | 5 +- include/db.h | 22 +- newbrt/backwards_11.c | 770 ------------------ newbrt/backwards_11.h | 18 - newbrt/brt-internal.h | 7 +- newbrt/brt-search.h | 7 +- newbrt/brt-serialize.c | 87 +- newbrt/brt-test-helpers.c | 5 +- newbrt/brt-verify.c | 48 +- newbrt/brt.c | 597 ++------------ newbrt/brt.h | 17 +- newbrt/brtdump.c | 7 +- newbrt/brttypes.h | 6 +- newbrt/fingerprint.c | 5 - newbrt/kv-pair.h | 12 - newbrt/logformat.c | 15 - newbrt/recover.c | 33 +- newbrt/recover.h | 1 - newbrt/roll.c | 58 -- newbrt/tdb-recover.c | 2 +- newbrt/tests/brt-serialize-sub-block-test.c | 2 +- newbrt/tests/brt-serialize-test.c | 2 +- newbrt/tests/brt-test-cursor-2.c | 3 +- newbrt/tests/brt-test-cursor.c | 154 +--- newbrt/tests/brt-test.c | 123 +-- newbrt/tests/brt-test1.c | 2 +- newbrt/tests/brt-test5.c | 2 +- newbrt/tests/brtloader-test-writer.c | 2 +- newbrt/tests/brtloader-test.c | 4 +- newbrt/tests/dup-delete-all.c | 105 --- newbrt/tests/keyrange-dupsort-unflat.c | 66 -- newbrt/tests/keyrange-dupsort.c | 88 -- newbrt/tests/keyrange.c | 2 +- newbrt/tests/recovery-bad-last-entry.c | 2 +- newbrt/tests/recovery-cbegin-cend-hello.c | 2 +- newbrt/tests/recovery-cbegin-cend.c | 2 +- newbrt/tests/recovery-cbegin.c | 2 +- newbrt/tests/recovery-cend-cbegin.c | 2 +- newbrt/tests/recovery-empty.c | 2 +- newbrt/tests/recovery-fopen-missing-file.c | 2 +- newbrt/tests/recovery-hello.c | 2 +- .../recovery-lsn-error-during-forward-scan.c | 2 +- newbrt/tests/recovery-no-datadir.c | 2 +- newbrt/tests/recovery-no-log.c | 2 +- newbrt/tests/recovery-no-logdir.c | 2 +- newbrt/tests/shortcut.c | 6 +- newbrt/tests/test-brt-delete-both.c | 60 -- newbrt/tests/test-del-inorder.c | 2 +- newbrt/tests/test-leafentry-nested.c | 12 - newbrt/tests/test.h | 4 +- newbrt/ule.c | 3 - release/examples/db-insert.c | 5 +- release/examples/db-scan.c | 3 +- src/lock_tree/locktree.c | 186 ++--- src/lock_tree/locktree.h | 76 +- src/lock_tree/tests/test_00000_createclose.c | 9 +- .../tests/test_00010_parameter_errors.c | 175 +--- src/lock_tree/tests/test_00020_read.c | 267 +++--- src/lock_tree/tests/test_00040_write.c | 270 +++--- .../tests/test_00060_lock_escalation.c | 244 +++--- src/lock_tree/tests/test_00070_ltm.c | 24 +- src/lock_tree/tests/test_00080_lt_refcount.c | 30 +- src/tests/Makefile | 1 - src/tests/big-nested-commit-abort.c | 1 - src/tests/big-nested-commit-commit.c | 4 +- src/tests/checkpoint_1.c | 2 - src/tests/checkpoint_stress.c | 2 +- src/tests/checkpoint_test.h | 45 +- src/tests/cursor-more-than-a-leaf-provdel.c | 4 +- src/tests/keyrange-dupsort-unflat.c | 75 -- src/tests/keyrange-dupsort.c | 98 --- src/tests/loader-cleanup-test.c | 2 +- src/tests/loader-dup-test.c | 1 - src/tests/loader-no-puts.c | 1 - src/tests/loader-reference-test.c | 1 - src/tests/loader-stress-test.c | 1 - src/tests/loader-tpch-load.c | 1 - src/tests/medium-nested-commit-commit.c | 1 - src/tests/multiprocess.c | 30 +- ...cover-checkpoint-fcreate-fdelete-fcreate.c | 2 - .../recover-checkpoint-fopen-dupsort-abort.c | 3 +- .../recover-checkpoint-fopen-dupsort-commit.c | 3 +- src/tests/recover-delboth-after-checkpoint.c | 3 +- src/tests/recover-delboth-checkpoint.c | 3 +- src/tests/recover-fassociate-dupsort.c | 5 +- src/tests/recover-fcreate-fdelete.c | 2 - ...recover-fopen-fdelete-checkpoint-fcreate.c | 2 - src/tests/recover-loader-test.c | 1 - src/tests/recover-test-logsuppress-put.c | 1 - src/tests/recover-test-logsuppress.c | 1 - src/tests/recovery_fileops_stress.c | 3 +- src/tests/recovery_fileops_unit.c | 6 +- src/tests/recovery_stress.c | 2 +- src/tests/test1842.c | 1 - src/tests/test938.c | 8 +- src/tests/test938b.c | 1 - src/tests/test938c.c | 19 +- src/tests/test944.c | 3 +- src/tests/test944a.c | 2 + src/tests/test_abort4.c | 21 +- src/tests/test_abort5.c | 19 +- src/tests/test_cursor_DB_NEXT_no_dup.c | 59 +- src/tests/test_cursor_delete.c | 84 +- src/tests/test_cursor_delete2a.c | 1 - src/tests/test_cursor_delete_next.c | 11 +- src/tests/test_cursor_null.c | 13 +- src/tests/test_db_delboth.c | 187 ----- src/tests/test_db_get_put_flags.c | 26 +- src/tests/test_db_set_flags.c | 3 - src/tests/test_db_subdb_different_flags.c | 2 - src/tests/test_db_txn_locks_nonheaviside.c | 274 ++----- .../test_db_txn_locks_read_uncommitted.c | 17 +- src/tests/test_dup_delete.c | 762 ----------------- src/tests/test_dup_dup.c | 301 ------- src/tests/test_dup_flags.c | 19 +- src/tests/test_dup_insert.c | 294 ------- src/tests/test_dup_next.c | 151 ---- src/tests/test_dup_search.c | 382 --------- src/tests/test_dupsort_del.c | 109 --- src/tests/test_dupsort_del_checksum.c | 116 --- src/tests/test_dupsort_delete.c | 121 --- src/tests/test_dupsort_get.c | 144 ---- src/tests/test_dupsort_get_both.c | 169 ---- src/tests/test_dupsort_get_both_1856.c | 163 ---- src/tests/test_dupsort_get_both_range.c | 175 ---- .../test_dupsort_get_both_range_reverse.c | 176 ---- src/tests/test_dupsort_set.c | 170 ---- src/tests/test_dupsort_set_range.c | 173 ---- src/tests/test_dupsort_set_range_reverse.c | 173 ---- src/tests/test_get_both_range.c | 200 ----- src/tests/test_get_zeroed_dbt.c | 10 +- src/tests/test_hsoc.c | 8 +- src/tests/test_insert_cursor_delete_insert.c | 8 +- src/tests/test_kv_limits.c | 18 +- src/tests/test_reverse_compare_fun.c | 21 +- src/tests/test_txn_nested1.c | 1 - src/tests/test_zero_length_keys.c | 1 - src/ydb-internal.h | 2 - src/ydb.c | 769 ++--------------- utils/Makefile | 23 +- utils/tokudb_dump.c | 2 - utils/tokudb_gen.c | 13 +- utils/tokudb_load.c | 4 - 170 files changed, 1099 insertions(+), 8708 deletions(-) delete mode 100644 newbrt/backwards_11.c delete mode 100644 newbrt/backwards_11.h delete mode 100644 newbrt/tests/dup-delete-all.c delete mode 100644 newbrt/tests/keyrange-dupsort-unflat.c delete mode 100644 newbrt/tests/keyrange-dupsort.c delete mode 100644 newbrt/tests/test-brt-delete-both.c delete mode 100644 src/tests/keyrange-dupsort-unflat.c delete mode 100644 src/tests/keyrange-dupsort.c delete mode 100644 src/tests/test_db_delboth.c delete mode 100644 src/tests/test_dup_delete.c delete mode 100644 src/tests/test_dup_dup.c delete mode 100644 src/tests/test_dup_insert.c delete mode 100644 src/tests/test_dup_next.c delete mode 100644 src/tests/test_dup_search.c delete mode 100644 src/tests/test_dupsort_del.c delete mode 100644 src/tests/test_dupsort_del_checksum.c delete mode 100644 src/tests/test_dupsort_delete.c delete mode 100644 src/tests/test_dupsort_get.c delete mode 100644 src/tests/test_dupsort_get_both.c delete mode 100644 src/tests/test_dupsort_get_both_1856.c delete mode 100644 src/tests/test_dupsort_get_both_range.c delete mode 100644 src/tests/test_dupsort_get_both_range_reverse.c delete mode 100644 src/tests/test_dupsort_set.c delete mode 100644 src/tests/test_dupsort_set_range.c delete mode 100644 src/tests/test_dupsort_set_range_reverse.c delete mode 100644 src/tests/test_get_both_range.c diff --git a/buildheader/db.h_4_1 b/buildheader/db.h_4_1 index 41c56fcd93d..00b051c8fd2 100644 --- a/buildheader/db.h_4_1 +++ b/buildheader/db.h_4_1 @@ -169,8 +169,6 @@ typedef enum { #define DB_LOCK_DEFAULT 1 #define DB_LOCK_OLDEST 6 #define DB_LOCK_RANDOM 7 -#define DB_DUP 2 -#define DB_DUPSORT 4 #define DB_KEYFIRST 16 #define DB_KEYLAST 17 #define DB_NOOVERWRITE 23 @@ -194,12 +192,9 @@ typedef enum { #define DB_DELETE_ANY 65536 #define DB_TRUNCATE_WITHCURSORS 131072 #define DB_FIRST 10 -#define DB_GET_BOTH 11 -#define DB_GET_BOTH_RANGE 13 #define DB_LAST 18 #define DB_CURRENT 8 #define DB_NEXT 19 -#define DB_NEXT_DUP 20 #define DB_NEXT_NODUP 21 #define DB_PREV 27 #define DB_PREV_NODUP 28 @@ -207,7 +202,6 @@ typedef enum { #define DB_SET_RANGE 32 #define DB_CURRENT_BINDING 253 #define DB_SET_RANGE_REVERSE 252 -#define DB_GET_BOTH_RANGE_REVERSE 251 #define DB_RMW 1073741824 #define DB_PRELOCKED 0x00800000 #define DB_PRELOCKED_WRITE 0x00400000 @@ -247,9 +241,8 @@ struct __toku_db_env { int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */; int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */; int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; - int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; - void *app_private; /* 32-bit offset=36 size=4, 64=bit offset=72 size=8 */ int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*) /* Fill in status struct */; + void *app_private; /* 32-bit offset=36 size=4, 64=bit offset=72 size=8 */ int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */; int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */; int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags); @@ -273,7 +266,7 @@ struct __toku_db_env { void *extra)); int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */; int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */; - void* __toku_dummy0[17]; + void* __toku_dummy0[18]; char __toku_dummy1[64]; void *api1_internal; /* 32-bit offset=212 size=4, 64=bit offset=360 size=8 */ void* __toku_dummy2[7]; @@ -355,21 +348,19 @@ struct __toku_db { #define db_struct_i(x) ((x)->i) int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact); int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *); - int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*); + int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*); void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */ DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */ int (*pre_acquire_table_lock)(DB*, DB_TXN*); const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/; const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/; - int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */; int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */; DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */; int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor) /* set row/dictionary descriptor for a db. Available only while db is open */; int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */; - int (*getf_get_both)(DB*, DB_TXN*, u_int32_t, DBT*, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_get_both without a persistent cursor) */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); - void* __toku_dummy0[18]; + void* __toku_dummy0[20]; char __toku_dummy1[96]; void *api_internal; /* 32-bit offset=236 size=4, 64=bit offset=376 size=8 */ void* __toku_dummy2[5]; @@ -386,21 +377,19 @@ struct __toku_db { int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=316 size=4, 64=bit offset=536 size=8 */ int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=320 size=4, 64=bit offset=544 size=8 */ int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t); /* 32-bit offset=324 size=4, 64=bit offset=552 size=8 */ - void* __toku_dummy5[4]; - int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=344 size=4, 64=bit offset=592 size=8 */ - void* __toku_dummy6[2]; + void* __toku_dummy5[7]; void (*set_errfile) (DB *, FILE*); /* 32-bit offset=356 size=4, 64=bit offset=616 size=8 */ - void* __toku_dummy7[2]; + void* __toku_dummy6[2]; int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=368 size=4, 64=bit offset=640 size=8 */ - void* __toku_dummy8[1]; + void* __toku_dummy7[1]; int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=376 size=4, 64=bit offset=656 size=8 */ - void* __toku_dummy9[1]; + void* __toku_dummy8[1]; int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=384 size=4, 64=bit offset=672 size=8 */ - void* __toku_dummy10[2]; + void* __toku_dummy9[2]; int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=396 size=4, 64=bit offset=696 size=8 */ int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=400 size=4, 64=bit offset=704 size=8 */ - void* __toku_dummy11[15]; /* Padding at the end */ - char __toku_dummy12[8]; /* Padding at the end */ + void* __toku_dummy10[15]; /* Padding at the end */ + char __toku_dummy11[8]; /* Padding at the end */ }; struct __toku_db_txn_active { u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */ @@ -450,20 +439,13 @@ struct __toku_dbc { int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range_reverse)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[4]; + void* __toku_dummy0[11]; char __toku_dummy1[104]; int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=272 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=280 size=8 */ diff --git a/buildheader/db.h_4_3 b/buildheader/db.h_4_3 index 8d0ea81e545..a6d02a6fb2f 100644 --- a/buildheader/db.h_4_3 +++ b/buildheader/db.h_4_3 @@ -169,8 +169,6 @@ typedef enum { #define DB_LOCK_DEFAULT 1 #define DB_LOCK_OLDEST 7 #define DB_LOCK_RANDOM 8 -#define DB_DUP 2 -#define DB_DUPSORT 4 #define DB_KEYFIRST 15 #define DB_KEYLAST 16 #define DB_NOOVERWRITE 22 @@ -195,12 +193,9 @@ typedef enum { #define DB_DELETE_ANY 65536 #define DB_TRUNCATE_WITHCURSORS 131072 #define DB_FIRST 9 -#define DB_GET_BOTH 10 -#define DB_GET_BOTH_RANGE 12 #define DB_LAST 17 #define DB_CURRENT 7 #define DB_NEXT 18 -#define DB_NEXT_DUP 19 #define DB_NEXT_NODUP 20 #define DB_PREV 25 #define DB_PREV_NODUP 26 @@ -208,7 +203,6 @@ typedef enum { #define DB_SET_RANGE 30 #define DB_CURRENT_BINDING 253 #define DB_SET_RANGE_REVERSE 252 -#define DB_GET_BOTH_RANGE_REVERSE 251 #define DB_RMW 536870912 #define DB_PRELOCKED 0x00800000 #define DB_PRELOCKED_WRITE 0x00400000 @@ -249,11 +243,10 @@ struct __toku_db_env { int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */; int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */; int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; - int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*) /* Fill in status struct */; int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */; - void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */ int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */; + void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */ int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags); int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn, const DBT *key, const DBT *val, @@ -275,7 +268,7 @@ struct __toku_db_env { void *extra)); int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */; int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */; - void* __toku_dummy0[17]; + void* __toku_dummy0[18]; char __toku_dummy1[96]; void *api1_internal; /* 32-bit offset=244 size=4, 64=bit offset=392 size=8 */ void* __toku_dummy2[7]; @@ -365,21 +358,19 @@ struct __toku_db { #define db_struct_i(x) ((x)->i) int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact); int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *); - int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*); + int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*); void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */ DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */ int (*pre_acquire_table_lock)(DB*, DB_TXN*); const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/; const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/; - int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */; int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */; DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */; int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor) /* set row/dictionary descriptor for a db. Available only while db is open */; int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */; - int (*getf_get_both)(DB*, DB_TXN*, u_int32_t, DBT*, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_get_both without a persistent cursor) */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); - void* __toku_dummy0[21]; + void* __toku_dummy0[23]; char __toku_dummy1[96]; void *api_internal; /* 32-bit offset=248 size=4, 64=bit offset=400 size=8 */ void* __toku_dummy2[5]; @@ -400,22 +391,20 @@ struct __toku_db { int (*remove) (DB *, const char *, const char *, u_int32_t); /* 32-bit offset=376 size=4, 64=bit offset=656 size=8 */ int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=380 size=4, 64=bit offset=664 size=8 */ int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t); /* 32-bit offset=384 size=4, 64=bit offset=672 size=8 */ - void* __toku_dummy7[3]; - int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=400 size=4, 64=bit offset=704 size=8 */ - void* __toku_dummy8[2]; + void* __toku_dummy7[6]; void (*set_errfile) (DB *, FILE*); /* 32-bit offset=412 size=4, 64=bit offset=728 size=8 */ - void* __toku_dummy9[2]; + void* __toku_dummy8[2]; int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=424 size=4, 64=bit offset=752 size=8 */ - void* __toku_dummy10[4]; + void* __toku_dummy9[4]; int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=444 size=4, 64=bit offset=792 size=8 */ - void* __toku_dummy11[1]; + void* __toku_dummy10[1]; int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=452 size=4, 64=bit offset=808 size=8 */ - void* __toku_dummy12[3]; + void* __toku_dummy11[3]; int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */ - void* __toku_dummy13[1]; + void* __toku_dummy12[1]; int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=476 size=4, 64=bit offset=856 size=8 */ - void* __toku_dummy14[23]; /* Padding at the end */ - char __toku_dummy15[8]; /* Padding at the end */ + void* __toku_dummy13[23]; /* Padding at the end */ + char __toku_dummy14[8]; /* Padding at the end */ }; struct __toku_db_txn_active { u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */ @@ -466,20 +455,13 @@ struct __toku_dbc { int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range_reverse)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[2]; + void* __toku_dummy0[9]; char __toku_dummy1[112]; int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=264 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=272 size=8 */ diff --git a/buildheader/db.h_4_4 b/buildheader/db.h_4_4 index ec55c8d6d6c..1a650763ef4 100644 --- a/buildheader/db.h_4_4 +++ b/buildheader/db.h_4_4 @@ -169,8 +169,6 @@ typedef enum { #define DB_LOCK_DEFAULT 1 #define DB_LOCK_OLDEST 7 #define DB_LOCK_RANDOM 8 -#define DB_DUP 16384 -#define DB_DUPSORT 32768 #define DB_KEYFIRST 15 #define DB_KEYLAST 16 #define DB_NOOVERWRITE 22 @@ -195,12 +193,9 @@ typedef enum { #define DB_DELETE_ANY 65536 #define DB_TRUNCATE_WITHCURSORS 131072 #define DB_FIRST 9 -#define DB_GET_BOTH 10 -#define DB_GET_BOTH_RANGE 12 #define DB_LAST 17 #define DB_CURRENT 7 #define DB_NEXT 18 -#define DB_NEXT_DUP 19 #define DB_NEXT_NODUP 20 #define DB_PREV 25 #define DB_PREV_NODUP 26 @@ -208,7 +203,6 @@ typedef enum { #define DB_SET_RANGE 30 #define DB_CURRENT_BINDING 253 #define DB_SET_RANGE_REVERSE 252 -#define DB_GET_BOTH_RANGE_REVERSE 251 #define DB_RMW 536870912 #define DB_PRELOCKED 0x00800000 #define DB_PRELOCKED_WRITE 0x00400000 @@ -251,11 +245,10 @@ struct __toku_db_env { int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */; int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */; int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; - int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*) /* Fill in status struct */; int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */; - void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */ int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */; + void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */ int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags); int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn, const DBT *key, const DBT *val, @@ -277,7 +270,7 @@ struct __toku_db_env { void *extra)); int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */; int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */; - void* __toku_dummy0[32]; + void* __toku_dummy0[33]; char __toku_dummy1[128]; void *api1_internal; /* 32-bit offset=336 size=4, 64=bit offset=544 size=8 */ void* __toku_dummy2[7]; @@ -369,21 +362,19 @@ struct __toku_db { #define db_struct_i(x) ((x)->i) int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact); int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *); - int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*); + int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*); void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */ DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */ int (*pre_acquire_table_lock)(DB*, DB_TXN*); const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/; const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/; - int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */; int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */; DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */; int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor) /* set row/dictionary descriptor for a db. Available only while db is open */; int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */; - int (*getf_get_both)(DB*, DB_TXN*, u_int32_t, DBT*, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_get_both without a persistent cursor) */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); - void* __toku_dummy0[23]; + void* __toku_dummy0[25]; char __toku_dummy1[96]; void *api_internal; /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */ void* __toku_dummy2[5]; @@ -407,22 +398,20 @@ struct __toku_db { int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=428 size=4, 64=bit offset=760 size=8 */ void* __toku_dummy9[2]; int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=440 size=4, 64=bit offset=784 size=8 */ - void* __toku_dummy10[3]; - int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=456 size=4, 64=bit offset=816 size=8 */ - void* __toku_dummy11[2]; + void* __toku_dummy10[6]; void (*set_errfile) (DB *, FILE*); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */ - void* __toku_dummy12[2]; + void* __toku_dummy11[2]; int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=480 size=4, 64=bit offset=864 size=8 */ - void* __toku_dummy13[6]; + void* __toku_dummy12[6]; int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=508 size=4, 64=bit offset=920 size=8 */ - void* __toku_dummy14[6]; + void* __toku_dummy13[6]; int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=536 size=4, 64=bit offset=976 size=8 */ - void* __toku_dummy15[2]; + void* __toku_dummy14[2]; int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t); /* 32-bit offset=548 size=4, 64=bit offset=1000 size=8 */ - void* __toku_dummy16[1]; + void* __toku_dummy15[1]; int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=556 size=4, 64=bit offset=1016 size=8 */ - void* __toku_dummy17[5]; /* Padding at the end */ - char __toku_dummy18[16]; /* Padding at the end */ + void* __toku_dummy16[5]; /* Padding at the end */ + char __toku_dummy17[16]; /* Padding at the end */ }; struct __toku_db_txn_active { u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */ @@ -474,20 +463,13 @@ struct __toku_dbc { int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range_reverse)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[4]; + void* __toku_dummy0[11]; char __toku_dummy1[104]; int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=272 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=280 size=8 */ diff --git a/buildheader/db.h_4_5 b/buildheader/db.h_4_5 index 630e487dd52..857f0010f35 100644 --- a/buildheader/db.h_4_5 +++ b/buildheader/db.h_4_5 @@ -169,8 +169,6 @@ typedef enum { #define DB_LOCK_DEFAULT 1 #define DB_LOCK_OLDEST 7 #define DB_LOCK_RANDOM 8 -#define DB_DUP 32768 -#define DB_DUPSORT 65536 #define DB_KEYFIRST 13 #define DB_KEYLAST 14 #define DB_NOOVERWRITE 20 @@ -195,12 +193,9 @@ typedef enum { #define DB_DELETE_ANY 65536 #define DB_TRUNCATE_WITHCURSORS 131072 #define DB_FIRST 7 -#define DB_GET_BOTH 8 -#define DB_GET_BOTH_RANGE 10 #define DB_LAST 15 #define DB_CURRENT 6 #define DB_NEXT 16 -#define DB_NEXT_DUP 17 #define DB_NEXT_NODUP 18 #define DB_PREV 23 #define DB_PREV_NODUP 24 @@ -208,7 +203,6 @@ typedef enum { #define DB_SET_RANGE 27 #define DB_CURRENT_BINDING 253 #define DB_SET_RANGE_REVERSE 252 -#define DB_GET_BOTH_RANGE_REVERSE 251 #define DB_RMW 1073741824 #define DB_PRELOCKED 0x00800000 #define DB_PRELOCKED_WRITE 0x00400000 @@ -251,16 +245,15 @@ struct __toku_db_env { int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */; int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */; int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; - int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*) /* Fill in status struct */; int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */; int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */; int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags); - void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */ int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn, const DBT *key, const DBT *val, uint32_t num_dbs, DB **db_array, DBT *keys, DBT *vals, uint32_t *flags_array, void *extra) /* Insert into multiple dbs */; + void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */ int (*set_generate_row_callback_for_put) (DB_ENV *env, int (*generate_row_for_put)(DB *dest_db, DB *src_db, DBT *dest_key, DBT *dest_val, @@ -277,7 +270,7 @@ struct __toku_db_env { void *extra)); int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */; int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */; - void* __toku_dummy0[32]; + void* __toku_dummy0[33]; char __toku_dummy1[128]; void *api1_internal; /* 32-bit offset=336 size=4, 64=bit offset=544 size=8 */ void* __toku_dummy2[8]; @@ -369,21 +362,19 @@ struct __toku_db { #define db_struct_i(x) ((x)->i) int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact); int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *); - int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*); + int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*); void *app_private; /* 32-bit offset=16 size=4, 64=bit offset=32 size=8 */ DB_ENV *dbenv; /* 32-bit offset=20 size=4, 64=bit offset=40 size=8 */ int (*pre_acquire_table_lock)(DB*, DB_TXN*); const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/; const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/; - int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */; int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */; DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */; int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor) /* set row/dictionary descriptor for a db. Available only while db is open */; int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */; - int (*getf_get_both)(DB*, DB_TXN*, u_int32_t, DBT*, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_get_both without a persistent cursor) */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); - void* __toku_dummy0[26]; + void* __toku_dummy0[28]; char __toku_dummy1[96]; void *api_internal; /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */ void* __toku_dummy2[5]; @@ -407,22 +398,20 @@ struct __toku_db { int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=440 size=4, 64=bit offset=784 size=8 */ void* __toku_dummy9[2]; int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=452 size=4, 64=bit offset=808 size=8 */ - void* __toku_dummy10[3]; - int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */ - void* __toku_dummy11[2]; + void* __toku_dummy10[6]; void (*set_errfile) (DB *, FILE*); /* 32-bit offset=480 size=4, 64=bit offset=864 size=8 */ - void* __toku_dummy12[2]; + void* __toku_dummy11[2]; int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=492 size=4, 64=bit offset=888 size=8 */ - void* __toku_dummy13[6]; + void* __toku_dummy12[6]; int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=520 size=4, 64=bit offset=944 size=8 */ - void* __toku_dummy14[6]; + void* __toku_dummy13[6]; int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=548 size=4, 64=bit offset=1000 size=8 */ - void* __toku_dummy15[2]; + void* __toku_dummy14[2]; int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t); /* 32-bit offset=560 size=4, 64=bit offset=1024 size=8 */ - void* __toku_dummy16[1]; + void* __toku_dummy15[1]; int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=568 size=4, 64=bit offset=1040 size=8 */ - void* __toku_dummy17[5]; /* Padding at the end */ - char __toku_dummy18[16]; /* Padding at the end */ + void* __toku_dummy16[5]; /* Padding at the end */ + char __toku_dummy17[16]; /* Padding at the end */ }; struct __toku_db_txn_active { u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */ @@ -474,20 +463,13 @@ struct __toku_dbc { int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range_reverse)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[8]; + void* __toku_dummy0[15]; char __toku_dummy1[104]; int (*c_close) (DBC *); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=208 size=4, 64=bit offset=312 size=8 */ diff --git a/buildheader/db.h_4_6 b/buildheader/db.h_4_6 index c26253308b7..60f0b150462 100644 --- a/buildheader/db.h_4_6 +++ b/buildheader/db.h_4_6 @@ -169,8 +169,6 @@ typedef enum { #define DB_LOCK_DEFAULT 1 #define DB_LOCK_OLDEST 7 #define DB_LOCK_RANDOM 8 -#define DB_DUP 32768 -#define DB_DUPSORT 65536 #define DB_KEYFIRST 13 #define DB_KEYLAST 14 #define DB_NOOVERWRITE 20 @@ -195,21 +193,16 @@ typedef enum { #define DB_DELETE_ANY 65536 #define DB_TRUNCATE_WITHCURSORS 131072 #define DB_FIRST 7 -#define DB_GET_BOTH 8 -#define DB_GET_BOTH_RANGE 10 #define DB_LAST 15 #define DB_CURRENT 6 #define DB_NEXT 16 -#define DB_NEXT_DUP 17 #define DB_NEXT_NODUP 18 #define DB_PREV 23 -#define DB_PREV_DUP 24 #define DB_PREV_NODUP 25 #define DB_SET 26 #define DB_SET_RANGE 27 #define DB_CURRENT_BINDING 253 #define DB_SET_RANGE_REVERSE 252 -#define DB_GET_BOTH_RANGE_REVERSE 251 #define DB_RMW 1073741824 #define DB_PRELOCKED 0x00800000 #define DB_PRELOCKED_WRITE 0x00400000 @@ -253,16 +246,15 @@ struct __toku_db_env { int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */; int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */; int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; - int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*) /* Fill in status struct */; int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */; int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */; int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags); - void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */ int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn, const DBT *key, const DBT *val, uint32_t num_dbs, DB **db_array, DBT *keys, DBT *vals, uint32_t *flags_array, void *extra) /* Insert into multiple dbs */; + void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */ int (*set_generate_row_callback_for_put) (DB_ENV *env, int (*generate_row_for_put)(DB *dest_db, DB *src_db, DBT *dest_key, DBT *dest_val, @@ -279,7 +271,7 @@ struct __toku_db_env { void *extra)); int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */; int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */; - void* __toku_dummy0[33]; + void* __toku_dummy0[34]; char __toku_dummy1[144]; void *api1_internal; /* 32-bit offset=356 size=4, 64=bit offset=568 size=8 */ void* __toku_dummy2[8]; @@ -375,19 +367,17 @@ struct __toku_db { char __toku_dummy0[8]; void *app_private; /* 32-bit offset=20 size=4, 64=bit offset=32 size=8 */ DB_ENV *dbenv; /* 32-bit offset=24 size=4, 64=bit offset=40 size=8 */ - int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*); + int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*); int (*pre_acquire_table_lock)(DB*, DB_TXN*); const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/; const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/; - int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */; int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */; DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */; int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor) /* set row/dictionary descriptor for a db. Available only while db is open */; int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */; - int (*getf_get_both)(DB*, DB_TXN*, u_int32_t, DBT*, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_get_both without a persistent cursor) */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); - void* __toku_dummy1[30]; + void* __toku_dummy1[32]; char __toku_dummy2[80]; void *api_internal; /* 32-bit offset=276 size=4, 64=bit offset=464 size=8 */ void* __toku_dummy3[5]; @@ -411,22 +401,20 @@ struct __toku_db { int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); /* 32-bit offset=460 size=4, 64=bit offset=832 size=8 */ void* __toku_dummy10[2]; int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=472 size=4, 64=bit offset=856 size=8 */ - void* __toku_dummy11[3]; - int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=488 size=4, 64=bit offset=888 size=8 */ - void* __toku_dummy12[2]; + void* __toku_dummy11[6]; void (*set_errfile) (DB *, FILE*); /* 32-bit offset=500 size=4, 64=bit offset=912 size=8 */ - void* __toku_dummy13[2]; + void* __toku_dummy12[2]; int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=512 size=4, 64=bit offset=936 size=8 */ - void* __toku_dummy14[7]; + void* __toku_dummy13[7]; int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=544 size=4, 64=bit offset=1000 size=8 */ - void* __toku_dummy15[7]; + void* __toku_dummy14[7]; int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=576 size=4, 64=bit offset=1064 size=8 */ - void* __toku_dummy16[2]; + void* __toku_dummy15[2]; int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t); /* 32-bit offset=588 size=4, 64=bit offset=1088 size=8 */ - void* __toku_dummy17[1]; + void* __toku_dummy16[1]; int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=596 size=4, 64=bit offset=1104 size=8 */ - void* __toku_dummy18[5]; /* Padding at the end */ - char __toku_dummy19[16]; /* Padding at the end */ + void* __toku_dummy17[5]; /* Padding at the end */ + char __toku_dummy18[16]; /* Padding at the end */ }; struct __toku_db_txn_active { u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */ @@ -479,20 +467,13 @@ struct __toku_dbc { int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range_reverse)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[18]; + void* __toku_dummy0[25]; char __toku_dummy1[104]; int (*c_close) (DBC *); /* 32-bit offset=244 size=4, 64=bit offset=384 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=248 size=4, 64=bit offset=392 size=8 */ diff --git a/buildheader/make_db_h.c b/buildheader/make_db_h.c index 4335d284ec6..f50e5c6fa65 100644 --- a/buildheader/make_db_h.c +++ b/buildheader/make_db_h.c @@ -95,8 +95,8 @@ static void print_defines (void) { dodefine(DB_LOCK_OLDEST); dodefine(DB_LOCK_RANDOM); - dodefine(DB_DUP); - dodefine(DB_DUPSORT); + //dodefine(DB_DUP); No longer supported #2862 + //dodefine(DB_DUPSORT); No longer supported #2862 dodefine(DB_KEYFIRST); dodefine(DB_KEYLAST); @@ -132,23 +132,23 @@ static void print_defines (void) { printf("#define DB_TRUNCATE_WITHCURSORS %d\n", 1<<17); // private tokudb dodefine(DB_FIRST); - dodefine(DB_GET_BOTH); - dodefine(DB_GET_BOTH_RANGE); + //dodefine(DB_GET_BOTH); No longer supported #2862. + //dodefine(DB_GET_BOTH_RANGE); No longer supported because we only support NODUP. #2862. dodefine(DB_LAST); dodefine(DB_CURRENT); dodefine(DB_NEXT); - dodefine(DB_NEXT_DUP); + //dodefine(DB_NEXT_DUP); No longer supported #2862 dodefine(DB_NEXT_NODUP); dodefine(DB_PREV); #if defined(DB_PREV_DUP) - dodefine(DB_PREV_DUP); + //dodefine(DB_PREV_DUP); #endif dodefine(DB_PREV_NODUP); dodefine(DB_SET); dodefine(DB_SET_RANGE); printf("#define DB_CURRENT_BINDING 253\n"); // private tokudb printf("#define DB_SET_RANGE_REVERSE 252\n"); // private tokudb - printf("#define DB_GET_BOTH_RANGE_REVERSE 251\n"); // private tokudb + //printf("#define DB_GET_BOTH_RANGE_REVERSE 251\n"); // private tokudb. No longer supported #2862. dodefine(DB_RMW); printf("#define DB_PRELOCKED 0x00800000\n"); // private tokudb printf("#define DB_PRELOCKED_WRITE 0x00400000\n"); // private tokudb @@ -529,7 +529,6 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ "int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */", "int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */", "int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */", - "int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */", "int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*) /* Fill in status struct */", "int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */", "int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */", @@ -595,16 +594,14 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ const char *extra[]={"int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact)", "int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *)", - "int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*)", + "int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*)", "int (*pre_acquire_table_lock)(DB*, DB_TXN*)", "const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/", "const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/", - "int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */", "int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */", "DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */", "int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor) /* set row/dictionary descriptor for a db. Available only while db is open */", "int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */", - "int (*getf_get_both)(DB*, DB_TXN*, u_int32_t, DBT*, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_get_both without a persistent cursor) */", "int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */", "int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION)", NULL}; @@ -643,20 +640,13 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ "int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", "int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", "int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", - "int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", - "int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", "int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", - "int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", - "int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", "int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", "int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *)", "int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)", "int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)", "int (*c_getf_set_range_reverse)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *)", - "int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *)", - "int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *)", - "int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *)", NULL}; assert(sizeof(dbc_fields32)==sizeof(dbc_fields64)); print_struct("dbc", INTERNAL_AT_END, dbc_fields32, dbc_fields64, sizeof(dbc_fields32)/sizeof(dbc_fields32[0]), extra); diff --git a/buildheader/sample_offsets.c b/buildheader/sample_offsets.c index 5f90089f6a9..cf78a9ea1f3 100644 --- a/buildheader/sample_offsets.c +++ b/buildheader/sample_offsets.c @@ -144,7 +144,6 @@ void sample_db_offsets (void) { STRUCT_SETUP(DB, remove, "int (*%s) (DB *, const char *, const char *, u_int32_t)"); STRUCT_SETUP(DB, rename, "int (*%s) (DB *, const char *, const char *, const char *, u_int32_t)"); STRUCT_SETUP(DB, set_bt_compare, "int (*%s) (DB *, int (*)(DB *, const DBT *, const DBT *))"); - STRUCT_SETUP(DB, set_dup_compare, "int (*%s) (DB *, int (*)(DB *, const DBT *, const DBT *))"); STRUCT_SETUP(DB, set_errfile, "void (*%s) (DB *, FILE*)"); STRUCT_SETUP(DB, set_flags, "int (*%s) (DB *, u_int32_t)"); STRUCT_SETUP(DB, set_pagesize, "int (*%s) (DB *, u_int32_t)"); diff --git a/buildheader/sample_offsets_32_4_1.h b/buildheader/sample_offsets_32_4_1.h index e417f8a3122..474abd6e2ba 100644 --- a/buildheader/sample_offsets_32_4_1.h +++ b/buildheader/sample_offsets_32_4_1.h @@ -60,7 +60,6 @@ struct fieldinfo db_fields32[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 316, 4}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 320, 4}, {"int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t)", 324, 4}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 344, 4}, {"void (*set_errfile) (DB *, FILE*)", 356, 4}, {"int (*set_flags) (DB *, u_int32_t)", 368, 4}, {"int (*set_pagesize) (DB *, u_int32_t)", 376, 4}, diff --git a/buildheader/sample_offsets_32_4_3.h b/buildheader/sample_offsets_32_4_3.h index 5ae7eabedf9..901d66f45b3 100644 --- a/buildheader/sample_offsets_32_4_3.h +++ b/buildheader/sample_offsets_32_4_3.h @@ -66,7 +66,6 @@ struct fieldinfo db_fields32[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 376, 4}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 380, 4}, {"int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t)", 384, 4}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 400, 4}, {"void (*set_errfile) (DB *, FILE*)", 412, 4}, {"int (*set_flags) (DB *, u_int32_t)", 424, 4}, {"int (*set_pagesize) (DB *, u_int32_t)", 444, 4}, diff --git a/buildheader/sample_offsets_32_4_4.h b/buildheader/sample_offsets_32_4_4.h index 60c62ee5720..c101dd1cf0d 100644 --- a/buildheader/sample_offsets_32_4_4.h +++ b/buildheader/sample_offsets_32_4_4.h @@ -66,7 +66,6 @@ struct fieldinfo db_fields32[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 424, 4}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 428, 4}, {"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 440, 4}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 456, 4}, {"void (*set_errfile) (DB *, FILE*)", 468, 4}, {"int (*set_flags) (DB *, u_int32_t)", 480, 4}, {"int (*set_pagesize) (DB *, u_int32_t)", 508, 4}, diff --git a/buildheader/sample_offsets_32_4_5.h b/buildheader/sample_offsets_32_4_5.h index f6a89b61042..fb26da9a704 100644 --- a/buildheader/sample_offsets_32_4_5.h +++ b/buildheader/sample_offsets_32_4_5.h @@ -65,7 +65,6 @@ struct fieldinfo db_fields32[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 436, 4}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 440, 4}, {"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 452, 4}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 468, 4}, {"void (*set_errfile) (DB *, FILE*)", 480, 4}, {"int (*set_flags) (DB *, u_int32_t)", 492, 4}, {"int (*set_pagesize) (DB *, u_int32_t)", 520, 4}, diff --git a/buildheader/sample_offsets_32_4_6.h b/buildheader/sample_offsets_32_4_6.h index 5ce958c7b36..d7bf0b10971 100644 --- a/buildheader/sample_offsets_32_4_6.h +++ b/buildheader/sample_offsets_32_4_6.h @@ -65,7 +65,6 @@ struct fieldinfo db_fields32[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 456, 4}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 460, 4}, {"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 472, 4}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 488, 4}, {"void (*set_errfile) (DB *, FILE*)", 500, 4}, {"int (*set_flags) (DB *, u_int32_t)", 512, 4}, {"int (*set_pagesize) (DB *, u_int32_t)", 544, 4}, diff --git a/buildheader/sample_offsets_64_4_1.h b/buildheader/sample_offsets_64_4_1.h index 029b38f80fe..55c3fb720d8 100644 --- a/buildheader/sample_offsets_64_4_1.h +++ b/buildheader/sample_offsets_64_4_1.h @@ -60,7 +60,6 @@ struct fieldinfo db_fields64[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 536, 8}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 544, 8}, {"int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t)", 552, 8}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 592, 8}, {"void (*set_errfile) (DB *, FILE*)", 616, 8}, {"int (*set_flags) (DB *, u_int32_t)", 640, 8}, {"int (*set_pagesize) (DB *, u_int32_t)", 656, 8}, diff --git a/buildheader/sample_offsets_64_4_3.h b/buildheader/sample_offsets_64_4_3.h index 7e3cc656cc1..4fbc8f5ee3a 100644 --- a/buildheader/sample_offsets_64_4_3.h +++ b/buildheader/sample_offsets_64_4_3.h @@ -66,7 +66,6 @@ struct fieldinfo db_fields64[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 656, 8}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 664, 8}, {"int (*truncate) (DB *, DB_TXN *, u_int32_t *, u_int32_t)", 672, 8}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 704, 8}, {"void (*set_errfile) (DB *, FILE*)", 728, 8}, {"int (*set_flags) (DB *, u_int32_t)", 752, 8}, {"int (*set_pagesize) (DB *, u_int32_t)", 792, 8}, diff --git a/buildheader/sample_offsets_64_4_4.h b/buildheader/sample_offsets_64_4_4.h index ee35be7fc7f..be072bc161f 100644 --- a/buildheader/sample_offsets_64_4_4.h +++ b/buildheader/sample_offsets_64_4_4.h @@ -66,7 +66,6 @@ struct fieldinfo db_fields64[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 752, 8}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 760, 8}, {"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 784, 8}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 816, 8}, {"void (*set_errfile) (DB *, FILE*)", 840, 8}, {"int (*set_flags) (DB *, u_int32_t)", 864, 8}, {"int (*set_pagesize) (DB *, u_int32_t)", 920, 8}, diff --git a/buildheader/sample_offsets_64_4_5.h b/buildheader/sample_offsets_64_4_5.h index 7a73e1f6de5..aea95e05a3e 100644 --- a/buildheader/sample_offsets_64_4_5.h +++ b/buildheader/sample_offsets_64_4_5.h @@ -65,7 +65,6 @@ struct fieldinfo db_fields64[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 776, 8}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 784, 8}, {"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 808, 8}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 840, 8}, {"void (*set_errfile) (DB *, FILE*)", 864, 8}, {"int (*set_flags) (DB *, u_int32_t)", 888, 8}, {"int (*set_pagesize) (DB *, u_int32_t)", 944, 8}, diff --git a/buildheader/sample_offsets_64_4_6.h b/buildheader/sample_offsets_64_4_6.h index e2ecc22737a..d82e63516d4 100644 --- a/buildheader/sample_offsets_64_4_6.h +++ b/buildheader/sample_offsets_64_4_6.h @@ -65,7 +65,6 @@ struct fieldinfo db_fields64[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 824, 8}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 832, 8}, {"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 856, 8}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 888, 8}, {"void (*set_errfile) (DB *, FILE*)", 912, 8}, {"int (*set_flags) (DB *, u_int32_t)", 936, 8}, {"int (*set_pagesize) (DB *, u_int32_t)", 1000, 8}, diff --git a/buildheader/sample_offsets_64_4_7.h b/buildheader/sample_offsets_64_4_7.h index 5153acdeab7..f0ad3f17230 100644 --- a/buildheader/sample_offsets_64_4_7.h +++ b/buildheader/sample_offsets_64_4_7.h @@ -65,7 +65,6 @@ struct fieldinfo db_fields64[] = { {"int (*remove) (DB *, const char *, const char *, u_int32_t)", 864, 8}, {"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)", 872, 8}, {"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 896, 8}, - {"int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))", 928, 8}, {"void (*set_errfile) (DB *, FILE*)", 952, 8}, {"int (*set_flags) (DB *, u_int32_t)", 976, 8}, {"int (*set_pagesize) (DB *, u_int32_t)", 1040, 8}, diff --git a/buildheader/tdb.h b/buildheader/tdb.h index 196a17bbf9c..7e907f04675 100644 --- a/buildheader/tdb.h +++ b/buildheader/tdb.h @@ -169,8 +169,6 @@ typedef enum { #define DB_LOCK_DEFAULT 1 #define DB_LOCK_OLDEST 7 #define DB_LOCK_RANDOM 8 -#define DB_DUP 32768 -#define DB_DUPSORT 65536 #define DB_KEYFIRST 13 #define DB_KEYLAST 14 #define DB_NOOVERWRITE 20 @@ -195,21 +193,16 @@ typedef enum { #define DB_DELETE_ANY 65536 #define DB_TRUNCATE_WITHCURSORS 131072 #define DB_FIRST 7 -#define DB_GET_BOTH 8 -#define DB_GET_BOTH_RANGE 10 #define DB_LAST 15 #define DB_CURRENT 6 #define DB_NEXT 16 -#define DB_NEXT_DUP 17 #define DB_NEXT_NODUP 18 #define DB_PREV 23 -#define DB_PREV_DUP 24 #define DB_PREV_NODUP 25 #define DB_SET 26 #define DB_SET_RANGE 27 #define DB_CURRENT_BINDING 253 #define DB_SET_RANGE_REVERSE 252 -#define DB_GET_BOTH_RANGE_REVERSE 251 #define DB_RMW 1073741824 #define DB_PRELOCKED 0x00800000 #define DB_PRELOCKED_WRITE 0x00400000 @@ -253,16 +246,15 @@ struct __toku_db_env { int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */; int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */; int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; - int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*) /* Fill in status struct */; int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */; int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */; int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags); - void *app_private; int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn, const DBT *key, const DBT *val, uint32_t num_dbs, DB **db_array, DBT *keys, DBT *vals, uint32_t *flags_array, void *extra) /* Insert into multiple dbs */; + void *app_private; int (*set_generate_row_callback_for_put) (DB_ENV *env, int (*generate_row_for_put)(DB *dest_db, DB *src_db, DBT *dest_key, DBT *dest_val, @@ -344,16 +336,14 @@ struct __toku_db { int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *); void *app_private; DB_ENV *dbenv; - int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*); + int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*); int (*pre_acquire_table_lock)(DB*, DB_TXN*); const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/; const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/; - int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */; int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */; DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */; int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor) /* set row/dictionary descriptor for a db. Available only while db is open */; int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */; - int (*getf_get_both)(DB*, DB_TXN*, u_int32_t, DBT*, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_get_both without a persistent cursor) */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); void *api_internal; @@ -370,7 +360,6 @@ struct __toku_db { int (*remove) (DB *, const char *, const char *, u_int32_t); int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); - int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); void (*set_errfile) (DB *, FILE*); int (*set_flags) (DB *, u_int32_t); int (*set_pagesize) (DB *, u_int32_t); @@ -415,19 +404,12 @@ struct __toku_dbc { int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range_reverse)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_close) (DBC *); int (*c_count) (DBC *, db_recno_t *, u_int32_t); int (*c_del) (DBC *, u_int32_t); diff --git a/cxx/db.cpp b/cxx/db.cpp index fb440f5543f..7f5164ec9f3 100644 --- a/cxx/db.cpp +++ b/cxx/db.cpp @@ -127,11 +127,6 @@ int Db::set_bt_compare(bt_compare_fcn_type bt_compare_fcn) { return the_Env->maybe_throw_error(ret); } -int Db::set_dup_compare(dup_compare_fcn_type dup_compare_fcn) { - int ret = the_db->set_dup_compare(the_db, dup_compare_fcn); - return the_Env->maybe_throw_error(ret); -} - int Db::fd(int *fdp) { int ret = the_db->fd(the_db, fdp); return the_Env->maybe_throw_error(ret); @@ -142,12 +137,6 @@ extern "C" int toku_dup_compare_callback_c(DB *db_c, const DBT *a, const DBT *b) return db_cxx->dup_compare_callback_cxx(db_cxx, Dbt::get_const_Dbt(a), Dbt::get_const_Dbt(b)); } -int Db::set_dup_compare(int (*dup_compare_callback)(Db *, const Dbt *, const Dbt *)) { - dup_compare_callback_cxx = dup_compare_callback; - int ret = the_db->set_dup_compare(the_db, toku_dup_compare_callback_c); - return the_Env->maybe_throw_error(ret); -} - void Db::set_errpfx(const char *errpfx) { the_Env->set_errpfx(errpfx); } diff --git a/cxx/tests/Makefile b/cxx/tests/Makefile index 1762e5c3d0e..06d08f5c578 100644 --- a/cxx/tests/Makefile +++ b/cxx/tests/Makefile @@ -116,7 +116,6 @@ check: $(TARGETS) \ check_test_reverse_compare_fun \ check_test1e \ check_db_create \ - check_db_create_DSM \ check_db_create_1 check_db_create_2 check_db_create_3 check_db_create_4 \ check_permissions \ check_exceptions \ @@ -137,10 +136,6 @@ check_db_create: db_create rm -rf $@.dir mkdir $@.dir $(VGRIND) ./db_create --env_dir $@.dir -s main $@.tdb $(SUMMARIZE_CMD) -check_db_create_DSM: db_create - rm -rf $@.dir - mkdir $@.dir - $(VGRIND) ./db_create --env_dir $@.dir -D -S -s main $@.tdb $(SUMMARIZE_CMD) # These don't need to set the env dir check_db_create_1: db_create diff --git a/cxx/tests/db_create.cpp b/cxx/tests/db_create.cpp index dbc71472bd2..59889d6024b 100644 --- a/cxx/tests/db_create.cpp +++ b/cxx/tests/db_create.cpp @@ -45,7 +45,7 @@ static int dbcreate(char *dbfile, char *dbname, int dbflags, int argc, char *arg } static int usage() { - fprintf(stderr, "db_create [-s DBNAME] [-D] [-S] DBFILE [KEY VAL]*\n"); + fprintf(stderr, "db_create [-s DBNAME] DBFILE [KEY VAL]*\n"); fprintf(stderr, "[--set_data_dir DIRNAME]\n"); return 1; } @@ -65,14 +65,6 @@ int main(int argc, char *argv[]) { dbname = argv[++i]; continue; } - if (0 == strcmp(arg, "-D")) { - dbflags += DB_DUP; - continue; - } - if (0 == strcmp(arg, "-S")) { - dbflags += DB_DUPSORT; - continue; - } if (0 == strcmp(arg, "--env_dir")) { if (i+1 >= argc) return usage(); diff --git a/cxx/tests/db_dump.cpp b/cxx/tests/db_dump.cpp index 080efc351ac..60f4ecd8c86 100644 --- a/cxx/tests/db_dump.cpp +++ b/cxx/tests/db_dump.cpp @@ -34,10 +34,12 @@ static int dbdump(const char *env_dir, const char *dbfile, const char *dbname) { u_int32_t dbflags; r = db.get_flags(&dbflags); assert(r == 0); +#ifndef TOKUDB if (dbflags & DB_DUP) printf("duplicates=1\n"); if (dbflags & DB_DUPSORT) printf("dupsort=1\n"); +#endif #if 0 u_int32_t nodesize; r = db.get_nodesize(&nodesize); assert(r == 0); diff --git a/cxx/tests/test_cursor_count.cpp b/cxx/tests/test_cursor_count.cpp index 2f21fff9a7a..7a906265d57 100644 --- a/cxx/tests/test_cursor_count.cpp +++ b/cxx/tests/test_cursor_count.cpp @@ -190,9 +190,8 @@ void walk(Db *db, int n) { r = my_cursor_count(cursor, &mycount, db); assert(r == 0); assert(mycount == count); #endif - if (k == n/2) assert((int)count == n); else assert(count == 1); + assert(count==1); // we support only NODUP databases now. } - assert(i == 2*n-1); toku_free(key.get_data()); toku_free(val.get_data()); r = cursor->close(); assert(r == 0); @@ -213,7 +212,7 @@ void test_zero_count(Db *db, int n) { r = cursor_set(cursor, htonl(n/2)); assert(r == 0); db_recno_t count; r = cursor->count(&count, 0); assert(r == 0); - assert((int)count == n); + assert((int)count == 1); Dbt key; key.set_flags(DB_DBT_REALLOC); Dbt val; val.set_flags(DB_DBT_REALLOC); @@ -226,10 +225,10 @@ void test_zero_count(Db *db, int n) { break; assert(newcount == count - 1); count = newcount; - r = cursor->get(&key, &val, DB_NEXT_DUP); + r = cursor->get(&key, &val, DB_NEXT); if (r != 0) break; } - assert(i == n); + assert(i == 2); if (key.get_data()) toku_free(key.get_data()); if (val.get_data()) toku_free(val.get_data()); r = cursor->close(); assert(r == 0); @@ -249,7 +248,7 @@ void test_next_nodup(Db *db, int n) { int v = *(int*)val.get_data(); if (verbose) printf("%d %d\n", k, v); assert(k == i); - if (k == n/2) assert(v == 0); else assert(v == i); + if (k == n/2) assert(v == n-1); else assert(v == i); i += 1; // r = my_next_nodup(cursor, &key, &val); r = cursor->get(&key, &val, DB_NEXT_NODUP); @@ -285,47 +284,6 @@ void test_prev_nodup(Db *db, int n) { r = cursor->close(); assert(r == 0); } -void test_next_dup(Db *db, int n) { - if (verbose) printf("test_next_dup\n"); - int r; - Dbc *cursor; - r = db->cursor(0, &cursor, 0); assert(r == 0); - int k = htonl(n/2); - Dbt setkey(&k, sizeof k); - Dbt key; key.set_flags(DB_DBT_REALLOC); - Dbt val; val.set_flags(DB_DBT_REALLOC); - r = cursor->get(&setkey, &val, DB_SET); assert(r == 0); - r = cursor->get(&key, &val, DB_CURRENT); assert(r == 0); - int i = 0; - while (r == 0) { - int k = htonl(*(int*)key.get_data()); - int v = *(int*)val.get_data(); - if (verbose) printf("%d %d\n", k, v); - assert(k == n/2); assert(v == i); - i += 1; - // r = my_next_dup(cursor, &key, &val); - r = cursor->get(&key, &val, DB_NEXT_DUP); - } - assert(i == n); -#ifdef DB_PREV_DUP - i = n - 1; - for (;;) { - r = cursor->get(&key, &val, DB_CURRENT); - assert(r == 0); - int k = htonl(*(int*)key.get_data()); - int v = *(int*)val.get_data(); - assert(k == n/2); assert(v == i); - r = cursor->get(&key, &val, DB_PREV_DUP); - if (r != 0) break; - i -= 1; - } - assert(i == 0); -#endif - if (key.get_data()) toku_free(key.get_data()); - if (val.get_data()) toku_free(val.get_data()); - r = cursor->close(); assert(r == 0); -} - #define DIR "test_cursor_count.dir" int main(int argc, char *argv[]) { @@ -349,7 +307,6 @@ int main(int argc, char *argv[]) { Db db(0, DB_CXX_NO_EXCEPTIONS); #endif - r = db.set_flags(DB_DUP + DB_DUPSORT); assert(r == 0); unlink(FNAME); r = db.open(0, FNAME, 0, DB_BTREE, DB_CREATE, 0777); assert(r == 0); @@ -358,7 +315,6 @@ int main(int argc, char *argv[]) { walk(&db, 10); test_next_nodup(&db, 10); test_prev_nodup(&db, 10); - test_next_dup(&db, 10); test_zero_count(&db, 10); return 0; diff --git a/cxx/tests/test_reverse_compare_fun.cpp b/cxx/tests/test_reverse_compare_fun.cpp index 9173c80ad70..acfac410cdc 100644 --- a/cxx/tests/test_reverse_compare_fun.cpp +++ b/cxx/tests/test_reverse_compare_fun.cpp @@ -53,8 +53,8 @@ void expect(Dbc *cursor, int k, int v) { toku_free(val.get_data()); } -void test_reverse_compare(int n, int dup_flags) { - if (verbose) printf("test_reverse_compare:%d %d\n", n, dup_flags); +void test_reverse_compare(int n) { + if (verbose) printf("test_reverse_compare:%d\n", n); Db *db; DbTxn * const null_txn = 0; @@ -72,21 +72,17 @@ void test_reverse_compare(int n, int dup_flags) { r = env.open(DIR, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0); db = new Db(&env, DB_CXX_NO_EXCEPTIONS); assert(db); - r = db->set_flags(dup_flags); - assert(r == 0); r = db->set_pagesize(4096); assert(r == 0); r = db->set_bt_compare(reverse_compare); assert(r == 0); - r = db->set_dup_compare(reverse_compare); - assert(r == 0); r = db->open(null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); /* insert n unique keys {0, 1, n-1} */ for (i=0; iset_flags(dup_flags); - assert(r == 0); r = db->set_pagesize(4096); assert(r == 0); r = db->set_bt_compare(reverse_compare); assert(r == 0); - r = db->set_dup_compare(reverse_compare); - assert(r == 0); r = db->open(null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); /* insert n unique keys {n, n+1, 2*n-1} */ for (i=n; i<2*n; i++) { int k, v; - k = htonl(dup_flags ? n : i); + k = htonl(i); Dbt key(&k, sizeof k); v = htonl(i); Dbt val(&v, sizeof v); @@ -130,7 +122,7 @@ void test_reverse_compare(int n, int dup_flags) { //for (i=0; i<2*n; i++) for (i=2*n-1; i>=0; i--) - expect(cursor, htonl(dup_flags ? n : i), htonl(i)); + expect(cursor, htonl(i), htonl(i)); r = cursor->close(); assert(r == 0); @@ -143,8 +135,7 @@ void test_reverse_compare(int n, int dup_flags) { int main(int argc, const char *argv[]) { int i; for (i = 1; i <= (1<<16); i *= 2) { - test_reverse_compare(i, 0); - test_reverse_compare(i, DB_DUP + DB_DUPSORT); + test_reverse_compare(i); } return 0; } diff --git a/db-benchmark-test/Makefile b/db-benchmark-test/Makefile index a99fa472132..8c95b226560 100644 --- a/db-benchmark-test/Makefile +++ b/db-benchmark-test/Makefile @@ -69,22 +69,17 @@ endif build.bdb: $(TARGET_BDB) $(SCANSCAN_BDB) $(WINDOWS_BDB_LIB_NAME) build.tdb: $(TARGET_TDB) $(SCANSCAN_TDB) -check: check-default check-rowsize-dup check-rowsize check-xfast check-x check-no-rollback check-4G child.benchmark.dir +check: check-default check-rowsize check-xfast check-x check-no-rollback check-4G child.benchmark.dir SUPPORT_KEYSIZE=$$((3*1024)) # at least 3KiB SUPPORT_ROWSIZE=$$((80*1024)) # at least 80KiB -.PHONY: check-rowsize check-rowsize-dup +.PHONY: check-rowsize check-rowsize: $(TARGET_TDB) ( $(VGRIND) ./$(TARGET_TDB) $(VERBVERBOSE) --env rowsize.key.dir --keysize $(SUPPORT_KEYSIZE) --periter 256 1 && \ $(VGRIND) ./$(TARGET_TDB) $(VERBVERBOSE) --env rowsize.val.dir --valsize $(SUPPORT_ROWSIZE) --periter 256 1 && \ $(VGRIND) ./$(TARGET_TDB) $(VERBVERBOSE) --env rowsize.keyval.dir --keysize $(SUPPORT_KEYSIZE) --valsize $(SUPPORT_ROWSIZE) --periter 256 1 ) $(SUMMARIZE_CMD) -check-rowsize-dup: $(TARGET_TDB) - ( $(VGRIND) ./$(TARGET_TDB) $(VERBVERBOSE) --env rowsize.dup.key.dir --dupsort --keysize $(SUPPORT_KEYSIZE) --periter 256 1 && \ - $(VGRIND) ./$(TARGET_TDB) $(VERBVERBOSE) --env rowsize.dup.val.dir --valsize $(SUPPORT_ROWSIZE) --periter 256 1 && \ - $(VGRIND) ./$(TARGET_TDB) $(VERBVERBOSE) --env rowsize.dup.keyval.dir --dupsort --keysize $(SUPPORT_KEYSIZE) --valsize $(SUPPORT_ROWSIZE) --periter 256 1 ) $(SUMMARIZE_CMD) - check-default: $(TARGET_TDB) $(VGRIND) ./$(TARGET_TDB) $(VERBVERBOSE) $(SUMMARIZE_CMD) diff --git a/db-benchmark-test/db-benchmark-test.c b/db-benchmark-test/db-benchmark-test.c index 9d4fafcce30..16b25243b46 100644 --- a/db-benchmark-test/db-benchmark-test.c +++ b/db-benchmark-test/db-benchmark-test.c @@ -612,9 +612,6 @@ static int test_main (int argc, char *const argv[]) { } else if (strcmp(arg, "--pagesize") == 0) { if (i+1 >= argc) return print_usage(argv[0]); pagesize = atoi(argv[++i]); - } else if (strcmp(arg, "--dupsort") == 0) { - dupflags = DB_DUP + DB_DUPSORT; - continue; } else if (strcmp(arg, "--env") == 0) { if (i+1 >= argc) return print_usage(argv[0]); dbdir = argv[++i]; diff --git a/db-benchmark-test/scanscan.c b/db-benchmark-test/scanscan.c index 9c3ef3b1876..b0395c30948 100644 --- a/db-benchmark-test/scanscan.c +++ b/db-benchmark-test/scanscan.c @@ -189,8 +189,7 @@ static void scanscan_setup (void) { if (prelock) { r = db->pre_acquire_read_lock(db, tid, - db->dbt_neg_infty(), db->dbt_neg_infty(), - db->dbt_pos_infty(), db->dbt_pos_infty()); + db->dbt_neg_infty(), db->dbt_pos_infty()); assert(r==0); } #endif @@ -386,8 +385,6 @@ static void scanscan_range (void) { #ifdef TOKUDB -typedef struct foo{int a; } FOO; - struct extra_verify { long long totalbytes; int rowcounter; diff --git a/include/db.h b/include/db.h index 196a17bbf9c..7e907f04675 100644 --- a/include/db.h +++ b/include/db.h @@ -169,8 +169,6 @@ typedef enum { #define DB_LOCK_DEFAULT 1 #define DB_LOCK_OLDEST 7 #define DB_LOCK_RANDOM 8 -#define DB_DUP 32768 -#define DB_DUPSORT 65536 #define DB_KEYFIRST 13 #define DB_KEYLAST 14 #define DB_NOOVERWRITE 20 @@ -195,21 +193,16 @@ typedef enum { #define DB_DELETE_ANY 65536 #define DB_TRUNCATE_WITHCURSORS 131072 #define DB_FIRST 7 -#define DB_GET_BOTH 8 -#define DB_GET_BOTH_RANGE 10 #define DB_LAST 15 #define DB_CURRENT 6 #define DB_NEXT 16 -#define DB_NEXT_DUP 17 #define DB_NEXT_NODUP 18 #define DB_PREV 23 -#define DB_PREV_DUP 24 #define DB_PREV_NODUP 25 #define DB_SET 26 #define DB_SET_RANGE 27 #define DB_CURRENT_BINDING 253 #define DB_SET_RANGE_REVERSE 252 -#define DB_GET_BOTH_RANGE_REVERSE 251 #define DB_RMW 1073741824 #define DB_PRELOCKED 0x00800000 #define DB_PRELOCKED_WRITE 0x00400000 @@ -253,16 +246,15 @@ struct __toku_db_env { int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */; int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */; int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; - int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */; int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*) /* Fill in status struct */; int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */; int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */; int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags); - void *app_private; int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn, const DBT *key, const DBT *val, uint32_t num_dbs, DB **db_array, DBT *keys, DBT *vals, uint32_t *flags_array, void *extra) /* Insert into multiple dbs */; + void *app_private; int (*set_generate_row_callback_for_put) (DB_ENV *env, int (*generate_row_for_put)(DB *dest_db, DB *src_db, DBT *dest_key, DBT *dest_val, @@ -344,16 +336,14 @@ struct __toku_db { int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *); void *app_private; DB_ENV *dbenv; - int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*); + int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*); int (*pre_acquire_table_lock)(DB*, DB_TXN*); const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/; const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/; - int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */; int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */; DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */; int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor) /* set row/dictionary descriptor for a db. Available only while db is open */; int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */; - int (*getf_get_both)(DB*, DB_TXN*, u_int32_t, DBT*, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_get_both without a persistent cursor) */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); void *api_internal; @@ -370,7 +360,6 @@ struct __toku_db { int (*remove) (DB *, const char *, const char *, u_int32_t); int (*rename) (DB *, const char *, const char *, const char *, u_int32_t); int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); - int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); void (*set_errfile) (DB *, FILE*); int (*set_flags) (DB *, u_int32_t); int (*set_pagesize) (DB *, u_int32_t); @@ -415,19 +404,12 @@ struct __toku_dbc { int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_getf_set_range_reverse)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); int (*c_close) (DBC *); int (*c_count) (DBC *, db_recno_t *, u_int32_t); int (*c_del) (DBC *, u_int32_t); diff --git a/newbrt/backwards_11.c b/newbrt/backwards_11.c deleted file mode 100644 index 1a729acfc49..00000000000 --- a/newbrt/backwards_11.c +++ /dev/null @@ -1,770 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "$Id: brt-serialize.c 18555 2010-03-18 01:20:07Z yfogel $" -#ident "Copyright (c) 2007, 2008, 2009 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "includes.h" - -#define PRINT 0 - - -static u_int32_t x1764_memory_11 (const void *buf, int len) -{ - const u_int64_t *lbuf=buf; - u_int64_t c=0; - while (len>=8) { - c = c*17 + *lbuf; - if (PRINT) printf("%d: c=%016" PRIx64 " sum=%016" PRIx64 "\n", __LINE__, *lbuf, c); - lbuf++; - len-=8; - } - if (len>0) { - const u_int8_t *cbuf=(u_int8_t*)lbuf; - int i; - u_int64_t input=0; - for (i=0; i>32); -} - -// Given a version 11 header, create a version 12 header. -// If new memory is needed for the new header, allocate it here and free the memory of the old version header. -static int -upgrade_brtheader_11_12(int fd, struct brt_header **brth_11, struct brt_header ** brth_12) { - int r = 0; - assert((*brth_11)->layout_version == BRT_LAYOUT_VERSION_11); - *brth_12 = *brth_11; - *brth_11 = NULL; - (*brth_12)->layout_version = BRT_LAYOUT_VERSION_12; - toku_list_init(&(*brth_12)->checkpoint_before_commit_link); - (void) toku_sync_fetch_and_increment_uint64(&upgrade_status.header); - { //Re-write descriptor to fix checksum (does not get done automatically). - DISKOFF offset; - DESCRIPTOR d = &(*brth_12)->descriptor; - //4 for checksum - toku_realloc_descriptor_on_disk((*brth_12)->blocktable, toku_serialize_descriptor_size(d)+4, &offset, (*brth_12)); - r = toku_serialize_descriptor_contents_to_fd(fd, d, offset); - } - return r; -} - -// Structure of brtnode is same for versions 11, 12. The only difference is in the -// disk format and layout version. -static int -upgrade_brtnode_11_12 (BRTNODE *brtnode_11, BRTNODE *brtnode_12) { - *brtnode_12 = *brtnode_11; - *brtnode_11 = NULL; - - BRTNODE brt = *brtnode_12; - brt->layout_version = BRT_LAYOUT_VERSION_12; - brt->dirty = 1; - if (brt->height) { - (void) toku_sync_fetch_and_increment_uint64(&upgrade_status.nonleaf); - } - else { - (void) toku_sync_fetch_and_increment_uint64(&upgrade_status.leaf); - } - //x1764 calculation (fingerprint) has changed between 11 and 12. - //Update all local fields based on x1764, verify several others. - toku_verify_or_set_counts(brt, TRUE); - return 0; -} - - -static u_int32_t -toku_serialize_descriptor_size_11(DESCRIPTOR desc) { - //Checksum NOT included in this. Checksum only exists in header's version. - u_int32_t size = 4+ //version - 4; //size - size += desc->dbt.size; - return size; -} - - -static unsigned int toku_brtnode_pivot_key_len_11 (BRTNODE node, struct kv_pair *pk) { - if (node->flags & TOKU_DB_DUPSORT) { - return kv_pair_keylen(pk) + kv_pair_vallen(pk); - } else { - return kv_pair_keylen(pk); - } -} - - - -enum { uncompressed_magic_len_11 = (8 // tokuleaf or tokunode - +4 // layout version - +4 // layout version original - ) -}; - -// uncompressed header offsets -enum { - uncompressed_magic_offset_11 = 0, - uncompressed_version_offset_11 = 8, -}; - -// compression header sub block sizes -struct sub_block_sizes { - u_int32_t compressed_size; // real compressed size - u_int32_t uncompressed_size; - u_int32_t compressed_size_bound; // estimated compressed size -}; - -// target sub-block sizs and max number of sub-blocks per block. -static const int target_sub_block_size_11 = 512*1024; -static const int max_sub_blocks_11 = 8; - -// round up n -static inline int roundup2(int n, int alignment) { - return (n+alignment-1)&~(alignment-1); -} - - -// get the size of the compression header -static size_t get_compression_header_size(int UU(layout_version), int n) { - return sizeof (u_int32_t) + (n * 2 * sizeof (u_int32_t)); -} - - - -// get the sum of the sub block uncompressed sizes -static size_t get_sum_uncompressed_size_11(int n, struct sub_block_sizes sizes[]) { - int i; - size_t uncompressed_size = 0; - for (i=0; iu.n.totalchildkeylens=0; - u_int32_t subtree_fingerprint = rbuf_int(rb); - u_int32_t check_subtree_fingerprint = 0; - result->u.n.n_children = rbuf_int(rb); - MALLOC_N(result->u.n.n_children+1, result->u.n.childinfos); - MALLOC_N(result->u.n.n_children, result->u.n.childkeys); - //printf("n_children=%d\n", result->n_children); - assert(result->u.n.n_children>=0); - for (i=0; iu.n.n_children; i++) { - u_int32_t childfp = rbuf_int(rb); - BNC_SUBTREE_FINGERPRINT(result, i)= childfp; - check_subtree_fingerprint += childfp; - struct subtree_estimates *se = &(BNC_SUBTREE_ESTIMATES(result, i)); - se->nkeys = rbuf_ulonglong(rb); - se->ndata = rbuf_ulonglong(rb); - se->dsize = rbuf_ulonglong(rb); - se->exact = (BOOL) (rbuf_char(rb) != 0); - } - for (i=0; iu.n.n_children-1; i++) { - if (result->flags & TOKU_DB_DUPSORT) { - bytevec keyptr, dataptr; - unsigned int keylen, datalen; - rbuf_bytes(rb, &keyptr, &keylen); - rbuf_bytes(rb, &dataptr, &datalen); - result->u.n.childkeys[i] = kv_pair_malloc(keyptr, keylen, dataptr, datalen); - } else { - bytevec childkeyptr; - unsigned int cklen; - rbuf_bytes(rb, &childkeyptr, &cklen); /* Returns a pointer into the rbuf. */ - result->u.n.childkeys[i] = kv_pair_malloc((void*)childkeyptr, cklen, 0, 0); - } - //printf(" key %d length=%d data=%s\n", i, result->childkeylens[i], result->childkeys[i]); - result->u.n.totalchildkeylens+=toku_brtnode_pivot_key_len_11(result, result->u.n.childkeys[i]); - } - for (i=0; iu.n.n_children; i++) { - BNC_BLOCKNUM(result,i) = rbuf_blocknum(rb); - BNC_HAVE_FULLHASH(result, i) = FALSE; - BNC_NBYTESINBUF(result,i) = 0; - //printf("Child %d at %lld\n", i, result->children[i]); - } - result->u.n.n_bytes_in_buffers = 0; - for (i=0; iu.n.n_children; i++) { - r=toku_fifo_create(&BNC_BUFFER(result,i)); - if (r!=0) { - int j; - if (0) { died_1: j=result->u.n.n_bytes_in_buffers; } - for (j=0; ju.n.n_children; cnum++) { - int n_in_this_hash = rbuf_int(rb); - //printf("%d in hash\n", n_in_hash); - for (i=0; irand4fingerprint * toku_calc_fingerprint_cmd(type, xids, key, keylen, val, vallen); - //printf("Found %s,%s\n", (char*)key, (char*)val); - { - r=toku_fifo_enq(BNC_BUFFER(result, cnum), key, keylen, val, vallen, type, xids); /* Copies the data into the hash table. */ - if (r!=0) { goto died_1; } - } - diff = keylen + vallen + KEY_VALUE_OVERHEAD + BRT_CMD_OVERHEAD + xids_get_serialize_size(xids); - result->u.n.n_bytes_in_buffers += diff; - BNC_NBYTESINBUF(result,cnum) += diff; - //printf("Inserted\n"); - xids_destroy(&xids); - } - } - if (check_local_fingerprint != result->local_fingerprint) { - fprintf(stderr, "%s:%d local fingerprint is wrong (found %8x calcualted %8x\n", __FILE__, __LINE__, result->local_fingerprint, check_local_fingerprint); - return toku_db_badformat(); - } - if (check_subtree_fingerprint+check_local_fingerprint != subtree_fingerprint) { - fprintf(stderr, "%s:%d subtree fingerprint is wrong\n", __FILE__, __LINE__); - return toku_db_badformat(); - } - } - (void)rbuf_int(rb); //Ignore the crc (already verified). - if (rb->ndone != rb->size) { //Verify we read exactly the entire block. - r = toku_db_badformat(); goto died_1; - } - return 0; -} - -static int -deserialize_brtnode_leaf_from_rbuf_11 (BRTNODE result, bytevec magic, struct rbuf *rb) { - int r; - int i; - - if (memcmp(magic, "tokuleaf", 8)!=0) { - r = toku_db_badformat(); - return r; - } - - result->u.l.leaf_stats.nkeys = rbuf_ulonglong(rb); - result->u.l.leaf_stats.ndata = rbuf_ulonglong(rb); - result->u.l.leaf_stats.dsize = rbuf_ulonglong(rb); - result->u.l.leaf_stats.exact = TRUE; - int n_in_buf = rbuf_int(rb); - result->u.l.n_bytes_in_buffer = 0; - result->u.l.seqinsert = 0; - - //printf("%s:%d r PMA= %p\n", __FILE__, __LINE__, result->u.l.buffer); - toku_mempool_init(&result->u.l.buffer_mempool, rb->buf, rb->size); - - u_int32_t actual_sum = 0; - u_int32_t start_of_data = rb->ndone; - OMTVALUE *MALLOC_N(n_in_buf, array); - for (i=0; ibuf[rb->ndone]); - u_int32_t disksize = leafentry_disksize(le); - rb->ndone += disksize; - assert(rb->ndone<=rb->size); - - array[i]=(OMTVALUE)le; - actual_sum += x1764_memory_11(le, disksize); - } - toku_trace("fill array"); - u_int32_t end_of_data = rb->ndone; - result->u.l.n_bytes_in_buffer += end_of_data-start_of_data + n_in_buf*OMT_ITEM_OVERHEAD; - actual_sum *= result->rand4fingerprint; - r = toku_omt_create_steal_sorted_array(&result->u.l.buffer, &array, n_in_buf, n_in_buf); - toku_trace("create omt"); - if (r!=0) { - toku_free(array); - r = toku_db_badformat(); - if (0) { died_1: toku_omt_destroy(&result->u.l.buffer); } - return r; - } - assert(array==NULL); - - result->u.l.buffer_mempool.frag_size = start_of_data; - result->u.l.buffer_mempool.free_offset = end_of_data; - - if (r!=0) goto died_1; - if (actual_sum!=result->local_fingerprint) { - //fprintf(stderr, "%s:%d Corrupted checksum stored=%08x rand=%08x actual=%08x height=%d n_keys=%d\n", __FILE__, __LINE__, result->rand4fingerprint, result->local_fingerprint, actual_sum, result->height, n_in_buf); - r = toku_db_badformat(); - goto died_1; - } else { - //fprintf(stderr, "%s:%d Good checksum=%08x height=%d\n", __FILE__, __LINE__, actual_sum, result->height); - } - - //toku_verify_counts_11(result); - - (void)rbuf_int(rb); //Ignore the crc (already verified). - if (rb->ndone != rb->size) { //Verify we read exactly the entire block. - r = toku_db_badformat(); goto died_1; - } - - r = toku_leaflock_borrow(result->u.l.leaflock_pool, &result->u.l.leaflock); - if (r!=0) goto died_1; - rb->buf = NULL; //Buffer was used for node's mempool. - return 0; -} - - -static int -deserialize_brtnode_from_rbuf_11 (BLOCKNUM blocknum, u_int32_t fullhash, BRTNODE *brtnode, struct brt_header *h, struct rbuf *rb) { - TAGMALLOC(BRTNODE, result); - int r; - if (result==0) { - r=errno; - if (0) { died0: toku_free(result); } - return r; - } - result->ever_been_written = 1; - - //printf("Deserializing %lld datasize=%d\n", off, datasize); - bytevec magic; - rbuf_literal_bytes(rb, &magic, 8); - result->layout_version = rbuf_int(rb); - assert(result->layout_version == BRT_LAYOUT_VERSION_11); - result->layout_version_original = rbuf_int(rb); - result->layout_version_read_from_disk = result->layout_version; - { - //Restrict scope for now since we do not support upgrades. - DESCRIPTOR_S desc; - //desc.dbt.data is TEMPORARY. Will be unusable when the rc buffer is freed. - deserialize_descriptor_from_rbuf_11(rb, &desc, TRUE); - //Just throw away. - } - result->nodesize = rbuf_int(rb); - - result->thisnodename = blocknum; - result->flags = rbuf_int(rb); - result->height = rbuf_int(rb); - result->rand4fingerprint = rbuf_int(rb); - result->local_fingerprint = rbuf_int(rb); -// printf("%s:%d read %08x\n", __FILE__, __LINE__, result->local_fingerprint); - result->dirty = 0; - result->fullhash = fullhash; - //printf("height==%d\n", result->height); - - if (result->height>0) - r = deserialize_brtnode_nonleaf_from_rbuf_11(result, magic, rb); - else { - result->u.l.leaflock_pool = toku_cachefile_leaflock_pool(h->cf); - r = deserialize_brtnode_leaf_from_rbuf_11(result, magic, rb); - } - if (r!=0) goto died0; - - //printf("%s:%d Ok got %lld n_children=%d\n", __FILE__, __LINE__, result->thisnodename, result->n_children); - if (result->height>0) { - // For height==0 we used the buf inside the OMT - toku_free(rb->buf); - rb->buf = NULL; - } - toku_trace("deserial done"); - *brtnode = result; - //toku_verify_counts_11(result); - return 0; -} - -static int -verify_decompressed_brtnode_checksum (struct rbuf *rb) { - int r = 0; - - if (rb->size >= 4) { - uint32_t verify_size = rb->size - 4; //Not counting the checksum - - toku_trace("x1764 start"); - uint32_t crc = x1764_memory_11(rb->buf, verify_size); - toku_trace("x1764"); - - uint32_t *crcp = (uint32_t*)(((uint8_t*)rb->buf) + verify_size); - uint32_t storedcrc = toku_dtoh32(*crcp); - if (crc!=storedcrc) { - printf("Bad CRC\n"); - printf("%s:%d crc=%08x stored=%08x\n", __FILE__, __LINE__, crc, storedcrc); - r = toku_db_badformat(); - } - } - else r = toku_db_badformat(); - return r; -} - -#define PAR_DECOMPRESS 1 - -#if PAR_DECOMPRESS - -#include "workset.h" - -struct decompress_work_11 { - struct work base; - void *compress_ptr; - void *uncompress_ptr; - u_int32_t compress_size; - u_int32_t uncompress_size; -}; - -// initialize the decompression work -static void -decompress_work_init_11(struct decompress_work_11 *dw, - void *compress_ptr, u_int32_t compress_size, - void *uncompress_ptr, u_int32_t uncompress_size) { - dw->compress_ptr = compress_ptr; - dw->compress_size = compress_size; - dw->uncompress_ptr = uncompress_ptr; - dw->uncompress_size = uncompress_size; -} - -// decompress one block -static void -decompress_block(struct decompress_work_11 *dw) { - uLongf destlen = dw->uncompress_size; - int r = uncompress(dw->uncompress_ptr, &destlen, dw->compress_ptr, dw->compress_size); - assert(destlen == dw->uncompress_size); - assert(r==Z_OK); -} - -// decompress blocks until there is no more work to do -static void * -decompress_worker_11(void *arg) { - struct workset *ws = (struct workset *) arg; - while (1) { - struct decompress_work_11 *dw = (struct decompress_work_11 *) workset_get(ws); - if (dw == NULL) - break; - decompress_block(dw); - } - return arg; -} - -#else - -#define DO_DECOMPRESS_WORKER 0 - -struct decompress_work_11 { - toku_pthread_t id; - void *compress_ptr; - void *uncompress_ptr; - u_int32_t compress_size; - u_int32_t uncompress_size; -}; - -// initialize the decompression work -static void init_decompress_work(struct decompress_work_11 *w, - void *compress_ptr, u_int32_t compress_size, - void *uncompress_ptr, u_int32_t uncompress_size) { - memset(&w->id, 0, sizeof(w->id)); - w->compress_ptr = compress_ptr; w->compress_size = compress_size; - w->uncompress_ptr = uncompress_ptr; w->uncompress_size = uncompress_size; -} - -// do the decompression work -static void do_decompress_work(struct decompress_work_11 *w) { - uLongf destlen = w->uncompress_size; - int r = uncompress(w->uncompress_ptr, &destlen, - w->compress_ptr, w->compress_size); - assert(destlen==w->uncompress_size); - assert(r==Z_OK); -} - -#if DO_DECOMPRESS_WORKER - -static void *decompress_worker_11(void *); - -static void start_decompress_work(struct decompress_work_11 *w) { - int r = toku_pthread_create(&w->id, NULL, decompress_worker_11, w); assert(r == 0); -} - -static void wait_decompress_work(struct decompress_work_11 *w) { - void *ret; - int r = toku_pthread_join(w->id, &ret); assert(r == 0); -} - -static void *decompress_worker_11(void *arg) { - struct decompress_work_11 *w = (struct decompress_work_11 *) arg; - do_decompress_work(w); - return arg; -} - -#endif - -#endif - -static int -decompress_brtnode_from_raw_block_into_rbuf_11(u_int8_t *raw_block, struct rbuf *rb, BLOCKNUM blocknum) { - int r; - int i; - // get the number of compressed sub blocks - int n_sub_blocks; - int compression_header_offset; - { - n_sub_blocks = toku_dtoh32(*(u_int32_t*)(&raw_block[uncompressed_magic_len_11])); - compression_header_offset = uncompressed_magic_len_11 + 4; - } - assert(0 < n_sub_blocks); - - // verify the sizes of the compressed sub blocks - if (0 && n_sub_blocks != 1) printf("%s:%d %d\n", __FUNCTION__, __LINE__, n_sub_blocks); - - struct sub_block_sizes sub_block_sizes[n_sub_blocks]; - for (i=0; i(1<<30)) { r = toku_db_badformat(); return r; } - u_int32_t uncompressed_size = toku_dtoh32(*(u_int32_t*)(&raw_block[compression_header_offset+8*i+4])); - if (0) printf("Block %" PRId64 " Compressed size = %u, uncompressed size=%u\n", blocknum.b, compressed_size, uncompressed_size); - if (uncompressed_size<=0 || uncompressed_size>(1<<30)) { r = toku_db_badformat(); return r; } - - sub_block_sizes[i].compressed_size = compressed_size; - sub_block_sizes[i].uncompressed_size = uncompressed_size; - } - - unsigned char *compressed_data = raw_block + uncompressed_magic_len_11 + get_compression_header_size(BRT_LAYOUT_VERSION_11, n_sub_blocks); - - size_t uncompressed_size = get_sum_uncompressed_size_11(n_sub_blocks, sub_block_sizes); - rb->size= uncompressed_magic_len_11 + uncompressed_size; - assert(rb->size>0); - - rb->buf=toku_xmalloc(rb->size); - - // construct the uncompressed block from the header and compressed sub blocks - memcpy(rb->buf, raw_block, uncompressed_magic_len_11); - -#if PAR_DECOMPRESS - // compute the number of additional threads needed for decompressing this node - int T = num_cores; // T = min(#cores, #blocks) - 1 - if (T > n_sub_blocks) - T = n_sub_blocks; - if (T > 0) - T = T - 1; // threads in addition to the running thread - - // init the decompression work set - struct workset ws; - workset_init(&ws); - - // initialize the decompression work and add to the work set - unsigned char *uncompressed_data = rb->buf+uncompressed_magic_len_11; - struct decompress_work_11 decompress_work_11[n_sub_blocks]; - workset_lock(&ws); - for (i = 0; i < n_sub_blocks; i++) { - decompress_work_init_11(&decompress_work_11[i], compressed_data, sub_block_sizes[i].compressed_size, uncompressed_data, sub_block_sizes[i].uncompressed_size); - uncompressed_data += sub_block_sizes[i].uncompressed_size; - compressed_data += sub_block_sizes[i].compressed_size; - workset_put_locked(&ws, &decompress_work_11[i].base); - } - workset_unlock(&ws); - - // decompress the sub-blocks - if (0) printf("%s:%d Cores=%d Blocks=%d T=%d\n", __FUNCTION__, __LINE__, num_cores, n_sub_blocks, T); - toku_pthread_t tids[T]; - threadset_create(tids, &T, decompress_worker_11, &ws); - decompress_worker_11(&ws); - - // cleanup - threadset_join(tids, T); - workset_destroy(&ws); - -#else - // decompress the sub blocks - unsigned char *uncompressed_data = rb->buf+uncompressed_magic_len_11; - struct decompress_work_11 decompress_work_11[n_sub_blocks]; - - for (i=0; i0) { -#if DO_DECOMPRESS_WORKER - start_decompress_work(&decompress_work_11[i]); -#else - do_decompress_work(&decompress_work_11[i]); -#endif - } - uncompressed_data += sub_block_sizes[i].uncompressed_size; - compressed_data += sub_block_sizes[i].compressed_size; - } - do_decompress_work(&decompress_work_11[0]); -#if DO_DECOMPRESS_WORKER - for (i=1; ibuf[uncompressed_magic_len_11], rb->buf[uncompressed_magic_len_11+1], - rb->buf[uncompressed_magic_len_11+2], rb->buf[uncompressed_magic_len_11+3]); - - rb->ndone=0; - - r = verify_decompressed_brtnode_checksum(rb); - return r; -} - - - - - - - -// ################ - - -static void -deserialize_descriptor_from_rbuf_11(struct rbuf *rb, DESCRIPTOR desc, BOOL temporary) { - desc->version = rbuf_int(rb); - u_int32_t size; - bytevec data; - rbuf_bytes(rb, &data, &size); - bytevec data_copy = data;; - if (size>0) { - if (!temporary) { - data_copy = toku_memdup(data, size); //Cannot keep the reference from rbuf. Must copy. - assert(data_copy); - } - } - else { - assert(size==0); - data_copy = NULL; - } - toku_fill_dbt(&desc->dbt, data_copy, size); - if (desc->version==0) assert(desc->dbt.size==0); -} - -static void -deserialize_descriptor_from_11(int fd, struct brt_header *h, DESCRIPTOR desc) { - DISKOFF offset; - DISKOFF size; - toku_get_descriptor_offset_size(h->blocktable, &offset, &size); - memset(desc, 0, sizeof(*desc)); - if (size > 0) { - assert(size>=4); //4 for checksum - { - unsigned char *XMALLOC_N(size, dbuf); - { - lock_for_pwrite(); - ssize_t r = pread(fd, dbuf, size, offset); - assert(r==size); - unlock_for_pwrite(); - } - { - // check the checksum - u_int32_t x1764 = x1764_memory_11(dbuf, size-4); - //printf("%s:%d read from %ld (x1764 offset=%ld) size=%ld\n", __FILE__, __LINE__, block_translation_address_on_disk, offset, block_translation_size_on_disk); - u_int32_t stored_x1764 = toku_dtoh32(*(int*)(dbuf + size-4)); - assert(x1764 == stored_x1764); - } - { - struct rbuf rb = {.buf = dbuf, .size = size, .ndone = 0}; - //Not temporary; must have a toku_memdup'd copy. - deserialize_descriptor_from_rbuf_11(&rb, desc, FALSE); - } - assert(toku_serialize_descriptor_size_11(desc)+4 == size); - toku_free(dbuf); - } - } -} - - -// We only deserialize brt header once and then share everything with all the brts. -static int -deserialize_brtheader_11 (int fd, struct rbuf *rb, struct brt_header **brth) { - // We already know: - // we have an rbuf representing the header. - // The checksum has been validated - - //Steal rbuf (used to simplify merge, reduce diff size, and keep old code) - struct rbuf rc = *rb; - memset(rb, 0, sizeof(*rb)); - - //Verification of initial elements. - { - //Check magic number - bytevec magic; - rbuf_literal_bytes(&rc, &magic, 8); - assert(memcmp(magic,"tokudata",8)==0); - } - - - struct brt_header *CALLOC(h); - if (h==0) return errno; - int ret=-1; - if (0) { died1: toku_free(h); return ret; } - h->type = BRTHEADER_CURRENT; - h->checkpoint_header = NULL; - h->dirty=0; - h->panic = 0; - h->panic_string = 0; - toku_list_init(&h->live_brts); - toku_list_init(&h->zombie_brts); - //version MUST be in network order on disk regardless of disk order - h->layout_version = rbuf_network_int(&rc); - //TODO: #1924 - assert(h->layout_version==BRT_LAYOUT_VERSION_11); - - //Size MUST be in network order regardless of disk order. - u_int32_t size = rbuf_network_int(&rc); - assert(size==rc.size); - - bytevec tmp_byte_order_check; - rbuf_literal_bytes(&rc, &tmp_byte_order_check, 8); //Must not translate byte order - int64_t byte_order_stored = *(int64_t*)tmp_byte_order_check; - assert(byte_order_stored == toku_byte_order_host); - - h->checkpoint_count = rbuf_ulonglong(&rc); - h->checkpoint_lsn = rbuf_lsn(&rc); - h->nodesize = rbuf_int(&rc); - DISKOFF translation_address_on_disk = rbuf_diskoff(&rc); - DISKOFF translation_size_on_disk = rbuf_diskoff(&rc); - assert(translation_address_on_disk>0); - assert(translation_size_on_disk>0); - - // printf("%s:%d translated_blocknum_limit=%ld, block_translation_address_on_disk=%ld\n", __FILE__, __LINE__, h->translated_blocknum_limit, h->block_translation_address_on_disk); - //Load translation table - { - lock_for_pwrite(); - unsigned char *XMALLOC_N(translation_size_on_disk, tbuf); - { - // This cast is messed up in 32-bits if the block translation table is ever more than 4GB. But in that case, the translation table itself won't fit in main memory. - ssize_t r = pread(fd, tbuf, translation_size_on_disk, translation_address_on_disk); - assert(r==translation_size_on_disk); - } - unlock_for_pwrite(); - // Create table and read in data. - toku_blocktable_create_from_buffer(&h->blocktable, - translation_address_on_disk, - translation_size_on_disk, - tbuf, - TRUE); - toku_free(tbuf); - } - - h->root = rbuf_blocknum(&rc); - h->root_hash.valid = FALSE; - h->flags = rbuf_int(&rc); - deserialize_descriptor_from_11(fd, h, &h->descriptor); - h->layout_version_original = rbuf_int(&rc); - (void)rbuf_int(&rc); //Read in checksum and ignore (already verified). - if (rc.ndone!=rc.size) {ret = EINVAL; goto died1;} - toku_free(rc.buf); - rc.buf = NULL; - *brth = h; - return 0; -} - - - - - - - diff --git a/newbrt/backwards_11.h b/newbrt/backwards_11.h deleted file mode 100644 index cce2a156998..00000000000 --- a/newbrt/backwards_11.h +++ /dev/null @@ -1,18 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "$Id$" -#ident "Copyright (c) 2007-2010 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#ifndef BACKWARD_11_H -#define BACKWARD_11_H - -static int upgrade_brtheader_11_12 (int fd, struct brt_header **brth_11, struct brt_header **brth_12); -static int upgrade_brtnode_11_12 (BRTNODE *brtnode_11, BRTNODE *brtnode_12); - -static int deserialize_brtheader_11 (int fd, struct rbuf *rb, struct brt_header **brth); - -static int decompress_brtnode_from_raw_block_into_rbuf_11(u_int8_t *raw_block, struct rbuf *rb, BLOCKNUM blocknum); -static int deserialize_brtnode_from_rbuf_11 (BLOCKNUM blocknum, u_int32_t fullhash, BRTNODE *brtnode, struct brt_header *h, struct rbuf *rb); - -#endif - diff --git a/newbrt/brt-internal.h b/newbrt/brt-internal.h index 10aec7710c5..c38a5f2c5ea 100644 --- a/newbrt/brt-internal.h +++ b/newbrt/brt-internal.h @@ -201,7 +201,6 @@ struct brt { BOOL did_set_descriptor; DESCRIPTOR_S temp_descriptor; int (*compare_fun)(DB*,const DBT*,const DBT*); - int (*dup_compare)(DB*,const DBT*,const DBT*); DB *db; // To pass to the compare fun, and close once transactions are done. OMT txns; // transactions that are using this OMT (note that the transaction checks the cf also) @@ -265,8 +264,7 @@ extern u_int32_t toku_calc_fingerprint_cmd (u_int32_t type, XIDS xids, const voi extern u_int32_t toku_calc_fingerprint_cmdstruct (BRT_MSG cmd); // How long is the pivot key? -unsigned int toku_brt_pivot_key_len (BRT, struct kv_pair *); // Given the tree -unsigned int toku_brtnode_pivot_key_len (BRTNODE, struct kv_pair *); // Given the node +unsigned int toku_brt_pivot_key_len (struct kv_pair *); // Values to be used to update brtcursor if a search is successful. struct brt_cursor_leaf_info_to_be { @@ -305,7 +303,7 @@ struct brt_cursor { // logs the memory allocation, but not the creation of the new node int toku_create_new_brtnode (BRT t, BRTNODE *result, int height, size_t mpsize); int toku_unpin_brtnode (BRT brt, BRTNODE node); -unsigned int toku_brtnode_which_child (BRTNODE node , DBT *k, DBT *d, BRT t); +unsigned int toku_brtnode_which_child (BRTNODE node , DBT *k, BRT t); /* Stuff for testing */ int toku_testsetup_leaf(BRT brt, BLOCKNUM *); @@ -319,7 +317,6 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM, enum brt_msg_type, char struct cmd_leafval_heaviside_extra { BRT t; BRT_MSG cmd; - int compare_both_keys; // Set to 1 for DUPSORT databases that are not doing a DELETE_BOTH }; int toku_cmd_leafval_heaviside (OMTVALUE leafentry, void *extra); diff --git a/newbrt/brt-search.h b/newbrt/brt-search.h index 6c7f7b91840..5e1e79ba125 100644 --- a/newbrt/brt-search.h +++ b/newbrt/brt-search.h @@ -20,7 +20,7 @@ struct brt_search; the compare function should be a step function from 0 to 1 for a left to right search and 1 to 0 for a right to left search */ -typedef int (*brt_search_compare_func_t)(struct brt_search */*so*/, DBT */*x*/, DBT */*y*/); +typedef int (*brt_search_compare_func_t)(struct brt_search */*so*/, DBT *); /* the search object contains the compare function, search direction, and the kv pair that is used in the compare function. the context is the user's private data */ @@ -29,13 +29,12 @@ typedef struct brt_search { brt_search_compare_func_t compare; enum brt_search_direction_e direction; const DBT *k; - const DBT *v; void *context; } brt_search_t; /* initialize the search compare object */ -static inline brt_search_t *brt_search_init(brt_search_t *so, brt_search_compare_func_t compare, enum brt_search_direction_e direction, const DBT *k, const DBT *v, void *context) { - so->compare = compare; so->direction = direction; so->k = k; so->v = v; so->context = context; +static inline brt_search_t *brt_search_init(brt_search_t *so, brt_search_compare_func_t compare, enum brt_search_direction_e direction, const DBT *k, void *context) { + so->compare = compare; so->direction = direction; so->k = k; so->context = context; return so; } diff --git a/newbrt/brt-serialize.c b/newbrt/brt-serialize.c index 59878267ab1..5afeb6c273b 100644 --- a/newbrt/brt-serialize.c +++ b/newbrt/brt-serialize.c @@ -6,10 +6,6 @@ #include "includes.h" #include "toku_atomic.h" -#include "backwards_11.h" -// NOTE: The backwards compatability functions are in a file that is included at the END of this file. - - static BRT_UPGRADE_STATUS_S upgrade_status; // accountability, used in backwards_x.c void @@ -206,9 +202,8 @@ toku_serialize_brtnode_size_slow (BRTNODE node) { size += 4; /* n_children */ size += 4; /* subtree fingerprint. */ size += 4*(node->u.n.n_children-1); /* key lengths*/ - if (node->flags & TOKU_DB_DUPSORT) size += 4*(node->u.n.n_children-1); for (int i=0; iu.n.n_children-1; i++) { - csize += toku_brtnode_pivot_key_len(node, node->u.n.childkeys[i]); + csize += toku_brt_pivot_key_len(node->u.n.childkeys[i]); } size += (8+4+4+1+3*8)*(node->u.n.n_children); /* For each child, a child offset, a count for the number of hash table entries, the subtree fingerprint, and 3*8 for the subtree estimates and 1 for the exact bit for the estimates. */ int n_buffers = node->u.n.n_children; @@ -245,7 +240,6 @@ toku_serialize_brtnode_size (BRTNODE node) { result += 4; /* subtree fingerpirnt */ result += 4; /* n_children */ result += 4*(node->u.n.n_children-1); /* key lengths*/ - if (node->flags & TOKU_DB_DUPSORT) result += 4*(node->u.n.n_children-1); /* data lengths */ assert(node->u.n.totalchildkeylens < (1<<30)); result += node->u.n.totalchildkeylens; /* the lengths of the pivot keys, without their key lengths. */ result += (8+4+4+1+3*8)*(node->u.n.n_children); /* For each child, a child offset, a count for the number of hash table entries, the subtree fingerprint, and 3*8 for the subtree estimates and one for the exact bit. */ @@ -317,12 +311,7 @@ serialize_nonleaf(BRTNODE node, int n_sub_blocks, struct sub_block sub_block[], } //printf("%s:%d w.ndone=%d\n", __FILE__, __LINE__, w.ndone); for (int i = 0; i < node->u.n.n_children-1; i++) { - if (node->flags & TOKU_DB_DUPSORT) { - wbuf_nocrc_bytes(wbuf, kv_pair_key(node->u.n.childkeys[i]), kv_pair_keylen(node->u.n.childkeys[i])); - wbuf_nocrc_bytes(wbuf, kv_pair_val(node->u.n.childkeys[i]), kv_pair_vallen(node->u.n.childkeys[i])); - } else { - wbuf_nocrc_bytes(wbuf, kv_pair_key(node->u.n.childkeys[i]), toku_brtnode_pivot_key_len(node, node->u.n.childkeys[i])); - } + wbuf_nocrc_bytes(wbuf, kv_pair_key(node->u.n.childkeys[i]), toku_brt_pivot_key_len(node->u.n.childkeys[i])); //printf("%s:%d w.ndone=%d (childkeylen[%d]=%d\n", __FILE__, __LINE__, w.ndone, i, node->childkeylens[i]); } for (int i = 0; i < node->u.n.n_children; i++) { @@ -683,20 +672,12 @@ deserialize_brtnode_nonleaf_from_rbuf (BRTNODE result, bytevec magic, struct rbu se->exact = (BOOL) (rbuf_char(rb) != 0); } for (int i=0; iu.n.n_children-1; i++) { - if (result->flags & TOKU_DB_DUPSORT) { - bytevec keyptr, dataptr; - unsigned int keylen, datalen; - rbuf_bytes(rb, &keyptr, &keylen); - rbuf_bytes(rb, &dataptr, &datalen); - result->u.n.childkeys[i] = kv_pair_malloc(keyptr, keylen, dataptr, datalen); - } else { - bytevec childkeyptr; - unsigned int cklen; - rbuf_bytes(rb, &childkeyptr, &cklen); /* Returns a pointer into the rbuf. */ - result->u.n.childkeys[i] = kv_pair_malloc((void*)childkeyptr, cklen, 0, 0); - } + bytevec childkeyptr; + unsigned int cklen; + rbuf_bytes(rb, &childkeyptr, &cklen); /* Returns a pointer into the rbuf. */ + result->u.n.childkeys[i] = kv_pair_malloc((void*)childkeyptr, cklen, 0, 0); //printf(" key %d length=%d data=%s\n", i, result->childkeylens[i], result->childkeys[i]); - result->u.n.totalchildkeylens+=toku_brtnode_pivot_key_len(result, result->u.n.childkeys[i]); + result->u.n.totalchildkeylens+=toku_brt_pivot_key_len(result->u.n.childkeys[i]); } for (int i=0; iu.n.n_children; i++) { BNC_BLOCKNUM(result,i) = rbuf_blocknum(rb); @@ -758,16 +739,9 @@ deserialize_brtnode_leaf_from_rbuf (BRTNODE result, bytevec magic, struct rbuf * // deserialize partition pivots for (int p = 0; p < npartitions-1; p++) { // just throw them away for now - if (result->flags & TOKU_DB_DUPSORT) { - bytevec keyptr, dataptr; - unsigned int keylen, datalen; - rbuf_bytes(rb, &keyptr, &keylen); - rbuf_bytes(rb, &dataptr, &datalen); - } else { - bytevec childkeyptr; - unsigned int cklen; - rbuf_bytes(rb, &childkeyptr, &cklen); - } + bytevec childkeyptr; + unsigned int cklen; + rbuf_bytes(rb, &childkeyptr, &cklen); } // deserialize the partition map @@ -955,9 +929,6 @@ static int decompress_from_raw_block_into_rbuf_versioned(u_int32_t version, u_int8_t *raw_block, size_t raw_block_size, struct rbuf *rb, BLOCKNUM blocknum) { int r; switch (version) { - case BRT_LAYOUT_VERSION_11: - r = decompress_brtnode_from_raw_block_into_rbuf_11(raw_block, rb, blocknum); - break; case BRT_LAYOUT_VERSION: r = decompress_from_raw_block_into_rbuf(raw_block, raw_block_size, rb, blocknum); break; @@ -970,18 +941,10 @@ decompress_from_raw_block_into_rbuf_versioned(u_int32_t version, u_int8_t *raw_b static int deserialize_brtnode_from_rbuf_versioned (u_int32_t version, BLOCKNUM blocknum, u_int32_t fullhash, BRTNODE *brtnode, struct brt_header *h, struct rbuf *rb) { int r = 0; - BRTNODE brtnode_11 = NULL; BRTNODE brtnode_12 = NULL; int upgrade = 0; switch (version) { - case BRT_LAYOUT_VERSION_11: - if (!upgrade) - r = deserialize_brtnode_from_rbuf_11(blocknum, fullhash, &brtnode_11, h, rb); - upgrade++; - if (r==0) - r = upgrade_brtnode_11_12(&brtnode_11, &brtnode_12); - //Fall through on purpose. case BRT_LAYOUT_VERSION: if (!upgrade) r = deserialize_brtnode_from_rbuf(blocknum, fullhash, &brtnode_12, h, rb); @@ -1492,18 +1455,10 @@ deserialize_brtheader (int fd, struct rbuf *rb, struct brt_header **brth) { static int deserialize_brtheader_versioned (int fd, struct rbuf *rb, struct brt_header **brth, u_int32_t version) { int rval; - struct brt_header *brth_11 = NULL; struct brt_header *brth_12 = NULL; int upgrade = 0; switch(version) { - case BRT_LAYOUT_VERSION_11: - if (!upgrade) - rval = deserialize_brtheader_11(fd, rb, &brth_11); - upgrade++; - if (rval == 0) - rval = upgrade_brtheader_11_12(fd, &brth_11, &brth_12); - //Fall through on purpose. case BRT_LAYOUT_VERSION: if (!upgrade) rval = deserialize_brtheader (fd, rb, &brth_12); @@ -1687,21 +1642,8 @@ toku_deserialize_brtheader_from (int fd, struct brt_header **brth) { } unsigned int -toku_brt_pivot_key_len (BRT brt, struct kv_pair *pk) { - if (brt->flags & TOKU_DB_DUPSORT) { - return kv_pair_keylen(pk) + kv_pair_vallen(pk); - } else { - return kv_pair_keylen(pk); - } -} - -unsigned int -toku_brtnode_pivot_key_len (BRTNODE node, struct kv_pair *pk) { - if (node->flags & TOKU_DB_DUPSORT) { - return kv_pair_keylen(pk) + kv_pair_vallen(pk); - } else { - return kv_pair_keylen(pk); - } +toku_brt_pivot_key_len (struct kv_pair *pk) { + return kv_pair_keylen(pk); } int @@ -1943,8 +1885,3 @@ cleanup: } - - -// NOTE: Backwards compatibility functions are in the included .c file(s): -#include "backwards_11.c" - diff --git a/newbrt/brt-test-helpers.c b/newbrt/brt-test-helpers.c index b5d41a16728..8b522397ff1 100644 --- a/newbrt/brt-test-helpers.c +++ b/newbrt/brt-test-helpers.c @@ -91,7 +91,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke assert(r==0); - struct cmd_leafval_heaviside_extra be = {brt, &cmd, node->flags & TOKU_DB_DUPSORT}; + struct cmd_leafval_heaviside_extra be = {brt, &cmd}; r = toku_omt_find_zero(node->u.l.buffer, toku_cmd_leafval_heaviside, &be, &storeddatav, &idx, NULL); @@ -129,10 +129,9 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t BRTNODE node=node_v; assert(node->height>0); - DBT k,v; + DBT k; int childnum = toku_brtnode_which_child(node, toku_fill_dbt(&k, key, keylen), - toku_fill_dbt(&v, val, vallen), brt); XIDS xids_0 = xids_get_root_xids(); diff --git a/newbrt/brt-verify.c b/newbrt/brt-verify.c index bba69b27a66..557f29f2bab 100644 --- a/newbrt/brt-verify.c +++ b/newbrt/brt-verify.c @@ -40,11 +40,6 @@ static int compare_pairs (BRT brt, struct kv_pair *a, struct kv_pair *b) { int cmp = brt->compare_fun(brt->db, toku_fill_dbt(&x, kv_pair_key(a), kv_pair_keylen(a)), toku_fill_dbt(&y, kv_pair_key(b), kv_pair_keylen(b))); - if (cmp==0 && (brt->flags & TOKU_DB_DUPSORT)) { - cmp = brt->dup_compare(brt->db, - toku_fill_dbt(&x, kv_pair_val(a), kv_pair_vallen(a)), - toku_fill_dbt(&y, kv_pair_val(b), kv_pair_vallen(b))); - } return cmp; } static int compare_leafentries (BRT brt, LEAFENTRY a, LEAFENTRY b) { @@ -52,11 +47,6 @@ static int compare_leafentries (BRT brt, LEAFENTRY a, LEAFENTRY b) { int cmp = brt->compare_fun(brt->db, toku_fill_dbt(&x, le_key(a), le_keylen(a)), toku_fill_dbt(&y, le_key(b), le_keylen(b))); - if (cmp==0 && (brt->flags & TOKU_DB_DUPSORT)) { - cmp = brt->dup_compare(brt->db, - toku_fill_dbt(&x, le_innermost_inserted_val(a), le_innermost_inserted_vallen(a)), - toku_fill_dbt(&y, le_innermost_inserted_val(b), le_innermost_inserted_vallen(b))); - } return cmp; } @@ -71,29 +61,6 @@ struct verify_pair_arg { int *resultp; }; -static void verify_pair (bytevec key, unsigned int keylen, - bytevec data __attribute__((__unused__)), - unsigned int datalen __attribute__((__unused__)), - int type __attribute__((__unused__)), - XIDS xids __attribute__((__unused__)), - void *arg) { - struct verify_pair_arg *vparg = (struct verify_pair_arg *)arg; - BRT brt = vparg->brt; - int i = vparg->i; - bytevec thislorange = vparg->thislorange; ITEMLEN thislolen = vparg->thislolen; - bytevec thishirange = vparg->thishirange; ITEMLEN thishilen = vparg->thishilen; - DBT k1,k2; - if (thislorange) assert(brt->compare_fun(brt->db, - toku_fill_dbt(&k1,thislorange,thislolen), - toku_fill_dbt(&k2,key,keylen)) <= 0); - if (thishirange && (brt->compare_fun(brt->db, - toku_fill_dbt(&k1,key,keylen), - toku_fill_dbt(&k2,thishirange,thishilen)) >= 0)) { - printf("%s:%d in buffer %d key %s is bigger than %s\n", __FILE__, __LINE__, i, (char*)key, (char*)thishirange); - *vparg->resultp = 1; - } -} - struct check_increasing_arg { BRT brt; LEAFENTRY prev; @@ -133,19 +100,14 @@ int toku_verify_brtnode (BRT brt, BLOCKNUM blocknum, bytevec lorange, ITEMLEN lo thislolen =lolen; } else { thislorange=kv_pair_key(node->u.n.childkeys[i-1]); - thislolen =toku_brt_pivot_key_len(brt, node->u.n.childkeys[i-1]); + thislolen =toku_brt_pivot_key_len(node->u.n.childkeys[i-1]); } if (node->u.n.n_children==0 || i+1>=node->u.n.n_children) { thishirange=hirange; thishilen =hilen; } else { thishirange=kv_pair_key(node->u.n.childkeys[i]); - thishilen =toku_brt_pivot_key_len(brt, node->u.n.childkeys[i]); - } - struct verify_pair_arg vparg = { brt, i, thislorange, thislolen, thishirange, thishilen, &result }; - if (!(brt->flags & TOKU_DB_DUP)) { - // verify_pair doesn't work for dupsort - toku_fifo_iterate(BNC_BUFFER(node,i), verify_pair, &vparg); + thishilen =toku_brt_pivot_key_len(node->u.n.childkeys[i]); } } //if (lorange) printf("%s:%d lorange=%s\n", __FILE__, __LINE__, (char*)lorange); @@ -157,16 +119,16 @@ int toku_verify_brtnode (BRT brt, BLOCKNUM blocknum, bytevec lorange, ITEMLEN lo if (i>0) { //printf(" %s:%d i=%d %p v=%s\n", __FILE__, __LINE__, i, node->u.n.childkeys[i-1], (char*)kv_pair_key(node->u.n.childkeys[i-1])); DBT k1,k2,k3; - toku_fill_dbt(&k2, kv_pair_key(node->u.n.childkeys[i-1]), toku_brt_pivot_key_len(brt, node->u.n.childkeys[i-1])); + toku_fill_dbt(&k2, kv_pair_key(node->u.n.childkeys[i-1]), toku_brt_pivot_key_len(node->u.n.childkeys[i-1])); if (lorange) assert(brt->compare_fun(brt->db, toku_fill_dbt(&k1, lorange, lolen), &k2) <0); if (hirange) assert(brt->compare_fun(brt->db, &k2, toku_fill_dbt(&k3, hirange, hilen)) <=0); } if (recurse) { result|=toku_verify_brtnode(brt, BNC_BLOCKNUM(node, i), (i==0) ? lorange : kv_pair_key(node->u.n.childkeys[i-1]), - (i==0) ? lolen : toku_brt_pivot_key_len(brt, node->u.n.childkeys[i-1]), + (i==0) ? lolen : toku_brt_pivot_key_len(node->u.n.childkeys[i-1]), (i==node->u.n.n_children-1) ? hirange : kv_pair_key(node->u.n.childkeys[i]), - (i==node->u.n.n_children-1) ? hilen : toku_brt_pivot_key_len(brt, node->u.n.childkeys[i]), + (i==node->u.n.n_children-1) ? hilen : toku_brt_pivot_key_len(node->u.n.childkeys[i]), recurse); } } diff --git a/newbrt/brt.c b/newbrt/brt.c index 253b5ac12c2..2a48843e9c5 100644 --- a/newbrt/brt.c +++ b/newbrt/brt.c @@ -283,12 +283,7 @@ fill_leafnode_estimates (OMTVALUE val, u_int32_t UU(idx), void *vs) struct fill_leafnode_estimates_state *s = vs; s->e->dsize += le_keylen(le) + le_innermost_inserted_vallen(le); s->e->ndata++; - if ((s->prevval == NULL) || - (0 == (s->node->flags & TOKU_DB_DUPSORT)) || - (le_keylen(le) != le_keylen(s->prevval)) || - (memcmp(le_key(le), le_key(s->prevval), le_keylen(le))!=0)) { // really should use comparison function - s->e->nkeys++; - } + s->e->nkeys++; s->prevval = le; return 0; } @@ -502,20 +497,12 @@ int toku_brtnode_fetch_callback (CACHEFILE UU(cachefile), int fd, BLOCKNUM noden static int leafval_heaviside_le (u_int32_t klen, void *kval, - u_int32_t dlen, void *dval, struct cmd_leafval_heaviside_extra *be) { BRT t = be->t; DBT dbt; - int cmp = t->compare_fun(t->db, - toku_fill_dbt(&dbt, kval, klen), - be->cmd->u.id.key); - if (cmp == 0 && be->compare_both_keys && be->cmd->u.id.val->data) { - return t->dup_compare(t->db, - toku_fill_dbt(&dbt, dval, dlen), - be->cmd->u.id.val); - } else { - return cmp; - } + return t->compare_fun(t->db, + toku_fill_dbt(&dbt, kval, klen), + be->cmd->u.id.key); } //TODO: #1125 optimize @@ -525,27 +512,18 @@ toku_cmd_leafval_heaviside (OMTVALUE lev, void *extra) { struct cmd_leafval_heaviside_extra *be = extra; u_int32_t keylen; void* key = le_key_and_len(le, &keylen); - u_int32_t vallen; - void* val = le_innermost_inserted_val_and_len(le, &vallen); return leafval_heaviside_le(keylen, key, - vallen, val, be); } // If you pass in data==0 then it only compares the key, not the data (even if is a DUPSORT database) static int -brt_compare_pivot(BRT brt, DBT *key, DBT *data, bytevec ck) +brt_compare_pivot(BRT brt, DBT *key, bytevec ck) { int cmp; DBT mydbt; struct kv_pair *kv = (struct kv_pair *) ck; - if (brt->flags & TOKU_DB_DUPSORT) { - cmp = brt->compare_fun(brt->db, key, toku_fill_dbt(&mydbt, kv_pair_key(kv), kv_pair_keylen(kv))); - if (cmp == 0 && data != 0) - cmp = brt->dup_compare(brt->db, data, toku_fill_dbt(&mydbt, kv_pair_val(kv), kv_pair_vallen(kv))); - } else { - cmp = brt->compare_fun(brt->db, key, toku_fill_dbt(&mydbt, kv_pair_key(kv), kv_pair_keylen(kv))); - } + cmp = brt->compare_fun(brt->db, key, toku_fill_dbt(&mydbt, kv_pair_key(kv), kv_pair_keylen(kv))); return cmp; } @@ -865,25 +843,10 @@ brtleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *splitk) struct subtree_estimates diff_est = zero_estimates; LEAFENTRY *MALLOC_N(n_leafentries-split_at, free_us); for (i=split_at; i0) ? leafentries[i-1] : 0; LEAFENTRY oldle = leafentries[i]; LEAFENTRY newle = toku_mempool_malloc(&B->u.l.buffer_mempool, leafentry_memsize(oldle), 1); assert(newle!=0); // it's a fresh mpool, so this should always work. - BOOL key_is_unique; - { - DBT xdbt,ydbt; - if (t->flags & TOKU_DB_DUPSORT) key_is_unique=TRUE; - else if (prevle==NULL) key_is_unique=TRUE; - else if (t->compare_fun(t->db, - toku_fill_dbt(&xdbt, le_key(prevle), le_keylen(prevle)), - toku_fill_dbt(&ydbt, le_key(oldle), le_keylen(oldle))) - ==0) { - key_is_unique=FALSE; - } else { - key_is_unique=TRUE; - } - } - if (key_is_unique) diff_est.nkeys++; + diff_est.nkeys++; diff_est.ndata++; diff_est.dsize += le_keylen(oldle) + le_innermost_inserted_vallen(oldle); //printf("%s:%d Added %u got %lu\n", __FILE__, __LINE__, le_keylen(oldle)+ le_innermost_inserted_vallen(oldle), diff_est.dsize); @@ -927,13 +890,8 @@ brtleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *splitk) r=toku_omt_fetch(node->u.l.buffer, toku_omt_size(node->u.l.buffer)-1, &lev, NULL); assert(r==0); // that fetch should have worked. LEAFENTRY le=lev; - if (node->flags&TOKU_DB_DUPSORT) { - splitk->size = le_keylen(le)+le_innermost_inserted_vallen(le); - splitk->data = kv_pair_malloc(le_key(le), le_keylen(le), le_innermost_inserted_val(le), le_innermost_inserted_vallen(le)); - } else { - splitk->size = le_keylen(le); - splitk->data = kv_pair_malloc(le_key(le), le_keylen(le), 0, 0); - } + splitk->size = le_keylen(le); + splitk->data = kv_pair_malloc(le_key(le), le_keylen(le), 0, 0); splitk->flags=0; } assert(r == 0); @@ -1039,8 +997,8 @@ brt_nonleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *spl assert(i>0); if (i>n_children_in_a) { B->u.n.childkeys[targchild-1] = node->u.n.childkeys[i-1]; - B->u.n.totalchildkeylens += toku_brt_pivot_key_len(t, node->u.n.childkeys[i-1]); - node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(t, node->u.n.childkeys[i-1]); + B->u.n.totalchildkeylens += toku_brt_pivot_key_len(node->u.n.childkeys[i-1]); + node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(node->u.n.childkeys[i-1]); node->u.n.childkeys[i-1] = 0; } } @@ -1063,8 +1021,8 @@ brt_nonleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *spl } splitk->data = (void*)(node->u.n.childkeys[n_children_in_a-1]); - splitk->size = toku_brt_pivot_key_len(t, node->u.n.childkeys[n_children_in_a-1]); - node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(t, node->u.n.childkeys[n_children_in_a-1]); + splitk->size = toku_brt_pivot_key_len(node->u.n.childkeys[n_children_in_a-1]); + node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(node->u.n.childkeys[n_children_in_a-1]); REALLOC_N(n_children_in_a+1, node->u.n.childinfos); REALLOC_N(n_children_in_a, node->u.n.childkeys); @@ -1158,7 +1116,7 @@ handle_split_of_child (BRT t, BRTNODE node, int childnum, } //if (logger) assert((t->flags&TOKU_DB_DUPSORT)==0); // the setpivot is wrong for TOKU_DB_DUPSORT, so recovery will be broken. node->u.n.childkeys[childnum]= pivot; - node->u.n.totalchildkeylens += toku_brt_pivot_key_len(t, pivot); + node->u.n.totalchildkeylens += toku_brt_pivot_key_len(pivot); } WHEN_NOT_GCOV( @@ -1256,59 +1214,9 @@ brt_split_child (BRT t, BRTNODE node, int childnum, BOOL *did_react) } } -//TODO: Rename this function -static int -should_compare_both_keys (BRTNODE node, BRT_MSG cmd) -// Effect: Return nonzero if we need to compare both the key and the value. -{ - switch (cmd->type) { - case BRT_INSERT_NO_OVERWRITE: - case BRT_INSERT: - return node->flags & TOKU_DB_DUPSORT; - case BRT_DELETE_BOTH: - case BRT_ABORT_BOTH: - case BRT_COMMIT_BOTH: - return 1; - case BRT_DELETE_ANY: - case BRT_ABORT_ANY: - case BRT_COMMIT_ANY: - case BRT_COMMIT_BROADCAST_ALL: - case BRT_COMMIT_BROADCAST_TXN: - case BRT_ABORT_BROADCAST_TXN: - return 0; - case BRT_NONE: - break; - } - abort(); return 0; -} - -static int -other_key_matches (BRTNODE node, u_int32_t idx, LEAFENTRY le) -{ - OMTVALUE other_lev = 0; - int r = toku_omt_fetch(node->u.l.buffer, idx, &other_lev, (OMTCURSOR)NULL); - assert(r==0); - LEAFENTRY other_le = other_lev; - u_int32_t other_keylen = le_keylen(other_le); - if (other_keylen == le_keylen(le) - && memcmp(le_key(other_le), le_key(le), other_keylen)==0) // really should use comparison function - return 1; - else - return 0; -} - static void -maybe_bump_nkeys (BRTNODE node, u_int32_t idx, LEAFENTRY le, int direction) { +maybe_bump_nkeys (BRTNODE node, int direction) { int keybump=direction; - - if (0 != (node->flags & TOKU_DB_DUPSORT)) { - if (idx>0) { - if (other_key_matches(node, idx-1, le)) keybump=0; - } - if (idx+1u.l.buffer)) { - if (other_key_matches(node, idx+1, le)) keybump=0; - } - } node->u.l.leaf_stats.nkeys += keybump;; assert(node->u.l.leaf_stats.exact); } @@ -1407,7 +1315,7 @@ brt_leaf_delete_leafentry (BRTNODE node, u_int32_t idx, LEAFENTRY le) // // Figure out if one of the other keys is the same key - maybe_bump_nkeys(node, idx, le, -1); + maybe_bump_nkeys(node, -1); int r; if ((r = toku_omt_delete_at(node->u.l.buffer, idx))) goto return_r; @@ -1507,7 +1415,7 @@ brt_leaf_apply_cmd_once (BRTNODE node, BRT_MSG cmd, assert(node->u.l.leaf_stats.dsize < (1U<<31)); // make sure we didn't underflow node->u.l.leaf_stats.ndata ++; // Look at the key to the left and the one to the right. If both are different then increment nkeys. - maybe_bump_nkeys(node, idx, new_le, +1); + maybe_bump_nkeys(node, +1); } } r=0; @@ -1539,8 +1447,7 @@ brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd, u_int32_t idx; u_int32_t omt_size; int r; - int compare_both = should_compare_both_keys(node, cmd); - struct cmd_leafval_heaviside_extra be = {t, cmd, compare_both}; + struct cmd_leafval_heaviside_extra be = {t, cmd}; //static int counter=0; //counter++; @@ -1590,25 +1497,6 @@ brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd, node->u.l.seqinsert = doing_seqinsert + 1; } break; - case BRT_DELETE_BOTH: - case BRT_ABORT_BOTH: - case BRT_COMMIT_BOTH: - - // Delete the one item - r = toku_omt_find_zero(node->u.l.buffer, toku_cmd_leafval_heaviside, &be, - &storeddatav, &idx, NULL); - if (r == DB_NOTFOUND) break; - if (r != 0) return r; - storeddata=storeddatav; - - VERIFY_NODE(t, node); - - //static int count=0; count++; - r = brt_leaf_apply_cmd_once(node, cmd, idx, storeddata); - if (r!=0) return r; - - VERIFY_NODE(t, node); - break; case BRT_DELETE_ANY: case BRT_ABORT_ANY: @@ -1784,7 +1672,7 @@ static int brt_nonleaf_cmd_once_to_child (BRT t, BRTNODE node, unsigned int chil } /* find the leftmost child that may contain the key */ -unsigned int toku_brtnode_which_child (BRTNODE node , DBT *k, DBT *d, BRT t) { +unsigned int toku_brtnode_which_child (BRTNODE node , DBT *k, BRT t) { assert(node->height>0); #define DO_PIVOT_SEARCH_LR 0 #if DO_PIVOT_SEARCH_LR @@ -1816,7 +1704,7 @@ unsigned int toku_brtnode_which_child (BRTNODE node , DBT *k, DBT *d, BRT t) { // check the last key to optimize seq insertions int n = node->u.n.n_children-1; - int cmp = brt_compare_pivot(t, k, d, node->u.n.childkeys[n-1]); + int cmp = brt_compare_pivot(t, k, node->u.n.childkeys[n-1]); if (cmp > 0) return n; // binary search the pivots @@ -1825,7 +1713,7 @@ unsigned int toku_brtnode_which_child (BRTNODE node , DBT *k, DBT *d, BRT t) { int mi; while (lo < hi) { mi = (lo + hi) / 2; - cmp = brt_compare_pivot(t, k, d, node->u.n.childkeys[mi]); + cmp = brt_compare_pivot(t, k, node->u.n.childkeys[mi]); if (cmp > 0) { lo = mi+1; continue; @@ -1852,7 +1740,7 @@ static int brt_nonleaf_cmd_once (BRT t, BRTNODE node, BRT_MSG cmd, verify_local_fingerprint_nonleaf(node); /* find the right subtree */ //TODO: accesses key, val directly - unsigned int childnum = toku_brtnode_which_child(node, cmd->u.id.key, cmd->u.id.val, t); + unsigned int childnum = toku_brtnode_which_child(node, cmd->u.id.key, t); int r = brt_nonleaf_cmd_once_to_child (t, node, childnum, cmd, re_array, did_io); @@ -1879,54 +1767,6 @@ return_r: return r; } -static int -brt_nonleaf_cmd_many (BRT t, BRTNODE node, BRT_MSG cmd, - enum reactivity re_array[], BOOL *did_io) -// Effect: Put the cmd into a nonleaf node. We may put it into several children, possibly causing the children to become reactive. -// We don't do the splitting and merging. That's up to the caller after doing all the puts it wants to do. -// The re_array[i] gets set to the reactivity of any modified child i. (And there may be several such children.) -{ - /* find all children that need a copy of the command */ - unsigned int sendchild[node->u.n.n_children]; - unsigned int delidx = 0; -#define sendchild_append(i) \ - if (delidx == 0 || sendchild[delidx-1] != i) sendchild[delidx++] = i; - unsigned int i; - for (i = 0; i+1 < (unsigned int)node->u.n.n_children; i++) { - //TODO: Is touching key directly - int cmp = brt_compare_pivot(t, cmd->u.id.key, 0, node->u.n.childkeys[i]); - if (cmp > 0) { - continue; - } else if (cmp < 0) { - sendchild_append(i); - break; - } else if (t->flags & TOKU_DB_DUPSORT) { - sendchild_append(i); - sendchild_append(i+1); - } else { - sendchild_append(i); - break; - } - } - - if (delidx == 0) - sendchild_append((unsigned int)(node->u.n.n_children-1)); -#undef sendchild_append - - /* issue the cmd to all of the children found previously */ - int r; - for (i=0; itype) { case BRT_INSERT_NO_OVERWRITE: case BRT_INSERT: - case BRT_DELETE_BOTH: - case BRT_ABORT_BOTH: - case BRT_COMMIT_BOTH: - do_once: - return brt_nonleaf_cmd_once(t, node, cmd, re_array, did_io); case BRT_DELETE_ANY: case BRT_ABORT_ANY: case BRT_COMMIT_ANY: - if (0 == (node->flags & TOKU_DB_DUPSORT)) goto do_once; // for nondupsort brt, delete_any message goes to one child. - return brt_nonleaf_cmd_many(t, node, cmd, re_array, did_io); // send message to at least one, possibly all children + return brt_nonleaf_cmd_once(t, node, cmd, re_array, did_io); case BRT_COMMIT_BROADCAST_ALL: case BRT_COMMIT_BROADCAST_TXN: case BRT_ABORT_BROADCAST_TXN: @@ -1989,12 +1823,12 @@ merge_leaf_nodes (BRTNODE a, BRTNODE b) { a->local_fingerprint += a->rand4fingerprint * le_crc; a->u.l.leaf_stats.ndata++; - maybe_bump_nkeys(a, idx, new_le, +1); + maybe_bump_nkeys(a, +1); a->u.l.leaf_stats.dsize+= le_keylen(le) + le_innermost_inserted_vallen(le); //printf("%s:%d Added %u got %lu\n", __FILE__, __LINE__, le_keylen(le)+le_innermost_inserted_vallen(le), a->u.l.leaf_stats.dsize); } { - maybe_bump_nkeys(b, 0, le, -1); + maybe_bump_nkeys(b, -1); int r = toku_omt_delete_at(omtb, 0); assert(r==0); b->u.l.n_bytes_in_buffer -= OMT_ITEM_OVERHEAD + le_size; @@ -2039,7 +1873,7 @@ balance_leaf_nodes (BRTNODE a, BRTNODE b, struct kv_pair **splitk) memcpy(new_le, le, le_size); int r = toku_omt_insert_at(omtto, new_le, to_idx); assert(r==0); - maybe_bump_nkeys(to, to_idx, le, +1); + maybe_bump_nkeys(to, +1); to ->u.l.n_bytes_in_buffer += OMT_ITEM_OVERHEAD + le_size; to ->local_fingerprint += to->rand4fingerprint * le_crc; @@ -2048,7 +1882,7 @@ balance_leaf_nodes (BRTNODE a, BRTNODE b, struct kv_pair **splitk) //printf("%s:%d Added %u got %lu\n", __FILE__, __LINE__, le_keylen(le)+ le_innermost_inserted_vallen(le), to->u.l.leaf_stats.dsize); } { - maybe_bump_nkeys(from, from_idx, le, -1); + maybe_bump_nkeys(from, -1); int r = toku_omt_delete_at(omtfrom, from_idx); assert(r==0); from->u.l.n_bytes_in_buffer -= OMT_ITEM_OVERHEAD + le_size; @@ -2067,11 +1901,7 @@ balance_leaf_nodes (BRTNODE a, BRTNODE b, struct kv_pair **splitk) assert(toku_omt_size(a->u.l.buffer)>0); { LEAFENTRY le = fetch_from_buf(a->u.l.buffer, toku_omt_size(a->u.l.buffer)-1); - if (a->flags&TOKU_DB_DUPSORT) { - *splitk = kv_pair_malloc(le_key(le), le_keylen(le), le_innermost_inserted_val(le), le_innermost_inserted_vallen(le)); - } else { - *splitk = kv_pair_malloc(le_key(le), le_keylen(le), 0, 0); - } + *splitk = kv_pair_malloc(le_key(le), le_keylen(le), 0, 0); } a->dirty = 1; // make them dirty even if nothing actually happened. b->dirty = 1; @@ -2120,8 +1950,7 @@ maybe_merge_pinned_leaf_nodes (BRTNODE parent, int childnum_of_parent, } static int -maybe_merge_pinned_nonleaf_nodes (BRT t, - BRTNODE parent, int childnum_of_parent, struct kv_pair *parent_splitk, +maybe_merge_pinned_nonleaf_nodes (BRTNODE parent, int childnum_of_parent, struct kv_pair *parent_splitk, BRTNODE a, BRTNODE b, BOOL *did_merge, BOOL *did_rebalance, struct kv_pair **splitk) { @@ -2138,7 +1967,7 @@ maybe_merge_pinned_nonleaf_nodes (BRT t, memcpy(a->u.n.childkeys + old_n_children, b->u.n.childkeys, (b->u.n.n_children-1)*sizeof(b->u.n.childkeys[0])); - a->u.n.totalchildkeylens += b->u.n.totalchildkeylens + toku_brt_pivot_key_len(t, parent_splitk); + a->u.n.totalchildkeylens += b->u.n.totalchildkeylens + toku_brt_pivot_key_len(parent_splitk); a->u.n.n_bytes_in_buffers += b->u.n.n_bytes_in_buffers; a->u.n.n_children = new_n_children; @@ -2173,8 +2002,7 @@ maybe_merge_pinned_nonleaf_nodes (BRT t, } static int -maybe_merge_pinned_nodes (BRT t, - BRTNODE parent, int childnum_of_parent, struct kv_pair *parent_splitk, +maybe_merge_pinned_nodes (BRTNODE parent, int childnum_of_parent, struct kv_pair *parent_splitk, BRTNODE a, BRTNODE b, BOOL *did_merge, BOOL *did_rebalance, struct kv_pair **splitk) // Effect: either merge a and b into one node (merge them into a) and set *did_merge = TRUE. @@ -2202,7 +2030,7 @@ maybe_merge_pinned_nodes (BRT t, if (a->height == 0) { return maybe_merge_pinned_leaf_nodes(parent, childnum_of_parent, a, b, parent_splitk, did_merge, did_rebalance, splitk); } else { - int r = maybe_merge_pinned_nonleaf_nodes(t, parent, childnum_of_parent, parent_splitk, a, b, did_merge, did_rebalance, splitk); + int r = maybe_merge_pinned_nonleaf_nodes(parent, childnum_of_parent, parent_splitk, a, b, did_merge, did_rebalance, splitk); verify_local_fingerprint_nonleaf(a); return r; } @@ -2270,9 +2098,9 @@ brt_merge_child (BRT t, BRTNODE node, int childnum_to_merge, BOOL *did_io, BOOL { struct kv_pair *splitk_kvpair = 0; struct kv_pair *old_split_key = node->u.n.childkeys[childnuma]; - unsigned int deleted_size = toku_brt_pivot_key_len(t, old_split_key); + unsigned int deleted_size = toku_brt_pivot_key_len(old_split_key); verify_local_fingerprint_nonleaf(childa); - r = maybe_merge_pinned_nodes(t, node, childnuma, node->u.n.childkeys[childnuma], childa, childb, &did_merge, &did_rebalance, &splitk_kvpair); + r = maybe_merge_pinned_nodes(node, childnuma, node->u.n.childkeys[childnuma], childa, childb, &did_merge, &did_rebalance, &splitk_kvpair); verify_local_fingerprint_nonleaf(childa); if (childa->height>0) { int i; for (i=0; i+1u.n.n_children; i++) assert(childa->u.n.childkeys[i]); } //(toku_verify_counts(childa), toku_verify_estimates(t,childa)); @@ -2306,7 +2134,7 @@ brt_merge_child (BRT t, BRTNODE node, int childnum_to_merge, BOOL *did_io, BOOL assert(splitk_kvpair); // If we didn't merge the nodes, then we need the correct pivot. node->u.n.childkeys[childnuma] = splitk_kvpair; - node->u.n.totalchildkeylens += toku_brt_pivot_key_len(t, node->u.n.childkeys[childnuma]); + node->u.n.totalchildkeylens += toku_brt_pivot_key_len(node->u.n.childkeys[childnuma]); verify_local_fingerprint_nonleaf(node); node->dirty = 1; } @@ -2727,13 +2555,7 @@ int toku_brt_maybe_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn, BOOL oplsn_ TXNID xid = toku_txn_get_txnid(txn); if (txn && (brt->h->txnid_that_created_or_locked_when_empty != xid)) { BYTESTRING keybs = {key->size, key->data}; - int need_data = (brt->flags&TOKU_DB_DUPSORT)!=0; // dupsorts don't need the data part - if (need_data) { - BYTESTRING databs = {val->size, val->data}; - r = toku_logger_save_rollback_cmdinsertboth(txn, toku_cachefile_filenum(brt->cf), &keybs, &databs); - } else { - r = toku_logger_save_rollback_cmdinsert (txn, toku_cachefile_filenum(brt->cf), &keybs); - } + r = toku_logger_save_rollback_cmdinsert(txn, toku_cachefile_filenum(brt->cf), &keybs); if (r!=0) return r; r = toku_txn_note_brt(txn, brt); if (r!=0) return r; @@ -3159,8 +2981,6 @@ static int verify_builtin_comparisons_consistent(BRT t, u_int32_t flags) { if ((flags & TOKU_DB_KEYCMP_BUILTIN) && (t->compare_fun != toku_builtin_compare_fun)) return EINVAL; - if ((flags & TOKU_DB_VALCMP_BUILTIN) && (t->dup_compare != toku_builtin_compare_fun)) - return EINVAL; return 0; } @@ -3384,12 +3204,8 @@ brt_open_for_redirect(BRT *new_brtp, const char *fname_in_env, TOKUTXN txn, BRT assert(old_h->dict_id.dictid != DICTIONARY_ID_NONE.dictid); r = toku_brt_create(&t); assert(r==0); - r = toku_brt_set_flags(t, old_h->flags); - assert(r==0); r = toku_brt_set_bt_compare(t, old_brt->compare_fun); assert(r==0); - r = toku_brt_set_dup_compare(t, old_brt->dup_compare); - assert(r==0); r = toku_brt_set_nodesize(t, old_brt->nodesize); assert(r==0); if (old_h->descriptor.version>0) { @@ -3671,6 +3487,7 @@ toku_brt_get_dictionary_id(BRT brt) { } int toku_brt_set_flags(BRT brt, unsigned int flags) { + assert(flags==(flags&TOKU_DB_KEYCMP_BUILTIN)); // make sure there are no extranious flags brt->did_set_flags = TRUE; brt->flags = flags; return 0; @@ -3678,9 +3495,11 @@ int toku_brt_set_flags(BRT brt, unsigned int flags) { int toku_brt_get_flags(BRT brt, unsigned int *flags) { *flags = brt->flags; + assert(brt->flags==(brt->flags&TOKU_DB_KEYCMP_BUILTIN)); // make sure there are no extranious flags return 0; } + int toku_brt_set_nodesize(BRT brt, unsigned int nodesize) { brt->nodesize = nodesize; return 0; @@ -3701,11 +3520,6 @@ brt_compare_func toku_brt_get_bt_compare (BRT brt) { } -int toku_brt_set_dup_compare(BRT brt, int (*dup_compare)(DB *, const DBT*, const DBT*)) { - brt->dup_compare = dup_compare; - return 0; -} - int toku_brt_create_cachetable(CACHETABLE *ct, long cachesize, LSN initial_lsn, TOKULOGGER logger) { if (cachesize == 0) cachesize = 128*1024*1024; @@ -4036,7 +3850,6 @@ int toku_brt_create(BRT *brt_ptr) { brt->did_set_descriptor = FALSE; brt->nodesize = BRT_DEFAULT_NODE_SIZE; brt->compare_fun = toku_builtin_compare_fun; - brt->dup_compare = toku_builtin_compare_fun; int r = toku_omt_create(&brt->txns); if (r!=0) { toku_free(brt); return r; } *brt_ptr = brt; @@ -4237,12 +4050,10 @@ brt_cursor_not_set(BRT_CURSOR cursor) { static int pair_leafval_heaviside_le (u_int32_t klen, void *kval, - u_int32_t dlen, void *dval, brt_search_t *search) { - DBT x,y; + DBT x; int cmp = search->compare(search, - search->k ? toku_fill_dbt(&x, kval, klen) : 0, - search->v ? toku_fill_dbt(&y, dval, dlen) : 0); + search->k ? toku_fill_dbt(&x, kval, klen) : 0); // The search->compare function returns only 0 or 1 switch (search->direction) { case BRT_SEARCH_LEFT: return cmp==0 ? -1 : +1; @@ -4258,11 +4069,8 @@ heaviside_from_search_t (OMTVALUE lev, void *extra) { brt_search_t *search = extra; u_int32_t keylen; void* key = le_key_and_len(le, &keylen); - u_int32_t vallen; - void* val = le_innermost_inserted_val_and_len(le, &vallen); return pair_leafval_heaviside_le (keylen, key, - vallen, val, search); } @@ -4536,10 +4344,9 @@ brt_search_nonleaf_node(BRT brt, BRTNODE node, brt_search_t *search, BRT_GET_STR for (c = 0; c < node->u.n.n_children-1; c++) { int p = search->direction & BRT_SEARCH_LEFT ? child[c] : child[c] - 1; struct kv_pair *pivot = node->u.n.childkeys[p]; - DBT pivotkey, pivotval; + DBT pivotkey; if (search->compare(search, - toku_fill_dbt(&pivotkey, kv_pair_key(pivot), kv_pair_keylen(pivot)), - brt->flags & TOKU_DB_DUPSORT ? toku_fill_dbt(&pivotval, kv_pair_val(pivot), kv_pair_vallen(pivot)): 0)) { + toku_fill_dbt(&pivotkey, kv_pair_key(pivot), kv_pair_keylen(pivot)))) { BOOL did_change_shape = FALSE; verify_local_fingerprint_nonleaf(node); int r = brt_search_child(brt, node, child[c], search, getf, getf_v, re, doprefetch, brtcursor, &did_change_shape); @@ -4657,66 +4464,19 @@ brt_cursor_search(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBACK_FUNC return r; } -static inline int compare_kv_xy(BRT brt, const DBT *k, const DBT *v, const DBT *x, const DBT *y) { - int cmp = brt->compare_fun(brt->db, k, x); - if (cmp == 0 && v && y) - cmp = brt->dup_compare(brt->db, v, y); - return cmp; -} - static inline int compare_k_x(BRT brt, const DBT *k, const DBT *x) { return brt->compare_fun(brt->db, k, x); } -static inline int compare_v_y(BRT brt, const DBT *v, const DBT *y) { - return brt->dup_compare(brt->db, v, y); -} - static int -brt_cursor_compare_one(brt_search_t *search, DBT *x, DBT *y) +brt_cursor_compare_one(brt_search_t *search __attribute__((__unused__)), DBT *x __attribute__((__unused__))) { - search = search; x = x; y = y; return 1; } -static int -brt_cursor_search_eq_kv_xy_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; - if (key==NULL) { - r = bcss->getf(0, NULL, 0, NULL, bcss->getf_v); - } else { - BRT_CURSOR cursor = bcss->cursor; - brt_search_t *search = bcss->search; - DBT newkey = {.size = keylen, .data=(void*)key}; - DBT newval = {.size = vallen, .data=(void*)val}; - if (compare_kv_xy(cursor->brt, search->k, search->v, &newkey, &newval) == 0) { - r = bcss->getf(keylen, key, vallen, val, bcss->getf_v); - } else { - r = bcss->getf(0, NULL, 0, NULL, bcss->getf_v); - if (r==0) r = TOKUDB_FOUND_BUT_REJECTED; - } - } - return r; -} - -/* search for the kv pair that matches the search object and is equal to kv */ -static int -brt_cursor_search_eq_kv_xy(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) -{ - brt_cursor_invalidate(cursor); - struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, search}; - int r = toku_brt_search(cursor->brt, search, brt_cursor_search_eq_kv_xy_getf, &bcss, cursor, &cursor->root_put_counter); - return r; -} - -static int brt_cursor_compare_set(brt_search_t *search, DBT *x, DBT *y) { +static int brt_cursor_compare_set(brt_search_t *search, DBT *x) { BRT brt = search->context; - return compare_kv_xy(brt, search->k, search->v, x, y) <= 0; /* return min xy: kv <= xy */ + return compare_k_x(brt, search->k, x) <= 0; /* return min xy: kv <= xy */ } static int @@ -4732,9 +4492,8 @@ brt_cursor_current_getf(ITEMLEN keylen, bytevec key, } else { BRT_CURSOR cursor = bcss->cursor; DBT newkey = {.size=keylen, .data=(void*)key}; // initializes other fields to zero - DBT newval = {.size=vallen, .data=(void*)val}; //Safe to access cursor->key/val because current_in_omt is FALSE - if (compare_kv_xy(cursor->brt, &cursor->key, &cursor->val, &newkey, &newval) != 0) { + if (compare_k_x(cursor->brt, &cursor->key, &newkey) != 0) { r = bcss->getf(0, NULL, 0, NULL, bcss->getf_v); // This was once DB_KEYEMPTY if (r==0) r = TOKUDB_FOUND_BUT_REJECTED; } @@ -4752,7 +4511,7 @@ toku_brt_cursor_current(BRT_CURSOR cursor, int op, BRT_GET_CALLBACK_FUNCTION get if (op == DB_CURRENT) { brt_cursor_invalidate(cursor); struct brt_cursor_search_struct bcss = {getf, getf_v, cursor, 0}; - brt_search_t search; brt_search_init(&search, brt_cursor_compare_set, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt); + brt_search_t search; brt_search_init(&search, brt_cursor_compare_set, BRT_SEARCH_LEFT, &cursor->key, cursor->brt); return toku_brt_search(cursor->brt, &search, brt_cursor_current_getf, &bcss, cursor, &cursor->root_put_counter); } brt_cursor_invalidate(cursor); @@ -4772,7 +4531,7 @@ toku_brt_flatten(BRT brt, TOKULOGGER logger) BRT_CURSOR tmp_cursor; int r = toku_brt_cursor(brt, &tmp_cursor, logger, TXNID_NONE, FALSE); if (r!=0) return r; - brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_LEFT, 0, 0, tmp_cursor->brt); + brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_LEFT, 0, tmp_cursor->brt); r = brt_cursor_search(tmp_cursor, &search, brt_flatten_getf, NULL); if (r==DB_NOTFOUND) r = 0; { @@ -4786,20 +4545,20 @@ toku_brt_flatten(BRT brt, TOKULOGGER logger) int toku_brt_cursor_first(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) { - brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_LEFT, 0, 0, cursor->brt); + brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_LEFT, 0, cursor->brt); return brt_cursor_search(cursor, &search, getf, getf_v); } int toku_brt_cursor_last(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) { - brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_RIGHT, 0, 0, cursor->brt); + brt_search_t search; brt_search_init(&search, brt_cursor_compare_one, BRT_SEARCH_RIGHT, 0, cursor->brt); return brt_cursor_search(cursor, &search, getf, getf_v); } -static int brt_cursor_compare_next(brt_search_t *search, DBT *x, DBT *y) { +static int brt_cursor_compare_next(brt_search_t *search, DBT *x) { BRT brt = search->context; - return compare_kv_xy(brt, search->k, search->v, x, y) < 0; /* return min xy: kv < xy */ + return compare_k_x(brt, search->k, x) < 0; /* return min xy: kv < xy */ } static int @@ -4921,48 +4680,16 @@ int toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) { int r; - - if ((cursor->brt->flags & TOKU_DB_DUP) && brt_cursor_next_shortcut(cursor, getf, getf_v)==0) { + if (brt_cursor_next_shortcut(cursor, getf, getf_v)==0) { r = 0; - } - else { - brt_search_t search; brt_search_init(&search, brt_cursor_compare_next, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt); + } else { + brt_search_t search; brt_search_init(&search, brt_cursor_compare_next, BRT_SEARCH_LEFT, &cursor->key, cursor->brt); r = brt_cursor_search(cursor, &search, getf, getf_v); } if (r == 0) brt_cursor_set_prefetching(cursor); return r; } -static int brt_cursor_compare_next_nodup(brt_search_t *search, DBT *x, DBT *y) { - BRT brt = search->context; y = y; - return compare_k_x(brt, search->k, x) < 0; /* return min x: k < x */ -} - -int -toku_brt_cursor_next_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) -{ - int r; - - if (!(cursor->brt->flags & TOKU_DB_DUP) && brt_cursor_next_shortcut(cursor, getf, getf_v)==0) { - r = 0; - } - else { - brt_search_t search; brt_search_init(&search, brt_cursor_compare_next_nodup, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt); - r = brt_cursor_search(cursor, &search, getf, getf_v); - } - if (r == 0) brt_cursor_set_prefetching(cursor); - return r; -} - -static int brt_cursor_compare_next_dup(brt_search_t *search, DBT *x, DBT *y) { - BRT brt = search->context; - int keycmp = compare_k_x(brt, search->k, x); - if (keycmp < 0) - return 1; - else - return keycmp == 0 && y && compare_v_y(brt, search->v, y) < 0; /* return min xy: k <= x && v < y */ -} - static int brt_cursor_search_eq_k_x_getf(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, @@ -4996,48 +4723,6 @@ brt_cursor_search_eq_k_x(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_CALLBA return r; } -int -toku_brt_cursor_next_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) -{ - int r; - brt_search_t search; brt_search_init(&search, brt_cursor_compare_next_dup, BRT_SEARCH_LEFT, &cursor->key, &cursor->val, cursor->brt); - r = brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v); - if (r == 0) brt_cursor_set_prefetching(cursor); - return r; -} - -static int brt_cursor_compare_get_both_range(brt_search_t *search, DBT *x, DBT *y) { - BRT brt = search->context; - int keycmp = compare_k_x(brt, search->k, x); - if (keycmp < 0) - return 1; - else - return keycmp == 0 && (y == 0 || compare_v_y(brt, search->v, y) <= 0); /* return min xy: k <= x && v <= y */ -} - -int -toku_brt_cursor_get_both_range(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) -{ - brt_search_t search; brt_search_init(&search, brt_cursor_compare_get_both_range, BRT_SEARCH_LEFT, key, val, cursor->brt); - return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v); -} - -static int brt_cursor_compare_get_both_range_reverse(brt_search_t *search, DBT *x, DBT *y) { - BRT brt = search->context; - int keycmp = compare_k_x(brt, search->k, x); - if (keycmp > 0) - return 1; - else - return keycmp == 0 && (y == 0 || compare_v_y(brt, search->v, y) >= 0); /* return min xy: k >= x && v >= y */ -} - -int -toku_brt_cursor_get_both_range_reverse(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) -{ - brt_search_t search; brt_search_init(&search, brt_cursor_compare_get_both_range_reverse, BRT_SEARCH_RIGHT, key, val, cursor->brt); - return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v); -} - static int brt_cursor_prev_shortcut (BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) // Effect: If possible, decrement the cursor and return the key-value pair @@ -5060,81 +4745,48 @@ brt_cursor_prev_shortcut (BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, voi -static int brt_cursor_compare_prev(brt_search_t *search, DBT *x, DBT *y) { +static int brt_cursor_compare_prev(brt_search_t *search, DBT *x) { BRT brt = search->context; - return compare_kv_xy(brt, search->k, search->v, x, y) > 0; /* return max xy: kv > xy */ + return compare_k_x(brt, search->k, x) > 0; /* return max xy: kv > xy */ } int toku_brt_cursor_prev(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) { - if (0!=(cursor->brt->flags & TOKU_DB_DUP) && - brt_cursor_prev_shortcut(cursor, getf, getf_v)==0) + if (brt_cursor_prev_shortcut(cursor, getf, getf_v)==0) return 0; - brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt); + brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev, BRT_SEARCH_RIGHT, &cursor->key, cursor->brt); return brt_cursor_search(cursor, &search, getf, getf_v); } -static int brt_cursor_compare_prev_nodup(brt_search_t *search, DBT *x, DBT *y) { - BRT brt = search->context; y = y; - return compare_k_x(brt, search->k, x) > 0; /* return max x: k > x */ -} - -int -toku_brt_cursor_prev_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) -{ - if (0==(cursor->brt->flags & TOKU_DB_DUP) && - brt_cursor_prev_shortcut(cursor, getf, getf_v)==0) - return 0; - brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev_nodup, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt); - return brt_cursor_search(cursor, &search, getf, getf_v); -} - -static int brt_cursor_compare_prev_dup(brt_search_t *search, DBT *x, DBT *y) { +static int brt_cursor_compare_set_range(brt_search_t *search, DBT *x) { BRT brt = search->context; - int keycmp = compare_k_x(brt, search->k, x); - if (keycmp > 0) - return 1; - else - return keycmp == 0 && y && compare_v_y(brt, search->v, y) > 0; /* return max xy: k >= x && v > y */ + return compare_k_x(brt, search->k, x) <= 0; /* return kv <= xy */ } int -toku_brt_cursor_prev_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) +toku_brt_cursor_set(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) { - brt_search_t search; brt_search_init(&search, brt_cursor_compare_prev_dup, BRT_SEARCH_RIGHT, &cursor->key, &cursor->val, cursor->brt); + brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range, BRT_SEARCH_LEFT, key, cursor->brt); return brt_cursor_search_eq_k_x(cursor, &search, getf, getf_v); } - -static int brt_cursor_compare_set_range(brt_search_t *search, DBT *x, DBT *y) { - BRT brt = search->context; - return compare_kv_xy(brt, search->k, search->v, x, y) <= 0; /* return kv <= xy */ -} - -int -toku_brt_cursor_set(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) -{ - brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range, BRT_SEARCH_LEFT, key, val, cursor->brt); - return brt_cursor_search_eq_kv_xy(cursor, &search, getf, getf_v); -} - int toku_brt_cursor_set_range(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) { - brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range, BRT_SEARCH_LEFT, key, NULL, cursor->brt); + brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range, BRT_SEARCH_LEFT, key, cursor->brt); return brt_cursor_search(cursor, &search, getf, getf_v); } -static int brt_cursor_compare_set_range_reverse(brt_search_t *search, DBT *x, DBT *y) { +static int brt_cursor_compare_set_range_reverse(brt_search_t *search, DBT *x) { BRT brt = search->context; - return compare_kv_xy(brt, search->k, search->v, x, y) >= 0; /* return kv >= xy */ + return compare_k_x(brt, search->k, x) >= 0; /* return kv >= xy */ } int toku_brt_cursor_set_range_reverse(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) { - brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range_reverse, BRT_SEARCH_RIGHT, key, NULL, cursor->brt); + brt_search_t search; brt_search_init(&search, brt_cursor_compare_set_range_reverse, BRT_SEARCH_RIGHT, key, cursor->brt); return brt_cursor_search(cursor, &search, getf, getf_v); } @@ -5142,7 +4794,7 @@ toku_brt_cursor_set_range_reverse(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_ //TODO: When tests have been rewritten, get rid of this function. //Only used by tests. int -toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, int get_flags) +toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, int get_flags) { int op = get_flags & DB_OPFLAGS_MASK; if (get_flags & ~DB_OPFLAGS_MASK) @@ -5157,45 +4809,21 @@ toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUN case DB_LAST: return toku_brt_cursor_last(cursor, getf, getf_v); case DB_NEXT: - if (brt_cursor_not_set(cursor)) - return toku_brt_cursor_first(cursor, getf, getf_v); - else - return toku_brt_cursor_next(cursor, getf, getf_v); - case DB_NEXT_DUP: - if (brt_cursor_not_set(cursor)) - return EINVAL; - else - return toku_brt_cursor_next_dup(cursor, getf, getf_v); case DB_NEXT_NODUP: if (brt_cursor_not_set(cursor)) return toku_brt_cursor_first(cursor, getf, getf_v); else - return toku_brt_cursor_next_nodup(cursor, getf, getf_v); + return toku_brt_cursor_next(cursor, getf, getf_v); case DB_PREV: - if (brt_cursor_not_set(cursor)) - return toku_brt_cursor_last(cursor, getf, getf_v); - else - return toku_brt_cursor_prev(cursor, getf, getf_v); -#if defined(DB_PREV_DUP) - case DB_PREV_DUP: - if (brt_cursor_not_set(cursor)) - return EINVAL; - else - return toku_brt_cursor_prev_dup(cursor, getf, getf_v); -#endif case DB_PREV_NODUP: if (brt_cursor_not_set(cursor)) return toku_brt_cursor_last(cursor, getf, getf_v); else - return toku_brt_cursor_prev_nodup(cursor, getf, getf_v); + return toku_brt_cursor_prev(cursor, getf, getf_v); case DB_SET: - return toku_brt_cursor_set(cursor, key, 0, getf, getf_v); + return toku_brt_cursor_set(cursor, key, getf, getf_v); case DB_SET_RANGE: return toku_brt_cursor_set_range(cursor, key, getf, getf_v); - case DB_GET_BOTH: - return toku_brt_cursor_set(cursor, key, val, getf, getf_v); - case DB_GET_BOTH_RANGE: - return toku_brt_cursor_get_both_range(cursor, key, val, getf, getf_v); default: ;// Fall through } return EINVAL; @@ -5242,7 +4870,7 @@ int toku_brt_dbt_set(DBT* key, DBT* key_source) { /* ********************************* lookup **************************************/ int -toku_brt_lookup (BRT brt, DBT *k, DBT *v, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) +toku_brt_lookup (BRT brt, DBT *k, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v) { int r, rr; BRT_CURSOR cursor; @@ -5250,8 +4878,8 @@ toku_brt_lookup (BRT brt, DBT *k, DBT *v, BRT_GET_CALLBACK_FUNCTION getf, void * rr = toku_brt_cursor(brt, &cursor, NULL, TXNID_NONE, FALSE); if (rr != 0) return rr; - int op = brt->flags & TOKU_DB_DUPSORT ? DB_GET_BOTH : DB_SET; - r = toku_brt_cursor_get(cursor, k, v, getf, getf_v, op); + int op = DB_SET; + r = toku_brt_cursor_get(cursor, k, getf, getf_v, op); rr = toku_brt_cursor_close(cursor); assert(rr == 0); @@ -5259,48 +4887,6 @@ toku_brt_lookup (BRT brt, DBT *k, DBT *v, BRT_GET_CALLBACK_FUNCTION getf, void * } /* ********************************* delete **************************************/ - -int toku_brt_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn) { - return toku_brt_maybe_delete_both(brt, key, val, txn, FALSE, ZERO_LSN); -} - -int toku_brt_maybe_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn, BOOL oplsn_valid, LSN oplsn) { - //{ unsigned i; printf("del %p keylen=%d key={", brt->db, key->size); for(i=0; isize; i++) printf("%d,", ((char*)key->data)[i]); printf("} datalen=%d data={", val->size); for(i=0; isize; i++) printf("%d,", ((char*)val->data)[i]); printf("}\n"); } - int r; - XIDS message_xids; - TXNID xid = toku_txn_get_txnid(txn); - if (txn && (brt->h->txnid_that_created_or_locked_when_empty != xid)) { - BYTESTRING keybs = {key->size, key->data}; - BYTESTRING databs = {val->size, val->data}; - r = toku_logger_save_rollback_cmddeleteboth(txn, toku_cachefile_filenum(brt->cf), &keybs, &databs); - if (r!=0) return r; - r = toku_txn_note_brt(txn, brt); - if (r!=0) return r; - message_xids = toku_txn_get_xids(txn); - } - else { - //Treat this delete as a commit-immediately delete. - //It will never be given an abort message (will be truncated on abort). - message_xids = xids_get_root_xids(); - } - TOKULOGGER logger = toku_txn_logger(txn); - if (logger && brt->h->txnid_that_suppressed_recovery_logs == TXNID_NONE) { - BYTESTRING keybs = {.len=key->size, .data=key->data}; - BYTESTRING valbs = {.len=val->size, .data=val->data}; - r = toku_log_enq_delete_both(logger, (LSN*)0, 0, toku_cachefile_filenum(brt->cf), xid, keybs, valbs); - if (r!=0) return r; - } - - LSN treelsn; - if (oplsn_valid && oplsn.lsn <= (treelsn = toku_brt_checkpoint_lsn(brt)).lsn) { - r = 0; - } else { - BRT_MSG_S brtcmd = { BRT_DELETE_BOTH, message_xids, .u.id={key,val}}; - r = toku_brt_root_put_cmd(brt, &brtcmd); - } - return r; -} - static int getf_nothing (ITEMLEN UU(keylen), bytevec UU(key), ITEMLEN UU(vallen), bytevec UU(val), void *UU(pair_v)) { return 0; @@ -5327,7 +4913,7 @@ toku_brt_cursor_delete(BRT_CURSOR cursor, int flags, TOKUTXN txn) { //If we try to use the omtcursor, there exists a race condition //(node could be evicted), but maybe_get_and_pin() prevents delete. brt_cursor_invalidate(cursor); - r = toku_brt_delete_both(cursor->brt, &cursor->key, &cursor->val, txn); + r = toku_brt_delete(cursor->brt, &cursor->key, txn); } } return r; @@ -5377,28 +4963,15 @@ static void toku_brt_keyrange_internal (BRT brt, CACHEKEY nodename, u_int32_t fu } } else { BRT_MSG_S cmd = { BRT_INSERT, 0, .u.id={key,0}}; - struct cmd_leafval_heaviside_extra be = {brt, &cmd, 0}; + struct cmd_leafval_heaviside_extra be = {brt, &cmd}; u_int32_t idx; int r = toku_omt_find_zero(node->u.l.buffer, toku_cmd_leafval_heaviside, &be, 0, &idx, NULL); *less += idx; - if (r==0 && (brt->flags & TOKU_DB_DUP)) { - // There is something, and so we now want to find the rightmost extent. - u_int32_t idx2; - r = toku_omt_find(node->u.l.buffer, toku_cmd_leafval_heaviside, &be, +1, 0, &idx2, NULL); - if (r==0) { - *greater += toku_omt_size(node->u.l.buffer)-idx2; - *equal += idx2-idx; - } else { - *equal += toku_omt_size(node->u.l.buffer)-idx; - } - //printf("%s:%d (%llu, %llu, %llu)\n", __FILE__, __LINE__, (unsigned long long)*less, (unsigned long long)*equal, (unsigned long long)*greater); - } else { - *greater += toku_omt_size(node->u.l.buffer)-idx; - if (r==0) { - (*greater)--; - (*equal)++; - } - } + *greater += toku_omt_size(node->u.l.buffer)-idx; + if (r==0) { + (*greater)--; + (*equal)++; + } } { int rr = toku_unpin_brtnode(brt, node); @@ -5481,7 +5054,7 @@ toku_dump_brtnode (FILE *file, BRT brt, BLOCKNUM blocknum, int depth, bytevec lo int i; for (i=0; i+1< node->u.n.n_children; i++) { fprintf(file, "%*spivotkey %d =", depth+1, "", i); - toku_print_BYTESTRING(file, toku_brt_pivot_key_len(brt, node->u.n.childkeys[i]), node->u.n.childkeys[i]->key); + toku_print_BYTESTRING(file, toku_brt_pivot_key_len(node->u.n.childkeys[i]), node->u.n.childkeys[i]->key); fprintf(file, "\n"); } for (i=0; i< node->u.n.n_children; i++) { @@ -5508,9 +5081,9 @@ toku_dump_brtnode (FILE *file, BRT brt, BLOCKNUM blocknum, int depth, bytevec lo } toku_dump_brtnode(file, brt, BNC_BLOCKNUM(node, i), depth+4, (i==0) ? lorange : node->u.n.childkeys[i-1]->key, - (i==0) ? lolen : toku_brt_pivot_key_len(brt, node->u.n.childkeys[i-1]), + (i==0) ? lolen : toku_brt_pivot_key_len(node->u.n.childkeys[i-1]), (i==node->u.n.n_children-1) ? hirange : node->u.n.childkeys[i]->key, - (i==node->u.n.n_children-1) ? hilen : toku_brt_pivot_key_len(brt, node->u.n.childkeys[i]) + (i==node->u.n.n_children-1) ? hilen : toku_brt_pivot_key_len(node->u.n.childkeys[i]) ); } } diff --git a/newbrt/brt.h b/newbrt/brt.h index 694141b9344..c4611d52c7a 100644 --- a/newbrt/brt.h +++ b/newbrt/brt.h @@ -42,13 +42,12 @@ int toku_dictionary_redirect_abort(struct brt_header *old_h, struct brt_header * u_int32_t toku_serialize_descriptor_size(const DESCRIPTOR desc); int toku_brt_create(BRT *); int toku_brt_set_flags(BRT, unsigned int flags); -int toku_brt_set_descriptor (BRT t, u_int32_t version, const DBT* descriptor); int toku_brt_get_flags(BRT, unsigned int *flags); +int toku_brt_set_descriptor (BRT t, u_int32_t version, const DBT* descriptor); int toku_brt_set_nodesize(BRT, unsigned int nodesize); int toku_brt_get_nodesize(BRT, unsigned int *nodesize); int toku_brt_set_bt_compare(BRT, brt_compare_func); -int toku_brt_set_dup_compare(BRT, brt_compare_func); brt_compare_func toku_brt_get_bt_compare (BRT brt); @@ -61,7 +60,7 @@ int toku_brt_open_recovery(BRT, const char *fname_in_env, int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags); int toku_brt_broadcast_commit_all (BRT brt); -int toku_brt_lookup (BRT brt, DBT *k, DBT *v, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); +int toku_brt_lookup (BRT brt, DBT *k, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); // Effect: Insert a key and data pair into a brt // Returns 0 if successful @@ -132,19 +131,17 @@ typedef struct brt_cursor *BRT_CURSOR; int toku_brt_cursor (BRT, BRT_CURSOR*, TOKULOGGER, TXNID, BOOL); // get is deprecated in favor of the individual functions below -int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, int get_flags); +int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v, int get_flags); int toku_brt_flatten(BRT, TOKULOGGER logger); int toku_brt_cursor_first(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_last(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_next(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_next_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); -int toku_brt_cursor_next_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_prev(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_prev_nodup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); -int toku_brt_cursor_prev_dup(BRT_CURSOR cursor, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_current(BRT_CURSOR cursor, int op, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); -int toku_brt_cursor_set(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); +int toku_brt_cursor_set(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_set_range(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_set_range_reverse(BRT_CURSOR cursor, DBT *key, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); int toku_brt_cursor_get_both_range(BRT_CURSOR cursor, DBT *key, DBT *val, BRT_GET_CALLBACK_FUNCTION getf, void *getf_v); @@ -170,10 +167,10 @@ DICTIONARY_ID toku_brt_get_dictionary_id(BRT); int toku_brt_height_of_root(BRT, int *height); // for an open brt, return the current height. enum brt_header_flags { - TOKU_DB_DUP = (1<<0), - TOKU_DB_DUPSORT = (1<<1), + //TOKU_DB_DUP = (1<<0), //Obsolete #2862 + //TOKU_DB_DUPSORT = (1<<1), //Obsolete #2862 TOKU_DB_KEYCMP_BUILTIN = (1<<2), - TOKU_DB_VALCMP_BUILTIN = (1<<3), + //TOKU_DB_VALCMP_BUILTIN = (1<<3), }; int toku_brt_keyrange (BRT brt, DBT *key, u_int64_t *less, u_int64_t *equal, u_int64_t *greater); diff --git a/newbrt/brtdump.c b/newbrt/brtdump.c index 044f9a273d1..a9d0e0f388b 100644 --- a/newbrt/brtdump.c +++ b/newbrt/brtdump.c @@ -94,10 +94,8 @@ dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) { for (i=0; iu.n.n_children-1; i++) { struct kv_pair *piv = n->u.n.childkeys[i]; printf(" pivot %d:", i); - assert(n->flags == 0 || n->flags == TOKU_DB_DUP+TOKU_DB_DUPSORT); + assert(n->flags == 0); print_item(kv_pair_key_const(piv), kv_pair_keylen(piv)); - if (n->flags == TOKU_DB_DUP+TOKU_DB_DUPSORT) - print_item(kv_pair_val_const(piv), kv_pair_vallen(piv)); printf("\n"); } printf(" children:\n"); @@ -116,11 +114,8 @@ dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) { case BRT_INSERT: printf("INSERT"); goto ok; case BRT_INSERT_NO_OVERWRITE: printf("INSERT_NO_OVERWRITE"); goto ok; case BRT_DELETE_ANY: printf("DELETE_ANY"); goto ok; - case BRT_DELETE_BOTH: printf("DELETE_BOTH"); goto ok; case BRT_ABORT_ANY: printf("ABORT_ANY"); goto ok; - case BRT_ABORT_BOTH: printf("ABORT_BOTH"); goto ok; case BRT_COMMIT_ANY: printf("COMMIT_ANY"); goto ok; - case BRT_COMMIT_BOTH: printf("COMMIT_BOTH"); goto ok; case BRT_COMMIT_BROADCAST_ALL: printf("COMMIT_BROADCAST_ALL"); goto ok; case BRT_COMMIT_BROADCAST_TXN: printf("COMMIT_BROADCAST_TXN"); goto ok; case BRT_ABORT_BROADCAST_TXN: printf("ABORT_BROADCAST_TXN"); goto ok; diff --git a/newbrt/brttypes.h b/newbrt/brttypes.h index 8b0b875d79b..8b3b1e03e3d 100644 --- a/newbrt/brttypes.h +++ b/newbrt/brttypes.h @@ -86,11 +86,11 @@ enum brt_msg_type { BRT_NONE = 0, BRT_INSERT = 1, BRT_DELETE_ANY = 2, // Delete any matching key. This used to be called BRT_DELETE. - BRT_DELETE_BOTH = 3, + //BRT_DELETE_BOTH = 3, BRT_ABORT_ANY = 4, // Abort any commands on any matching key. - BRT_ABORT_BOTH = 5, // Abort commands that match both the key and the value + //BRT_ABORT_BOTH = 5, // Abort commands that match both the key and the value BRT_COMMIT_ANY = 6, - BRT_COMMIT_BOTH = 7, + //BRT_COMMIT_BOTH = 7, BRT_COMMIT_BROADCAST_ALL = 8, // Broadcast to all leafentries, (commit all transactions). BRT_COMMIT_BROADCAST_TXN = 9, // Broadcast to all leafentries, (commit specific transaction). BRT_ABORT_BROADCAST_TXN = 10, // Broadcast to all leafentries, (commit specific transaction). diff --git a/newbrt/fingerprint.c b/newbrt/fingerprint.c index 7be955454c1..6770f698213 100644 --- a/newbrt/fingerprint.c +++ b/newbrt/fingerprint.c @@ -21,11 +21,6 @@ static void toku_calc_more_murmur_kvpair (struct x1764 *mm, const void *key, int u_int32_t toku_calccrc32_kvpair (const void *key, int keylen, const void *val, int vallen) { return toku_calc_more_crc32_kvpair(toku_null_crc, key, keylen, val, vallen); } - -u_int32_t toku_calccrc32_kvpair_struct (const struct kv_pair *kvp) { - return toku_calccrc32_kvpair(kv_pair_key_const(kvp), kv_pair_keylen(kvp), - kv_pair_val_const(kvp), kv_pair_vallen(kvp)); -} #endif u_int32_t toku_calc_fingerprint_cmd (u_int32_t type, XIDS xids, const void *key, u_int32_t keylen, const void *val, u_int32_t vallen) { diff --git a/newbrt/kv-pair.h b/newbrt/kv-pair.h index 06a9e40aeac..23d8bf86218 100644 --- a/newbrt/kv-pair.h +++ b/newbrt/kv-pair.h @@ -67,18 +67,6 @@ static inline unsigned int kv_pair_keylen(const struct kv_pair *pair) { return pair->keylen; } -static inline void *kv_pair_val(struct kv_pair *pair) { - return pair->key + pair->keylen; -} - -static inline const void *kv_pair_val_const(const struct kv_pair *pair) { - return pair->key + pair->keylen; -} - -static inline unsigned int kv_pair_vallen(const struct kv_pair *pair) { - return pair->vallen; -} - #if defined(__cplusplus) || defined(__cilkplusplus) }; #endif diff --git a/newbrt/logformat.c b/newbrt/logformat.c index 1c1f2dd1ab9..43d24f6e5f9 100644 --- a/newbrt/logformat.c +++ b/newbrt/logformat.c @@ -56,16 +56,6 @@ const struct logtype rollbacks[] = { {"FILENUM", "filenum", 0}, {"BYTESTRING", "key", 0}, NULLFIELD}}, - {"cmdinsertboth", 'I', FA{ - {"FILENUM", "filenum", 0}, - {"BYTESTRING", "key", 0}, - {"BYTESTRING", "data", 0}, - NULLFIELD}}, - {"cmddeleteboth", 'D', FA{ - {"FILENUM", "filenum", 0}, - {"BYTESTRING", "key", 0}, - {"BYTESTRING", "data", 0}, - NULLFIELD}}, {"cmddelete", 'd', FA{ {"FILENUM", "filenum", 0}, {"BYTESTRING", "key", 0}, @@ -157,11 +147,6 @@ const struct logtype logtypes[] = { {"BYTESTRING", "key", 0}, {"BYTESTRING", "value", 0}, NULLFIELD}}, - {"enq_delete_both", 'D', FA{{"FILENUM", "filenum", 0}, - {"TXNID", "xid", 0}, - {"BYTESTRING", "key", 0}, - {"BYTESTRING", "value", 0}, - NULLFIELD}}, {"enq_delete_any", 'E', FA{{"FILENUM", "filenum", 0}, {"TXNID", "xid", 0}, {"BYTESTRING", "key", 0}, diff --git a/newbrt/recover.c b/newbrt/recover.c index 9c977126c36..318dc3dd5d4 100644 --- a/newbrt/recover.c +++ b/newbrt/recover.c @@ -176,7 +176,6 @@ struct recover_env { CACHETABLE ct; TOKULOGGER logger; brt_compare_func bt_compare; - brt_compare_func dup_compare; generate_row_for_put_func generate_row_for_put; generate_row_for_del_func generate_row_for_del; struct scan_state ss; @@ -185,7 +184,7 @@ struct recover_env { }; typedef struct recover_env *RECOVER_ENV; -static int recover_env_init (RECOVER_ENV renv, brt_compare_func bt_compare, brt_compare_func dup_compare, +static int recover_env_init (RECOVER_ENV renv, brt_compare_func bt_compare, generate_row_for_put_func generate_row_for_put, generate_row_for_del_func generate_row_for_del, size_t cachetable_size) { @@ -198,7 +197,6 @@ static int recover_env_init (RECOVER_ENV renv, brt_compare_func bt_compare, brt_ toku_logger_write_log_files(renv->logger, FALSE); toku_logger_set_cachetable(renv->logger, renv->ct); renv->bt_compare = bt_compare; - renv->dup_compare = dup_compare; renv->generate_row_for_put = generate_row_for_put; renv->generate_row_for_del = generate_row_for_del; file_map_init(&renv->fmap); @@ -252,8 +250,6 @@ static int internal_recover_fopen_or_fcreate (RECOVER_ENV renv, BOOL must_create // set the key compare functions if (!(treeflags & TOKU_DB_KEYCMP_BUILTIN) && renv->bt_compare) toku_brt_set_bt_compare(brt, renv->bt_compare); - if (!(treeflags & TOKU_DB_VALCMP_BUILTIN) && renv->dup_compare) - toku_brt_set_dup_compare(brt, renv->dup_compare); // TODO mode (FUTURE FEATURE) mode = mode; @@ -799,30 +795,6 @@ static int toku_recover_backward_enq_insert_no_overwrite (struct logtype_enq_ins return 0; } -static int toku_recover_enq_delete_both (struct logtype_enq_delete_both *l, RECOVER_ENV renv) { - int r; - TOKUTXN txn = NULL; - r = toku_txnid2txn(renv->logger, l->xid, &txn); - assert(r == 0); - assert(txn!=NULL); - struct file_map_tuple *tuple = NULL; - r = file_map_find(&renv->fmap, l->filenum, &tuple); - if (r==0) { - //Maybe do the deletion if we found the cachefile. - DBT keydbt, valdbt; - toku_fill_dbt(&keydbt, l->key.data, l->key.len); - toku_fill_dbt(&valdbt, l->value.data, l->value.len); - r = toku_brt_maybe_delete_both(tuple->brt, &keydbt, &valdbt, txn, TRUE, l->lsn); - assert(r == 0); - } - return 0; -} - -static int toku_recover_backward_enq_delete_both (struct logtype_enq_delete_both *UU(l), RECOVER_ENV UU(renv)) { - // nothing - return 0; -} - static int toku_recover_enq_delete_any (struct logtype_enq_delete_any *l, RECOVER_ENV renv) { int r; TOKUTXN txn = NULL; @@ -1321,7 +1293,6 @@ toku_recover_unlock(int lockfd) { int tokudb_recover(const char *env_dir, const char *log_dir, brt_compare_func bt_compare, - brt_compare_func dup_compare, generate_row_for_put_func generate_row_for_put, generate_row_for_del_func generate_row_for_del, size_t cachetable_size) { @@ -1335,7 +1306,7 @@ int tokudb_recover(const char *env_dir, const char *log_dir, int rr = 0; if (tokudb_needs_recovery(log_dir, FALSE)) { struct recover_env renv; - r = recover_env_init(&renv, bt_compare, dup_compare, + r = recover_env_init(&renv, bt_compare, generate_row_for_put, generate_row_for_del, cachetable_size); diff --git a/newbrt/recover.h b/newbrt/recover.h index 9e248819137..f367d5c0c66 100644 --- a/newbrt/recover.h +++ b/newbrt/recover.h @@ -21,7 +21,6 @@ extern "C" { // Returns 0 if success int tokudb_recover (const char *env_dir, const char *log_dir, brt_compare_func bt_compare, - brt_compare_func dup_compare, generate_row_for_put_func generate_row_for_put, generate_row_for_del_func generate_row_for_del, size_t cachetable_size); diff --git a/newbrt/roll.c b/newbrt/roll.c index fafbb51b5ef..aa944c6f64b 100644 --- a/newbrt/roll.c +++ b/newbrt/roll.c @@ -182,23 +182,6 @@ int toku_commit_cmdinsert (FILENUM filenum, BYTESTRING key, TOKUTXN txn, YIELDF #endif } -int -toku_commit_cmdinsertboth (FILENUM filenum, - BYTESTRING key, - BYTESTRING data, - TOKUTXN txn, - YIELDF UU(yield), - void * UU(yieldv), - LSN oplsn) -{ -#if TOKU_DO_COMMIT_CMD_INSERT - return do_insertion (BRT_COMMIT_BOTH, filenum, key, &data, txn, oplsn); -#else - key = key; data = data; oplsn = oplsn; - return do_nothing_with_filenum(txn, filenum); -#endif -} - int toku_rollback_cmdinsert (FILENUM filenum, BYTESTRING key, @@ -210,47 +193,6 @@ toku_rollback_cmdinsert (FILENUM filenum, return do_insertion (BRT_ABORT_ANY, filenum, key, 0, txn, oplsn); } -int -toku_rollback_cmdinsertboth (FILENUM filenum, - BYTESTRING key, - BYTESTRING data, - TOKUTXN txn, - YIELDF UU(yield), - void * UU(yieldv), - LSN oplsn) -{ - return do_insertion (BRT_ABORT_BOTH, filenum, key, &data, txn, oplsn); -} - -int -toku_commit_cmddeleteboth (FILENUM filenum, - BYTESTRING key, - BYTESTRING data, - TOKUTXN txn, - YIELDF UU(yield), - void * UU(yieldv), - LSN oplsn) -{ -#if TOKU_DO_COMMIT_CMD_DELETE_BOTH - return do_insertion (BRT_COMMIT_BOTH, filenum, key, &data, txn, oplsn); -#else - xid = xid; key = key; data = data; - return do_nothing_with_filenum(txn, filenum); -#endif -} - -int -toku_rollback_cmddeleteboth (FILENUM filenum, - BYTESTRING key, - BYTESTRING data, - TOKUTXN txn, - YIELDF UU(yield), - void * UU(yieldv), - LSN oplsn) -{ - return do_insertion (BRT_ABORT_BOTH, filenum, key, &data, txn, oplsn); -} - int toku_commit_cmddelete (FILENUM filenum, BYTESTRING key, diff --git a/newbrt/tdb-recover.c b/newbrt/tdb-recover.c index 3e64237798d..454cf5cdb68 100644 --- a/newbrt/tdb-recover.c +++ b/newbrt/tdb-recover.c @@ -36,7 +36,7 @@ int recovery_main (int argc, const char *const argv[]) { return(1); } - int r = tokudb_recover(data_dir, log_dir, NULL, NULL, NULL, NULL, 0); + int r = tokudb_recover(data_dir, log_dir, NULL, NULL, NULL, 0); if (r!=0) { fprintf(stderr, "Recovery failed\n"); return(1); diff --git a/newbrt/tests/brt-serialize-sub-block-test.c b/newbrt/tests/brt-serialize-sub-block-test.c index e071d52d15a..ac961c88c13 100644 --- a/newbrt/tests/brt-serialize-sub-block-test.c +++ b/newbrt/tests/brt-serialize-sub-block-test.c @@ -57,7 +57,7 @@ static void test_sub_block(int n) { int k = htonl(i); int v = i; struct check_pair pair = {sizeof k, &k, sizeof v, &v, 0}; - error = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); + error = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_NEXT); if (error != 0) { assert(pair.call_count==0); break; diff --git a/newbrt/tests/brt-serialize-test.c b/newbrt/tests/brt-serialize-test.c index 5cfb2e69ad0..4fd80fb4877 100644 --- a/newbrt/tests/brt-serialize-test.c +++ b/newbrt/tests/brt-serialize-test.c @@ -115,7 +115,7 @@ test_serialize_nonleaf(void) { assert(dn->rand4fingerprint==randval); assert(dn->u.n.n_children==2); assert(strcmp(kv_pair_key(dn->u.n.childkeys[0]), "hello")==0); - assert(toku_brtnode_pivot_key_len(dn, dn->u.n.childkeys[0])==6); + assert(toku_brt_pivot_key_len(dn->u.n.childkeys[0])==6); assert(dn->u.n.totalchildkeylens==6); assert(BNC_BLOCKNUM(dn,0).b==30); assert(BNC_BLOCKNUM(dn,1).b==35); diff --git a/newbrt/tests/brt-test-cursor-2.c b/newbrt/tests/brt-test-cursor-2.c index f5a28fbe795..e9246e68a03 100644 --- a/newbrt/tests/brt-test-cursor-2.c +++ b/newbrt/tests/brt-test-cursor-2.c @@ -57,12 +57,11 @@ static void test_multiple_brt_cursor_dbts(int n, DB *db) { void *ptrs[n]; for (i=0; i max_key) { /* there is no smallest key if v > the max key */ assert(r == DB_NOTFOUND); @@ -849,7 +849,7 @@ static void test_brt_cursor_delete(int n, DB *db) { /* walk the tree and delete under the cursor */ for (;;) { struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0}; - error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_NEXT); + error = toku_brt_cursor_get(cursor, &key, lookup_checkf, &pair, DB_NEXT); if (error == DB_NOTFOUND) { assert(pair.call_count==0); break; @@ -874,127 +874,6 @@ static void test_brt_cursor_delete(int n, DB *db) { assert(error == 0); } -static void test_brt_cursor_get_both(int n, DB *db) { - if (verbose) printf("test_brt_cursor_get_both:%d %p\n", n, db); - - int error; - CACHETABLE ct; - BRT brt; - BRT_CURSOR cursor=0; - - unlink(fname); - - error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); - assert(error == 0); - - error = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); - assert(error == 0); - - error = toku_brt_cursor(brt, &cursor, NULL, TXNID_NONE, FALSE); - assert(error == 0); - - { - /* verify get_both on an empty tree fails */ - int k = toku_htonl(n+1); - int v = n+1; - DBT key, val; - toku_fill_dbt(&key, &k, sizeof k); - toku_fill_dbt(&val, &v, sizeof v); - struct check_pair pair = {0,0,0,0,0}; - error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH); - assert(error == DB_NOTFOUND); - assert(pair.call_count==0); - } - - - int i; - /* insert keys 0, 1, 2, .. (n-1) */ - for (i=0; i>8)&255); b[1] = a[2] = (unsigned char)((i>>16)&255); b[0] = a[3] = (unsigned char)((i>>24)&255); - r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); + r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1); } @@ -432,7 +432,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { b[2] = a[1] = (unsigned char)((i>>8)&255); b[1] = a[2] = (unsigned char)((i>>16)&255); b[0] = a[3] = (unsigned char)((i>>24)&255); - r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); + r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1); toku_cachetable_verify(ct); @@ -559,7 +559,7 @@ static void test_brt_delete_present(int n) { int k = toku_htonl(i); DBT key = {.size=sizeof k, .data=&k}; struct check_pair pair = {0, 0, 0, 0, 0}; - r = toku_brt_lookup(t, &key, NULL, lookup_checkf, &pair); + r = toku_brt_lookup(t, &key, lookup_checkf, &pair); assert(r == DB_NOTFOUND); assert(pair.call_count==0); } @@ -572,7 +572,7 @@ static void test_brt_delete_present(int n) { { struct check_pair pair = {0,0,0,0,0}; - r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST); + r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_FIRST); assert(r != 0); assert(pair.call_count==0); } @@ -661,7 +661,7 @@ static void test_brt_delete_cursor_first(int n) { int k2 = k; int v = i; struct check_pair pair = {sizeof k, &k2, sizeof v, &v, 0}; - r = toku_brt_lookup(t, &key, 0, lookup_checkf, &pair); + r = toku_brt_lookup(t, &key, lookup_checkf, &pair); assert(r == 0); assert(pair.call_count==1); } @@ -679,7 +679,7 @@ static void test_brt_delete_cursor_first(int n) { int k = toku_htonl(i); DBT key = {.size=sizeof k, .data=&k}; struct check_pair pair = {0,0,0,0,0}; - r = toku_brt_lookup(t, &key, NULL, lookup_checkf, &pair); + r = toku_brt_lookup(t, &key, lookup_checkf, &pair); assert(r == DB_NOTFOUND); assert(pair.call_count==0); } @@ -690,7 +690,7 @@ static void test_brt_delete_cursor_first(int n) { int k = toku_htonl(i); DBT key = {.size=sizeof k, .data=&k}; struct check_pair pair = {0,0,0,0,0}; - r = toku_brt_lookup(t, &key, NULL, lookup_checkf, &pair); + r = toku_brt_lookup(t, &key, lookup_checkf, &pair); assert(r == DB_NOTFOUND); assert(pair.call_count==0); } @@ -705,7 +705,7 @@ static void test_brt_delete_cursor_first(int n) { int kv = toku_htonl(n-1); int vv = n-1; struct check_pair pair = {sizeof kv, &kv, sizeof vv, &vv, 0}; - r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST); + r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_FIRST); assert(r == 0); assert(pair.call_count==1); } @@ -758,7 +758,7 @@ static void test_insert_delete_lookup(int n) { int k = toku_htonl(n-1); DBT key = {.size=sizeof k, .data=&k}; struct check_pair pair = {0,0,0,0,0}; - r = toku_brt_lookup(t, &key, NULL, lookup_checkf, &pair); + r = toku_brt_lookup(t, &key, lookup_checkf, &pair); assert(r == DB_NOTFOUND); assert(pair.call_count==0); } @@ -772,73 +772,6 @@ static void test_insert_delete_lookup(int n) { delete_both <0,i> for all even i verify <0,i> exists for all odd i */ -static void test_brt_delete_both(int n) { - if (verbose) printf("test_brt_delete_both:%d\n", n); - - BRT t=0; - int r; - CACHETABLE ct; - int i; - - r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); - unlink(fname); - r = toku_brt_create(&t); assert(r == 0); - r = toku_brt_set_flags(t, TOKU_DB_DUP + TOKU_DB_DUPSORT); assert(r == 0); - r = toku_brt_set_nodesize(t, 4096); assert(r == 0); - r = toku_brt_open(t, fname, 1, 1, ct, null_txn, (DB*)0); - assert(r==0); - - DBT key, val; - int k, v; - - for (i=0; i max_key) { /* there is no smallest key if v > the max key */ assert(r == DB_NOTFOUND); @@ -1247,7 +1179,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) { int k = toku_htonl(v); DBT key = {.size=sizeof k, .data=&k}; struct check_pair pair = {sizeof k, &k, sizeof v, &v, 0}; - r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, cursor_op); + r = toku_brt_cursor_get(cursor, &key, lookup_checkf, &pair, cursor_op); assert(r == 0); assert(pair.call_count==1); if (cursor_op == DB_SET) assert(key.data == &k); @@ -1260,7 +1192,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) { int k = toku_htonl(i); DBT key = {.size=sizeof k, .data=&k}; struct check_pair pair = {0,0,0,0,0}; - r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, DB_SET); + r = toku_brt_cursor_get(cursor, &key, lookup_checkf, &pair, DB_SET); assert(r == DB_NOTFOUND); assert(pair.call_count==0); assert(key.data == &k); @@ -1274,6 +1206,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) { } static void test_new_brt_cursors(int dup_mode) { + assert(dup_mode==0); test_new_brt_cursor_create_close(); toku_memory_check_all_free(); test_new_brt_cursor_first(8, dup_mode); toku_memory_check_all_free(); test_new_brt_cursor_last(8, dup_mode); toku_memory_check_all_free(); @@ -1293,8 +1226,6 @@ static void brt_blackbox_test (void) { test_wrongendian_compare(1, 257); toku_memory_check_all_free(); test_wrongendian_compare(1, 1000); toku_memory_check_all_free(); test_new_brt_cursors(0); - test_new_brt_cursors(TOKU_DB_DUP+TOKU_DB_DUPSORT); - test_brt_delete_both(512); toku_memory_check_all_free(); test_read_what_was_written(); toku_memory_check_all_free(); if (verbose) printf("did read_what_was_written\n"); test_cursor_next(); toku_memory_check_all_free(); diff --git a/newbrt/tests/brt-test1.c b/newbrt/tests/brt-test1.c index 29caa28a002..a9b53a70fc4 100644 --- a/newbrt/tests/brt-test1.c +++ b/newbrt/tests/brt-test1.c @@ -23,7 +23,7 @@ static void test1 (void) { toku_brt_insert(t, toku_fill_dbt(&k, "hello", 6), toku_fill_dbt(&v, "there", 6), null_txn); { struct check_pair pair = {6, "hello", 6, "there", 0}; - r = toku_brt_lookup(t, toku_fill_dbt(&k, "hello", 6), NULL, lookup_checkf, &pair); + r = toku_brt_lookup(t, toku_fill_dbt(&k, "hello", 6), lookup_checkf, &pair); assert(r==0); assert(pair.call_count==1); } diff --git a/newbrt/tests/brt-test5.c b/newbrt/tests/brt-test5.c index c0c51394312..87aeb2e446c 100644 --- a/newbrt/tests/brt-test5.c +++ b/newbrt/tests/brt-test5.c @@ -42,7 +42,7 @@ static void test5 (void) { snprintf(key, 100, "key%d", rk); snprintf(valexpected, 100, "val%d", values[rk]); struct check_pair pair = {1+strlen(key), key, 1+strlen(valexpected), valexpected, 0}; - r = toku_brt_lookup(t, toku_fill_dbt(&k, key, 1+strlen(key)), NULL, lookup_checkf, &pair); + r = toku_brt_lookup(t, toku_fill_dbt(&k, key, 1+strlen(key)), lookup_checkf, &pair); assert(r==0); assert(pair.call_count==1); } diff --git a/newbrt/tests/brtloader-test-writer.c b/newbrt/tests/brtloader-test-writer.c index 29c6a38d9dd..fb73b8efac2 100644 --- a/newbrt/tests/brtloader-test-writer.c +++ b/newbrt/tests/brtloader-test-writer.c @@ -62,7 +62,7 @@ static void verify_dbfile(int n, const char *name) { int kk = i; int vv = i; struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0}; - r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); + r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_NEXT); if (r != 0) { assert(pair.call_count ==0); break; diff --git a/newbrt/tests/brtloader-test.c b/newbrt/tests/brtloader-test.c index 525b254f714..a3c5a5e6673 100644 --- a/newbrt/tests/brtloader-test.c +++ b/newbrt/tests/brtloader-test.c @@ -259,7 +259,7 @@ static void verify_dbfile(int n, int sorted_keys[], const char *sorted_vals[], c int i; for (i=0; i - -static TOKUTXN const null_txn = 0; -static DB * const null_db = 0; - -static void test_delete_all (void) { - char fname[]= __FILE__ ".brt"; - u_int32_t limit =200; - unlink(fname); - CACHETABLE ct; - int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); - BRT t; - r = toku_brt_create(&t); assert(r==0); - r = toku_brt_set_flags(t, TOKU_DB_DUP + TOKU_DB_DUPSORT); assert(r == 0); - r = toku_brt_set_nodesize(t, 4096); assert(r == 0); - r = toku_brt_open(t, fname, 1, 1, ct, null_txn, (DB*)0); assert(r==0); - u_int32_t i; - for (i=0; i - -static TOKUTXN const null_txn = 0; -static DB * const null_db = 0; - -static void test_flat (void) { - char fname[]= __FILE__ ".brt"; - u_int64_t limit=100; - u_int64_t ilimit=100; - unlink(fname); - CACHETABLE ct; - // set the cachetable to size 1 so that things won't fit. - int r = toku_brt_create_cachetable(&ct, 1, ZERO_LSN, NULL_LOGGER); assert(r==0); - BRT t; - r = toku_brt_create(&t); assert(r==0); - r = toku_brt_set_flags(t, TOKU_DB_DUP + TOKU_DB_DUPSORT); assert(r == 0); - r = toku_brt_set_nodesize(t, 4096); assert(r == 0); - r = toku_brt_open(t, fname, 1, 1, ct, null_txn, (DB*)0); - u_int64_t i; - for (i=0; i=prevless); prevless=less; - assert(greater<=prevgreater); prevgreater=greater; - } - r = toku_close_brt(t, 0); assert(r==0); - r = toku_cachetable_close(&ct); assert(r==0); -} - -int -test_main (int argc , const char *argv[]) { - default_parse_args(argc, argv); - - test_flat(); - toku_malloc_cleanup(); - if (verbose) printf("test ok\n"); - return 0; -} - diff --git a/newbrt/tests/keyrange-dupsort.c b/newbrt/tests/keyrange-dupsort.c deleted file mode 100644 index 913cb49585c..00000000000 --- a/newbrt/tests/keyrange-dupsort.c +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2008 Tokutek Inc. All rights reserved." - -#include "includes.h" -#include "test.h" - -#include - -static TOKUTXN const null_txn = 0; -static DB * const null_db = 0; - -static void test_flat (void) { - char fname[]= __FILE__ ".brt"; - u_int64_t limit=100; - u_int64_t ilimit=100; - unlink(fname); - CACHETABLE ct; - int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); - BRT t; - r = toku_brt_create(&t); assert(r==0); - r = toku_brt_set_flags(t, TOKU_DB_DUP + TOKU_DB_DUPSORT); assert(r == 0); - r = toku_brt_set_nodesize(t, 4096); assert(r == 0); - r = toku_brt_open(t, fname, 1, 1, ct, null_txn, (DB*)0); - u_int64_t i; - for (i=0; i= argc) return print_usage(argv[0]); - pagesize = atoi(argv[++i]); - } else if (strcmp(arg, "--dupsort") == 0) { - dupflags = DB_DUP + DB_DUPSORT; - continue; + pagesize = atoi(argv[++i]); } else if (strcmp(arg, "--env") == 0) { if (i+1 >= argc) return print_usage(argv[0]); dbdir = argv[++i]; diff --git a/release/examples/db-scan.c b/release/examples/db-scan.c index 6516ca0b10f..8fc01c3c2d0 100644 --- a/release/examples/db-scan.c +++ b/release/examples/db-scan.c @@ -132,8 +132,7 @@ static void scanscan_setup (void) { if (prelock) { r = db->pre_acquire_read_lock(db, tid, - db->dbt_neg_infty(), db->dbt_neg_infty(), - db->dbt_pos_infty(), db->dbt_pos_infty()); + db->dbt_neg_infty(), db->dbt_pos_infty()); assert(r==0); } #endif diff --git a/src/lock_tree/locktree.c b/src/lock_tree/locktree.c index bd3f869c417..1f7f76c35aa 100644 --- a/src/lock_tree/locktree.c +++ b/src/lock_tree/locktree.c @@ -95,7 +95,6 @@ static inline int toku_ltm_add_lt(toku_ltm* mgr, toku_lock_tree* lt) { } int toku__lt_point_cmp(const toku_point* x, const toku_point* y) { - int partial_result; DBT point_1; DBT point_2; @@ -113,20 +112,9 @@ int toku__lt_point_cmp(const toku_point* x, const toku_point* y) { be the sole determinant of the comparison */ return toku__infinite_compare(x->key_payload, y->key_payload); } - partial_result = x->lt->compare_fun(x->lt->db, - toku__recreate_DBT(&point_1, x->key_payload, x->key_len), - toku__recreate_DBT(&point_2, y->key_payload, y->key_len)); - if (partial_result) return partial_result; - - if (!x->lt->duplicates) return 0; - - if (toku__lt_is_infinite(x->data_payload) || - toku__lt_is_infinite(y->data_payload)) { - return toku__infinite_compare(x->data_payload, y->data_payload); - } - return x->lt->dup_compare(x->lt->db, - toku__recreate_DBT(&point_1, x->data_payload, x->data_len), - toku__recreate_DBT(&point_2, y->data_payload, y->data_len)); + return x->lt->compare_fun(x->lt->db, + toku__recreate_DBT(&point_1, x->key_payload, x->key_len), + toku__recreate_DBT(&point_2, y->key_payload, y->key_len)); } /* Lock tree manager functions begin here */ @@ -134,7 +122,6 @@ int toku_ltm_create(toku_ltm** pmgr, u_int32_t max_locks, int (*panic)(DB*, int), toku_dbt_cmp (*get_compare_fun_from_db)(DB*), - toku_dbt_cmp (*get_dup_compare_from_db)(DB*), void* (*user_malloc) (size_t), void (*user_free) (void*), void* (*user_realloc)(void*, size_t)) { @@ -144,7 +131,7 @@ int toku_ltm_create(toku_ltm** pmgr, if (!pmgr || !max_locks || !user_malloc || !user_free || !user_realloc) { r = EINVAL; goto cleanup; } - assert(panic && get_compare_fun_from_db && get_dup_compare_from_db); + assert(panic && get_compare_fun_from_db); tmp_mgr = (toku_ltm*)user_malloc(sizeof(*tmp_mgr)); if (!tmp_mgr) { r = ENOMEM; goto cleanup; } @@ -162,7 +149,6 @@ int toku_ltm_create(toku_ltm** pmgr, tmp_mgr->free = user_free; tmp_mgr->realloc = user_realloc; tmp_mgr->get_compare_fun_from_db = get_compare_fun_from_db; - tmp_mgr->get_dup_compare_from_db = get_dup_compare_from_db; r = toku_lth_create(&tmp_mgr->lth, user_malloc, user_free, user_realloc); if (r!=0) { goto cleanup; } @@ -325,9 +311,6 @@ static inline void toku__p_free(toku_lock_tree* tree, toku_point* point) { if (!toku__lt_is_infinite(point->key_payload)) { tree->free(point->key_payload); } - if (!toku__lt_is_infinite(point->data_payload)) { - tree->free(point->data_payload); - } tree->free(point); } @@ -335,8 +318,8 @@ static inline void toku__p_free(toku_lock_tree* tree, toku_point* point) { Allocate and copy the payload. */ static inline int toku__payload_copy(toku_lock_tree* tree, - void** payload_out, u_int32_t* len_out, - void* payload_in, u_int32_t len_in) { + void** payload_out, u_int32_t* len_out, + void* payload_in, u_int32_t len_in) { assert(payload_out && len_out); if (!len_in) { assert(!payload_in || toku__lt_is_infinite(payload_in)); @@ -368,16 +351,7 @@ static inline int toku__p_makecopy(toku_lock_tree* tree, toku_point** ppoint) { r = toku__payload_copy(tree, &temp_point->key_payload, &temp_point->key_len, point->key_payload, point->key_len); - if (0) { - died2: - if (!toku__lt_is_infinite(temp_point->key_payload)) { - tree->free(temp_point->key_payload); } - goto died1; } if (r!=0) goto died1; - toku__payload_copy(tree, - &temp_point->data_payload, &temp_point->data_len, - point->data_payload, point->data_len); - if (r!=0) goto died2; *ppoint = temp_point; return 0; } @@ -652,22 +626,12 @@ static inline void toku__payload_from_dbt(void** payload, u_int32_t* len, } static inline void toku__init_point(toku_point* point, toku_lock_tree* tree, - const DBT* key, const DBT* data) { + const DBT* key) { assert(point && tree && key); - assert(!tree->duplicates == !data); memset(point, 0, sizeof(toku_point)); point->lt = tree; toku__payload_from_dbt(&point->key_payload, &point->key_len, key); - if (tree->duplicates) { - assert(data); - toku__payload_from_dbt(&point->data_payload, &point->data_len, data); - } - else { - assert(data == NULL); - point->data_payload = NULL; - point->data_len = 0; - } } static inline void toku__init_query(toku_interval* query, @@ -928,11 +892,9 @@ static inline int toku__consolidate(toku_lock_tree* tree, BOOL found_only, } static inline void toku__lt_init_full_query(toku_lock_tree* tree, toku_interval* query, - toku_point* left, toku_point* right) { - DBT* neg_inf_dups = tree->duplicates ? (DBT*)toku_lt_neg_infinity : NULL; - DBT* pos_inf_dups = tree->duplicates ? (DBT*)toku_lt_infinity : NULL; - toku__init_point(left, tree, (DBT*)toku_lt_neg_infinity, neg_inf_dups); - toku__init_point(right, tree, (DBT*)toku_lt_infinity, pos_inf_dups); + toku_point* left, toku_point* right) { + toku__init_point(left, tree, (DBT*)toku_lt_neg_infinity); + toku__init_point(right, tree, (DBT*)toku_lt_infinity); toku__init_query(query, left, right); } @@ -993,8 +955,7 @@ static inline BOOL toku__r_backwards(toku_interval* range) { /* Optimization: if all the pointers are equal, clearly left == right. */ return (BOOL) - ((left->key_payload != right->key_payload || - left->data_payload != right->data_payload) && + ((left->key_payload != right->key_payload) && toku__lt_point_cmp(left, right) > 0); } @@ -1002,53 +963,38 @@ static inline int toku__lt_unlock_deferred_txns(toku_lock_tree* tree); static inline void toku__lt_set_comparison_functions(toku_lock_tree* tree, DB* db) { - assert(!tree->db && !tree->compare_fun && !tree->dup_compare); + assert(!tree->db && !tree->compare_fun); tree->db = db; tree->compare_fun = tree->get_compare_fun_from_db(tree->db); assert(tree->compare_fun); - tree->dup_compare = tree->get_dup_compare_from_db(tree->db); - assert(tree->dup_compare); } static inline void toku__lt_clear_comparison_functions(toku_lock_tree* tree) { assert(tree); tree->db = NULL; tree->compare_fun = NULL; - tree->dup_compare = NULL; } /* Preprocess step for acquire functions. */ static inline int toku__lt_preprocess(toku_lock_tree* tree, DB* db, __attribute__((unused)) TXNID txn, - const DBT* key_left, const DBT** pdata_left, - const DBT* key_right, const DBT** pdata_right, + const DBT* key_left, + const DBT* key_right, toku_point* left, toku_point* right, toku_interval* query, BOOL* out_of_locks) { int r = ENOSYS; - assert(pdata_left && pdata_right); if (!tree || !db || !key_left || !key_right || !out_of_locks) {r = EINVAL; goto cleanup; } - if (!tree->duplicates) *pdata_right = *pdata_left = NULL; - const DBT* data_left = *pdata_left; - const DBT* data_right = *pdata_right; - if (tree->duplicates && (!data_left || !data_right)) { r = EINVAL; goto cleanup; } - if (tree->duplicates && key_left != data_left && - toku__lt_is_infinite(key_left)) { r = EINVAL; goto cleanup; } - if (tree->duplicates && key_right != data_right && - toku__lt_is_infinite(key_right)) { r = EINVAL; goto cleanup; } /* Verify that NULL keys have payload and size that are mutually consistent*/ if ((r = toku__lt_verify_null_key(key_left)) != 0) { goto cleanup; } - if ((r = toku__lt_verify_null_key(data_left)) != 0) { goto cleanup; } if ((r = toku__lt_verify_null_key(key_right)) != 0) { goto cleanup; } - if ((r = toku__lt_verify_null_key(data_right)) != 0) { goto cleanup; } - toku__init_point(left, tree, key_left, data_left); - toku__init_point(right, tree, key_right, data_right); + toku__init_point(left, tree, key_left); + toku__init_point(right, tree, key_right); toku__init_query(query, left, right); - tree->settings_final = TRUE; toku__lt_set_comparison_functions(tree, db); @@ -1058,7 +1004,7 @@ static inline int toku__lt_preprocess(toku_lock_tree* tree, DB* db, r = 0; cleanup: if (r == 0) { - assert(tree->db && tree->compare_fun && tree->dup_compare); + assert(tree->db && tree->compare_fun); /* Cleanup all existing deleted transactions */ if (!toku_rth_is_empty(tree->txns_to_unlock)) { r = toku__lt_unlock_deferred_txns(tree); @@ -1204,18 +1150,17 @@ static inline int toku__lt_borderwrite_insert(toku_lock_tree* tree, } /* TODO: Investigate better way of passing comparison functions. */ -int toku_lt_create(toku_lock_tree** ptree, BOOL duplicates, +int toku_lt_create(toku_lock_tree** ptree, int (*panic)(DB*, int), toku_ltm* mgr, toku_dbt_cmp (*get_compare_fun_from_db)(DB*), - toku_dbt_cmp (*get_dup_compare_from_db)(DB*), void* (*user_malloc) (size_t), void (*user_free) (void*), void* (*user_realloc)(void*, size_t)) { int r = ENOSYS; toku_lock_tree* tmp_tree = NULL; if (!ptree || !mgr || - !get_compare_fun_from_db || !get_dup_compare_from_db || !panic || + !get_compare_fun_from_db || !panic || !user_malloc || !user_free || !user_realloc) { r = EINVAL; goto cleanup; } @@ -1223,14 +1168,12 @@ int toku_lt_create(toku_lock_tree** ptree, BOOL duplicates, tmp_tree = (toku_lock_tree*)user_malloc(sizeof(*tmp_tree)); if (!tmp_tree) { r = ENOMEM; goto cleanup; } memset(tmp_tree, 0, sizeof(toku_lock_tree)); - tmp_tree->duplicates = duplicates; tmp_tree->panic = panic; tmp_tree->mgr = mgr; tmp_tree->malloc = user_malloc; tmp_tree->free = user_free; tmp_tree->realloc = user_realloc; tmp_tree->get_compare_fun_from_db = get_compare_fun_from_db; - tmp_tree->get_dup_compare_from_db = get_dup_compare_from_db; tmp_tree->lock_escalation_allowed = TRUE; r = toku_ltm_get_max_locks_per_db(mgr, &tmp_tree->max_locks); if (r!=0) { goto cleanup; } @@ -1285,17 +1228,11 @@ void toku_ltm_invalidate_lt(toku_ltm* mgr, DICTIONARY_ID dict_id) { static inline void toku_lt_set_dict_id(toku_lock_tree* lt, DICTIONARY_ID dict_id) { assert(lt && dict_id.dictid != DICTIONARY_ID_NONE.dictid); - assert(!lt->settings_final); lt->dict_id = dict_id; } -static inline BOOL toku_lt_get_dups(toku_lock_tree* lt) { - assert(lt); - return lt->duplicates; -} - int toku_ltm_get_lt(toku_ltm* mgr, toku_lock_tree** ptree, - BOOL duplicates, DICTIONARY_ID dict_id) { + DICTIONARY_ID dict_id) { /* first look in hash table to see if lock tree exists for that db, if so return it */ int r = ENOSYS; @@ -1309,15 +1246,13 @@ int toku_ltm_get_lt(toku_ltm* mgr, toku_lock_tree** ptree, /* Load already existing lock tree. */ assert (map->tree != NULL); *ptree = map->tree; - assert(duplicates == toku_lt_get_dups(map->tree)); toku_lt_add_ref(*ptree); r = 0; goto cleanup; } /* Must create new lock tree for this dict_id*/ - r = toku_lt_create(&tree, duplicates, mgr->panic, mgr, + r = toku_lt_create(&tree, mgr->panic, mgr, mgr->get_compare_fun_from_db, - mgr->get_dup_compare_from_db, mgr->malloc, mgr->free, mgr->realloc); if (r != 0) { goto cleanup; } toku_lt_set_dict_id(tree, dict_id); @@ -1383,15 +1318,15 @@ cleanup: // toku_lt_acquire_read_lock() used only by test programs int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key, const DBT* data) { - return toku_lt_acquire_range_read_lock(tree, db, txn, key, data, key, data); + const DBT* key) { + return toku_lt_acquire_range_read_lock(tree, db, txn, key, key); } static int toku__lt_try_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key_left, const DBT* data_left, - const DBT* key_right, const DBT* data_right, + const DBT* key_left, + const DBT* key_right, BOOL* out_of_locks) { int r; toku_point left; @@ -1401,8 +1336,8 @@ static int toku__lt_try_acquire_range_read_lock(toku_lock_tree* tree, if (!out_of_locks) { return EINVAL; } r = toku__lt_preprocess(tree, db, txn, - key_left, &data_left, - key_right, &data_right, + key_left, + key_right, &left, &right, &query, out_of_locks); if (r!=0) { goto cleanup; } @@ -1755,15 +1690,15 @@ cleanup: } int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key_left, const DBT* data_left, - const DBT* key_right, const DBT* data_right) { + const DBT* key_left, + const DBT* key_right) { BOOL out_of_locks = FALSE; int r = ENOSYS; r = toku__lt_try_acquire_range_read_lock(tree, db, txn, - key_left, data_left, - key_right, data_right, - &out_of_locks); + key_left, + key_right, + &out_of_locks); if (r != 0) { goto cleanup; } if (out_of_locks) { @@ -1777,8 +1712,8 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, } r = toku__lt_try_acquire_range_read_lock(tree, db, txn, - key_left, data_left, - key_right, data_right, + key_left, + key_right, &out_of_locks); if (r != 0) { goto cleanup; } } @@ -1828,7 +1763,7 @@ cleanup: static int toku__lt_try_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key, const DBT* data, + const DBT* key, BOOL* out_of_locks) { int r = ENOSYS; toku_point endpoint; @@ -1837,8 +1772,8 @@ static int toku__lt_try_acquire_write_lock(toku_lock_tree* tree, BOOL free_left = FALSE; r = toku__lt_preprocess(tree, db, txn, - key, &data, - key, &data, + key, + key, &endpoint, &endpoint, &query, out_of_locks); if (r!=0) { goto cleanup; } @@ -1898,13 +1833,13 @@ cleanup: // toku_lt_acquire_write_lock() used only by test programs int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key, const DBT* data) { + const DBT* key) { BOOL out_of_locks = FALSE; int r = ENOSYS; r = toku__lt_try_acquire_write_lock(tree, db, txn, - key, data, - &out_of_locks); + key, + &out_of_locks); if (r != 0) { goto cleanup; } if (out_of_locks) { @@ -1918,8 +1853,8 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, } r = toku__lt_try_acquire_write_lock(tree, db, txn, - key, data, - &out_of_locks); + key, + &out_of_locks); if (r != 0) { goto cleanup; } } if (out_of_locks) { @@ -1933,27 +1868,26 @@ cleanup: } static int toku__lt_try_acquire_range_write_lock(toku_lock_tree* tree, - DB* db, TXNID txn, - const DBT* key_left, const DBT* data_left, - const DBT* key_right, const DBT* data_right, - BOOL* out_of_locks) { + DB* db, TXNID txn, + const DBT* key_left, + const DBT* key_right, + BOOL* out_of_locks) { int r; toku_point left; toku_point right; toku_interval query; - if (key_left == key_right && - (data_left == data_right || (tree && !tree->duplicates))) { + if (key_left == key_right) { return toku__lt_try_acquire_write_lock(tree, db, txn, - key_left, data_left, + key_left, out_of_locks); } r = toku__lt_preprocess(tree, db, txn, - key_left, &data_left, - key_right, &data_right, - &left, &right, - &query, out_of_locks); + key_left, + key_right, + &left, &right, + &query, out_of_locks); if (r!=0) { goto cleanup; } if (tree->table_is_locked) { @@ -1981,15 +1915,15 @@ cleanup: } int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key_left, const DBT* data_left, - const DBT* key_right, const DBT* data_right) { + const DBT* key_left, + const DBT* key_right) { BOOL out_of_locks = FALSE; int r = ENOSYS; r = toku__lt_try_acquire_range_write_lock(tree, db, txn, - key_left, data_left, - key_right, data_right, - &out_of_locks); + key_left, + key_right, + &out_of_locks); if (r != 0) { goto cleanup; } if (out_of_locks) { @@ -2003,9 +1937,9 @@ int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, } r = toku__lt_try_acquire_range_write_lock(tree, db, txn, - key_left, data_left, - key_right, data_right, - &out_of_locks); + key_left, + key_right, + &out_of_locks); if (r != 0) { goto cleanup; } } if (out_of_locks) { diff --git a/src/lock_tree/locktree.h b/src/lock_tree/locktree.h index 2a879eef624..b88e8e4311c 100644 --- a/src/lock_tree/locktree.h +++ b/src/lock_tree/locktree.h @@ -60,10 +60,6 @@ typedef struct __toku_ltm toku_ltm; struct __toku_lock_tree { /** The database for which this locktree will be handling locks */ DB* db; - /** Whether the db supports duplicate */ - BOOL duplicates; - /** Whether the duplicates flag can no longer be changed. */ - BOOL settings_final; toku_range_tree* mainread; /**< See design document */ toku_range_tree* borderwrite; /**< See design document */ toku_rth* rth; /**< Stores local(read|write)set tables */ @@ -93,7 +89,7 @@ struct __toku_lock_tree { also owned by lt. We gave a pointer only to this memory to the range tree earlier when we inserted a range, but the range tree does not own it! - - tree->buf[i].{left,right}.{key_payload,data_payload} is owned by + - tree->buf[i].{left,right}.key_payload is owned by the lt, we made copies from the DB at some point */ toku_range* buf; @@ -104,12 +100,8 @@ struct __toku_lock_tree { toku_ltm* mgr; /** Function to retrieve the key compare function from the database. */ toku_dbt_cmp (*get_compare_fun_from_db)(DB*); - /** Function to retrieve the data compare function from the database. */ - toku_dbt_cmp (*get_dup_compare_from_db)(DB*); /** The key compare function */ int (*compare_fun)(DB*,const DBT*,const DBT*); - /** The data compare function */ - int (*dup_compare)(DB*,const DBT*,const DBT*); /** The panic function */ int (*panic)(DB*, int); /** The user malloc function */ @@ -163,8 +155,6 @@ struct __toku_ltm { toku_idlth* idlth; /** Function to retrieve the key compare function from the database. */ toku_dbt_cmp (*get_compare_fun_from_db)(DB*); - /** Function to retrieve the data compare function from the database. */ - toku_dbt_cmp (*get_dup_compare_from_db)(DB*); /** The panic function */ int (*panic)(DB*, int); /** The user malloc function */ @@ -196,8 +186,6 @@ struct __toku_point { is defined */ void* key_payload; /**< The key ... */ u_int32_t key_len; /**< and its length */ - void* data_payload; /**< The data ... */ - u_int32_t data_len; /**< and its length */ }; #if !defined(__TOKU_POINT) #define __TOKU_POINT @@ -208,9 +196,7 @@ typedef struct __toku_point toku_point; Create a lock tree. Should be called only inside DB->open. \param ptree We set *ptree to the newly allocated tree. - \param duplicates Whether the db supports duplicates. \param get_compare_fun_from_db Accessor for the key compare function. - \param get_dup_compare_from_db Accessor for the data compare function. \param panic The function to cause the db to panic. i.e., godzilla_rampage() \param payload_capacity The maximum amount of memory to use for dbt payloads. @@ -231,11 +217,10 @@ typedef struct __toku_point toku_point; If this library is ever exported to users, we will use error datas instead. */ -int toku_lt_create(toku_lock_tree** ptree, BOOL duplicates, +int toku_lt_create(toku_lock_tree** ptree, int (*panic)(DB*, int), toku_ltm* mgr, toku_dbt_cmp (*get_compare_fun_from_db)(DB*), - toku_dbt_cmp (*get_dup_compare_from_db)(DB*), void* (*user_malloc) (size_t), void (*user_free) (void*), void* (*user_realloc)(void*, size_t)); @@ -244,7 +229,7 @@ int toku_lt_create(toku_lock_tree** ptree, BOOL duplicates, Gets a lock tree for a given DB with id dict_id */ int toku_ltm_get_lt(toku_ltm* mgr, toku_lock_tree** ptree, - BOOL duplicates, DICTIONARY_ID dict_id); + DICTIONARY_ID dict_id); void toku_ltm_invalidate_lt(toku_ltm* mgr, DICTIONARY_ID dict_id); @@ -285,11 +270,7 @@ int toku_lt_close(toku_lock_tree* tree); memory allowed for payloads. The following is asserted: - (tree == NULL || txn == NULL || key == NULL) or - (tree->db is dupsort && data == NULL) or - (tree->db is dupsort && key != data && - (key == toku_lt_infinity || - (toku_lock_tree* tree, TXNID txn, const DBT* key, const DBT* data); + (tree == NULL || txn == NULL || key == NULL); If this library is ever exported to users, we will use EINVAL instead. In BDB, txn can actually be NULL (mixed operations with transactions and @@ -297,7 +278,7 @@ int toku_lt_close(toku_lock_tree* tree); to verify that MySQL does or does not use this. */ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key, const DBT* data); + const DBT* key); /* Acquires a read lock on a key range (or key/data range). (Closed range). @@ -306,19 +287,15 @@ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, \param txn The TOKU Transaction this lock is for. Note that txn == NULL is not supported at this time. \param key_left The left end key of the range. - \param data_left The left end data of the range. \param key_right The right end key of the range. - \param data_right The right end data of the range. \return - 0 Success. - DB_LOCK_NOTGRANTED If there is a conflict in getting the lock. This can only happen if some other transaction has a write lock that overlaps this range. - - EDOM In a DB_DUPSORT db: - If (key_left, data_left) > (key_right, data_right) or - In a nodup db: if (key_left) > (key_right) - (According to the db's comparison functions.) + - EDOM if (key_left) > (key_right) + (According to the db's comparison function.) - ENOMEM If adding the lock would exceed the maximum memory allowed for payloads. @@ -326,14 +303,6 @@ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, EINVAL should be used instead: If (tree == NULL || txn == NULL || key_left == NULL || key_right == NULL) or - (tree->db is dupsort && - (data_left == NULL || data_right == NULL)) or - (tree->db is dupsort && key_left != data_left && - (key_left == toku_lt_infinity || - key_left == toku_lt_neg_infinity)) or - (tree->db is dupsort && key_right != data_right && - (key_right == toku_lt_infinity || - key_right == toku_lt_neg_infinity)) Memory: It is safe to free keys and datas after this call. If the lock tree needs to hold onto the key or data, it will make copies @@ -344,8 +313,8 @@ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, to verify that MySQL does or does not use this. */ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key_left, const DBT* data_left, - const DBT* key_right, const DBT* data_right); + const DBT* key_left, + const DBT* key_right); /** Acquires a write lock on a single key (or key/data). @@ -366,10 +335,7 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, The following is asserted, but if this library is ever exported to users, EINVAL should be used instead: - If (tree == NULL || txn == NULL || key == NULL) or - (tree->db is dupsort && data == NULL) or - (tree->db is dupsort && key != data && - (key == toku_lt_infinity || key == toku_lt_neg_infinity)) + If (tree == NULL || txn == NULL || key == NULL) Memory: It is safe to free keys and datas after this call. @@ -377,7 +343,7 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, to its local memory. */ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key, const DBT* data); + const DBT* key); //In BDB, txn can actually be NULL (mixed operations with transactions and no transactions). //This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use @@ -393,8 +359,6 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, * txn The TOKU Transaction this lock is for. * key_left The left end key of the range. * key_right The right end key of the range. - * data_left The left end data of the range. - * data_right The right end data of the range. * Returns: * 0 Success. * DB_LOCK_NOTGRANTED If there is a conflict in getting the lock. @@ -402,18 +366,7 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, * a write (or read) lock that overlaps this range. * EINVAL If (tree == NULL || txn == NULL || * key_left == NULL || key_right == NULL) or - * (tree->db is dupsort && - * (data_left == NULL || data_right == NULL)) or - or - * (tree->db is dupsort && key_left != data_left && - * (key_left == toku_lt_infinity || - * key_left == toku_lt_neg_infinity)) or - * (tree->db is dupsort && key_right != data_right && - * (key_right == toku_lt_infinity || - * key_right == toku_lt_neg_infinity)) - * ERANGE In a DB_DUPSORT db: - * If (key_left, data_left) > (key_right, data_right) or - * In a nodup db: if (key_left) > (key_right) + * ERANGE If (key_left) > (key_right) * (According to the db's comparison functions. * ENOSYS THis is not yet implemented. Till it is, it will return ENOSYS, * if other errors do not occur first. @@ -429,8 +382,8 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, * *** Note that txn == NULL is not supported at this time. */ int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, - const DBT* key_left, const DBT* data_left, - const DBT* key_right, const DBT* data_right); + const DBT* key_left, + const DBT* key_right); //In BDB, txn can actually be NULL (mixed operations with transactions and no transactions). //This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use @@ -469,7 +422,6 @@ int toku_ltm_create(toku_ltm** pmgr, u_int32_t max_locks, int (*panic)(DB*, int), toku_dbt_cmp (*get_compare_fun_from_db)(DB*), - toku_dbt_cmp (*get_dup_compare_from_db)(DB*), void* (*user_malloc) (size_t), void (*user_free) (void*), void* (*user_realloc)(void*, size_t)); diff --git a/src/lock_tree/tests/test_00000_createclose.c b/src/lock_tree/tests/test_00000_createclose.c index f01cd1f8f66..bdc3a1c3164 100644 --- a/src/lock_tree/tests/test_00000_createclose.c +++ b/src/lock_tree/tests/test_00000_createclose.c @@ -5,16 +5,15 @@ int main(void) { toku_lock_tree* lt = NULL; toku_ltm* mgr = NULL; u_int32_t max_locks = 1000; - BOOL duplicates; r = toku_ltm_create(&mgr, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); - for (duplicates = FALSE; duplicates < TRUE; duplicates++) { - r = toku_lt_create(<, duplicates, dbpanic, mgr, - get_compare_fun_from_db, get_dup_compare_from_db, + { + r = toku_lt_create(<, dbpanic, mgr, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(lt); diff --git a/src/lock_tree/tests/test_00010_parameter_errors.c b/src/lock_tree/tests/test_00010_parameter_errors.c index eb530428891..203f02d091e 100644 --- a/src/lock_tree/tests/test_00010_parameter_errors.c +++ b/src/lock_tree/tests/test_00010_parameter_errors.c @@ -3,114 +3,49 @@ #include "test.h" static DBT _key; -static DBT _data; DBT* key; -DBT* data; u_int32_t max_locks = 1000; toku_ltm* ltm = NULL; static void do_range_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, - const DBT*, const DBT*, - const DBT*, const DBT*)) { + const DBT*, + const DBT*)) { int r; toku_lock_tree* lt = NULL; DB* db = (DB*)1; TXNID txn = (TXNID)1; // Fake. - BOOL duplicates = FALSE; DBT _key_l = _key; DBT _key_r = _key; - DBT _data_l = _data; - DBT _data_r = _data; DBT* key_l = &_key_l; DBT* key_r = &_key_r; - DBT* data_l; - DBT* data_r; - DBT* reverse_data_l; - DBT* reverse_data_r; - for (duplicates = FALSE; duplicates < TRUE; duplicates++) { - if (duplicates) { - data_l = &_data_l; - data_r = &_data_r; - reverse_data_l = NULL; - reverse_data_r = NULL; - } - else { - data_l = NULL; - data_r = NULL; - reverse_data_l = &_data_l; - reverse_data_r = &_data_r; - } - r = toku_lt_create(<, duplicates, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + { + r = toku_lt_create(<, dbpanic, ltm, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(lt); if (acquire == toku_lt_acquire_range_write_lock) { - r = acquire(lt, db, txn, key_l, data_l, - key_r, data_r); + r = acquire(lt, db, txn, key_l, key_r); CKERR2(r, ENOSYS); } - r = acquire(NULL, db, txn, key_l, data_l, - key_r, data_r); + r = acquire(NULL, db, txn, key_l, key_r); CKERR2(r, EINVAL); - r = acquire(lt, db, txn, NULL, data_l, - key_r, data_r); + r = acquire(lt, db, txn, NULL, key_r); CKERR2(r, EINVAL); - if (duplicates) { - r = acquire(lt, db, txn, key_l, reverse_data_l, - key_r, data_r); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, key_l, data_l, - key_r, reverse_data_r); - CKERR2(r, EINVAL); - } - r = acquire(lt, db, txn, key_l, data_l, - NULL, data_r); + r = acquire(lt, db, txn, key_l, NULL); CKERR2(r, EINVAL); - /* Infinite tests. */ - if (duplicates) { - r = acquire(lt, db, txn, toku_lt_infinity, data_l, - key_r, data_r); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, toku_lt_neg_infinity, data_l, - key_r, data_r); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, key_l, data_l, - toku_lt_infinity, data_r); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, key_l, data_l, - toku_lt_neg_infinity, data_r); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, toku_lt_infinity, toku_lt_neg_infinity, - key_r, data_r); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, toku_lt_neg_infinity, toku_lt_infinity, - key_r, data_r); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, key_l, data_l, - toku_lt_infinity, toku_lt_neg_infinity); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, key_l, data_l, - toku_lt_neg_infinity, toku_lt_infinity); - CKERR2(r, EINVAL); - } /* left > right tests. */ - const DBT* d_inf = duplicates ? toku_lt_infinity : NULL; const DBT* inf = toku_lt_infinity; - const DBT* d_ninf = duplicates ? toku_lt_neg_infinity : NULL; const DBT* ninf = toku_lt_neg_infinity; - r = acquire(lt, db, txn, inf, d_inf, - key_r, data_r); + r = acquire(lt, db, txn, inf, key_r); CKERR2(r, EDOM); - r = acquire(lt, db, txn, key_l, data_l, - ninf, d_ninf); + r = acquire(lt, db, txn, key_l, ninf); CKERR2(r, EDOM); - r = acquire(lt, db, txn, inf, d_inf, - ninf, d_ninf); + r = acquire(lt, db, txn, inf, ninf); CKERR2(r, EDOM); /* Cleanup. */ @@ -122,29 +57,19 @@ static void do_range_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, } static void do_point_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, - const DBT*, const DBT*)) { + const DBT*)) { int r; toku_lock_tree* lt = NULL; TXNID txn = (TXNID)1; // Fake. DB* db = (DB*)0x1; - BOOL duplicates = FALSE; lt = NULL; - DBT* reverse_data; /* Point read tests. */ key = &_key; - for (duplicates = FALSE; duplicates < TRUE; duplicates++) { - if (duplicates) { - data = &_data; - reverse_data = NULL; - } - else { - reverse_data = &_data; - data = NULL; - } - r = toku_lt_create(<, duplicates, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + { + r = toku_lt_create(<, dbpanic, ltm, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(lt); @@ -152,29 +77,12 @@ static void do_point_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, r = toku_lt_unlock(NULL, (TXNID)1); CKERR2(r, EINVAL); - r = acquire(NULL, db, txn, key, data); + r = acquire(NULL, db, txn, key); CKERR2(r, EINVAL); - r = acquire(lt, db, txn, NULL, data); + r = acquire(lt, db, txn, NULL); CKERR2(r, EINVAL); - if (duplicates) { - r = acquire(lt, db, txn, key, reverse_data); - CKERR2(r, EINVAL); - } - - /* Infinite tests. */ - if (duplicates) { - r = acquire(lt, db, txn, toku_lt_infinity, data); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, toku_lt_neg_infinity, data); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, toku_lt_infinity, toku_lt_neg_infinity); - CKERR2(r, EINVAL); - r = acquire(lt, db, txn, toku_lt_neg_infinity, toku_lt_infinity); - CKERR2(r, EINVAL); - } - /* Cleanup. */ r = toku_lt_close(lt); CKERR(r); @@ -188,37 +96,36 @@ int main(int argc, const char *argv[]) { int r; toku_lock_tree* lt = NULL; - BOOL duplicates = FALSE; r = toku_ltm_create(NULL, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR2(r, EINVAL); assert(ltm == NULL); r = toku_ltm_create(<m, 0, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR2(r, EINVAL); assert(ltm == NULL); r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, NULL, toku_free, toku_realloc); CKERR2(r, EINVAL); assert(ltm == NULL); r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, NULL, toku_realloc); CKERR2(r, EINVAL); assert(ltm == NULL); r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, NULL); CKERR2(r, EINVAL); assert(ltm == NULL); /* Actually create it. */ r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(ltm); @@ -242,41 +149,37 @@ int main(int argc, const char *argv[]) { assert(get_max == max_locks); /* create tests. */ - for (duplicates = FALSE; duplicates < TRUE; duplicates++) { - r = toku_lt_create(NULL, duplicates, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + { + r = toku_lt_create(NULL, dbpanic, ltm, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR2(r, EINVAL); - r = toku_lt_create(<, duplicates, NULL, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + r = toku_lt_create(<, NULL, ltm, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR2(r, EINVAL); - r = toku_lt_create(<, duplicates, dbpanic, NULL, - get_compare_fun_from_db, get_dup_compare_from_db, + r = toku_lt_create(<, dbpanic, NULL, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR2(r, EINVAL); - r = toku_lt_create(<, duplicates, dbpanic, ltm, - NULL, get_dup_compare_from_db, + r = toku_lt_create(<, dbpanic, ltm, + NULL, toku_malloc, toku_free, toku_realloc); CKERR2(r, EINVAL); - r = toku_lt_create(<, duplicates, dbpanic, ltm, - get_compare_fun_from_db, NULL, - toku_malloc, toku_free, toku_realloc); - CKERR2(r, EINVAL); - r = toku_lt_create(<, duplicates, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + r = toku_lt_create(<, dbpanic, ltm, + get_compare_fun_from_db, NULL, toku_free, toku_realloc); CKERR2(r, EINVAL); - r = toku_lt_create(<, duplicates, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + r = toku_lt_create(<, dbpanic, ltm, + get_compare_fun_from_db, toku_malloc, NULL, toku_realloc); CKERR2(r, EINVAL); - r = toku_lt_create(<, duplicates, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + r = toku_lt_create(<, dbpanic, ltm, + get_compare_fun_from_db, toku_malloc, toku_free, NULL); CKERR2(r, EINVAL); } diff --git a/src/lock_tree/tests/test_00020_read.c b/src/lock_tree/tests/test_00020_read.c index 782418e5f1a..2c5c205baeb 100644 --- a/src/lock_tree/tests/test_00020_read.c +++ b/src/lock_tree/tests/test_00020_read.c @@ -26,36 +26,31 @@ toku_range* buf; unsigned buflen; unsigned numfound; -static void init_query(BOOL dups) { +static void init_query(void) { init_point(&qleft, lt); init_point(&qright, lt); qleft.key_payload = (void *) toku_lt_neg_infinity; qright.key_payload = (void *) toku_lt_infinity; - if (dups) { - qleft.data_payload = qleft.key_payload; - qright.data_payload = qright.key_payload; - } - memset(&query,0,sizeof(query)); query.left = &qleft; query.right = &qright; } -static void setup_tree(BOOL dups) { +static void setup_tree(void) { assert(!lt && !ltm); r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(ltm); - r = toku_lt_create(<, dups, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + r = toku_lt_create(<, dbpanic, ltm, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(lt); - init_query(dups); + init_query(); } static void close_tree(void) { @@ -79,33 +74,19 @@ static DBT* set_to_infty(DBT *dbt, int value) { } -static void lt_insert(BOOL dups, int key_l, int data_l, int key_r, int data_r) { +static void lt_insert(int key_l, int key_r) { DBT _key_left; DBT _key_right; - DBT _data_left; - DBT _data_right; DBT* key_left = &_key_left; DBT* key_right = &_key_right; - DBT* data_left = dups ? &_data_left : NULL; - DBT* data_right = dups ? &_data_right: NULL; key_left = set_to_infty(key_left, key_l); key_right = set_to_infty(key_right, key_r); - if (dups) { - if (key_left != &_key_left) data_left = key_left; - else data_left = set_to_infty(data_left, data_l); - if (key_right != &_key_right) data_right = key_right; - else data_right = set_to_infty(data_right, data_r); - assert(key_left && data_left); - assert(key_right && data_right); - } else { - data_left = data_right = NULL; - assert(key_left && !data_left); - assert(key_right && !data_right); - } + assert(key_left); + assert(key_right); - r = toku_lt_acquire_range_read_lock(lt, db, txn, key_left, data_left, - key_right, data_right); + r = toku_lt_acquire_range_read_lock(lt, db, txn, key_left, + key_right); CKERR(r); } @@ -126,23 +107,20 @@ static void setup_payload_len(void** payload, u_int32_t* len, int val) { } static void temporarily_fake_comparison_functions(void) { - assert(!lt->db && !lt->compare_fun && !lt->dup_compare); + assert(!lt->db && !lt->compare_fun); lt->db = db; lt->compare_fun = get_compare_fun_from_db(db); - lt->dup_compare = get_dup_compare_from_db(db); } static void stop_fake_comparison_functions(void) { - assert(lt->db && lt->compare_fun && lt->dup_compare); + assert(lt->db && lt->compare_fun); lt->db = NULL; lt->compare_fun = NULL; - lt->dup_compare = NULL; } -static void lt_find(BOOL dups, toku_range_tree* rt, - unsigned k, int key_l, int data_l, - int key_r, int data_r, - TXNID find_txn) { +static void lt_find(toku_range_tree* rt, + unsigned k, int key_l, int key_r, + TXNID find_txn) { temporarily_fake_comparison_functions(); r = toku_rt_find(rt, &query, 0, &buf, &buflen, &numfound); CKERR(r); @@ -151,16 +129,8 @@ temporarily_fake_comparison_functions(); toku_point left, right; init_point(&left, lt); setup_payload_len(&left.key_payload, &left.key_len, key_l); - if (dups) { - if (key_l < null) left.data_payload = left.key_payload; - else setup_payload_len(&left.data_payload, &left.data_len, data_l); - } init_point(&right, lt); setup_payload_len(&right.key_payload, &right.key_len, key_r); - if (dups) { - if (key_r < null) right.data_payload = right.key_payload; - else setup_payload_len(&right.data_payload, &right.data_len, data_r); - } unsigned i; for (i = 0; i < numfound; i++) { if (toku__lt_point_cmp(buf[i].ends.left, &left ) == 0 && @@ -173,42 +143,31 @@ cleanup: } -static void insert_1(BOOL dups, int key_l, int key_r, int data_l, int data_r, - const void* kl, const void* dl, const void* kr, const void* dr) { +static void insert_1(int key_l, int key_r, + const void* kl, const void* kr) { DBT _key_left; DBT _key_right; - DBT _data_left; - DBT _data_right; DBT* key_left = &_key_left; DBT* key_right = &_key_right; - DBT* data_left = dups ? &_data_left : NULL; - DBT* data_right = dups ? &_data_right: NULL; dbt_init (key_left, &nums[key_l], sizeof(nums[key_l])); dbt_init (key_right, &nums[key_r], sizeof(nums[key_r])); - if (dups) { - dbt_init(data_left, &nums[data_l], sizeof(nums[data_l])); - dbt_init(data_right, &nums[data_r], sizeof(nums[data_r])); - if (dl) data_left = (DBT*)dl; - if (dr) data_right = (DBT*)dr; - } if (kl) key_left = (DBT*)kl; if (kr) key_right = (DBT*)kr; - setup_tree(dups); - r = toku_lt_acquire_range_read_lock(lt, db, txn, key_left, data_left, - key_right, data_right); + setup_tree(); + r = toku_lt_acquire_range_read_lock(lt, db, txn, key_left, key_right); CKERR(r); close_tree(); - setup_tree(dups); - r = toku_lt_acquire_read_lock(lt, db, txn, key_left, data_left); + setup_tree(); + r = toku_lt_acquire_read_lock(lt, db, txn, key_left); CKERR(r); close_tree(); } -static void runtest(BOOL dups) { +static void runtest(void) { int i; const DBT* choices[3]; @@ -220,205 +179,192 @@ static void runtest(BOOL dups) { int b = i % 3; if (a > b) continue; - insert_1(dups, 3, 3, 7, 7, choices[a], choices[a], - choices[b], choices[b]); + insert_1(3, 3, choices[a], choices[b]); } toku_range_tree *rt; /* ************************************** */ - setup_tree(dups); + setup_tree(); /////BUG HERE MAYBE NOT CONSOLIDATING. - /*nodups: - [(3, 3), (7,7)] and [(4,4), (5,5)] - dups: - [(3, 3), (3,7)] and [(3,4), (3,5)] + /* + [3, 7] and [4, 5] */ - lt_insert(dups, - 3, 3, - dups ? 3 : 7, 7); - lt_insert(dups, - dups ? 3 : 4, 4, - dups ? 3 : 5, 5); + lt_insert(3, 7); + lt_insert(4, 5); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 1, - 3, 3, - dups ? 3 : 7, 7, + lt_find(rt, 1, + 3, + 7, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 1, - 3, 3, - dups ? 3 : 7, 7, + lt_find(rt, 1, + 3, + 7, txn); #endif close_tree(); /* ************************************** */ - setup_tree(dups); + setup_tree(); - /*nodups: - [(3, 3), (7,7)] and [(4,4), (5,5)] - dups: - [(3, 3), (3,7)] and [(3,4), (3,5)] + /* + [3, 7)] and [4, 5] */ - lt_insert(dups, - dups ? 3 : 4, 4, - dups ? 3 : 5, 5); - lt_insert(dups, - 3, 3, - dups ? 3 : 7, 7); + lt_insert(4, 5); + lt_insert(3, 7); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 1, - 3, 3, - dups ? 3 : 7, 7, + lt_find(rt, 1, + 3, + 7, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 1, - 3, 3, - dups ? 3 : 7, 7, + lt_find(rt, 1, + 3, + 7, txn); #endif rt = NULL; close_tree(); /* ************************************** */ - setup_tree(dups); - lt_insert(dups, 3, 3, 3, 3); - lt_insert(dups, 4, 4, 4, 4); - lt_insert(dups, 3, 3, 3, 3); + setup_tree(); + lt_insert(3, 3); + lt_insert(4, 4); + lt_insert(3, 3); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 2, 3, 3, 3, 3, txn); - lt_find(dups, rt, 2, 4, 4, 4, 4, txn); + lt_find(rt, 2, 3, 3, txn); + lt_find(rt, 2, 4, 4, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 2, 3, 3, 3, 3, txn); - lt_find(dups, rt, 2, 4, 4, 4, 4, txn); + lt_find(rt, 2, 3, 3, txn); + lt_find(rt, 2, 4, 4, txn); #endif rt = NULL; close_tree(); /* ************************************** */ - setup_tree(dups); + setup_tree(); for (i = 0; i < 20; i += 2) { - lt_insert(dups, i, 5, i + 1, 10); + lt_insert(i, i + 1); } rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); for (i = 0; i < 20; i += 2) { - lt_find(dups, rt, 10, i, 5, i + 1, 10, txn); + lt_find(rt, 10, i, i + 1, txn); } #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); for (i = 0; i < 20; i += 2) { - lt_find(dups, rt, 10, i, 5, i + 1, 10, txn); + lt_find(rt, 10, i, i + 1, txn); } #endif - lt_insert(dups, 0, neg_infinite, 20, infinite); + lt_insert(0, 20); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find( dups, rt, 1, 0, neg_infinite, 20, infinite, txn); + lt_find( rt, 1, 0, 20, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find( dups, rt, 1, 0, neg_infinite, 20, infinite, txn); + lt_find( rt, 1, 0, 20, txn); #endif rt = NULL; close_tree(); /* ************************************** */ - setup_tree(dups); - lt_insert(dups, 0, neg_infinite, 1, infinite); - lt_insert(dups, 1, neg_infinite, 2, infinite); + setup_tree(); + lt_insert(0, 1); + lt_insert(1, 2); - lt_insert(dups, 4, neg_infinite, 5, infinite); - lt_insert(dups, 3, neg_infinite, 4, infinite); + lt_insert(4, 5); + lt_insert(3, 4); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 2, 0, neg_infinite, 2, infinite, txn); - lt_find(dups, rt, 2, 3, neg_infinite, 5, infinite, txn); + lt_find(rt, 2, 0, 2, txn); + lt_find(rt, 2, 3, 5, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 2, 0, neg_infinite, 2, infinite, txn); - lt_find(dups, rt, 2, 3, neg_infinite, 5, infinite, txn); + lt_find(rt, 2, 0, 2, txn); + lt_find(rt, 2, 3, 5, txn); #endif - lt_insert(dups, 2, neg_infinite, 3, infinite); + lt_insert(2, 3); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 1, 0, neg_infinite, 5, infinite, txn); + lt_find(rt, 1, 0, 5, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 1, 0, neg_infinite, 5, infinite, txn); + lt_find(rt, 1, 0, 5, txn); #endif rt = NULL; close_tree(); /* ************************************** */ - setup_tree(dups); - lt_insert(dups, 1, neg_infinite, 3, infinite); - lt_insert(dups, 4, neg_infinite, 6, infinite); - lt_insert(dups, 2, neg_infinite, 5, infinite); + setup_tree(); + lt_insert(1, 3); + lt_insert(4, 6); + lt_insert(2, 5); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 1, 1, neg_infinite, 6, infinite, txn); + lt_find(rt, 1, 1, 6, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 1, 1, neg_infinite, 6, infinite, txn); + lt_find(rt, 1, 1, 6, txn); #endif close_tree(); - setup_tree(dups); - lt_insert(dups, neg_infinite, neg_infinite, 3, infinite); - lt_insert(dups, 4, neg_infinite, 5, infinite); - lt_insert(dups, 6, neg_infinite, 8, infinite); - lt_insert(dups, 2, neg_infinite, 7, infinite); + setup_tree(); + lt_insert(neg_infinite, 3); + lt_insert( 4, 5); + lt_insert( 6, 8); + lt_insert( 2, 7); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 1, neg_infinite, neg_infinite, 8, infinite, txn); + lt_find(rt, 1, neg_infinite, 8, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 1, neg_infinite, neg_infinite, 8, infinite, txn); + lt_find(rt, 1, neg_infinite, 8, txn); #endif close_tree(); - setup_tree(dups); - lt_insert(dups, 1, neg_infinite, 2, infinite); - lt_insert(dups, 3, neg_infinite, infinite, infinite); - lt_insert(dups, 2, neg_infinite, 3, infinite); + setup_tree(); + lt_insert(1, 2); + lt_insert(3, infinite); + lt_insert(2, 3); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 1, 1, neg_infinite, infinite, infinite, txn); + lt_find(rt, 1, 1, infinite, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 1, 1, neg_infinite, infinite, infinite, txn); + lt_find(rt, 1, 1, infinite, txn); #endif close_tree(); - setup_tree(dups); - lt_insert(dups, 1, neg_infinite, 2, infinite); - lt_insert(dups, 3, neg_infinite, 4, infinite); - lt_insert(dups, 5, neg_infinite, 6, infinite); - lt_insert(dups, 2, neg_infinite, 5, infinite); + setup_tree(); + lt_insert(1, 2); + lt_insert(3, 4); + lt_insert(5, 6); + lt_insert(2, 5); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 1, 1, neg_infinite, 6, infinite, txn); + lt_find(rt, 1, 1, 6, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 1, 1, neg_infinite, 6, infinite, txn); + lt_find(rt, 1, 1, 6, txn); #endif close_tree(); - setup_tree(dups); - lt_insert(dups, 1, neg_infinite, 2, infinite); - lt_insert(dups, 3, neg_infinite, 5, infinite); - lt_insert(dups, 2, neg_infinite, 4, infinite); + setup_tree(); + lt_insert(1, 2); + lt_insert(3, 5); + lt_insert(2, 4); rt = toku__lt_ifexist_selfread(lt, txn); assert(rt); - lt_find(dups, rt, 1, 1, neg_infinite, 5, infinite, txn); + lt_find(rt, 1, 1, 5, txn); #ifndef TOKU_RT_NOOVERLAPS rt = lt->mainread; assert(rt); - lt_find(dups, rt, 1, 1, neg_infinite, 5, infinite, txn); + lt_find(rt, 1, 1, 5, txn); #endif close_tree(); @@ -447,8 +393,7 @@ int main(int argc, const char *argv[]) { init_test(); - runtest(FALSE); - runtest(TRUE); + runtest(); close_test(); return 0; diff --git a/src/lock_tree/tests/test_00040_write.c b/src/lock_tree/tests/test_00040_write.c index c2092986342..a0eacb424f2 100644 --- a/src/lock_tree/tests/test_00040_write.c +++ b/src/lock_tree/tests/test_00040_write.c @@ -7,17 +7,12 @@ toku_lock_tree* lt = NULL; toku_ltm* ltm = NULL; DB* db = (DB*)1; u_int32_t max_locks = 1000; -BOOL duplicates = FALSE; int nums[100]; DBT _keys_left[2]; DBT _keys_right[2]; -DBT _datas_left[2]; -DBT _datas_right[2]; DBT* keys_left[2]; DBT* keys_right[2]; -DBT* datas_left [2]; -DBT* datas_right[2]; toku_point qleft, qright; toku_interval query; @@ -25,36 +20,31 @@ toku_range* buf; unsigned buflen; unsigned numfound; -static void init_query(BOOL dups) { +static void init_query(void) { init_point(&qleft, lt); init_point(&qright, lt); qleft.key_payload = (void *) toku_lt_neg_infinity; qright.key_payload = (void *) toku_lt_infinity; - if (dups) { - qleft.data_payload = qleft.key_payload; - qright.data_payload = qright.key_payload; - } - memset(&query,0,sizeof(query)); query.left = &qleft; query.right = &qright; } -static void setup_tree(BOOL dups) { +static void setup_tree(void) { assert(!lt && !ltm); r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(ltm); - r = toku_lt_create(<, dups, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + r = toku_lt_create(<, dbpanic, ltm, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(lt); - init_query(dups); + init_query(); } static void close_tree(void) { @@ -78,50 +68,37 @@ static DBT* set_to_infty(DBT *dbt, int value) { } -static void lt_insert(BOOL dups, int r_expect, char txn, int key_l, int data_l, - int key_r, int data_r, BOOL read_flag) { +static void lt_insert(int r_expect, char txn, int key_l, + int key_r, BOOL read_flag) { DBT _key_left; DBT _key_right; - DBT _data_left; - DBT _data_right; DBT* key_left = &_key_left; DBT* key_right = &_key_right; - DBT* data_left = dups ? &_data_left : NULL; - DBT* data_right = dups ? &_data_right: NULL; key_left = set_to_infty(key_left, key_l); key_right = set_to_infty(key_right, key_r); - if (dups) { - if (key_left != &_key_left) data_left = key_left; - else data_left = set_to_infty(data_left, data_l); - if (key_right != &_key_right) data_right = key_right; - else data_right = set_to_infty(data_right, data_r); - assert(key_left && data_left); - assert(!read_flag || (key_right && data_right)); - } else { - data_left = data_right = NULL; - assert(key_left && !data_left); - assert(!read_flag || (key_right && !data_right)); + { + assert(key_left); + assert(!read_flag || key_right); } TXNID local_txn = (TXNID) (size_t) txn; if (read_flag) r = toku_lt_acquire_range_read_lock(lt, db, local_txn, - key_left, data_left, - key_right, data_right); + key_left, + key_right); else - r = toku_lt_acquire_write_lock(lt, db, local_txn, key_left, data_left); + r = toku_lt_acquire_write_lock(lt, db, local_txn, key_left); CKERR2(r, r_expect); } -static void lt_insert_read(BOOL dups, int r_expect, char txn, int key_l, int data_l, - int key_r, int data_r) { - lt_insert(dups, r_expect, txn, key_l, data_l, key_r, data_r, TRUE); +static void lt_insert_read(int r_expect, char txn, int key_l, int key_r) { + lt_insert(r_expect, txn, key_l, key_r, TRUE); } -static void lt_insert_write(BOOL dups, int r_expect, char txn, int key_l, int data_l) { - lt_insert(dups, r_expect, txn, key_l, data_l, 0, 0, FALSE); +static void lt_insert_write(int r_expect, char txn, int key_l) { + lt_insert(r_expect, txn, key_l, 0, FALSE); } @@ -131,148 +108,148 @@ static void lt_unlock(char ctxn) { CKERR(retval); } -static void runtest(BOOL dups) { +static void runtest(void) { /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 1, 1); + setup_tree(); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 1); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 1, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 1); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_read (dups, 0, 'a', 1, 1, 1, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_read (0, 'a', 1, 1); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_read (dups, DB_LOCK_NOTGRANTED, 'b', 1, 1, 1, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_read (DB_LOCK_NOTGRANTED, 'b', 1, 1); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_read (dups, 0, 'b', 1, 1, 1, 1); - lt_insert_write(dups, DB_LOCK_NOTGRANTED, 'a', 1, 1); + setup_tree(); + lt_insert_read (0, 'b', 1, 1); + lt_insert_write(DB_LOCK_NOTGRANTED, 'a', 1); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 3, 1); - lt_insert_write(dups, 0, 'a', 4, 1); - lt_insert_write(dups, 0, 'a', 5, 1); - lt_insert_read (dups, DB_LOCK_NOTGRANTED, 'b', 2, 1, 4, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 3); + lt_insert_write(0, 'a', 4); + lt_insert_write(0, 'a', 5); + lt_insert_read (DB_LOCK_NOTGRANTED, 'b', 2, 4); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 3, 1); - lt_insert_write(dups, 0, 'a', 4, 1); - lt_insert_write(dups, 0, 'a', 5, 1); - lt_insert_write (dups, DB_LOCK_NOTGRANTED, 'b', 2, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 3); + lt_insert_write(0, 'a', 4); + lt_insert_write(0, 'a', 5); + lt_insert_write (DB_LOCK_NOTGRANTED, 'b', 2); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 4, 1); - lt_insert_write(dups, 0, 'a', 5, 1); - lt_insert_read (dups, 0, 'b', 3, 1, 3, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 4); + lt_insert_write(0, 'a', 5); + lt_insert_read (0, 'b', 3, 3); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 4, 1); - lt_insert_write(dups, 0, 'a', 5, 1); - lt_insert_read (dups, 0, 'b', 3, 1, 3, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 4); + lt_insert_write(0, 'a', 5); + lt_insert_read (0, 'b', 3, 3); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'b', 1, 1); - lt_insert_write(dups, 0, 'b', 2, 1); - lt_insert_write(dups, 0, 'b', 3, 1); - lt_insert_write(dups, 0, 'b', 4, 1); - lt_insert_write(dups, 0, 'a', 5, 1); - lt_insert_write(dups, 0, 'a', 6, 1); - lt_insert_write(dups, 0, 'a', 7, 1); - lt_insert_write(dups, 0, 'a', 8, 1); - lt_insert_write(dups, 0, 'a', 9, 1); - lt_insert_read (dups, DB_LOCK_NOTGRANTED, 'a', 3, 1, 7, 1); + setup_tree(); + lt_insert_write(0, 'b', 1); + lt_insert_write(0, 'b', 2); + lt_insert_write(0, 'b', 3); + lt_insert_write(0, 'b', 4); + lt_insert_write(0, 'a', 5); + lt_insert_write(0, 'a', 6); + lt_insert_write(0, 'a', 7); + lt_insert_write(0, 'a', 8); + lt_insert_write(0, 'a', 9); + lt_insert_read (DB_LOCK_NOTGRANTED, 'a', 3, 7); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'b', 1, 1); - lt_insert_write(dups, 0, 'b', 2, 1); - lt_insert_write(dups, 0, 'b', 3, 1); - lt_insert_write(dups, 0, 'b', 4, 1); - lt_insert_write(dups, 0, 'b', 5, 1); - lt_insert_write(dups, 0, 'b', 6, 1); - lt_insert_write(dups, 0, 'b', 7, 1); - lt_insert_write(dups, 0, 'b', 8, 1); - lt_insert_write(dups, 0, 'b', 9, 1); - lt_insert_read (dups, DB_LOCK_NOTGRANTED, 'a', 3, 1, 7, 1); + setup_tree(); + lt_insert_write(0, 'b', 1); + lt_insert_write(0, 'b', 2); + lt_insert_write(0, 'b', 3); + lt_insert_write(0, 'b', 4); + lt_insert_write(0, 'b', 5); + lt_insert_write(0, 'b', 6); + lt_insert_write(0, 'b', 7); + lt_insert_write(0, 'b', 8); + lt_insert_write(0, 'b', 9); + lt_insert_read (DB_LOCK_NOTGRANTED, 'a', 3, 7); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 3, 1); - lt_insert_write(dups, 0, 'a', 4, 1); - lt_insert_read (dups, 0, 'a', 3, 1, 7, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 3); + lt_insert_write(0, 'a', 4); + lt_insert_read (0, 'a', 3, 7); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'b', 1, 1); - lt_insert_write(dups, 0, 'b', 2, 1); - lt_insert_write(dups, 0, 'b', 3, 1); - lt_insert_write(dups, 0, 'b', 4, 1); - lt_insert_read (dups, DB_LOCK_NOTGRANTED, 'a', 3, 1, 7, 1); + setup_tree(); + lt_insert_write(0, 'b', 1); + lt_insert_write(0, 'b', 2); + lt_insert_write(0, 'b', 3); + lt_insert_write(0, 'b', 4); + lt_insert_read (DB_LOCK_NOTGRANTED, 'a', 3, 7); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 4, 1); - lt_insert_write(dups, 0, 'a', 5, 1); - lt_insert_write(dups, 0, 'a', 3, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 4); + lt_insert_write(0, 'a', 5); + lt_insert_write(0, 'a', 3); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'b', 4, 1); - lt_insert_write(dups, 0, 'b', 5, 1); - lt_insert_write(dups, 0, 'a', 3, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'b', 4); + lt_insert_write(0, 'b', 5); + lt_insert_write(0, 'a', 3); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 2, 1); - lt_insert_write(dups, 0, 'a', 3, 1); - lt_insert_write(dups, 0, 'a', 4, 1); - lt_insert_read (dups, DB_LOCK_NOTGRANTED, 'b', 3, 1, 3, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 2); + lt_insert_write(0, 'a', 3); + lt_insert_write(0, 'a', 4); + lt_insert_read (DB_LOCK_NOTGRANTED, 'b', 3, 3); lt_unlock('a'); - lt_insert_write(dups, 0, 'b', 3, 1); - lt_insert_read (dups, DB_LOCK_NOTGRANTED, 'a', 3, 1, 3, 1); + lt_insert_write(0, 'b', 3); + lt_insert_read (DB_LOCK_NOTGRANTED, 'a', 3, 3); lt_unlock('b'); - lt_insert_read (dups, 0, 'a', 3, 1, 3, 1); + lt_insert_read (0, 'a', 3, 3); close_tree(); /* ********************* */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 3, 1); - lt_insert_write(dups, 0, 'b', 2, 1); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 3); + lt_insert_write(0, 'b', 2); lt_unlock('b'); close_tree(); /* ********************* */ @@ -296,8 +273,7 @@ int main(int argc, const char *argv[]) { init_test(); - runtest(FALSE); - runtest(TRUE); + runtest(); close_test(); diff --git a/src/lock_tree/tests/test_00060_lock_escalation.c b/src/lock_tree/tests/test_00060_lock_escalation.c index 25f808b1007..98e08beb79e 100644 --- a/src/lock_tree/tests/test_00060_lock_escalation.c +++ b/src/lock_tree/tests/test_00060_lock_escalation.c @@ -12,12 +12,8 @@ int nums[10000]; DBT _keys_left[2]; DBT _keys_right[2]; -DBT _datas_left[2]; -DBT _datas_right[2]; DBT* keys_left[2] ; DBT* keys_right[2] ; -DBT* datas_left [2] ; -DBT* datas_right[2] ; toku_point qleft, qright; toku_interval query; @@ -25,36 +21,31 @@ toku_range* buf; unsigned buflen; unsigned numfound; -static void init_query(BOOL dups) { +static void init_query(void) { init_point(&qleft, lt); init_point(&qright, lt); qleft.key_payload = (void *) toku_lt_neg_infinity; qright.key_payload = (void *) toku_lt_infinity; - if (dups) { - qleft.data_payload = qleft.key_payload; - qright.data_payload = qright.key_payload; - } - memset(&query,0,sizeof(query)); query.left = &qleft; query.right = &qright; } -static void setup_tree(BOOL dups) { +static void setup_tree(void) { assert(!lt && !ltm); r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(ltm); - r = toku_lt_create(<, dups, dbpanic, ltm, - get_compare_fun_from_db, get_dup_compare_from_db, + r = toku_lt_create(<, dbpanic, ltm, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(lt); - init_query(dups); + init_query(); } static void close_tree(void) { @@ -78,50 +69,36 @@ static DBT* set_to_infty(DBT *dbt, int value) { } -static void lt_insert(BOOL dups, int r_expect, char txn, int key_l, int data_l, - int key_r, int data_r, BOOL read_flag) { +static void lt_insert(int r_expect, char txn, int key_l, int key_r, BOOL read_flag) { DBT _key_left; DBT _key_right; - DBT _data_left; - DBT _data_right; DBT* key_left = &_key_left; DBT* key_right = &_key_right; - DBT* data_left = dups ? &_data_left : NULL; - DBT* data_right = dups ? &_data_right: NULL; key_left = set_to_infty(key_left, key_l); key_right = set_to_infty(key_right, key_r); - if (dups) { - if (key_left != &_key_left) data_left = key_left; - else data_left = set_to_infty(data_left, data_l); - if (key_right != &_key_right) data_right = key_right; - else data_right = set_to_infty(data_right, data_r); - assert(key_left && data_left); - assert(!read_flag || (key_right && data_right)); - } else { - data_left = data_right = NULL; - assert(key_left && !data_left); - assert(!read_flag || (key_right && !data_right)); + { + assert(key_left); + assert(!read_flag || key_right); } TXNID local_txn = (TXNID) (size_t) txn; if (read_flag) r = toku_lt_acquire_range_read_lock(lt, db, local_txn, - key_left, data_left, - key_right, data_right); + key_left, + key_right); else - r = toku_lt_acquire_write_lock(lt, db, local_txn, key_left, data_left); + r = toku_lt_acquire_write_lock(lt, db, local_txn, key_left); CKERR2(r, r_expect); } -static void lt_insert_read(BOOL dups, int r_expect, char txn, int key_l, int data_l, - int key_r, int data_r) { - lt_insert(dups, r_expect, txn, key_l, data_l, key_r, data_r, TRUE); +static void lt_insert_read(int r_expect, char txn, int key_l, int key_r) { + lt_insert(r_expect, txn, key_l, key_r, TRUE); } -static void lt_insert_write(BOOL dups, int r_expect, char txn, int key_l, int data_l) { - lt_insert(dups, r_expect, txn, key_l, data_l, 0, 0, FALSE); +static void lt_insert_write(int r_expect, char txn, int key_l) { + lt_insert(r_expect, txn, key_l, 0, FALSE); } static void lt_unlock(char ctxn) { @@ -130,14 +107,14 @@ static void lt_unlock(char ctxn) { CKERR(retval); } -static void run_escalation_test(BOOL dups) { +static void run_escalation_test(void) { int i = 0; /* ******************** */ /* 1 transaction request 1000 write locks, make sure it succeeds*/ - setup_tree(dups); + setup_tree(); assert(lt->lock_escalation_allowed); for (i = 0; i < 1000; i++) { - lt_insert_write(dups, 0, 'a', i, i); + lt_insert_write(0, 'a', i); assert(lt->lock_escalation_allowed); } close_tree(); @@ -146,15 +123,15 @@ static void run_escalation_test(BOOL dups) { TXN A grabs 1 3 5 7 9 TXN B grabs 2 4 6 8 10 make sure lock escalation fails, and that we run out of locks */ - setup_tree(dups); + setup_tree(); // this should grab ten locks successfully for (i = 1; i < 10; i+=2) { - lt_insert_write(dups, 0, 'a', i, i); - lt_insert_write(dups, 0, 'b', i+1, i+1); + lt_insert_write(0, 'a', i); + lt_insert_write(0, 'b', i+1); } - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'a', 100, 100); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'b', 100, 100); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'c', 100, 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'a', 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'b', 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'c', 100); close_tree(); /* ******************** */ /* @@ -167,24 +144,24 @@ static void run_escalation_test(BOOL dups) { txn C grabs 60,70,80,90,100 lock escalation should work */ - setup_tree(dups); + setup_tree(); assert(lt->lock_escalation_allowed); // this should grab ten locks successfully for (i = 1; i < 10; i+=2) { - lt_insert_write(dups, 0, 'a', i, i); - lt_insert_write(dups, 0, 'b', i+1, i+1); + lt_insert_write(0, 'a', i); + lt_insert_write(0, 'b', i+1); } assert(lt->lock_escalation_allowed); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'a', 100, 100); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'b', 100, 100); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'c', 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'a', 100, 100, 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'b', 100, 100, 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'c', 100, 100, 100, 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'a', 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'b', 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'c', 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'a', 100, 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'b', 100, 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'c', 100, 100); lt_unlock('b'); assert(lt->lock_escalation_allowed); for (i = 50; i < 1000; i++) { - lt_insert_write(dups, 0, 'c', i, i); + lt_insert_write(0, 'c', i); assert(lt->lock_escalation_allowed); } close_tree(); @@ -195,25 +172,25 @@ static void run_escalation_test(BOOL dups) { txn C attempts to grab lock, escalation, and lock grab, should fail lock */ - setup_tree(dups); + setup_tree(); assert(lt->lock_escalation_allowed); // this should grab ten locks successfully for (i = 0; i < 10; i ++) { if (i == 2 || i == 5) { continue; } - lt_insert_write(dups, 0, 'a', i, i); + lt_insert_write(0, 'a', i); } - lt_insert_read (dups, 0, 'b', 5, 5, 5, 5); - lt_insert_read (dups, 0, 'b', 2, 2, 2, 2); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'a', 100, 100); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'b', 100, 100); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'c', 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'a', 100, 100, 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'b', 100, 100, 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'c', 100, 100, 100, 100); + lt_insert_read (0, 'b', 5, 5); + lt_insert_read (0, 'b', 2, 2); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'a', 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'b', 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'c', 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'a', 100, 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'b', 100, 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'c', 100, 100); lt_unlock('b'); assert(lt->lock_escalation_allowed); for (i = 50; i < 1000; i++) { - lt_insert_write(dups, 0, 'c', i, i); + lt_insert_write(0, 'c', i); assert(lt->lock_escalation_allowed); } close_tree(); @@ -225,56 +202,56 @@ static void run_escalation_test(BOOL dups) { txn C attempts to grab lock, escalation, and lock grab, should fail lock */ - setup_tree(dups); + setup_tree(); assert(lt->lock_escalation_allowed); // this should grab ten locks successfully for (i = 0; i < 7; i++) { - lt_insert_write(dups, 0, 'a', i, i); + lt_insert_write(0, 'a', i); } - lt_insert_read (dups, 0, 'b', 5, 5, 6, 6); - lt_insert_read (dups, 0, 'b', 2, 2, 3, 3); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'a', 100, 100); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'b', 100, 100); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'c', 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'a', 100, 100, 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'b', 100, 100, 100, 100); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'c', 100, 100, 100, 100); + lt_insert_read (0, 'b', 5, 6); + lt_insert_read (0, 'b', 2, 3); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'a', 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'b', 100); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'c', 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'a', 100, 100, 100, 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'b', 100, 100, 100, 100); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'c', 100, 100, 100, 100); lt_unlock('b'); assert(lt->lock_escalation_allowed); for (i = 50; i < 1000; i++) { - lt_insert_write(dups, 0, 'c', i, i); + lt_insert_write(0, 'c', i); assert(lt->lock_escalation_allowed); } close_tree(); #endif /* ******************** */ /* escalate on read lock, */ - setup_tree(dups); + setup_tree(); for (i = 0; i < 10; i++) { - lt_insert_write(dups, 0, 'a', i, i); + lt_insert_write(0, 'a', i); } - lt_insert_read(dups, 0, 'a', 10, 10, 10, 10); + lt_insert_read(0, 'a', 10, 10); close_tree(); /* ******************** */ /* escalate on read lock of different transaction. */ - setup_tree(dups); + setup_tree(); for (i = 0; i < 10; i++) { - lt_insert_write(dups, 0, 'a', i, i); + lt_insert_write(0, 'a', i); } - lt_insert_read(dups, 0, 'b', 10, 10, 10, 10); + lt_insert_read(0, 'b', 10, 10); close_tree(); /* ******************** */ /* txn A grabs write lock 0,9 txn A grabs read lock 1,2,3,4,5,6,7,8 txn B grabs write lock 11, 12, should succeed */ - setup_tree(dups); + setup_tree(); for (i = 1; i < 9; i++) { - lt_insert_read(dups, 0, 'a', i, i, i, i); + lt_insert_read(0, 'a', i, i); } - lt_insert_write(dups, 0, 'a', 0, 0); - lt_insert_write(dups, 0, 'a', 9, 9); + lt_insert_write(0, 'a', 0); + lt_insert_write(0, 'a', 9); for (i = 50; i < 1000; i++) { - lt_insert_write(dups, 0, 'b', i, i); + lt_insert_write(0, 'b', i); assert(lt->lock_escalation_allowed); } close_tree(); @@ -282,55 +259,55 @@ static void run_escalation_test(BOOL dups) { /* [1-A-5] [10-B-15] [20-A-25] BORDER WRITE [2B] [6C] [12A] [22A] READ LOCKS check that only last borderwrite range is escalated */ - setup_tree(dups); - lt_insert_write(dups, 0, 'a', 1, 1); - lt_insert_write(dups, 0, 'a', 5, 5); - lt_insert_write(dups, 0, 'b', 10, 10); - lt_insert_write(dups, 0, 'b', 15, 15); - lt_insert_write(dups, 0, 'a', 20, 20); - lt_insert_write(dups, 0, 'a', 23, 23); - lt_insert_write(dups, 0, 'a', 25, 25); + setup_tree(); + lt_insert_write(0, 'a', 1); + lt_insert_write(0, 'a', 5); + lt_insert_write(0, 'b', 10); + lt_insert_write(0, 'b', 15); + lt_insert_write(0, 'a', 20); + lt_insert_write(0, 'a', 23); + lt_insert_write(0, 'a', 25); - lt_insert_read(dups, 0, 'b', 2, 2, 2, 2); - lt_insert_read(dups, 0, 'a', 12, 12, 12, 12); - lt_insert_read(dups, 0, 'a', 22, 22, 22, 22); + lt_insert_read(0, 'b', 2, 2); + lt_insert_read(0, 'a', 12, 12); + lt_insert_read(0, 'a', 22, 22); - lt_insert_read(dups, 0, 'a', 100, 100, 100, 100); + lt_insert_read(0, 'a', 100, 100); - lt_insert_write(dups, DB_LOCK_NOTGRANTED, 'b', 24, 24); - lt_insert_write(dups, 0, 'a', 14, 14); - lt_insert_write(dups, 0, 'b', 4, 4); + lt_insert_write(DB_LOCK_NOTGRANTED, 'b', 24); + lt_insert_write(0, 'a', 14); + lt_insert_write(0, 'b', 4); close_tree(); /* ******************** */ /* Test read lock escalation, no writes. */ - setup_tree(dups); + setup_tree(); assert(lt->lock_escalation_allowed); for (i = 0; i < 1000; i ++) { - lt_insert_read (dups, 0, 'b', i, i, i, i); + lt_insert_read (0, 'b', i, i); } close_tree(); /* ******************** */ /* Test read lock escalation, writes of same kind. */ - setup_tree(dups); + setup_tree(); assert(lt->lock_escalation_allowed); - lt_insert_write(dups, 0, 'b', 5, 5); - lt_insert_write(dups, 0, 'b', 10, 10); + lt_insert_write(0, 'b', 5); + lt_insert_write(0, 'b', 10); for (i = 0; i < 1000; i ++) { - lt_insert_read (dups, 0, 'b', i, i, i, i); + lt_insert_read (0, 'b', i, i); } close_tree(); /* ******************** */ /* Test read lock escalation, writes of other kind. */ - setup_tree(dups); + setup_tree(); assert(lt->lock_escalation_allowed); - lt_insert_write(dups, 0, 'a', 0, 0); - lt_insert_write(dups, 0, 'b', 5, 5); - lt_insert_write(dups, 0, 'a', 7, 7); - lt_insert_write(dups, 0, 'c', 10, 10); - lt_insert_write(dups, 0, 'a', 13, 13); + lt_insert_write(0, 'a', 0); + lt_insert_write(0, 'b', 5); + lt_insert_write(0, 'a', 7); + lt_insert_write(0, 'c', 10); + lt_insert_write(0, 'a', 13); for (i = 0; i < 1000; i ++) { if (i % 5 == 0) { continue; } - lt_insert_read (dups, 0, 'a', i, i, i, i); + lt_insert_read (0, 'a', i, i); } close_tree(); /* ******************** */ @@ -341,28 +318,28 @@ static void run_escalation_test(BOOL dups) { lock */ /* - setup_tree(dups); + setup_tree(); assert(lt->lock_escalation_allowed); // this should grab ten locks successfully for (i = 0; i < 9; i ++) { if (i == 2 || i == 5) { continue; } - lt_insert_write(dups, 0, 'a', i*10, i*10); + lt_insert_write(0, 'a', i*10); } for (i = 0; i < 10; i++) { - lt_insert_read (dups, 0, 'b', 50+i, 50+i, 50+i, 50+i); + lt_insert_read (0, 'b', 50+i, 50+i); } - lt_insert_write(dups, 0, 'a', 9*10, 9*10); - lt_insert_read (dups, 0, 'b', 20, 20, 20, 20); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'a', 1000, 1000); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'b', 1000, 1000); - lt_insert_write(dups, TOKUDB_OUT_OF_LOCKS, 'c', 1000, 1000); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'a', 1000, 1000, 1000, 1000); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'b', 1000, 1000, 1000, 1000); - lt_insert_read(dups, TOKUDB_OUT_OF_LOCKS, 'c', 1000, 1000, 1000, 1000); + lt_insert_write(0, 'a', 9*10); + lt_insert_read (0, 'b', 20, 20); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'a', 1000); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'b', 1000); + lt_insert_write(TOKUDB_OUT_OF_LOCKS, 'c', 1000); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'a', 1000, 1000); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'b', 1000, 1000); + lt_insert_read(TOKUDB_OUT_OF_LOCKS, 'c', 1000, 1000); lt_unlock('b'); assert(lt->lock_escalation_allowed); for (i = 100; i < 1000; i++) { - lt_insert_write(dups, 0, 'c', i, i); + lt_insert_write(0, 'c', i); assert(lt->lock_escalation_allowed); } close_tree(); @@ -389,8 +366,7 @@ int main(int argc, const char *argv[]) { init_test(); - run_escalation_test(FALSE); - run_escalation_test(TRUE); + run_escalation_test(); close_test(); diff --git a/src/lock_tree/tests/test_00070_ltm.c b/src/lock_tree/tests/test_00070_ltm.c index 7cab0ae29ec..bc3536e2938 100644 --- a/src/lock_tree/tests/test_00070_ltm.c +++ b/src/lock_tree/tests/test_00070_ltm.c @@ -11,21 +11,20 @@ toku_lock_tree* lt [10] = {0}; toku_ltm* ltm = NULL; DB* db = (DB*)1; u_int32_t max_locks = 10; -BOOL duplicates = FALSE; int nums[10000]; static void setup_ltm(void) { assert(!ltm); r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(ltm); } -static void setup_tree(BOOL dups, size_t index, DICTIONARY_ID dict_id) { +static void setup_tree(size_t index, DICTIONARY_ID dict_id) { assert(!lt[index] && ltm); - r = toku_ltm_get_lt(ltm, <[index], dups, dict_id); + r = toku_ltm_get_lt(ltm, <[index], dict_id); CKERR(r); assert(lt[index]); } @@ -40,26 +39,26 @@ static void close_ltm(void) { ltm = NULL; } -static void run_test(BOOL dups) { +static void run_test(void) { DICTIONARY_ID dict_id1 = {1}; DICTIONARY_ID dict_id2 = {2}; DICTIONARY_ID dict_id3 = dict_id1; setup_ltm(); - setup_tree(dups, 0, dict_id1); - setup_tree(dups, 1, dict_id1); + setup_tree(0, dict_id1); + setup_tree(1, dict_id1); assert(lt[0] == lt[1]); - setup_tree(dups, 2, dict_id2); + setup_tree(2, dict_id2); assert(lt[0] != lt[2]); - setup_tree(dups, 3, dict_id3); + setup_tree(3, dict_id3); assert(lt[0] == lt[3]); toku_ltm_invalidate_lt(ltm, dict_id1); - setup_tree(dups, 4, dict_id1); + setup_tree(4, dict_id1); assert(lt[0] != lt[4]); - setup_tree(dups, 5, dict_id1); + setup_tree(5, dict_id1); assert(lt[0] != lt[5]); assert(lt[4] == lt[5]); @@ -75,8 +74,7 @@ int main(int argc, const char *argv[]) { CKERR(r); toku_os_mkdir(TESTDIR, S_IRWXU|S_IRWXG|S_IRWXO); - run_test(FALSE); - run_test(TRUE); + run_test(); return 0; } diff --git a/src/lock_tree/tests/test_00080_lt_refcount.c b/src/lock_tree/tests/test_00080_lt_refcount.c index df13c1f9a00..ec023c571ab 100644 --- a/src/lock_tree/tests/test_00080_lt_refcount.c +++ b/src/lock_tree/tests/test_00080_lt_refcount.c @@ -19,18 +19,18 @@ int nums[10000]; static void setup_ltm(void) { assert(!ltm); r = toku_ltm_create(<m, max_locks, dbpanic, - get_compare_fun_from_db, get_dup_compare_from_db, + get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc); CKERR(r); assert(ltm); } -static void db_open_tree(BOOL dups, size_t index, size_t db_id_index) { +static void db_open_tree(size_t index, size_t db_id_index) { assert((lt_refs[index] == 0 && !lts[index]) || (lt_refs[index] > 0 && lts[index])); assert(ltm); lt_refs[index]++; - r = toku_ltm_get_lt(ltm, <s[index], dups, dict_ids[db_id_index]); + r = toku_ltm_get_lt(ltm, <s[index], dict_ids[db_id_index]); CKERR(r); assert(lts[index]); } @@ -63,44 +63,44 @@ static void close_ltm(void) { ltm = NULL; } -static void run_test(BOOL dups) { +static void run_test(void) { setup_ltm(); //Start: /* ********************************************************************** */ //Open and close. - db_open_tree(dups, 0, 0); + db_open_tree(0, 0); db_close_tree(0); /* ********************************************************************** */ //Open with db and transaction, db closes first. - db_open_tree(dups, 0, 0); + db_open_tree(0, 0); txn_open_tree(0); db_close_tree(0); txn_close_tree(0); /* ********************************************************************** */ //Open with db and transaction, txn closes first. - db_open_tree(dups, 0, 0); + db_open_tree(0, 0); txn_open_tree(0); txn_close_tree(0); db_close_tree(0); /* ********************************************************************** */ //Open with multiple db handles. - db_open_tree(dups, 0, 0); - db_open_tree(dups, 0, 0); + db_open_tree(0, 0); + db_open_tree(0, 0); db_close_tree(0); db_close_tree(0); /* ********************************************************************** */ //Open with multiple db handles and txns. - db_open_tree(dups, 0, 0); + db_open_tree(0, 0); txn_open_tree(0); - db_open_tree(dups, 0, 0); + db_open_tree(0, 0); db_close_tree(0); db_close_tree(0); txn_close_tree(0); /* ********************************************************************** */ //Open with multiple db handles and txns. - db_open_tree(dups, 0, 0); - db_open_tree(dups, 0, 0); + db_open_tree(0, 0); + db_open_tree(0, 0); txn_open_tree(0); db_close_tree(0); db_close_tree(0); @@ -145,9 +145,7 @@ int main(int argc, const char *argv[]) { initial_setup(); - run_test(FALSE); - - run_test(TRUE); + run_test(); close_test(); return 0; diff --git a/src/tests/Makefile b/src/tests/Makefile index 3e9746e0909..355f753cdb2 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile @@ -207,7 +207,6 @@ BDB_BINS = $(patsubst %.c,%.bdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(BDB_DON endif TDB_TESTS_THAT_SHOULD_FAIL= \ - test944 \ test_truncate_txn_abort \ test_db_no_env \ #\ ends prev line diff --git a/src/tests/big-nested-commit-abort.c b/src/tests/big-nested-commit-abort.c index 2a8ee560684..d8c8b700972 100644 --- a/src/tests/big-nested-commit-abort.c +++ b/src/tests/big-nested-commit-abort.c @@ -89,7 +89,6 @@ setup (void) { env->set_errfile(env, stderr); r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUPSORT); r=env->txn_begin(env, 0, &txn, 0); assert(r==0); r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); diff --git a/src/tests/big-nested-commit-commit.c b/src/tests/big-nested-commit-commit.c index ff048b1e25d..46d7015fc35 100644 --- a/src/tests/big-nested-commit-commit.c +++ b/src/tests/big-nested-commit-commit.c @@ -82,6 +82,9 @@ setup (void) { r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=db_env_create(&env, 0); CKERR(r); +#ifdef TOKUDB + r=env->set_redzone(env, 0); CKERR(r); +#endif r=env->set_lk_max_locks(env, N); CKERR(r); #ifndef TOKUDB r=env->set_lk_max_objects(env, N); CKERR(r); @@ -89,7 +92,6 @@ setup (void) { env->set_errfile(env, stderr); r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUPSORT); r=env->txn_begin(env, 0, &txn, 0); assert(r==0); r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); diff --git a/src/tests/checkpoint_1.c b/src/tests/checkpoint_1.c index 8ea0fe46ac3..c8396c7e17e 100644 --- a/src/tests/checkpoint_1.c +++ b/src/tests/checkpoint_1.c @@ -162,12 +162,10 @@ test_main (int argc, char * const argv[]) { n = 0; for (snap = 0; snap < 2; snap++) { checkpoint_test_1(0, n, snap); - checkpoint_test_1(DB_DUP|DB_DUPSORT, n, snap); } for (n = 1; n <= 1<<9; n*= 2) { for (snap = 0; snap < 2; snap++) { checkpoint_test_1(0, n, snap); - checkpoint_test_1(DB_DUP|DB_DUPSORT, n, snap); } } diff --git a/src/tests/checkpoint_stress.c b/src/tests/checkpoint_stress.c index acf5e75f33b..24999599528 100644 --- a/src/tests/checkpoint_stress.c +++ b/src/tests/checkpoint_stress.c @@ -198,7 +198,7 @@ u_int64_t max_windows_cachesize = 256 << 20; static void run_test (int iter, int die) { - u_int32_t flags = DB_DUP|DB_DUPSORT; + u_int32_t flags = 0; int i; diff --git a/src/tests/checkpoint_test.h b/src/tests/checkpoint_test.h index cc1617c831b..569a43bc1b0 100644 --- a/src/tests/checkpoint_test.h +++ b/src/tests/checkpoint_test.h @@ -21,7 +21,7 @@ typedef struct { } DICTIONARY_S, *DICTIONARY; -static inline int64_t UU() +static inline int64_t generate_val(int64_t key) { int64_t val = key + 314; return val; @@ -103,8 +103,6 @@ static void UU() r = env->set_redzone(env, 0); CKERR(r); r = env->set_default_bt_compare(env, int64_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, int64_dbt_cmp); - CKERR(r); if (bytes) { r = env->set_cachesize(env, bytes >> 30, bytes % (1<<30), 1); CKERR(r); @@ -291,8 +289,8 @@ db_truncate(DB* db, DB_TXN *txn) { static void UU() insert_random(DB *db1, DB *db2, DB_TXN *txn) { - int64_t k = random64(); - int64_t v = random64(); + int64_t v = random(); + int64_t k = ((int64_t)(random()) << 32) + v; int r; DBT key; DBT val; @@ -312,19 +310,16 @@ insert_random(DB *db1, DB *db2, DB_TXN *txn) { static void UU() delete_both_random(DB *db1, DB *db2, DB_TXN *txn, u_int32_t flags) { int64_t k = random64(); - int64_t v = random64(); int r; DBT key; - DBT val; dbt_init(&key, &k, sizeof(k)); - dbt_init(&val, &v, sizeof(v)); if (db1) { - r = db1->delboth(db1, txn, &key, &val, flags); + r = db1->del(db1, txn, &key, flags); CKERR2s(r, 0, DB_NOTFOUND); } if (db2) { - r = db2->delboth(db2, txn, &key, &val, flags); + r = db2->del(db2, txn, &key, flags); CKERR2s(r, 0, DB_NOTFOUND); } } @@ -335,18 +330,15 @@ static void UU() delete_fixed(DB *db1, DB *db2, DB_TXN *txn, int64_t k, u_int32_t flags) { int r; DBT key; - DBT val; - int64_t v = generate_val(k); dbt_init(&key, &k, sizeof(k)); - dbt_init(&val, &v, sizeof(v)); if (db1) { - r = db1->delboth(db1, txn, &key, &val, flags); + r = db1->del(db1, txn, &key, flags); CKERR2s(r, 0, DB_NOTFOUND); } if (db2) { - r = db2->delboth(db2, txn, &key, &val, flags); + r = db2->del(db2, txn, &key, flags); CKERR2s(r, 0, DB_NOTFOUND); } } @@ -371,13 +363,14 @@ insert_n(DB *db1, DB *db2, DB_TXN *txn, int firstkey, int n, int offset) { // printf("enter %s, iter = %d\n", __FUNCTION__, iter); // printf("db1 = 0x%08lx, db2 = 0x%08lx, *txn = 0x%08lx, firstkey = %d, n = %d\n", // (unsigned long) db1, (unsigned long) db2, (unsigned long) txn, firstkey, n); - fflush(stdout); for (i = 0; ic_get(c1, &key2, &val2, DB_GET_BOTH); + v = generate_val(firstkey); + k = (firstkey<<32) + v; + r1 = c1->c_get(c1, &key2, &val2, DB_SET); CKERR(r1); int64_t i; for (i = 1; ic_get(c1, &key1, &val1, DB_NEXT); assert(r1==0); - rval = verify_identical_dbts(&key1, &key2) | - verify_identical_dbts(&val1, &val2); - assert(rval == 0); + assert(key1.size==8 && val1.size==8 && *(int64_t*)key1.data==k && *(int64_t*)val1.data==v); } // now verify that there are no rows after the last expected r1 = c1->c_get(c1, &key1, &val1, DB_NEXT); diff --git a/src/tests/cursor-more-than-a-leaf-provdel.c b/src/tests/cursor-more-than-a-leaf-provdel.c index 91f7154c71c..d13455d7f47 100644 --- a/src/tests/cursor-more-than-a-leaf-provdel.c +++ b/src/tests/cursor-more-than-a-leaf-provdel.c @@ -18,6 +18,9 @@ setup (void) { r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=db_env_create(&env, 0); CKERR(r); +#ifdef TOKUDB + r=env->set_redzone(env, 0); CKERR(r); +#endif env->set_errfile(env, stderr); #ifdef USE_BDB r=env->set_lk_max_objects(env, 2*num_insert); CKERR(r); @@ -28,7 +31,6 @@ setup (void) { r=env->txn_begin(env, 0, &txn, 0); assert(r==0); r=db->set_bt_compare(db, int_dbt_cmp); CKERR(r); - r=db->set_dup_compare(db, int_dbt_cmp); CKERR(r); r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=txn->commit(txn, 0); assert(r==0); } diff --git a/src/tests/keyrange-dupsort-unflat.c b/src/tests/keyrange-dupsort-unflat.c deleted file mode 100644 index f4bd6bc58a8..00000000000 --- a/src/tests/keyrange-dupsort-unflat.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - - -#include -#include -#include - -static DB_ENV *env; -static DB_TXN *txn = 0; -static DB *db = 0; - -static void test (void) { - u_int64_t limit=100; - u_int64_t ilimit=100; - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - r=db_env_create(&env, 0); CKERR(r); - // set the cachetable to size 1 so that things won't fit. - r=env->set_cachesize(env, 0, 1, 1); - env->set_errfile(env, stderr); - r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUP|DB_DUPSORT); assert(r==0); - r=db->set_pagesize(db, 4096); - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - r=txn->commit(txn, 0); assert(r==0); - - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - u_int64_t i; - for (i=0; iput(db, txn, dbt_init(&k, key, 1+strlen(key)), dbt_init(&v,val, 1+strlen(val)), DB_YESOVERWRITE); - assert(r == 0); - } - } - r=txn->commit(txn, 0); assert(r==0); - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - u_int64_t prevless = 0; - u_int64_t prevgreater = limit*ilimit; - for (i=0; i<2*limit+1; i++) { - char key[100]; - snprintf(key, 100, "%08llu", (unsigned long long)i); - DBT k; - u_int64_t less,equal,greater; - int is_exact; - r = db->key_range64(db, txn, dbt_init(&k, key, 1+strlen(key)), &less, &equal, &greater, &is_exact); - assert(r == 0); - //printf("key %llu/%llu %llu %llu %llu\n", (unsigned long long)2*i+1, (unsigned long long)2*limit+1, (unsigned long long)less, (unsigned long long)equal, (unsigned long long)greater); - assert(less<=ilimit*i); - assert(equal<=ilimit); - assert(less+equal+greater <= limit*ilimit); - assert(less>=prevless); prevless=less; - assert(greater<=prevgreater); prevgreater=greater; - } - r=txn->commit(txn, 0); assert(r==0); - r = db->close(db, 0); assert(r==0); - r = env->close(env, 0); assert(r==0); -} - -int -test_main (int argc , char * const argv[]) { - parse_args(argc, argv); - test(); - return 0; -} diff --git a/src/tests/keyrange-dupsort.c b/src/tests/keyrange-dupsort.c deleted file mode 100644 index 21e1f415fa5..00000000000 --- a/src/tests/keyrange-dupsort.c +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - - -#include -#include -#include - -static DB_ENV *env; -static DB_TXN *txn = 0; -static DB *db = 0; - -static void test (void) { - u_int64_t limit=10; - u_int64_t ilimit=10; - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - r=db_env_create(&env, 0); CKERR(r); - // set the cachetable to size 1 so that things won't fit. - r=env->set_cachesize(env, 0, 1, 1); - env->set_errfile(env, stderr); - r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUP|DB_DUPSORT); assert(r==0); - r=db->set_pagesize(db, 4096); - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - r=txn->commit(txn, 0); assert(r==0); - - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - u_int64_t i; - for (i=0; iput(db, txn, dbt_init(&k, key, 1+strlen(key)), dbt_init(&v,val, 1+strlen(val)), DB_YESOVERWRITE); - assert(r == 0); - } - } - r=txn->commit(txn, 0); assert(r==0); - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - // flatten it. - for (i=0; iget(db, txn, dbt_init(&k, key, 1+strlen(key)), dbt_init(&v, val, 1+strlen(val)), 0); - assert(r==0); - } - } - r=txn->commit(txn, 0); assert(r==0); - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - for (i=0; ikey_range64(db, txn, dbt_init(&k, key, 1+strlen(key)), &less, &equal, &greater, &is_exact); - assert(r == 0); - //printf("key %llu/%llu %llu %llu %llu\n", (unsigned long long)2*i+1, (unsigned long long)2*limit+1, (unsigned long long)less, (unsigned long long)equal, (unsigned long long)greater); - assert(less==ilimit*i); - assert(equal==ilimit); - assert(less+equal+greater == limit*ilimit); - } - for (i=0; i<1+limit; i++) { - char key[100]; - snprintf(key, 100, "%08llu", (unsigned long long)2*i); - DBT k; - u_int64_t less,equal,greater; - int is_exact; - r = db->key_range64(db, txn, dbt_init(&k, key, 1+strlen(key)), &less, &equal, &greater, &is_exact); - assert(r == 0); - //printf("key %llu/%llu %llu %llu %llu\n", (unsigned long long)2*i, (unsigned long long)2*limit, (unsigned long long)less, (unsigned long long)equal, (unsigned long long)greater); - assert(less==ilimit*i); - assert(equal==0); - assert(less+equal+greater == limit*ilimit); - } - r=txn->commit(txn, 0); assert(r==0); - r = db->close(db, 0); assert(r==0); - r = env->close(env, 0); assert(r==0); -} - -int -test_main (int argc , char * const argv[]) { - parse_args(argc, argv); - test(); - return 0; -} diff --git a/src/tests/loader-cleanup-test.c b/src/tests/loader-cleanup-test.c index 620745d5b06..2c0f6b775c3 100644 --- a/src/tests/loader-cleanup-test.c +++ b/src/tests/loader-cleanup-test.c @@ -760,8 +760,8 @@ static void run_test(enum test_type t, int trigger) r = toku_os_mkdir(env_dir, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = db_env_create(&env, 0); CKERR(r); + r = env->set_redzone(env, 0); CKERR(r); r = env->set_default_bt_compare(env, uint_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, uint_dbt_cmp); CKERR(r); r = env->set_generate_row_callback_for_put(env, put_multiple_generate); CKERR(r); diff --git a/src/tests/loader-dup-test.c b/src/tests/loader-dup-test.c index 4aebf09816c..6c7b854d3ec 100644 --- a/src/tests/loader-dup-test.c +++ b/src/tests/loader-dup-test.c @@ -303,7 +303,6 @@ static void run_test(void) r = db_env_create(&env, 0); CKERR(r); r = env->set_default_bt_compare(env, uint_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, uint_dbt_cmp); CKERR(r); r = env->set_generate_row_callback_for_put(env, put_multiple_generate); CKERR(r); int envflags = DB_INIT_LOCK | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOG | DB_CREATE | DB_PRIVATE; diff --git a/src/tests/loader-no-puts.c b/src/tests/loader-no-puts.c index fb482dc7028..24e2ad5e0c5 100644 --- a/src/tests/loader-no-puts.c +++ b/src/tests/loader-no-puts.c @@ -108,7 +108,6 @@ static void run_test(void) r = db_env_create(&env, 0); CKERR(r); r = env->set_default_bt_compare(env, int64_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, int64_dbt_cmp); CKERR(r); r = env->set_generate_row_callback_for_put(env, put_multiple_generate); CKERR(r); // int envflags = DB_INIT_LOCK | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE | DB_INIT_LOG; diff --git a/src/tests/loader-reference-test.c b/src/tests/loader-reference-test.c index 6493f0402ad..141945f301c 100644 --- a/src/tests/loader-reference-test.c +++ b/src/tests/loader-reference-test.c @@ -113,7 +113,6 @@ static void run_test(void) r = env->set_lg_dir(env, "log"); CKERR(r); r = env->set_default_bt_compare(env, int64_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, int64_dbt_cmp); CKERR(r); r = env->set_generate_row_callback_for_put(env, put_multiple_generate); CKERR(r); // int envflags = DB_INIT_LOCK | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE | DB_INIT_LOG; diff --git a/src/tests/loader-stress-test.c b/src/tests/loader-stress-test.c index 95262d96d81..1d77e74c1f1 100644 --- a/src/tests/loader-stress-test.c +++ b/src/tests/loader-stress-test.c @@ -455,7 +455,6 @@ static void run_test(void) r = env->set_tmp_dir(env, tmp_subdir); CKERR(r); } r = env->set_default_bt_compare(env, uint_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, uint_dbt_cmp); CKERR(r); if ( verbose ) printf("CACHESIZE = %d MB\n", CACHESIZE); r = env->set_cachesize(env, CACHESIZE / 1024, (CACHESIZE % 1024)*1024*1024, 1); CKERR(r); if (datadir) { diff --git a/src/tests/loader-tpch-load.c b/src/tests/loader-tpch-load.c index 3acf7d0161a..33e4087674e 100644 --- a/src/tests/loader-tpch-load.c +++ b/src/tests/loader-tpch-load.c @@ -368,7 +368,6 @@ static int run_test(void) r = db_env_create(&env, 0); CKERR(r); r = env->set_default_bt_compare(env, tpch_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, tpch_dbt_cmp); CKERR(r); // select which TPC-H table to load if ( USE_REGION ) { r = env->set_generate_row_callback_for_put(env, generate_rows_for_region); CKERR(r); diff --git a/src/tests/medium-nested-commit-commit.c b/src/tests/medium-nested-commit-commit.c index c2f59efcae4..dd77988568e 100644 --- a/src/tests/medium-nested-commit-commit.c +++ b/src/tests/medium-nested-commit-commit.c @@ -98,7 +98,6 @@ test_setup (void) { env->set_errfile(env, stderr); r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUPSORT); r=env->txn_begin(env, 0, &txn, 0); assert(r==0); r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); diff --git a/src/tests/multiprocess.c b/src/tests/multiprocess.c index b80f0545582..2bf95647c0b 100644 --- a/src/tests/multiprocess.c +++ b/src/tests/multiprocess.c @@ -30,6 +30,8 @@ test_env (const char *envdir0, const char *envdir1, int expect_open_return) { DB_ENV *env; r = db_env_create(&env, 0); CKERR(r); + r = env->set_redzone(env, 0); + CKERR(r); int envflags = DB_INIT_LOCK | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE | DB_RECOVER; r = env->open(env, envdir0, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); @@ -37,6 +39,8 @@ test_env (const char *envdir0, const char *envdir1, int expect_open_return) { DB_ENV *env2; r = db_env_create(&env2, 0); CKERR(r); + r = env2->set_redzone(env2, 0); + CKERR(r); r = env2->open(env2, envdir1, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR2(r, expect_open_return); @@ -81,6 +85,8 @@ test_datadir (const char *envdir0, const char *datadir0, const char *envdir1, co DB_ENV *env; r = db_env_create(&env, 0); CKERR(r); + r = env->set_redzone(env, 0); + CKERR(r); r = env->set_data_dir(env, datadir0); CKERR(r); int envflags = DB_INIT_LOCK | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE | DB_RECOVER; @@ -90,6 +96,8 @@ test_datadir (const char *envdir0, const char *datadir0, const char *envdir1, co DB_ENV *env2; r = db_env_create(&env2, 0); CKERR(r); + r = env2->set_redzone(env2, 0); + CKERR(r); r = env2->set_data_dir(env2, datadir1); CKERR(r); r = env2->open(env2, envdir1, envflags, S_IRWXU+S_IRWXG+S_IRWXO); @@ -135,6 +143,8 @@ test_logdir (const char *envdir0, const char *datadir0, const char *envdir1, con DB_ENV *env; r = db_env_create(&env, 0); CKERR(r); + r = env->set_redzone(env, 0); + CKERR(r); r = env->set_lg_dir(env, datadir0); CKERR(r); int envflags = DB_INIT_LOCK | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE | DB_RECOVER; @@ -144,6 +154,8 @@ test_logdir (const char *envdir0, const char *datadir0, const char *envdir1, con DB_ENV *env2; r = db_env_create(&env2, 0); CKERR(r); + r = env2->set_redzone(env2, 0); + CKERR(r); r = env2->set_lg_dir(env2, datadir1); CKERR(r); r = env2->open(env2, envdir1, envflags, S_IRWXU+S_IRWXG+S_IRWXO); @@ -165,11 +177,19 @@ static char * full_name(const char *subdir) { char wd[256]; assert(getcwd(wd, sizeof wd) != NULL); - char *path = toku_malloc(strlen(wd) + strlen(subdir) + 1); - sprintf(path, "%s%s", wd, subdir); + char *path = toku_malloc(strlen(wd) + strlen(subdir) + 2); + sprintf(path, "%s/%s", wd, subdir); return path; } +static void +unlink_dir (const char *dir) { + int len = strlen(dir)+100; + char cmd[len]; + snprintf(cmd, len, "rm -rf %s", dir); + system(cmd); +} + int test_main (int argc, char * const argv[]) { parse_args(argc, argv); @@ -184,6 +204,12 @@ test_main (int argc, char * const argv[]) { test_datadir(env0, data0, env1, data0, EWOULDBLOCK); test_logdir(env0, data0, env1, data1, 0); test_logdir(env0, data0, env1, data0, EWOULDBLOCK); + + unlink_dir(env0); + unlink_dir(env1); + unlink_dir(data0); + unlink_dir(data1); + toku_free(data0); toku_free(data1); diff --git a/src/tests/recover-checkpoint-fcreate-fdelete-fcreate.c b/src/tests/recover-checkpoint-fcreate-fdelete-fcreate.c index 40921a9c5f2..c8a8f1b620e 100644 --- a/src/tests/recover-checkpoint-fcreate-fdelete-fcreate.c +++ b/src/tests/recover-checkpoint-fcreate-fdelete-fcreate.c @@ -33,7 +33,6 @@ static void run_test (void) { // create r = db_create(&db, env, 0); CKERR(r); - r = db->set_flags(db, DB_DUPSORT); CKERR(r); r = db->open(db, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r); r = db->close(db, 0); CKERR(r); @@ -52,7 +51,6 @@ static void run_recover (void) { r = db_create(&db, env, 0); CKERR(r); r = db->open(db, NULL, namea, NULL, DB_UNKNOWN, DB_AUTO_COMMIT, 0666); CKERR(r); r = db->get_flags(db, &dbflags); CKERR(r); - assert(dbflags == DB_DUPSORT); r = db->close(db, 0); CKERR(r); r = env->close(env, 0); CKERR(r); diff --git a/src/tests/recover-checkpoint-fopen-dupsort-abort.c b/src/tests/recover-checkpoint-fopen-dupsort-abort.c index c79f4f2095c..f8be3719424 100644 --- a/src/tests/recover-checkpoint-fopen-dupsort-abort.c +++ b/src/tests/recover-checkpoint-fopen-dupsort-abort.c @@ -26,7 +26,6 @@ static void run_test (BOOL do_commit, BOOL do_abort) { r = env->txn_checkpoint(env, 0, 0, 0); CKERR(r); r = db_create(&dbb, env, 0); CKERR(r); - r = dbb->set_flags(dbb, DB_DUPSORT); CKERR(r); r = dbb->open(dbb, NULL, nameb, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r); DB_TXN *txn; r = env->txn_begin(env, NULL, &txn, 0); CKERR(r); @@ -69,7 +68,7 @@ static void run_recover (BOOL did_commit) { dbflags = 0; r = dbb->get_flags(dbb, &dbflags); CKERR(r); - assert(dbflags == DB_DUPSORT); + assert(dbflags == 0); DBT aa={.size=0}, ab={.size=0}; DBT ba={.size=0}, bb={.size=0}; diff --git a/src/tests/recover-checkpoint-fopen-dupsort-commit.c b/src/tests/recover-checkpoint-fopen-dupsort-commit.c index 75c691729a4..177b6b79658 100644 --- a/src/tests/recover-checkpoint-fopen-dupsort-commit.c +++ b/src/tests/recover-checkpoint-fopen-dupsort-commit.c @@ -26,7 +26,6 @@ static void run_test (BOOL do_commit, BOOL do_abort) { r = env->txn_checkpoint(env, 0, 0, 0); CKERR(r); r = db_create(&dbb, env, 0); CKERR(r); - r = dbb->set_flags(dbb, DB_DUPSORT); CKERR(r); r = dbb->open(dbb, NULL, nameb, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r); DB_TXN *txn; r = env->txn_begin(env, NULL, &txn, 0); CKERR(r); @@ -69,7 +68,7 @@ static void run_recover (BOOL did_commit) { dbflags = 0; r = dbb->get_flags(dbb, &dbflags); CKERR(r); - assert(dbflags == DB_DUPSORT); + assert(dbflags == 0); DBT aa={.size=0}, ab={.size=0}; DBT ba={.size=0}, bb={.size=0}; diff --git a/src/tests/recover-delboth-after-checkpoint.c b/src/tests/recover-delboth-after-checkpoint.c index 3068e7dea05..05124e23e48 100644 --- a/src/tests/recover-delboth-after-checkpoint.c +++ b/src/tests/recover-delboth-after-checkpoint.c @@ -40,8 +40,7 @@ run_test (BOOL do_commit, BOOL do_abort) { { unsigned char c = 128; DBT k = {.data=&c, .size=sizeof c}; - DBT v = {.data=&c, .size=sizeof c}; - r = dba->delboth(dba, txn, &k, &v, 0); CKERR(r); + r = dba->del(dba, txn, &k, 0); CKERR(r); } if (do_commit) { diff --git a/src/tests/recover-delboth-checkpoint.c b/src/tests/recover-delboth-checkpoint.c index 70e43c99963..bd6318d99ab 100644 --- a/src/tests/recover-delboth-checkpoint.c +++ b/src/tests/recover-delboth-checkpoint.c @@ -38,8 +38,7 @@ run_test (BOOL do_commit, BOOL do_abort) { { unsigned char c = 128; DBT k = {.data=&c, .size=sizeof c}; - DBT v = {.data=&c, .size=sizeof c}; - r = dba->delboth(dba, txn, &k, &v, 0); CKERR(r); + r = dba->del(dba, txn, &k, 0); CKERR(r); } r = env->txn_checkpoint(env, 0, 0, 0); CKERR(r); diff --git a/src/tests/recover-fassociate-dupsort.c b/src/tests/recover-fassociate-dupsort.c index 56a7b6bc12e..80212b95e67 100644 --- a/src/tests/recover-fassociate-dupsort.c +++ b/src/tests/recover-fassociate-dupsort.c @@ -20,11 +20,9 @@ static void run_test (void) { r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = db_create(&dba, env, 0); CKERR(r); - r = dba->set_flags(dba, DB_DUPSORT); CKERR(r); r = dba->open(dba, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r); r = db_create(&dbb, env, 0); CKERR(r); - r = dbb->set_flags(dbb, DB_DUPSORT); CKERR(r); r = dbb->open(dbb, NULL, nameb, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r); DB_TXN *txn; @@ -54,13 +52,12 @@ static void run_recover (void) { r = db_create(&dba, env, 0); CKERR(r); r = dba->open(dba, NULL, namea, NULL, DB_UNKNOWN, DB_AUTO_COMMIT, 0666); CKERR(r); r = dba->get_flags(dba, &dbflags); CKERR(r); - assert(dbflags == DB_DUPSORT); r = dba->close(dba, 0); CKERR(r); DB *dbb; r = db_create(&dbb, env, 0); CKERR(r); r = dbb->open(dbb, NULL, nameb, NULL, DB_UNKNOWN, DB_AUTO_COMMIT, 0666); CKERR(r); r = dbb->get_flags(dbb, &dbflags); CKERR(r); - assert(dbflags == DB_DUPSORT); + assert(dbflags == 0); r = dbb->close(dbb, 0); CKERR(r); r = env->close(env, 0); CKERR(r); diff --git a/src/tests/recover-fcreate-fdelete.c b/src/tests/recover-fcreate-fdelete.c index 6dbb76e6778..d29162df2df 100644 --- a/src/tests/recover-fcreate-fdelete.c +++ b/src/tests/recover-fcreate-fdelete.c @@ -32,7 +32,6 @@ static void run_test (void) { r = env->txn_checkpoint(env, 0, 0, 0); CKERR(r); r = db_create(&db, env, 0); CKERR(r); - r = db->set_flags(db, DB_DUPSORT); CKERR(r); r = db->open(db, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r); r = db->close(db, 0); CKERR(r); @@ -53,7 +52,6 @@ static void run_recover (void) { r = db_create(&db, env, 0); CKERR(r); r = db->open(db, NULL, namea, NULL, DB_UNKNOWN, DB_AUTO_COMMIT, 0666); CKERR(r); r = db->get_flags(db, &dbflags); CKERR(r); - assert(dbflags == DB_DUPSORT); r = db->close(db, 0); CKERR(r); r = env->close(env, 0); CKERR(r); diff --git a/src/tests/recover-fopen-fdelete-checkpoint-fcreate.c b/src/tests/recover-fopen-fdelete-checkpoint-fcreate.c index b58a1d6d1bb..0b5ce04f6ee 100644 --- a/src/tests/recover-fopen-fdelete-checkpoint-fcreate.c +++ b/src/tests/recover-fopen-fdelete-checkpoint-fcreate.c @@ -60,7 +60,6 @@ static void run_test (void) { // fcreate with different treeflags r = db_create(&db, env, 0); CKERR(r); - r = db->set_flags(db, DB_DUPSORT); CKERR(r); r = db->open(db, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r); // insert something @@ -83,7 +82,6 @@ static void run_recover (void) { r = db_create(&db, env, 0); CKERR(r); r = db->open(db, NULL, namea, NULL, DB_UNKNOWN, DB_AUTO_COMMIT, 0666); CKERR(r); r = db->get_flags(db, &dbflags); CKERR(r); - assert(dbflags == DB_DUPSORT); r = db->close(db, 0); CKERR(r); r = env->close(env, 0); CKERR(r); diff --git a/src/tests/recover-loader-test.c b/src/tests/recover-loader-test.c index 517abd2f009..2b6b9bd23bc 100644 --- a/src/tests/recover-loader-test.c +++ b/src/tests/recover-loader-test.c @@ -359,7 +359,6 @@ static void run_test(void) r = db_env_create(&env, 0); CKERR(r); r = env->set_default_bt_compare(env, uint_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, uint_dbt_cmp); CKERR(r); r = env->set_generate_row_callback_for_put(env, put_multiple_generate); CKERR(r); // int envflags = DB_INIT_LOCK | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE; diff --git a/src/tests/recover-test-logsuppress-put.c b/src/tests/recover-test-logsuppress-put.c index 475e845d4cd..fd3e484dac1 100644 --- a/src/tests/recover-test-logsuppress-put.c +++ b/src/tests/recover-test-logsuppress-put.c @@ -140,7 +140,6 @@ do_x1_shutdown (void) { r=db_env_create(&env, 0); assert(r==0); env->set_errfile(env, stderr); r = env->set_default_bt_compare(env, uint_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, uint_dbt_cmp); CKERR(r); r = env->set_generate_row_callback_for_put(env, put_multiple_generate); CKERR(r); diff --git a/src/tests/recover-test-logsuppress.c b/src/tests/recover-test-logsuppress.c index 753e617a813..e9635e37899 100644 --- a/src/tests/recover-test-logsuppress.c +++ b/src/tests/recover-test-logsuppress.c @@ -149,7 +149,6 @@ do_x1_shutdown (void) { r=db_env_create(&env, 0); assert(r==0); env->set_errfile(env, stderr); r = env->set_default_bt_compare(env, uint_dbt_cmp); CKERR(r); - r = env->set_default_dup_compare(env, uint_dbt_cmp); CKERR(r); r = env->set_generate_row_callback_for_put(env, put_multiple_generate); CKERR(r); diff --git a/src/tests/recovery_fileops_stress.c b/src/tests/recovery_fileops_stress.c index 356266e2ed3..81c4cf629bb 100644 --- a/src/tests/recovery_fileops_stress.c +++ b/src/tests/recovery_fileops_stress.c @@ -448,6 +448,7 @@ static void env_startup(int recovery_flags) { int r; int envflags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE | recovery_flags; r = db_env_create(&env, 0); CKERR(r); + r=env->set_redzone(env, 0); CKERR(r); env->set_errfile(env, stderr); r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); //Disable auto-checkpointing. @@ -512,7 +513,7 @@ static void verify_sequential_rows(DB* compare_db, int64_t firstkey, int64_t num k = firstkey; v = generate_val(k); - r1 = c1->c_get(c1, &key2, &val2, DB_GET_BOTH); + r1 = c1->c_get(c1, &key2, &val2, DB_SET); CKERR(r1); int64_t i; diff --git a/src/tests/recovery_fileops_unit.c b/src/tests/recovery_fileops_unit.c index 6d1984cde9d..b3de9f29a40 100644 --- a/src/tests/recovery_fileops_unit.c +++ b/src/tests/recovery_fileops_unit.c @@ -303,7 +303,7 @@ fcreate(void) { dbt_init(&val, "delete_me2", sizeof("delete_me2")); r = db->put(db, txn, &key, &val, DB_YESOVERWRITE); CKERR(r); - r = db->delboth(db, txn, &key, &val, DB_DELETE_ANY); + r = db->del(db, txn, &key, 0); CKERR(r); r = db->close(db, 0); CKERR(r); @@ -530,11 +530,11 @@ verify_file_exists(const char *name, int should_exist) { dbt_init(&key, choices, sizeof(choices)); dbt_init(&val, NULL, 0); r = db->get(db, txn, &key, &val, DB_YESOVERWRITE); - r = db->getf_get_both(db, txn, 0, &key, &val, getf_do_nothing, NULL); + r = db->getf_set(db, txn, 0, &key, getf_do_nothing, NULL); CKERR(r); dbt_init(&key, "name", sizeof("name")); dbt_init(&val, (void*)name, strlen(name)+1); - r = db->getf_get_both(db, txn, 0, &key, &val, getf_do_nothing, NULL); + r = db->getf_set(db, txn, 0, &key, getf_do_nothing, NULL); CKERR(r); DBC *c; diff --git a/src/tests/recovery_stress.c b/src/tests/recovery_stress.c index 40a417c0f5c..8f0a4d9f945 100644 --- a/src/tests/recovery_stress.c +++ b/src/tests/recovery_stress.c @@ -397,7 +397,7 @@ static void post_checkpoint_acts(ITER_SPEC spec) { static void run_test (int iter) { - u_int32_t flags = DB_DUP|DB_DUPSORT; + u_int32_t flags = 0; int i, r; if (iter == 0) diff --git a/src/tests/test1842.c b/src/tests/test1842.c index d4dc26f0d13..ed4b17e9ced 100644 --- a/src/tests/test1842.c +++ b/src/tests/test1842.c @@ -60,7 +60,6 @@ setup_db (u_int32_t dup_mode) { r = db_create(&db, env, 0); CKERR(r); r=db->set_bt_compare(db, int_dbt_cmp); CKERR(r); - r=db->set_dup_compare(db, length_int_dbt_cmp); CKERR(r); r = db->set_flags(db, dup_mode); assert(r == 0); CKERR(r); r = db->open(db, txn, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = txn->commit(txn, 0); CKERR(r); diff --git a/src/tests/test938.c b/src/tests/test938.c index 8ca3b49e176..da11556dd57 100644 --- a/src/tests/test938.c +++ b/src/tests/test938.c @@ -47,10 +47,10 @@ run (int choice) { r=env->txn_begin(env, 0, &txn, 0); CKERR(r); for (i=0; iput(db, txn, dbt_init(&kdbt, &key, 1), dbt_init(&vdbt, &val, 1), DB_YESOVERWRITE); CKERR(r); + r=db->put(db, txn, dbt_init(&kdbt, &key, 2), dbt_init(&vdbt, &val, 1), DB_YESOVERWRITE); CKERR(r); } r=txn->commit(txn, DB_TXN_NOSYNC); CKERR(r); } @@ -129,11 +129,13 @@ test_main(int argc, char *const argv[]) { DB_TXN *txn; { r = db_env_create(&env, 0); CKERR(r); +#ifdef TOKUDB + r = env->set_redzone(env, 0); CKERR(r); +#endif r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); env->set_errfile(env, stderr); r=env->txn_begin(env, 0, &txn, 0); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUP|DB_DUPSORT); r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=txn->commit(txn, 0); CKERR(r); } diff --git a/src/tests/test938b.c b/src/tests/test938b.c index 9be58f96b3d..125882e0edd 100644 --- a/src/tests/test938b.c +++ b/src/tests/test938b.c @@ -65,7 +65,6 @@ test_main(int argc, char *const argv[]) { env->set_errfile(env, stderr); r=env->txn_begin(env, 0, &txn, 0); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUP|DB_DUPSORT); r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=txn->commit(txn, 0); CKERR(r); } diff --git a/src/tests/test938c.c b/src/tests/test938c.c index b312651c2b9..46442aa50d1 100644 --- a/src/tests/test938c.c +++ b/src/tests/test938c.c @@ -24,8 +24,9 @@ run (void) { // It also fails for BDB for other reasons (page-level locking vs. row-level locking) { r=env->txn_begin(env, 0, &txn, 0); CKERR(r); + char kk[2] = {v2, v102}; DBT k,v; - r=db->put(db, txn, dbt_init(&k, &v2, 1), dbt_init(&v, &v102, 1), DB_YESOVERWRITE); CKERR(r); + r=db->put(db, txn, dbt_init(&k, &kk, 2), dbt_init(&v, &v102, 1), DB_YESOVERWRITE); CKERR(r); r=txn->commit(txn, 0); CKERR(r); } @@ -34,14 +35,18 @@ run (void) { r=env->txn_begin(env, 0, &txn2, 0); CKERR(r); DBT k,v; - - r=db->put(db, txn, dbt_init(&k, &v1, 1), dbt_init(&v, &v101, 1), DB_YESOVERWRITE); CKERR(r); + { + char kk[2] = {v1, v101}; + r=db->put(db, txn, dbt_init(&k, &kk, 2), dbt_init(&v, &v101, 1), DB_YESOVERWRITE); CKERR(r); + } DBC *c2; r=db->cursor(db, txn2, &c2, 0); CKERR(r); - - r=c2->c_get(c2, dbt_init(&k, &v2, 1), dbt_init(&v, &v102, 1), DB_GET_BOTH); CKERR(r); + { + char kk[2] = {v2, v102}; + r=c2->c_get(c2, dbt_init(&k, &kk, 2), dbt_init(&v, &v102, 1), DB_SET); CKERR(r); + } r=c2->c_get(c2, dbt_init_malloc(&k), dbt_init_malloc(&v), DB_NEXT); assert(r==DB_NOTFOUND); r=c2->c_close(c2); @@ -62,11 +67,13 @@ test_main(int argc, char *const argv[]) { DB_TXN *txn; { r = db_env_create(&env, 0); CKERR(r); +#ifdef TOKUDB + r = env->set_redzone(env, 0); CKERR(r); +#endif r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); env->set_errfile(env, stderr); r=env->txn_begin(env, 0, &txn, 0); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUP|DB_DUPSORT); r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=txn->commit(txn, 0); CKERR(r); } diff --git a/src/tests/test944.c b/src/tests/test944.c index 15321c18ce4..4bcc9d7a845 100644 --- a/src/tests/test944.c +++ b/src/tests/test944.c @@ -119,12 +119,13 @@ test_main(int argc, char *const argv[]) { DB_TXN *txn; { r = db_env_create(&env, 0); CKERR(r); +#ifdef USE_TDB r = env->set_redzone(env, 0); CKERR(r); +#endif r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); env->set_errfile(env, stderr); r=env->txn_begin(env, 0, &txn, 0); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUP|DB_DUPSORT); r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=txn->commit(txn, 0); CKERR(r); } diff --git a/src/tests/test944a.c b/src/tests/test944a.c index 6d7ee8f6cc5..4c881c4af74 100644 --- a/src/tests/test944a.c +++ b/src/tests/test944a.c @@ -116,7 +116,9 @@ test_main(int argc, char *const argv[]) { DB_TXN *txn; { r = db_env_create(&env, 0); CKERR(r); +#ifdef USE_TDB r = env->set_redzone(env, 0); CKERR(r); +#endif r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); env->set_errfile(env, stderr); r=env->txn_begin(env, 0, &txn, 0); CKERR(r); diff --git a/src/tests/test_abort4.c b/src/tests/test_abort4.c index 2e48f0a661b..b5ef6d5e822 100644 --- a/src/tests/test_abort4.c +++ b/src/tests/test_abort4.c @@ -23,7 +23,7 @@ DB_TXN *txn; u_int32_t find_num; static void -init(u_int32_t dup_flags) { +init(void) { int r; r = system("rm -rf " ENVDIR); CKERR(r); @@ -31,10 +31,6 @@ init(u_int32_t dup_flags) { r=db_env_create(&env, 0); CKERR(r); r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - if (dup_flags) { - r = db->set_flags(db, dup_flags); - CKERR(r); - } r=db->open(db, null_txn, "foo.db", 0, DB_BTREE, DB_CREATE|DB_EXCL, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r); r=db->close(db, 0); CKERR(r); @@ -165,24 +161,24 @@ verify_and_tear_down(int close_first) { } static void -runtests(u_int32_t dup_flags) { +runtests(void) { int close_first; for (close_first = 0; close_first < 2; close_first++) { - init(dup_flags); + init(); abort_txn(); verify_and_tear_down(close_first); u_int32_t n; for (n = 1; n < 1<<20; n*=2) { if (verbose) { - printf("\t%s:%d-%s() dup=%05x close_first=%d n=%06x\n", - __FILE__, __LINE__, __FUNCTION__, dup_flags, close_first, n); + printf("\t%s:%d-%s() close_first=%d n=%06x\n", + __FILE__, __LINE__, __FUNCTION__, close_first, n); fflush(stdout); } - init(dup_flags); + init(); test_insert_and_abort(n); verify_and_tear_down(close_first); - init(dup_flags); + init(); test_insert_and_abort_and_insert(n); verify_and_tear_down(close_first); } @@ -193,8 +189,7 @@ int test_main(int argc, char *const argv[]) { parse_args(argc, argv); - runtests(0); - runtests(DB_DUPSORT|DB_DUP); + runtests(); return 0; } diff --git a/src/tests/test_abort5.c b/src/tests/test_abort5.c index e634bb19cdb..df2dcab347f 100644 --- a/src/tests/test_abort5.c +++ b/src/tests/test_abort5.c @@ -24,7 +24,7 @@ DB_TXN *childtxn; u_int32_t find_num; static void -init(u_int32_t dup_flags) { +init(void) { int r; r = system("rm -rf " ENVDIR); CKERR(r); @@ -32,10 +32,6 @@ init(u_int32_t dup_flags) { r=db_env_create(&env, 0); CKERR(r); r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r=db_create(&db, env, 0); CKERR(r); - if (dup_flags) { - r = db->set_flags(db, dup_flags); - CKERR(r); - } r=db->open(db, null_txn, "foo.db", 0, DB_BTREE, DB_CREATE|DB_EXCL, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r); r=db->close(db, 0); CKERR(r); @@ -197,20 +193,20 @@ verify_and_tear_down(int close_first) { } static void -runtests(u_int32_t dup_flags, int abort_type) { - if (verbose) printf("\t"__FILE__": runtests(%u,%d)\n", dup_flags, abort_type); +runtests(int abort_type) { + if (verbose) printf("\t"__FILE__": runtests(%d)\n", abort_type); int close_first; for (close_first = 0; close_first < 2; close_first++) { - init(dup_flags); + init(); abort_txn(abort_type); verify_and_tear_down(close_first); u_int32_t n; for (n = 1; n < 1<<10; n*=2) { - init(dup_flags); + init(); test_insert_and_abort(n, abort_type); verify_and_tear_down(close_first); - init(dup_flags); + init(); test_insert_and_abort_and_insert(n, abort_type); verify_and_tear_down(close_first); } @@ -222,8 +218,7 @@ test_main (int argc, char *const argv[]) { parse_args(argc, argv); int abort_type; for (abort_type = 0; abort_type<3; abort_type++) { - runtests(0, abort_type); - runtests(DB_DUPSORT|DB_DUP, abort_type); + runtests(abort_type); } return 0; } diff --git a/src/tests/test_cursor_DB_NEXT_no_dup.c b/src/tests/test_cursor_DB_NEXT_no_dup.c index f6c8aed672c..55e309a86bf 100644 --- a/src/tests/test_cursor_DB_NEXT_no_dup.c +++ b/src/tests/test_cursor_DB_NEXT_no_dup.c @@ -16,7 +16,6 @@ static DBC* cursor = NULL; static DB* db = NULL; static DB_ENV* env = NULL; static int r = 0; -static BOOL dups = FALSE; static DB_TXN* null_txn = NULL; static void setup_env(void) { @@ -40,16 +39,12 @@ static void close_env(void) { env = NULL; } -static void setup_db(u_int32_t dup_flags) { +static void setup_db(void) { assert(env && !db && !cursor); r = db_create(&db, env, 0); CKERR(r); assert(db); db->set_errfile(db, stderr); - if (dup_flags) { - r = db->set_flags(db, dup_flags); - CKERR(r); - } r = db->open(db, null_txn, "foo.db", "main", DB_BTREE, DB_CREATE, 0666); CKERR(r); assert(db); @@ -99,17 +94,17 @@ static void c_get(u_int32_t flag, char key_expect, char data_expect) { char got_data = *(char*)data.data; if (verbose && (got_key != key_expect || got_data != data_expect)) { - printf("DUPS [%d] c_get(%u) Expect (%c,%c)\n" + printf("c_get(%u) Expect (%c,%c)\n" " Got (%c,%c)\n", - (int)dups, flag, key_expect, data_expect, got_key, got_data); + flag, key_expect, data_expect, got_key, got_data); } assert(got_key == key_expect); assert(got_data == data_expect); } -static void test_skip_key(u_int32_t dup_flags, u_int32_t flag, BOOL is_next) { +static void test_skip_key(u_int32_t flag, BOOL is_next) { setup_env(); - setup_db(dup_flags); + setup_db(); setup_cursor(); /* ********************************************************************** */ @@ -130,50 +125,19 @@ static void test_skip_key(u_int32_t dup_flags, u_int32_t flag, BOOL is_next) { close_env(); } -static void test_do_not_skip_key(u_int32_t dup_flags, u_int32_t flag, BOOL is_next) { - setup_env(); - setup_db(dup_flags); - setup_cursor(); - - char key = 'g'; - char data = 'g'; - int forward = is_next ? 1 : -1; - - insert(key, data); - insert((char)(key + forward), data); - c_get(flag, key, data); - insert(key, (char)(data + forward)); - c_get(flag, key, (char)(data + forward)); - - close_cursor(); - close_db(); - close_env(); -} - -static void run_test(u_int32_t dup_flags) { - dups = (BOOL)(dup_flags != 0); +static void run_test(void) { /* ********************************************************************** */ /* Test DB_NEXT works properly. */ - if (dups) { - test_do_not_skip_key(dup_flags, DB_NEXT, TRUE); - } - else { - test_skip_key(dup_flags, DB_NEXT, TRUE); - } + test_skip_key(DB_NEXT, TRUE); /* ********************************************************************** */ /* Test DB_PREV works properly. */ - if (dups) { - test_do_not_skip_key(dup_flags, DB_PREV, FALSE); - } - else { - test_skip_key(dup_flags, DB_PREV, FALSE); - } + test_skip_key(DB_PREV, FALSE); /* ********************************************************************** */ /* Test DB_PREV_NODUP works properly. */ - test_skip_key(dup_flags, DB_PREV_NODUP, FALSE); + test_skip_key(DB_PREV_NODUP, FALSE); /* ********************************************************************** */ /* Test DB_NEXT_NODUP works properly. */ - test_skip_key(dup_flags, DB_NEXT_NODUP, TRUE); + test_skip_key(DB_NEXT_NODUP, TRUE); /* ********************************************************************** */ } @@ -183,8 +147,7 @@ test_main(int argc, char *const argv[]) { parse_args(argc, argv); - run_test(0); - run_test(DB_DUP | DB_DUPSORT); + run_test(); return 0; } diff --git a/src/tests/test_cursor_delete.c b/src/tests/test_cursor_delete.c index 465000c1c0c..e2f73ffb00b 100644 --- a/src/tests/test_cursor_delete.c +++ b/src/tests/test_cursor_delete.c @@ -31,13 +31,7 @@ cursor_expect (DBC *cursor, int k, int v, int op) { toku_free(val.data); } -static void -cursor_expect_fail (DBC *cursor, int op, int expectr) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), op); - assert(r == expectr); -} - + /* generate a multi-level tree and delete all entries with a cursor verify that the pivot flags are toggled (currently by inspection) */ @@ -60,6 +54,9 @@ test_cursor_delete (int dup_mode) { /* create the dup database file */ DB_ENV *env; r = db_env_create(&env, 0); assert(r == 0); +#ifdef USE_TDB + r = env->set_redzone(env, 0); CKERR(r); +#endif r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); DB *db; @@ -71,7 +68,7 @@ test_cursor_delete (int dup_mode) { int i; for (i=0; iput(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); assert(r == 0); @@ -82,7 +79,7 @@ test_cursor_delete (int dup_mode) { r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); for (i=0; ic_del(cursor, 0); assert(r == 0); } @@ -93,73 +90,6 @@ test_cursor_delete (int dup_mode) { r = env->close(env, 0); assert(r == 0); } -/* insert duplicate duplicates into a sorted duplicate tree */ -static void -test_cursor_delete_dupsort (void) { - if (verbose) { - printf("test_cursor_delete_dupsort\n"); fflush(stdout); - } - - int pagesize = 4096; - int elementsize = 32; - int npp = pagesize/elementsize; - int n = 16*npp; /* build a 2 level tree */ - - DB_TXN * const null_txn = 0; - const char * const fname = "test.cursor.delete.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - db->set_errfile(db,0); // Turn off those annoying errors - r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0); - r = db->set_pagesize(db, pagesize); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - int i; - for (i=0; iput(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0); - if (i == 0) - assert(r == 0); - else - assert(r == DB_KEYEXIST); -#endif -#ifdef USE_TDB - r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0); - assert(r == EINVAL); - r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -#endif - } - - /* verify the sort order with a cursor */ - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - cursor_expect(cursor, htonl(1), htonl(1), DB_NEXT); - - r = cursor->c_del(cursor, 0); assert(r == 0); - - cursor_expect_fail(cursor, DB_NEXT, DB_NOTFOUND); - - r = cursor->c_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - int test_main(int argc, char *const argv[]) { parse_args(argc, argv); @@ -168,8 +98,6 @@ test_main(int argc, char *const argv[]) { #ifdef USE_BDB test_cursor_delete(DB_DUP); #endif - test_cursor_delete(DB_DUP + DB_DUPSORT); - test_cursor_delete_dupsort(); return 0; } diff --git a/src/tests/test_cursor_delete2a.c b/src/tests/test_cursor_delete2a.c index a9a6c0cf3b6..e032d4f3ee0 100644 --- a/src/tests/test_cursor_delete2a.c +++ b/src/tests/test_cursor_delete2a.c @@ -26,7 +26,6 @@ test_cursor_delete2 (void) { r = dbenv->open(dbenv, ENVDIR, DB_PRIVATE|DB_INIT_MPOOL|DB_CREATE|DB_INIT_TXN, 0); CKERR(r); r = db_create(&db, dbenv, 0); CKERR(r); - r = db->set_flags(db, DB_DUP|DB_DUPSORT); CKERR(r); r = dbenv->txn_begin(dbenv, 0, &txn, 0); CKERR(r); r = db->open(db, txn, "primary.db", NULL, DB_BTREE, DB_CREATE, 0600); CKERR(r); r = txn->commit(txn, 0); CKERR(r); diff --git a/src/tests/test_cursor_delete_next.c b/src/tests/test_cursor_delete_next.c index e79b307b45d..9d1536926f8 100644 --- a/src/tests/test_cursor_delete_next.c +++ b/src/tests/test_cursor_delete_next.c @@ -28,9 +28,11 @@ setup_db (char* name) { toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); r = db_env_create(&env, 0); CKERR(r); +#ifdef USE_TDB + r = env->set_redzone(env, 0); CKERR(r); +#endif r = env->open(env, ENVDIR, DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL, 0666); CKERR(r); r = db_create(&db, env, 0); CKERR(r); - r = db->set_flags(db, DB_DUP | DB_DUPSORT); CKERR(r); r = db->set_pagesize(db, 4096); CKERR(r); r = db->open(db, null_txn, name, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r); } @@ -51,7 +53,7 @@ insert (void) { dbt_init(&value, "value1", sizeof("value1")); r = db->put(db, null_txn, &key, &value, DB_YESOVERWRITE); CKERR(r); - dbt_init(&key, "key", sizeof("key")); + dbt_init(&key, "key2", sizeof("key2")); dbt_init(&value, "value2", sizeof("value2")); r = db->put(db, null_txn, &key, &value, DB_YESOVERWRITE); CKERR(r); } @@ -76,10 +78,5 @@ test_main(int argc, char *const argv[]) { cursor_range_with_delete(DB_NEXT); close_db(); - setup_db("nextdup.db"); - insert(); - cursor_range_with_delete(DB_NEXT_DUP); - close_db(); - return 0; } diff --git a/src/tests/test_cursor_null.c b/src/tests/test_cursor_null.c index 84af466de47..9aed826a441 100644 --- a/src/tests/test_cursor_null.c +++ b/src/tests/test_cursor_null.c @@ -106,7 +106,7 @@ close_dbc (char name) { } static void -setup_dbs (u_int32_t dup_flags) { +setup_dbs (void) { int r; r = system("rm -rf " ENVDIR); @@ -124,10 +124,6 @@ setup_dbs (u_int32_t dup_flags) { r = db_create(&db, dbenv, 0); CKERR(r); - if (dup_flags) { - r = db->set_flags(db, dup_flags); - CKERR(r); - } char a; r = db->open(db, null_txn, "foobar.db", NULL, DB_BTREE, DB_CREATE, 0600); @@ -152,7 +148,7 @@ close_dbs (void) { } static void -test (u_int32_t dup_flags) { +test (void) { /* ********************************************************************** */ int key; int data; @@ -162,7 +158,7 @@ test (u_int32_t dup_flags) { else key = 1; if (i & 0x2) data = -1; else data = 1; - setup_dbs(dup_flags); + setup_dbs(); put(key, data); cget(DB_SET, TRUE, 'a', key, data); cget(DB_CURRENT, TRUE, 'a', key, data); @@ -174,7 +170,6 @@ test (u_int32_t dup_flags) { int test_main(int argc, char *const argv[]) { parse_args(argc, argv); - test(0); - test(DB_DUP | DB_DUPSORT); + test(); return 0; } diff --git a/src/tests/test_db_delboth.c b/src/tests/test_db_delboth.c deleted file mode 100644 index d4ffb1d35a6..00000000000 --- a/src/tests/test_db_delboth.c +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include -#include - - -#ifdef USE_TDB -enum {INFLATE=128}; -static void -db_put (DB *db, int k, int v) { - DBT key, val; - static int vv[INFLATE]; - vv[0] = v; - int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, vv, sizeof vv), DB_YESOVERWRITE); - CKERR(r); -} - -static void -expect_db_delboth (DB *db, int k, int v, u_int32_t flags, int expectr) { - DBT key, val; - static int vv[INFLATE]; - vv[0] = v; - int r = db->delboth(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, vv, sizeof vv), flags); - CKERR2(r, expectr); -} - -static void -expect_db_getboth (DB *db, int k, int v, int expectr) { - DBT key, val; - static int vv[INFLATE]; - vv[0] = v; - int r = db->get(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, vv, sizeof vv), DB_GET_BOTH); - CKERR2(r, expectr); -} - -static void -test_db_delboth (int n, int dup_mode) { - if (verbose) printf("test_db_delboth:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test.db.delete.brt"; - int r; - - r = system("rm -rf " ENVDIR); - CKERR(r); - r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - CKERR(r); - r = db->set_flags(db, dup_mode); - CKERR(r); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - CKERR(r); - - /* insert n pairs */ - int i; - for (i=0; iclose(db, 0); - CKERR(r); - r = db_create(&db, env, 0); - CKERR(r); - r = db->set_flags(db, dup_mode); - CKERR(r); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - CKERR(r); - - /* insert n pairs */ - for (i=0; iclose(db, 0); CKERR(r); - r = env->close(env, 0); CKERR(r); -} -#endif //USE_TDB - -int -test_main(int argc, char *const argv[]) { - parse_args(argc, argv); - - -#ifdef USE_TDB - test_db_delboth(0, 0); - - int i; - for (i = 1; i <= (1<<10); i *= 2) { - test_db_delboth(i, 0); - test_db_delboth(i, DB_DUP|DB_DUPSORT); - } -#else - if (verbose) printf("Test %s not applicable to BDB.\n", __FILE__); -#endif - - return 0; -} - diff --git a/src/tests/test_db_get_put_flags.c b/src/tests/test_db_get_put_flags.c index 7a50346512d..4f5eb8a4c11 100644 --- a/src/tests/test_db_get_put_flags.c +++ b/src/tests/test_db_get_put_flags.c @@ -50,6 +50,9 @@ setup (u_int32_t flags) { toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); /* Open/create primary */ r = db_env_create(&dbenv, 0); assert(r == 0); +#ifdef USE_TDB + r = dbenv->set_redzone(dbenv, 0); CKERR(r); +#endif r = dbenv->open(dbenv, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); r = db_create(&dbp, dbenv, 0); CKERR(r); dbp->set_errfile(dbp,0); // Turn off those annoying errors @@ -103,32 +106,19 @@ get_bad_flags (DB* db, u_int32_t flags, int r_expect, int keyint, int dataint) { PUT_TEST put_tests[] = { {0, DB_NODUPDATA, EINVAL, 0, 0}, //r_expect must change to 0, once implemented. - {DB_DUP|DB_DUPSORT, DB_NODUPDATA, EINVAL_FOR_TDB_OK_FOR_BDB, 0, 0}, //r_expect must change to 0, and don't skip with BDB once implemented. {0, DB_YESOVERWRITE, 0, 0, 0}, - {DB_DUP|DB_DUPSORT, DB_YESOVERWRITE, 0, 0, 0}, {0, DB_NOOVERWRITE, 0, 0, 0}, - {DB_DUP|DB_DUPSORT, DB_NOOVERWRITE, 0, 0, 0}, {0, 0, 0, 0, 0}, - {DB_DUP|DB_DUPSORT, 0, EINVAL_FOR_TDB_OK_FOR_BDB, 0, 0}, //r_expect must be EINVAL for TokuDB since DB_DUPSORT doesn't accept put with flags==0 - {DB_DUP|DB_DUPSORT, 0, EINVAL_FOR_TDB_OK_FOR_BDB, 0, 0}, }; const int num_put = sizeof(put_tests) / sizeof(put_tests[0]); GET_TEST get_tests[] = { - {{0, 0, 0, 0, 0}, DB_GET_BOTH, 0, 0, 0}, - {{0, 0, 0, 0, 0}, DB_GET_BOTH, 0, 0, 0}, - {{0, 0, 0, 0, 0}, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, - {{0, DB_YESOVERWRITE, 0, 0, 0}, DB_GET_BOTH, 0, 0, 0}, - {{0, DB_YESOVERWRITE, 0, 0, 0}, DB_GET_BOTH, 0, 0, 0}, - {{0, DB_YESOVERWRITE, 0, 0, 0}, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, - {{DB_DUP|DB_DUPSORT, DB_YESOVERWRITE, 0, 0, 0}, DB_GET_BOTH, 0, 0, 0}, - {{DB_DUP|DB_DUPSORT, 0, EINVAL_FOR_TDB_OK_FOR_BDB, 0, 0}, DB_GET_BOTH, IS_TDB ? DB_NOTFOUND : 0, 0, 0}, - {{DB_DUP|DB_DUPSORT, DB_YESOVERWRITE, 0, 0, 0}, DB_GET_BOTH, 0, 0, 0}, - {{DB_DUP|DB_DUPSORT, DB_YESOVERWRITE, 0, 0, 0}, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, - {{0, DB_YESOVERWRITE, 0, 0, 0}, DB_RMW, EINVAL, 0, 0}, - {{DB_DUP|DB_DUPSORT, 0, EINVAL_FOR_TDB_OK_FOR_BDB, 0, 0}, DB_GET_BOTH, DB_NOTFOUND, 0, 1}, + {{0, 0, 0, 0, 0}, 0 , 0, 0, 0}, + {{0, 0, 0, 0, 0}, 0 , 0, 0, 0}, + {{0, DB_YESOVERWRITE, 0, 0, 0}, 0 , 0, 0, 0}, + {{0, DB_YESOVERWRITE, 0, 0, 0}, 0 , 0, 0, 0}, + {{0, DB_YESOVERWRITE, 0, 0, 0}, DB_RMW, EINVAL, 0, 0}, {{0, 0, 0, 0, 0}, DB_RMW, EINVAL, 0, 0}, - {{DB_DUP|DB_DUPSORT, DB_YESOVERWRITE, 0, 0, 0}, DB_RMW, EINVAL, 0, 0}, }; const int num_get = sizeof(get_tests) / sizeof(get_tests[0]); diff --git a/src/tests/test_db_set_flags.c b/src/tests/test_db_set_flags.c index 9f3f5a844a7..47e2272d863 100644 --- a/src/tests/test_db_set_flags.c +++ b/src/tests/test_db_set_flags.c @@ -43,9 +43,6 @@ test_main(int argc, char *const argv[]) { parse_args(argc, argv); test_db_set_flags(0, 0, 0, 0); - test_db_set_flags(0, 0, DB_DUP, EINVAL); - test_db_set_flags(DB_DUP+DB_DUPSORT, 0, DB_DUP+DB_DUPSORT, EINVAL); - test_db_set_flags(DB_DUP+DB_DUPSORT, 0, 0, 0); return 0; } diff --git a/src/tests/test_db_subdb_different_flags.c b/src/tests/test_db_subdb_different_flags.c index 0e2d74609c4..43c45b6bbf0 100644 --- a/src/tests/test_db_subdb_different_flags.c +++ b/src/tests/test_db_subdb_different_flags.c @@ -35,7 +35,6 @@ test_main(int argc, char *const argv[]) { r = db->close(db, 0); CKERR(r); r = db_create(&db, env, 0); CKERR(r); - r = db->set_flags(db, DB_DUP | DB_DUPSORT); CKERR(r); r = db->open(db, null_txn, fname, "subdb", DB_BTREE, DB_CREATE, 0666); CKERR(r); r = db->close(db, 0); CKERR(r); @@ -52,7 +51,6 @@ test_main(int argc, char *const argv[]) { r = db_create(&db, env, 0); CKERR(r); r = db->open(db, null_txn, fname, "subdb", DB_BTREE, 0, 0666); CKERR(r); - r = db->get_flags(db, &flags); CKERR(r); assert(flags==(DB_DUP | DB_DUPSORT)); r = db->close(db, 0); CKERR(r); r = db_create(&db, env, 0); CKERR(r); diff --git a/src/tests/test_db_txn_locks_nonheaviside.c b/src/tests/test_db_txn_locks_nonheaviside.c index 30ac8d1111a..3e17d13c17a 100644 --- a/src/tests/test_db_txn_locks_nonheaviside.c +++ b/src/tests/test_db_txn_locks_nonheaviside.c @@ -151,7 +151,7 @@ early_abort (char name) { } static void -setup_dbs (u_int32_t dup_flags) { +setup_dbs (void) { int r; r = system("rm -rf " ENVDIR); @@ -169,14 +169,8 @@ setup_dbs (u_int32_t dup_flags) { r = db_create(&db, dbenv, 0); CKERR(r); - if (dup_flags) { - r = db->set_flags(db, dup_flags); - CKERR(r); - } r = db->set_bt_compare( db, int_dbt_cmp); CKERR(r); - r = db->set_dup_compare(db, int_dbt_cmp); - CKERR(r); char a; for (a = 'a'; a <= 'z'; a++) init_txn(a); @@ -207,15 +201,15 @@ close_dbs(void) { static __attribute__((__unused__)) void -test_abort (u_int32_t dup_flags) { +test_abort (void) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); early_abort('a'); cget(TRUE, FALSE, 'b', 1, 1, 0, 0, DB_SET); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 1, 1, 0, 0, DB_SET); cget(TRUE, FALSE, 'b', 1, 1, 0, 0, DB_SET); put(FALSE, 'a', 1, 1); @@ -231,33 +225,33 @@ test_abort (u_int32_t dup_flags) { } static void -test_both (u_int32_t dup_flags, u_int32_t db_flags) { +test_both (u_int32_t db_flags) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 1, 1, 0, 0, db_flags); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 1, 1, 0, 0, db_flags); cget(TRUE, FALSE, 'a', 2, 1, 0, 0, db_flags); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 1, 1, 0, 0, db_flags); cget(TRUE, FALSE, 'a', 1, 1, 0, 0, db_flags); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 1, 1, 0, 0, db_flags); cget(TRUE, FALSE, 'b', 2, 1, 0, 0, db_flags); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 1, 1, 0, 0, db_flags); cget(TRUE, FALSE, 'b', 1, 1, 0, 0, db_flags); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 1, 1, 0, 0, db_flags); cget(TRUE, FALSE, 'b', 1, 1, 0, 0, db_flags); put(FALSE, 'a', 1, 1); @@ -273,9 +267,9 @@ test_both (u_int32_t dup_flags, u_int32_t db_flags) { static void -test_last (u_int32_t dup_flags) { +test_last (void) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 0, 0, 0, 0, DB_LAST); put(FALSE, 'b', 2, 1); put(TRUE, 'a', 2, 1); @@ -284,7 +278,7 @@ test_last (u_int32_t dup_flags) { put(TRUE, 'b', 2, 1); close_dbs(); /* ****************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); cget(TRUE, TRUE, 'a', 0, 0, 1, 1, DB_LAST); put(FALSE, 'b', 2, 1); @@ -292,7 +286,7 @@ test_last (u_int32_t dup_flags) { cget(TRUE, TRUE, 'a', 0, 0, 1, 1, DB_LAST); close_dbs(); /* ****************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); put(TRUE, 'a', 3, 1); put(TRUE, 'a', 6, 1); @@ -303,17 +297,17 @@ test_last (u_int32_t dup_flags) { put(TRUE, 'b', -1, 1); close_dbs(); /* ****************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); cget(TRUE, TRUE, 'a', 0, 0, 1, 1, DB_LAST); - put((BOOL)(dup_flags != 0), 'b', 1, 0); + put(FALSE, 'b', 1, 0); close_dbs(); } static void -test_first (u_int32_t dup_flags) { +test_first (void) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', 0, 0, 0, 0, DB_FIRST); put(FALSE, 'b', 2, 1); put(TRUE, 'a', 2, 1); @@ -322,7 +316,7 @@ test_first (u_int32_t dup_flags) { put(TRUE, 'b', 2, 1); close_dbs(); /* ****************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); cget(TRUE, TRUE, 'a', 0, 0, 1, 1, DB_FIRST); put(TRUE, 'b', 2, 1); @@ -330,7 +324,7 @@ test_first (u_int32_t dup_flags) { cget(TRUE, TRUE, 'a', 0, 0, 1, 1, DB_FIRST); close_dbs(); /* ****************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); put(TRUE, 'a', 3, 1); put(TRUE, 'a', 6, 1); @@ -341,41 +335,41 @@ test_first (u_int32_t dup_flags) { put(FALSE, 'b', -1, 1); close_dbs(); /* ****************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); cget(TRUE, TRUE, 'a', 0, 0, 1, 1, DB_FIRST); - put((BOOL)(dup_flags != 0), 'b', 1, 2); + put(FALSE, 'b', 1, 2); close_dbs(); } static void -test_set_range (u_int32_t dup_flags, u_int32_t flag, int i) { +test_set_range (u_int32_t flag, int i) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); cget(TRUE, FALSE, 'a', i*2, i*1, 0, 0, flag); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); cget(TRUE, FALSE, 'b', i*2, i*1, 0, 0, flag); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); cget(TRUE, FALSE, 'b', i*1, i*1, 0, 0, flag); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); cget(TRUE, FALSE, 'b', i*5, i*5, 0, 0, flag); put(FALSE, 'a', i*7, i*6); @@ -398,61 +392,9 @@ test_set_range (u_int32_t dup_flags, u_int32_t flag, int i) { } static void -test_both_range (u_int32_t dup_flags, u_int32_t flag, int i) { - if (dup_flags == 0) { - test_both(dup_flags, flag); - return; - } +test_next (u_int32_t next_type) { /* ********************************************************************** */ - setup_dbs(dup_flags); - cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); - close_dbs(); - /* ********************************************************************** */ - setup_dbs(dup_flags); - cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); - cget(TRUE, FALSE, 'a', i*2, i*1, 0, 0, flag); - close_dbs(); - /* ********************************************************************** */ - setup_dbs(dup_flags); - cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); - cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); - close_dbs(); - /* ********************************************************************** */ - setup_dbs(dup_flags); - cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); - cget(TRUE, FALSE, 'b', i*2, i*1, 0, 0, flag); - close_dbs(); - /* ********************************************************************** */ - setup_dbs(dup_flags); - cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); - cget(TRUE, FALSE, 'b', i*1, i*1, 0, 0, flag); - close_dbs(); - /* ********************************************************************** */ - setup_dbs(dup_flags); - cget(TRUE, FALSE, 'a', i*1, i*1, 0, 0, flag); - cget(TRUE, FALSE, 'b', i*5, i*5, 0, 0, flag); - put(TRUE, 'a', i*5, 0); - put(FALSE, 'a', i*5, i*5); - put(FALSE, 'a', i*5, i*6); - put(TRUE, 'a', i*6, 0); - put(TRUE, 'b', i*1, 0); - early_commit('b'); - put(TRUE, 'a', i*5, 0); - put(TRUE, 'a', i*5, i*5); - put(TRUE, 'a', i*5, i*6); - put(TRUE, 'a', i*6, 0); - cget(TRUE, FALSE, 'a', i*1, i*1, i*4, i*4, flag); - cget(TRUE, TRUE, 'a', i*1, 0, i*1, 0, flag); - cget(FALSE, TRUE, 'c', i*5, i*5, i*5, i*5, flag); - early_commit('a'); - cget(TRUE, TRUE, 'c', i*5, i*5, i*5, i*5, flag); - close_dbs(); -} - -static void -test_next (u_int32_t dup_flags, u_int32_t next_type) { - /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 2, 1); put(TRUE, 'a', 5, 1); cget(TRUE, TRUE, 'a', 0, 0, 2, 1, next_type); @@ -461,12 +403,12 @@ test_next (u_int32_t dup_flags, u_int32_t next_type) { put(FALSE, 'b', -1, 1); cget(FALSE, TRUE, 'a', 0, 0, 4, 1, next_type); early_commit('b'); - cget(TRUE, TRUE, 'a', 2, 1, 2, 1, DB_GET_BOTH); + cget(TRUE, TRUE, 'a', 2, 1, 2, 1, DB_SET); cget(TRUE, TRUE, 'a', 0, 0, 4, 1, next_type); cget(TRUE, TRUE, 'a', 0, 0, 5, 1, next_type); close_dbs(); /* ****************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); put(TRUE, 'a', 3, 1); put(TRUE, 'a', 6, 1); @@ -480,9 +422,9 @@ test_next (u_int32_t dup_flags, u_int32_t next_type) { } static void -test_prev (u_int32_t dup_flags, u_int32_t next_type) { +test_prev (u_int32_t next_type) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', -2, -1); put(TRUE, 'a', -5, -1); cget(TRUE, TRUE, 'a', 0, 0, -2, -1, next_type); @@ -491,12 +433,12 @@ test_prev (u_int32_t dup_flags, u_int32_t next_type) { put(FALSE, 'b', 1, -1); cget(FALSE, TRUE, 'a', 0, 0, -4, -1, next_type); early_commit('b'); - cget(TRUE, TRUE, 'a', -2, -1, -2, -1, DB_GET_BOTH); + cget(TRUE, TRUE, 'a', -2, -1, -2, -1, DB_SET); cget(TRUE, TRUE, 'a', 0, 0, -4, -1, next_type); cget(TRUE, TRUE, 'a', 0, 0, -5, -1, next_type); close_dbs(); /* ****************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', -1, -1); put(TRUE, 'a', -3, -1); put(TRUE, 'a', -6, -1); @@ -510,92 +452,58 @@ test_prev (u_int32_t dup_flags, u_int32_t next_type) { } static void -test_nextdup (u_int32_t dup_flags, u_int32_t next_type, int i) { - /* ****************************************** */ - if (dup_flags == 0) return; - setup_dbs(dup_flags); - put(TRUE, 'c', i*1, i*1); - early_commit('c'); - cget(TRUE, TRUE, 'a', i*1, i*1, i*1, i*1, DB_GET_BOTH); - cget(TRUE, FALSE, 'a', 0, 0, i*1, i*1, next_type); - put(TRUE, 'b', i*2, i*1); - put(FALSE, 'b', i*1, i*1); - put(FALSE, 'b', i*1, i*2); - put(TRUE, 'b', i*1, 0); - close_dbs(); - /* ****************************************** */ - setup_dbs(dup_flags); - put(TRUE, 'c', i*1, i*1); - put(TRUE, 'c', i*1, i*3); - early_commit('c'); - cget(TRUE, TRUE, 'a', i*1, i*1, i*1, i*1, DB_GET_BOTH); - cget(TRUE, TRUE, 'a', 0, 0, i*1, i*3, next_type); - put(TRUE, 'b', i*2, i*1); - put(TRUE, 'b', i*1, i*4); - put(FALSE, 'b', i*1, i*1); - put(FALSE, 'b', i*1, i*2); - put(FALSE, 'b', i*1, i*3); - put(TRUE, 'b', i*1, 0); - close_dbs(); -} - -static void -test_cdel (u_int32_t dup_flags) { +test_cdel (void) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'c', 1, 1); early_commit('c'); - cget(TRUE, TRUE, 'a', 1, 1, 1, 1, DB_GET_BOTH); + cget(TRUE, TRUE, 'a', 1, 1, 1, 1, DB_SET); cdel(TRUE, TRUE, 'a'); - cget(FALSE, TRUE, 'b', 1, 1, 1, 1, DB_GET_BOTH); - cget((BOOL)(dup_flags != 0), FALSE, 'b', 1, 2, 1, 2, DB_GET_BOTH); - cget((BOOL)(dup_flags != 0), FALSE, 'b', 1, 0, 1, 0, DB_GET_BOTH); - cget(TRUE, FALSE, 'b', 0, 0, 0, 0, DB_GET_BOTH); - cget(TRUE, FALSE, 'b', 2, 10, 2, 10, DB_GET_BOTH); + cget(FALSE, TRUE, 'b', 1, 1, 1, 1, DB_SET); + cget(FALSE, FALSE, 'b', 1, 2, 1, 2, DB_SET); + cget(FALSE, FALSE, 'b', 1, 0, 1, 0, DB_SET); + cget(TRUE, FALSE, 'b', 0, 0, 0, 0, DB_SET); + cget(TRUE, FALSE, 'b', 2, 10, 2, 10, DB_SET); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'c', 1, 1); early_commit('c'); - cget(TRUE, TRUE, 'a', 1, 1, 1, 1, DB_GET_BOTH); - cget(TRUE, TRUE, 'b', 1, 1, 1, 1, DB_GET_BOTH); + cget(TRUE, TRUE, 'a', 1, 1, 1, 1, DB_SET); + cget(TRUE, TRUE, 'b', 1, 1, 1, 1, DB_SET); cdel(FALSE, TRUE, 'a'); close_dbs(); } static void -test_dbdel (u_int32_t dup_flags) { - if (dup_flags != 0) { - if (verbose) printf("Pinhead! Can't dbdel now with duplicates!\n"); - return; - } +test_dbdel (void) { /* If DB_DELETE_ANY changes to 0, then find is meaningful and has to be fixed in test_dbdel*/ /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'c', 1, 1); early_commit('c'); dbdel(TRUE, TRUE, 'a', 1); - cget(FALSE, TRUE, 'b', 1, 1, 1, 1, DB_GET_BOTH); - cget(FALSE, TRUE, 'b', 1, 4, 1, 4, DB_GET_BOTH); - cget(FALSE, TRUE, 'b', 1, 0, 1, 4, DB_GET_BOTH); - cget(TRUE, FALSE, 'b', 0, 0, 0, 0, DB_GET_BOTH); - cget(TRUE, FALSE, 'b', 2, 10, 2, 10, DB_GET_BOTH); + cget(FALSE, TRUE, 'b', 1, 1, 1, 1, DB_SET); + cget(FALSE, TRUE, 'b', 1, 4, 1, 4, DB_SET); + cget(FALSE, TRUE, 'b', 1, 0, 1, 4, DB_SET); + cget(TRUE, FALSE, 'b', 0, 0, 0, 0, DB_SET); + cget(TRUE, FALSE, 'b', 2, 10, 2, 10, DB_SET); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); dbdel(TRUE, TRUE, 'a', 1); - cget(FALSE, TRUE, 'b', 1, 1, 1, 1, DB_GET_BOTH); - cget(FALSE, TRUE, 'b', 1, 4, 1, 4, DB_GET_BOTH); - cget(FALSE, TRUE, 'b', 1, 0, 1, 4, DB_GET_BOTH); - cget(TRUE, FALSE, 'b', 0, 0, 0, 0, DB_GET_BOTH); - cget(TRUE, FALSE, 'b', 2, 10, 2, 10, DB_GET_BOTH); + cget(FALSE, TRUE, 'b', 1, 1, 1, 1, DB_SET); + cget(FALSE, TRUE, 'b', 1, 4, 1, 4, DB_SET); + cget(FALSE, TRUE, 'b', 1, 0, 1, 4, DB_SET); + cget(TRUE, FALSE, 'b', 0, 0, 0, 0, DB_SET); + cget(TRUE, FALSE, 'b', 2, 10, 2, 10, DB_SET); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'c', 1, 1); early_commit('c'); - cget(TRUE, TRUE, 'b', 1, 1, 1, 1, DB_GET_BOTH); + cget(TRUE, TRUE, 'b', 1, 1, 1, 1, DB_SET); dbdel(FALSE, TRUE, 'a', 1); dbdel(TRUE, TRUE, 'a', 2); dbdel(TRUE, TRUE, 'a', 0); @@ -603,12 +511,12 @@ test_dbdel (u_int32_t dup_flags) { } static void -test_current (u_int32_t dup_flags) { +test_current (void) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); early_commit('a'); - cget(TRUE, TRUE, 'b', 1, 1, 1, 1, DB_GET_BOTH); + cget(TRUE, TRUE, 'b', 1, 1, 1, 1, DB_SET); cget(TRUE, TRUE, 'b', 1, 1, 1, 1, DB_CURRENT); cdel(TRUE, TRUE, 'b'); cget(TRUE, FALSE, 'b', 1, 1, 1, 1, DB_CURRENT); @@ -634,56 +542,45 @@ ignore (void *ignore __attribute__((__unused__))) { #define TOKU_IGNORE(x) ignore((void*)x) static void -test (u_int32_t dup_flags) { +test (void) { /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); early_abort('a'); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); early_commit('a'); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); put(TRUE, 'a', 1, 1); close_dbs(); /* ********************************************************************** */ - test_both(dup_flags, DB_SET); - test_both(dup_flags, DB_GET_BOTH); + test_both( DB_SET); /* ********************************************************************** */ - test_first(dup_flags); + test_first(); /* ********************************************************************** */ - test_last(dup_flags); + test_last(); /* ********************************************************************** */ - test_set_range(dup_flags, DB_SET_RANGE, 1); + test_set_range( DB_SET_RANGE, 1); #ifdef DB_SET_RANGE_REVERSE - test_set_range(dup_flags, DB_SET_RANGE_REVERSE, -1); + test_set_range( DB_SET_RANGE_REVERSE, -1); #endif /* ********************************************************************** */ - test_both_range(dup_flags, DB_GET_BOTH_RANGE, 1); -#ifdef DB_GET_BOTH_RANGE_REVERSE - test_both_range(dup_flags, DB_GET_BOTH_RANGE_REVERSE, -1); -#endif + test_next( DB_NEXT); + test_next( DB_NEXT_NODUP); /* ********************************************************************** */ - test_next(dup_flags, DB_NEXT); - test_next(dup_flags, DB_NEXT_NODUP); + test_prev( DB_PREV); + test_prev( DB_PREV_NODUP); /* ********************************************************************** */ - test_prev(dup_flags, DB_PREV); - test_prev(dup_flags, DB_PREV_NODUP); + test_cdel(); /* ********************************************************************** */ - test_nextdup(dup_flags, DB_NEXT_DUP, 1); - #ifdef DB_PREV_DUP - test_nextdup(dup_flags, DB_PREV_DUP, -1); - #endif + test_dbdel(); /* ********************************************************************** */ - test_cdel(dup_flags); - /* ********************************************************************** */ - test_dbdel(dup_flags); - /* ********************************************************************** */ - test_current(dup_flags); + test_current(); /* ********************************************************************** */ } @@ -696,8 +593,7 @@ test_main(int argc, char *const argv[]) { printf("Warning: " __FILE__" does not work in BDB.\n"); } } else { - test(0); - test(DB_DUP | DB_DUPSORT); + test(); /* test_abort(0); test_abort(DB_DUP | DB_DUPSORT); diff --git a/src/tests/test_db_txn_locks_read_uncommitted.c b/src/tests/test_db_txn_locks_read_uncommitted.c index a5bda36ef1a..97ef1c056ce 100644 --- a/src/tests/test_db_txn_locks_read_uncommitted.c +++ b/src/tests/test_db_txn_locks_read_uncommitted.c @@ -81,7 +81,7 @@ early_commit (char name) { } static void -setup_dbs (u_int32_t dup_flags) { +setup_dbs (void) { int r; r = system("rm -rf " ENVDIR); @@ -99,14 +99,8 @@ setup_dbs (u_int32_t dup_flags) { r = db_create(&db, dbenv, 0); CKERR(r); - if (dup_flags) { - r = db->set_flags(db, dup_flags); - CKERR(r); - } r = db->set_bt_compare( db, int_dbt_cmp); CKERR(r); - r = db->set_dup_compare(db, int_dbt_cmp); - CKERR(r); char a; for (a = 'a'; a <= 'z'; a++) init_txn(a, 0); @@ -190,13 +184,13 @@ table_prelock(char txn, BOOL success) { } static void -test (u_int32_t dup_flags) { +test (void) { char txn; /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); close_dbs(); /* ********************************************************************** */ - setup_dbs(dup_flags); + setup_dbs(); table_scan('0', TRUE); table_prelock('a', TRUE); put(TRUE, 'a', 0, 0); @@ -221,7 +215,6 @@ test (u_int32_t dup_flags) { int test_main(int argc, char *const argv[]) { parse_args(argc, argv); - test(0); - test(DB_DUP | DB_DUPSORT); + test(); return 0; } diff --git a/src/tests/test_dup_delete.c b/src/tests/test_dup_delete.c deleted file mode 100644 index 32e0b001f4a..00000000000 --- a/src/tests/test_dup_delete.c +++ /dev/null @@ -1,762 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -expect (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -/* verify dup keys delete */ -static void -test_dup_delete (int n, int dup_mode) { - if (verbose) printf("test_dup_delete:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_dup_delete.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n-1 unique keys {0, 1, n-1} - {n/2} */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert n duplicates */ - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - unsigned int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == htonl(n)); - toku_free(val.data); - } - - { - DBT key; int k = htonl(n/2); - r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); - } - - /* verify lookup fails */ - { - int k = htonl(n/2); - DBT key, val; - r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == DB_NOTFOUND); - } - - /* verify all dups are removed using a cursor */ - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; ic_close(cursor); - assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0), assert(r == 0); -} - -static __attribute__((__unused__)) -void -test_dup_delete_delete (int n) { - if (verbose) printf("test_dup_delete_delete:%d\n", n); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_dup_delete_delete.brt"; - int r; - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, DB_DUP); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert n-1 unique keys {0, 1, n-1} - {n/2} */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, DB_DUP); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert n duplicates */ - for (i=0; idel(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); - - /* delete again */ - r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); - - - /* verify all dups are remove using a cursor */ - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; ic_close(cursor); - assert(r == 0); - - r = db->close(db, 0); - assert(r == 0); - r = env->close(env, 0), assert(r == 0); -} - -static void -test_dup_delete_insert (int n, int dup_mode) { - if (verbose) printf("test_dup_delete_insert:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_dup_delete_insert.brt"; - int r; - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert n-1 unique keys {0, 1, n-1} - {n/2} */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert n duplicates */ - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - unsigned int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == htonl(0)); - toku_free(val.data); - } - - { - int k = htonl(n/2); - DBT key; - r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); - } - - /* insert n duplicates */ - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - unsigned int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == htonl(0)); - toku_free(val.data); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; ic_close(cursor); - assert(r == 0); - - r = db->close(db, 0); - assert(r == 0); - r = env->close(env, 0), assert(r == 0); -} - -static __attribute__((__unused__)) -void -test_all_dup_delete_insert (int n) { - if (verbose) printf("test_all_dup_delete_insert:%d\n", n); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_all_dup_delete_insert.brt"; - int r; - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, DB_DUP); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, DB_DUP); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert n duplicates */ - for (i=0; idel(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); - } - - /* insert n duplicates */ - for (i=0; icursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; ic_close(cursor); - assert(r == 0); - - r = db->close(db, 0); - assert(r == 0); - r = env->close(env, 0), assert(r == 0); -} - -static void -test_walk_empty (int n, int dup_mode) { - if (verbose) printf("test_walk_empty:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_walk_empty.brt"; - int r; - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert n duplicates */ - for (i=0; idel(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); - assert(r == 0); - - { - DBT key, val; - r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r != 0); - } - - r = cursor->c_close(cursor); - assert(r == 0); - - r = db->close(db, 0); - assert(r == 0); - r = env->close(env, 0), assert(r == 0); -} - -/* insert, close, delete, insert, search */ -static __attribute__((__unused__)) -void -test_icdi_search (int n, int dup_mode) { - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - int r; - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - unsigned int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == htonl(0)); - toku_free(val.data); - } - - /* reopen the database to force nonleaf buffering */ - r = db->close(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - { - int k = htonl(n/2); - DBT key; - r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); - } - - /* insert n duplicates */ - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - unsigned int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == htonl(n)); - toku_free(val.data); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; ic_close(cursor); - assert(r == 0); - - r = db->close(db, 0); - assert(r == 0); - r = env->close(env, 0), assert(r == 0); -} - -/* insert, close, insert, search */ -static __attribute__((__unused__)) -void -test_ici_search (int n, int dup_mode) { - if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_ici_search.brt"; - int r; - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - unsigned int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == htonl(0)); - toku_free(val.data); - } - - /* reopen the database to force nonleaf buffering */ - r = db->close(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert n duplicates */ - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - unsigned int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == htonl(0)); - toku_free(val.data); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; i<2*n; i++) { - expect(cursor, htonl(n/2), htonl(i)); - } - - r = cursor->c_close(cursor); - assert(r == 0); - - r = db->close(db, 0); - assert(r == 0); - r = env->close(env, 0), assert(r == 0); -} - -static void -expect_db_lookup (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -/* insert 0, insert 1, close, insert 0, search 0 */ -static __attribute__((__unused__)) -void -test_i0i1ci0_search (int n, int dup_mode) { - if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_i0i1ci0.brt"; - int r; - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert <0,0> */ - db_put(db, 0, 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert <0,1> */ - db_put(db, 0, 1); - - /* verify dup search digs deep into the tree */ - expect_db_lookup(db, 0, 0); - - r = db->close(db, 0); - assert(r == 0); - r = env->close(env, 0), assert(r == 0); -} - -int -test_main(int argc, char *const argv[]) { - int i; - int r; - - parse_args(argc, argv); - -#ifdef USE_BDB - /* dup tests */ - for (i = 1; i <= (1<<16); i *= 2) { - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - test_dup_delete(i, DB_DUP); - test_dup_delete_insert(i, DB_DUP); - test_all_dup_delete_insert(i); - test_walk_empty(i, DB_DUP); - } -#endif - - /* dupsort tests */ - for (i = 1; i <= (1<<16); i *= 2) { - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - test_dup_delete(i, DB_DUP + DB_DUPSORT); - test_dup_delete_insert(i, DB_DUP + DB_DUPSORT); - test_walk_empty(i, DB_DUP + DB_DUPSORT); - } - - return 0; -} diff --git a/src/tests/test_dup_dup.c b/src/tests/test_dup_dup.c deleted file mode 100644 index 338515163a0..00000000000 --- a/src/tests/test_dup_dup.c +++ /dev/null @@ -1,301 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include -#include - - -int errors; - -static void -db_put (DB *db, int k, int v, u_int32_t put_flags, int rexpect) { - DBT key, val; - // Turn off error messages if we expect there to be an error. - if (rexpect!=0) { - db->set_errfile(db, 0); - } else { - db->set_errfile(db, stderr); - } - int r = db->put(db, 0, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), put_flags); - if (r != rexpect) { - if (IS_TDB) { - if (r == EINVAL && put_flags == DB_NODUPDATA) { - static int did_warn = 0; - if (!did_warn) { - if (verbose) printf("%s:%d:WARNING:tokdub does not support DB_NODUPDATA yet\n", __FILE__, __LINE__); - did_warn=1; - } - return; - } - } - printf("Expected %d, got %d\n", rexpect, r); - if (r != rexpect) errors = 1; - } -} - -static int -maybe_do_db_dup_warning (int r, int dup_mode) { - if (IS_TDB) { - static int did_warn=0; - if (r != 0 && dup_mode == DB_DUP) { - if (did_warn==0) { - did_warn=1; - if (verbose) printf("%s:%d:WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__); - } - return 1; - } - } - return 0; -} - -static void -test_dup_key (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) { - if (verbose) printf("test_dup_key: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_insert.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - db->set_errfile(db, stderr); - r = db->set_flags(db, dup_mode); - if (maybe_do_db_dup_warning(r, dup_mode)) { - r = db->close(db, 0); assert(r == 0); return; - } - assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - if (maybe_do_db_dup_warning(r, dup_mode)) { - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); - return; - } - assert(r == 0); - - db_put(db, 0, 0, put_flags, rexpect); - db_put(db, 0, 1, put_flags, rexpectdupdup); - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - for (;;) { - DBT key, val; - r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - if (r != 0) break; - assert(key.size == sizeof (int)); - assert(val.size == sizeof (int)); - int kk, vv; - memcpy(&kk, key.data, key.size); - memcpy(&vv, val.data, val.size); - if (verbose) printf("kk %d vv %d\n", kk, vv); - toku_free(key.data); - toku_free(val.data); - } - - r = cursor->c_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -static void -test_dup_dup (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) { - if (verbose) printf("test_dup_dup: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_insert.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - db->set_errfile(db, stderr); - r = db->set_flags(db, dup_mode); - if (maybe_do_db_dup_warning(r, dup_mode)) { - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); - return; - } - assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - if (maybe_do_db_dup_warning(r, dup_mode)) { - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); - return; - } - assert(r == 0); - - db_put(db, 0, 0, put_flags, rexpect); - db_put(db, 0, 0, put_flags, rexpectdupdup); - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - for (;;) { - DBT key, val; - r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - if (r != 0) break; - assert(key.size == sizeof (int)); - assert(val.size == sizeof (int)); - int kk, vv; - memcpy(&kk, key.data, key.size); - memcpy(&vv, val.data, val.size); - if (verbose) printf("kk %d vv %d\n", kk, vv); - toku_free(key.data); - toku_free(val.data); - } - - r = cursor->c_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -static void -test_put_00_01_01 (int dup_mode, u_int32_t put_flags) { - if (verbose) printf("test_put_00_01_01: %d, %u\n", dup_mode, put_flags); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_insert.brt"; - int r, expectr; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - db->set_errfile(db, stderr); - r = db->set_flags(db, dup_mode); - if (maybe_do_db_dup_warning(r, dup_mode)) { - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); - return; - } - assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - expectr = 0; - db_put(db, 0, 0, put_flags, expectr); - - expectr = put_flags == DB_NOOVERWRITE ? DB_KEYEXIST : 0; - db_put(db, 0, 1, put_flags, expectr); - - expectr = (put_flags == DB_NOOVERWRITE || dup_mode & DB_DUPSORT) ? DB_KEYEXIST : 0; - if (IS_TDB) { - if (put_flags == DB_YESOVERWRITE) expectr = 0; - } - db_put(db, 0, 1, put_flags, expectr); - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - for (;;) { - DBT key, val; - r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - if (r != 0) break; - assert(key.size == sizeof (int)); - assert(val.size == sizeof (int)); - int kk, vv; - memcpy(&kk, key.data, key.size); - memcpy(&vv, val.data, val.size); - if (verbose) printf("kk %d vv %d\n", kk, vv); - toku_free(key.data); - toku_free(val.data); - } - - r = cursor->c_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -int -test_main(int argc, char *const argv[]) { - - int yes_overwrite=0; - if (IS_TDB) - yes_overwrite = DB_YESOVERWRITE; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - test_put_00_01_01(0, 0); - test_put_00_01_01(0, DB_NOOVERWRITE); - - test_put_00_01_01(DB_DUP | DB_DUPSORT, yes_overwrite); - test_put_00_01_01(DB_DUP | DB_DUPSORT, DB_NOOVERWRITE); - - /* dup key uniq data */ - test_dup_key(0, 0, 0, 0); - test_dup_key(0, DB_NODUPDATA, EINVAL, EINVAL); - test_dup_key(0, DB_NOOVERWRITE, 0, DB_KEYEXIST); - - test_dup_key(DB_DUP, 0, 0, 0); - test_dup_key(DB_DUP, DB_NODUPDATA, EINVAL, EINVAL); - test_dup_key(DB_DUP, DB_NOOVERWRITE, 0, DB_KEYEXIST); - - if (IS_TDB) { - test_dup_key(DB_DUP | DB_DUPSORT, 0, EINVAL, EINVAL); - //test_dup_key(DB_DUP | DB_DUPSORT, 0, 0, 0); - test_dup_key(DB_DUP | DB_DUPSORT, DB_YESOVERWRITE, 0, 0); - } else { - test_dup_key(DB_DUP | DB_DUPSORT, 0, 0, 0); - } - test_dup_key(DB_DUP | DB_DUPSORT, DB_NODUPDATA, 0, 0); - test_dup_key(DB_DUP | DB_DUPSORT, DB_NOOVERWRITE, 0, DB_KEYEXIST); - - /* dup key dup data */ - test_dup_dup(0, 0, 0, 0); - test_dup_dup(0, DB_NODUPDATA, EINVAL, EINVAL); - test_dup_dup(0, DB_NOOVERWRITE, 0, DB_KEYEXIST); - - test_dup_dup(DB_DUP, 0, 0, 0); - test_dup_dup(DB_DUP, DB_NODUPDATA, EINVAL, EINVAL); - test_dup_dup(DB_DUP, DB_NOOVERWRITE, 0, DB_KEYEXIST); - - if (IS_TDB) { - // test_dup_dup(DB_DUP | DB_DUPSORT, 0, EINVAL, EINVAL); - //test_dup_dup(DB_DUP | DB_DUPSORT, 0, 0, DB_KEYEXIST); - test_dup_dup(DB_DUP | DB_DUPSORT, DB_YESOVERWRITE, 0, 0); - } else { - test_dup_dup(DB_DUP | DB_DUPSORT, 0 , 0, DB_KEYEXIST); - } - test_dup_dup(DB_DUP | DB_DUPSORT, DB_NODUPDATA, 0, DB_KEYEXIST); - test_dup_dup(DB_DUP | DB_DUPSORT, DB_NOOVERWRITE, 0, DB_KEYEXIST); - - return errors; -} diff --git a/src/tests/test_dup_flags.c b/src/tests/test_dup_flags.c index 1098bc32569..815a9636981 100644 --- a/src/tests/test_dup_flags.c +++ b/src/tests/test_dup_flags.c @@ -30,25 +30,12 @@ test_dup_flags (u_int32_t dup_flags) { DB *db; r = db_create(&db, env, 0); assert(r == 0); + if (IS_TDB) assert(dup_flags==0); r = db->set_flags(db, dup_flags); - if (IS_TDB) { - if (r != 0 && dup_flags == DB_DUP) { - if (verbose) printf("%s:%d: WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__); - r = db->close(db, 0); assert(r == 0); - return; - } - } assert(r == 0); u_int32_t flags; r = db->get_flags(db, &flags); assert(r == 0); assert(flags == dup_flags); + if (IS_TDB) assert(dup_flags==0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - if (IS_TDB) { - if (r != 0 && dup_flags == DB_DUP) { - if (verbose) printf("%s:%d: WARNING: tokudb does not support DB_DUP\n", __FILE__, __LINE__); - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); - return; - } - } assert(r == 0); r = db->close(db, 0); assert(r == 0); @@ -85,8 +72,6 @@ test_main(int argc, char *const argv[]) { /* test flags */ test_dup_flags(0); - test_dup_flags(DB_DUP); - test_dup_flags(DB_DUP + DB_DUPSORT); return 0; } diff --git a/src/tests/test_dup_insert.c b/src/tests/test_dup_insert.c deleted file mode 100644 index 44c0a7e6341..00000000000 --- a/src/tests/test_dup_insert.c +++ /dev/null @@ -1,294 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -expect (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -static int mycmp(const void *a, const void *b) { - return memcmp(a, b, sizeof (int)); -} - -/* verify that key insertions are stored in insert order */ -static void -test_insert (int n, int dup_mode) { - if (verbose) printf("test_insert:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_insert.brt"; - int r; - int i; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - int values[n]; - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - if (i == n/2) { - if (dup_mode & DB_DUPSORT) - assert(vv == sortvalues[0]); - else if (dup_mode & DB_DUP) - assert(vv == values[0]); - else - assert(vv == values[n-1]); - } else - assert(vv == values[i]); - toku_free(val.data); - } - - /* verify the sort order with a cursor */ - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; ic_close(cursor); - assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -/* verify dup keys are buffered in order in non-leaf nodes */ -static void -test_nonleaf_insert (int n, int dup_mode) { - if (verbose) printf("test_nonleaf_insert:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_nonleaf_insert.brt"; - int r; - int i; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - int values[n]; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert n duplicates */ - for (i=0; iget(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - if (i == n/2) { - if (dup_mode & DB_DUPSORT) - assert(vv == sortvalues[0]); - else if (dup_mode & DB_DUP) - assert(vv == values[0]); - else - assert(vv == values[n-1]); - } else - assert(vv == values[i]); - toku_free(val.data); - } - - /* verify the sort order with a cursor */ - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; ic_close(cursor); - assert(r == 0); - - r = db->close(db, 0); - assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - /* nodup tests */ - for (i = 1; i <= (1<<16); i *= 2) { - test_insert(i, 0); - test_nonleaf_insert(i, 0); - } - - /* dup tests */ - if (IS_TDB) { - // printf("%s:%d:WARNING:tokudb does not support DB_DUP\n", __FILE__, __LINE__); - } else { - for (i = 1; i <= (1<<16); i *= 2) { - test_insert(i, DB_DUP); - test_nonleaf_insert(i, DB_DUP); - } - } - - /* dupsort tests */ - for (i = 1; i <= (1<<16); i *= 2) { - test_insert(i, DB_DUP + DB_DUPSORT); - test_nonleaf_insert(i, DB_DUP + DB_DUPSORT); - } - - return 0; -} diff --git a/src/tests/test_dup_next.c b/src/tests/test_dup_next.c deleted file mode 100644 index ae2665e60e9..00000000000 --- a/src/tests/test_dup_next.c +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" -/* test the cursor DB_NEXT_DUP operation */ - - -#include -#include - -#include -#include -#include -#include -#include - - -static int testlevel = 0; - -static DBT * -dbt_init_zero (DBT *dbt) { - memset(dbt, 0, sizeof *dbt); - return dbt; -} - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -expect_cursor_set (DBC *cursor, int k, int expectv) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_zero(&val), DB_SET); - assert(r == 0); - assert(val.size == sizeof expectv); - int vv; - memcpy(&vv, val.data, val.size); - assert(expectv == vv); -} - -static int -expect_cursor_get (DBC *cursor, int expectk, int expectv, int op) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_zero(&key), dbt_init_zero(&val), op); - if (r == 0) { - assert(key.size == sizeof expectk); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof expectv); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != expectk || vv != expectv) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(expectk), (uint32_t)htonl(kk), (uint32_t)htonl(expectv), (uint32_t)htonl(vv)); - assert(kk == expectk); - assert(vv == expectv); - } - return r; -} - -static void -test_dup_next (int n, int dup_mode) { - if (verbose) printf("test_dup_next:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_dup_next.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - db->set_errfile(db,0); // Turn off those annoying errors - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - int i; - - /* insert (0,0), (1,0), .. (n-1,0) */ - for (i=0; icursor(db, null_txn, &cursor, 0); assert(r == 0); - - /* assert cursor not set */ - r = expect_cursor_get(cursor, htonl(1), htonl(0), DB_NEXT_DUP); assert(r == EINVAL); - - /* set the cursor to (n/2,0) */ - expect_cursor_set(cursor, htonl(n/2), htonl(0)); - - for (i=1; ic_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -int -test_main(int argc, char *const argv[]) { - int i; - for (i = 1; i < argc; i++) { - const char *arg = argv[i]; - if (0 == strcmp(arg, "-v") || 0 == strcmp(arg, "--verbose")) { - verbose++; - continue; - } - if (0 == strcmp(arg, "-l") || 0 == strcmp(arg, "--level")) { - testlevel++; - continue; - } - } - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - for (i = 1; i <= 65536; i = testlevel ? i+1 : i*2) { - test_dup_next(i, DB_DUP + DB_DUPSORT); - test_dup_next(i, 0); - } - - return 0; -} diff --git a/src/tests/test_dup_search.c b/src/tests/test_dup_search.c deleted file mode 100644 index d27dc500c56..00000000000 --- a/src/tests/test_dup_search.c +++ /dev/null @@ -1,382 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_get (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -/* insert, close, delete, insert, search */ -static void -test_icdi_search (int n, int dup_mode) { - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - db_del(db, htonl(n/2)); - - /* insert n duplicates */ - for (i=0; icursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; ic_close(cursor); - assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -/* insert, close, insert, search */ -static void -test_ici_search (int n, int dup_mode) { - if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_ici_search.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert n duplicates */ - for (i=0; icursor(db, null_txn, &cursor, 0); - assert(r == 0); - - for (i=0; i<2*n; i++) { - expect_cursor_get(cursor, htonl(n/2), htonl(i)); - } - - r = cursor->c_close(cursor); - assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -/* insert 0, insert 1, close, insert 0, search 0 */ -static void -test_i0i1ci0_search (int n, int dup_mode) { - if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_i0i1ci0.brt"; - int r; - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* insert <0,0> */ - db_put(db, 0, 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* insert <0,1> */ - db_put(db, 0, 1); - - /* verify dup search digs deep into the tree */ - expect_db_get(db, 0, 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -/* insert dup keys with data descending from n to 1 */ -static void -test_reverse_search (int n, int dup_mode) { - if (verbose) printf("test_reverse_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_reverse_search.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); - assert(r == 0); - - /* seq inserts to build the tree */ - int i; - for (i=0; iclose(db, 0); - assert(r == 0); - r = db_create(&db, env, 0); - assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); - r = db->set_pagesize(db, 4096); - assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); - assert(r == 0); - - /* dup key inserts , , .. */ - for (i=0; iclose(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - int limit = 1<<13; - if (verbose > 1) - limit = 1<<16; - - /* dup search */ - if (IS_TDB) { - if (verbose) printf("%s:%d:WARNING:tokudb does not support DB_DUP\n", __FILE__, __LINE__); - } else { - for (i = 1; i <= limit; i *= 2) { - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - test_ici_search(i, DB_DUP); - test_icdi_search(i, DB_DUP); - test_i0i1ci0_search(i, DB_DUP); - } - } - - /* dupsort search */ - for (i = 1; i <= limit; i *= 2) { - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - test_ici_search(i, DB_DUP + DB_DUPSORT); - test_icdi_search(i, DB_DUP + DB_DUPSORT); - test_i0i1ci0_search(i, DB_DUP + DB_DUPSORT); - } - - /* insert data in descending order */ - for (i = 1; i <= limit; i *= 2) { - test_reverse_search(i, 0); -#ifdef USE_BDB - test_reverse_search(i, DB_DUP); -#endif - test_reverse_search(i, DB_DUP + DB_DUPSORT); - } - - return 0; -} diff --git a/src/tests/test_dupsort_del.c b/src/tests/test_dupsort_del.c deleted file mode 100644 index 567bf4d95be..00000000000 --- a/src/tests/test_dupsort_del.c +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" -/* Test to see if delete works right with dupsort. - * The issue is that things might look OK before the commit, but bad after the commit. - */ - -#include -#include - -static DB_ENV *env; -static DB *db; -static DB_TXN *txn; - -#ifndef TOKUDB -#define DB_YESOVERWRITE 0 -#endif - -static void insert (int i, int j) { - char hello[30], there[30]; - DBT key,data; - if (verbose) printf("Insert %d\n", i); - snprintf(hello, sizeof(hello), "hello%d", i); - snprintf(there, sizeof(there), "there%d", j); - int r = db->put(db, txn, - dbt_init(&key, hello, strlen(hello)+1), - dbt_init(&data, there, strlen(there)+1), - DB_YESOVERWRITE); - CKERR(r); -} - -static void delete (int i, int j) { - char hello[30], there[30]; - DBC *dbc; - DBT key, val; - if (verbose) printf("delete %d\n", i); - snprintf(hello, sizeof(hello), "hello%d", i); - snprintf(there, sizeof(there), "there%d", j); - int r = db->cursor(db, txn, &dbc, 0); - CKERR(r); - r = dbc->c_get(dbc, - dbt_init(&key, hello, strlen(hello)+1), - dbt_init(&val, there, strlen(there)+1), - DB_GET_BOTH); - CKERR(r); - r = dbc->c_del(dbc, 0); - CKERR(r); - r = dbc->c_close(dbc); - CKERR(r); -} - -static void lookup (int i, int expect, int expectj) { - char hello[30], there[30]; - DBT key,data; - snprintf(hello, sizeof(hello), "hello%d", i); - memset(&data, 0, sizeof(data)); - if (verbose) printf("Looking up %d (expecting %s)\n", i, expect==0 ? "to find" : "not to find"); - int r = db->get(db, txn, - dbt_init(&key, hello, strlen(hello)+1), - &data, - 0); - assert(expect==r); - if (expect==0) { - CKERR(r); - snprintf(there, sizeof(there), "there%d", expectj); - assert(data.size==strlen(there)+1); - assert(strcmp(data.data, there)==0); - } -} - -static void -test_dupsort_del (void) { - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); - - r=db_env_create(&env, 0); assert(r==0); - env->set_errfile(env, stderr); - r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUPSORT); - - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - insert(0, 0); - insert(0, 1); - r=txn->commit(txn, 0); assert(r==0); - - r=env->txn_begin(env, 0, &txn, 0); CKERR(r); - lookup(0, 0, 0); - delete(0, 0); - lookup(0, 0, 1); - r=txn->commit(txn, 0); CKERR(r); - - r=env->txn_begin(env, 0, &txn, 0); CKERR(r); - lookup(0, 0, 1); - r=txn->commit(txn, 0); CKERR(r); - - r=db->close(db, 0); CKERR(r); - r=env->close(env, 0); CKERR(r); -} - -int -test_main (int argc, char *const argv[]) { - parse_args(argc, argv); - test_dupsort_del(); - return 0; -} diff --git a/src/tests/test_dupsort_del_checksum.c b/src/tests/test_dupsort_del_checksum.c deleted file mode 100644 index e0bc84f9fb0..00000000000 --- a/src/tests/test_dupsort_del_checksum.c +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" -/* Test to see if delete works right with dupsort. - * The issue is that things might look OK before the commit, but bad after the commit. - * In #690 we saw corrupted checksum errors. This actually tries to get that error to occur, whereas - * test_dupsort_del.c notices that the wrong thing is being saved. - */ - -#include -#include - -static DB_ENV *env; -static DB *db; -static DB_TXN *txn; - -#ifndef TOKUDB -#define DB_YESOVERWRITE 0 -#endif - -static void insert (int i, int j) { - char hello[30], there[30]; - DBT key,data; - if (verbose) printf("Insert %d\n", i); - snprintf(hello, sizeof(hello), "hello%d", i); - snprintf(there, sizeof(there), "there%d", j); - int r = db->put(db, txn, - dbt_init(&key, hello, strlen(hello)+1), - dbt_init(&data, there, strlen(there)+1), - DB_YESOVERWRITE); - CKERR(r); -} - -static void delete (int i, int j) { - char hello[30], there[30]; - DBC *dbc; - DBT key, val; - if (verbose) printf("delete %d\n", i); - snprintf(hello, sizeof(hello), "hello%d", i); - snprintf(there, sizeof(there), "there%d", j); - int r = db->cursor(db, txn, &dbc, 0); - CKERR(r); - r = dbc->c_get(dbc, - dbt_init(&key, hello, strlen(hello)+1), - dbt_init(&val, there, strlen(there)+1), - DB_GET_BOTH); - CKERR(r); - r = dbc->c_del(dbc, 0); - CKERR(r); - r = dbc->c_close(dbc); - CKERR(r); -} - -static void lookup (int i, int expect, int expectj) { - char hello[30], there[30]; - DBT key,data; - snprintf(hello, sizeof(hello), "hello%d", i); - memset(&data, 0, sizeof(data)); - if (verbose) printf("Looking up %d (expecting %s)\n", i, expect==0 ? "to find" : "not to find"); - int r = db->get(db, txn, - dbt_init(&key, hello, strlen(hello)+1), - &data, - 0); - assert(expect==r); - if (expect==0) { - CKERR(r); - snprintf(there, sizeof(there), "there%d", expectj); - assert(data.size==strlen(there)+1); - assert(strcmp(data.data, there)==0); - } -} - -static void -test_abort3 (void) { - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); - - r=db_env_create(&env, 0); assert(r==0); - env->set_errfile(env, stderr); - r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUPSORT); - - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - insert(0, 0); - insert(0, 1); - r=txn->commit(txn, 0); assert(r==0); - - r=env->txn_begin(env, 0, &txn, 0); CKERR(r); - lookup(0, 0, 0); - delete(0, 0); - lookup(0, 0, 1); - r=txn->commit(txn, 0); CKERR(r); - - // close the file and reopen in, and do the lookup - r=db->close(db, 0); CKERR(r); - - r=db_create(&db, env, 0); CKERR(r); - r=db->set_flags(db, DB_DUPSORT); - r=env->txn_begin(env, 0, &txn, 0); assert(r==0); - r=db->open(db, txn, "foo.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - lookup(0, 0, 1); - r=txn->commit(txn, 0); CKERR(r); - r=db->close(db, 0); CKERR(r); - r=env->close(env, 0); CKERR(r); -} - -int -test_main (int argc, char *const argv[]) { - parse_args(argc, argv); - test_abort3(); - return 0; -} diff --git a/src/tests/test_dupsort_delete.c b/src/tests/test_dupsort_delete.c deleted file mode 100644 index abf3f87d6c3..00000000000 --- a/src/tests/test_dupsort_delete.c +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN *const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), DB_DELETE_ANY); - assert(r == 0); -} - -static void -expect_cursor_get (DBC *cursor, int op, int expectr) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), op); - assert(r == expectr); -} - -static int mycmp(const void *a, const void *b) { - return memcmp(a, b, sizeof (int)); -} - -static void -test_dupsort_delete (int n) { - if (verbose) printf("test_dupsort_delete:%d\n", n); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_dupsort_delete.brt"; - int r; - int i; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - int values[n]; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(n)); - - for (i=0; icursor(db, null_txn, &cursor, 0); assert(r == 0); - - /* verify all gone */ - expect_cursor_get(cursor, DB_NEXT, DB_NOTFOUND); - - r = cursor->c_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - // test_dupsort_delete(256); return 0; - - /* nodup tests */ - for (i = 1; i <= (1<<16); i *= 2) { - test_dupsort_delete(i); - } - - return 0; -} diff --git a/src/tests/test_dupsort_get.c b/src/tests/test_dupsort_get.c deleted file mode 100644 index 52c336bc29d..00000000000 --- a/src/tests/test_dupsort_get.c +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_set (DBC *cursor, int k) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET); - assert(r == 0); - toku_free(val.data); -} - -static void -expect_cursor_get_current (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); - assert(r == 0); - int kk, vv; - assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); - assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); - toku_free(key.data); toku_free(val.data); -} - - -static void -test_dupsort_get (int n, int dup_mode) { - if (verbose) printf("test_dupsort_get:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test.dupsort.get.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(n/2)); - - for (i=n-1; i>=0; i--) - db_put(db, htonl(n/2), htonl(i)); - - expect_db_get(db, htonl(n/2), htonl(0)); - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - expect_cursor_set(cursor, htonl(n/2)); - expect_cursor_get_current(cursor, htonl(n/2), 0); - r = cursor->c_del(cursor, 0); assert(r == 0); - if (n > 1) expect_db_get(db, htonl(n/2), htonl(1)); - - r = cursor->c_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - int limit = 1<<13; - if (verbose > 1) - limit = 1<<16; - - for (i=1; i <= limit; i *= 2) { - test_dupsort_get(i, DB_DUP + DB_DUPSORT); - } - return 0; -} diff --git a/src/tests/test_dupsort_get_both.c b/src/tests/test_dupsort_get_both.c deleted file mode 100644 index f9c9ed9d95b..00000000000 --- a/src/tests/test_dupsort_get_both.c +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_get (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -static void -expect_cursor_get_both (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH); - assert(r == 0); -} - -static void -expect_cursor_get_current (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); - assert(r == 0); - int kk, vv; - assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); - assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); - toku_free(key.data); toku_free(val.data); -} - - -/* insert, close, delete, insert, search */ -static void -test_icdi_search (int n, int dup_mode) { - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(n/2)); - - /* insert n duplicates */ - for (i=0; icursor(db, 0, &cursor, 0); assert(r == 0); - expect_cursor_get_both(cursor, k, v); - expect_cursor_get_current(cursor, k, v); - r = cursor->c_close(cursor); assert(r == 0); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - for (i=0; ic_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - int limit = 1<<13; - if (verbose > 1) - limit = 1<<16; - - for (i=1; i <= limit; i *= 2) { - test_icdi_search(i, DB_DUP + DB_DUPSORT); - } - return 0; -} diff --git a/src/tests/test_dupsort_get_both_1856.c b/src/tests/test_dupsort_get_both_1856.c deleted file mode 100644 index e3aaa0676bc..00000000000 --- a/src/tests/test_dupsort_get_both_1856.c +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_get (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -static void -expect_cursor_get_both (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH); - assert(r == 0); -} - -static void -expect_cursor_get_current (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); - assert(r == 0); - int kk, vv; - assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); - assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); - toku_free(key.data); toku_free(val.data); -} - - -/* insert, close, delete, insert, search */ -static void -test_icdi_search (int n, int dup_mode) { - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(n/2)); - - /* insert n duplicates */ - for (i=0; icursor(db, 0, &cursor, 0); assert(r == 0); - expect_cursor_get_both(cursor, k, v); - expect_cursor_get_current(cursor, k, v); - r = cursor->c_close(cursor); assert(r == 0); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - for (i=0; ic_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - test_icdi_search(161, DB_DUP + DB_DUPSORT); - - return 0; -} diff --git a/src/tests/test_dupsort_get_both_range.c b/src/tests/test_dupsort_get_both_range.c deleted file mode 100644 index 8a3f39779ad..00000000000 --- a/src/tests/test_dupsort_get_both_range.c +++ /dev/null @@ -1,175 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_get (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)ntohl(k), (uint32_t)ntohl(kk), (uint32_t)ntohl(v), (uint32_t)ntohl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -static void -expect_cursor_get_both_range (DBC *cursor, int k, int v, int expectr) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH_RANGE); - assert(r == expectr); -} - -static void -expect_cursor_get_current (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); - assert(r == 0); - int kk, vv; - assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); - assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); - toku_free(key.data); toku_free(val.data); -} - - -/* insert, close, delete, insert, search */ -static void -test_icdi_search (int n, int dup_mode) { - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(1+n/2)); - - /* insert n duplicates */ - for (i=n-1; i>=0; i--) { - int k = htonl(1+n/2); - int v = htonl(1+n+i); - db_put(db, k, v); - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - expect_cursor_get_both_range(cursor, k, v, 0); - expect_cursor_get_current(cursor, k, v); - r = cursor->c_close(cursor); assert(r == 0); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - expect_cursor_get_both_range(cursor, 0, 0, DB_NOTFOUND); - expect_cursor_get_both_range(cursor, 0, 0, DB_NOTFOUND); - if (n>1) - expect_cursor_get_both_range(cursor, htonl(1+n/2), 0, 0); - expect_cursor_get_both_range(cursor, htonl(1+n), 0, DB_NOTFOUND); - r = cursor->c_close(cursor); assert(r == 0); - - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - for (i=0; ic_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - int limit = 1<<13; - if (verbose > 1) - limit = 1<<16; - - for (i=1; i <= limit; i *= 2) { - test_icdi_search(i, DB_DUP + DB_DUPSORT); - } - return 0; -} diff --git a/src/tests/test_dupsort_get_both_range_reverse.c b/src/tests/test_dupsort_get_both_range_reverse.c deleted file mode 100644 index bbfaf7c6cc1..00000000000 --- a/src/tests/test_dupsort_get_both_range_reverse.c +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_get (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)ntohl(k), (uint32_t)ntohl(kk), (uint32_t)ntohl(v), (uint32_t)ntohl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -static void -expect_cursor_get_both_range_reverse (DBC *cursor, int k, int v, int expectr) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_GET_BOTH_RANGE_REVERSE); - assert(r == expectr); -} - -static void -expect_cursor_get_current (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); - assert(r == 0); - int kk, vv; - assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); - assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); - toku_free(key.data); toku_free(val.data); -} - - -/* insert, close, delete, insert, search */ -static void -test_icdi_search (int n, int dup_mode) { - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(1+n/2)); - - /* insert n duplicates */ - for (i=0; icursor(db, null_txn, &cursor, 0); assert(r == 0); - expect_cursor_get_both_range_reverse(cursor, k, v, 0); - expect_cursor_get_current(cursor, k, v); - r = cursor->c_close(cursor); assert(r == 0); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - expect_cursor_get_both_range_reverse(cursor, 0, 0, DB_NOTFOUND); - expect_cursor_get_both_range_reverse(cursor, 0, 0, DB_NOTFOUND); - if (n>1) - expect_cursor_get_both_range_reverse(cursor, htonl(1+n/2), htonl(1+n+n), 0); - expect_cursor_get_both_range_reverse(cursor, htonl(1+n), 0, DB_NOTFOUND); - expect_cursor_get_both_range_reverse(cursor, htonl(1), 0, DB_NOTFOUND); - r = cursor->c_close(cursor); assert(r == 0); - - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - for (i=0; ic_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - int limit = 1<<13; - if (verbose > 1) - limit = 1<<16; - - for (i=1; i <= limit; i *= 2) { - test_icdi_search(i, DB_DUP + DB_DUPSORT); - } - return 0; -} diff --git a/src/tests/test_dupsort_set.c b/src/tests/test_dupsort_set.c deleted file mode 100644 index ed382698cce..00000000000 --- a/src/tests/test_dupsort_set.c +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), 0); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_get (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -static void -expect_cursor_set (DBC *cursor, int k) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET); - assert(r == 0); - toku_free(val.data); -} - -static void -expect_cursor_get_current (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); - assert(r == 0); - int kk, vv; - assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); - assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); - toku_free(key.data); toku_free(val.data); -} - - -/* insert, close, delete, insert, search */ -static void -test_icdi_search (int n, int dup_mode) { - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - int r; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(n/2)); - - /* insert n duplicates */ - for (i=0; icursor(db, 0, &cursor, 0); assert(r == 0); - expect_cursor_set(cursor, k); - expect_cursor_get_current(cursor, k, htonl(n+0)); - r = cursor->c_close(cursor); assert(r == 0); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - for (i=0; ic_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int r; - r = system("rm -rf " ENVDIR); - CKERR(r); - toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - - int limit = 1<<13; - if (verbose > 1) - limit = 1<<16; - - for (i=1; i <= limit; i *= 2) { - test_icdi_search(i, DB_DUP + DB_DUPSORT); - } - return 0; -} diff --git a/src/tests/test_dupsort_set_range.c b/src/tests/test_dupsort_set_range.c deleted file mode 100644 index 8632e61f46c..00000000000 --- a/src/tests/test_dupsort_set_range.c +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -#ifndef DB_DELETE_ANY -#define DB_DELETE_ANY 0 -#endif -#ifndef DB_YESOVERWRITE -#define DB_YESOVERWRITE 0 -#endif - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), DB_DELETE_ANY); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_get (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -static void -expect_cursor_set_range (DBC *cursor, int k) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET_RANGE); - assert(r == 0); - toku_free(val.data); -} - -static void -expect_cursor_get_current (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); - assert(r == 0); - int kk, vv; - assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); - assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); - toku_free(key.data); toku_free(val.data); -} - - -/* insert, close, delete, insert, search */ -static void -test_icdi_search (int n, int dup_mode) { - int r; - - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(n/2)); - - /* insert n duplicates */ - for (i=n-1; i >= 0; i--) { - int k = htonl(n/2); - int v = htonl(n+i); - db_put(db, k, v); - - DBC *cursor; - r = db->cursor(db, 0, &cursor, 0); assert(r == 0); - expect_cursor_set_range(cursor, k); - expect_cursor_get_current(cursor, k, htonl(n+i)); - r = cursor->c_close(cursor); assert(r == 0); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - for (i=0; ic_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int limit = 1<<13; - if (verbose > 1) - limit = 1<<16; - - for (i = 1; i <= limit; i *= 2) { - test_icdi_search(i, DB_DUP + DB_DUPSORT); - } - return 0; -} diff --git a/src/tests/test_dupsort_set_range_reverse.c b/src/tests/test_dupsort_set_range_reverse.c deleted file mode 100644 index dae03b03aa8..00000000000 --- a/src/tests/test_dupsort_set_range_reverse.c +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -#ifndef DB_DELETE_ANY -#define DB_DELETE_ANY 0 -#endif -#ifndef DB_YESOVERWRITE -#define DB_YESOVERWRITE 0 -#endif - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static void -db_del (DB *db, int k) { - DB_TXN * const null_txn = 0; - DBT key; - int r = db->del(db, null_txn, dbt_init(&key, &k, sizeof k), DB_DELETE_ANY); - assert(r == 0); -} - -static void -expect_db_get (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->get(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0); - assert(r == 0); - int vv; - assert(val.size == sizeof vv); - memcpy(&vv, val.data, val.size); - assert(vv == v); - toku_free(val.data); -} - -static void -expect_cursor_get (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); - assert(r == 0); - assert(key.size == sizeof k); - int kk; - memcpy(&kk, key.data, key.size); - assert(val.size == sizeof v); - int vv; - memcpy(&vv, val.data, val.size); - if (kk != k || vv != v) printf("expect key %u got %u - %u %u\n", (uint32_t)htonl(k), (uint32_t)htonl(kk), (uint32_t)htonl(v), (uint32_t)htonl(vv)); - assert(kk == k); - assert(vv == v); - - toku_free(key.data); - toku_free(val.data); -} - -static void -expect_cursor_set_range_reverse (DBC *cursor, int k) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET_RANGE_REVERSE); - assert(r == 0); - toku_free(val.data); -} - -static void -expect_cursor_get_current (DBC *cursor, int k, int v) { - DBT key, val; - int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT); - assert(r == 0); - int kk, vv; - assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); - assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); - toku_free(key.data); toku_free(val.data); -} - - -/* insert, close, delete, insert, search */ -static void -test_icdi_search (int n, int dup_mode) { - int r; - - if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); - - DB_TXN * const null_txn = 0; - const char * const fname = "test_icdi_search.brt"; - - r = system("rm -rf " ENVDIR); CKERR(r); - r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n duplicates */ - int i; - for (i=0; iclose(db, 0); assert(r == 0); - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); - - db_del(db, htonl(n/2)); - - /* insert n duplicates */ - for (i=0; i < n; i++) { - int k = htonl(n/2); - int v = htonl(n+i); - db_put(db, k, v); - - DBC *cursor; - r = db->cursor(db, 0, &cursor, 0); assert(r == 0); - expect_cursor_set_range_reverse(cursor, k); - expect_cursor_get_current(cursor, k, htonl(n+i)); - r = cursor->c_close(cursor); assert(r == 0); - } - - DBC *cursor; - r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0); - - for (i=0; ic_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - int i; - - parse_args(argc, argv); - - int limit = 1<<13; - if (verbose > 1) - limit = 1<<16; - - for (i = 1; i <= limit; i *= 2) { - test_icdi_search(i, DB_DUP + DB_DUPSORT); - } - return 0; -} diff --git a/src/tests/test_get_both_range.c b/src/tests/test_get_both_range.c deleted file mode 100644 index 8cd12ea2cc1..00000000000 --- a/src/tests/test_get_both_range.c +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- mode: C; c-basic-offset: 4 -*- */ -#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." -#include "test.h" - -#include -#include - -#include -#include -#include -#include - - -static DBT * -dbt_init_user (DBT *d, void *uptr, int ulen) { - memset(d, 0, sizeof *d); - d->data = uptr; - d->ulen = ulen; - d->flags = DB_DBT_USERMEM; - return d; -} - -static void -db_put (DB *db, int k, int v) { - DB_TXN * const null_txn = 0; - DBT key, val; - int r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE); - assert(r == 0); -} - -static char annotated_envdir[]= ENVDIR " "; - -static void test_get_both(int n, int dup_mode, int op) { - if (verbose) printf("test_get_both_range:%d %d %d\n", n, dup_mode, op); - - DB_TXN * const null_txn = 0; - char fname[sizeof(ENVDIR)+100]; - snprintf(fname, sizeof(fname), "test_icdi_search_brt"); - int r; - - { - char rmcmd[sizeof(annotated_envdir)+10]; - snprintf(rmcmd, sizeof(rmcmd), "rm -rf %s", annotated_envdir); - r = system(rmcmd); - CKERR(r); - } - toku_os_mkdir(annotated_envdir, S_IRWXU+S_IRWXG+S_IRWXO); - - unlink(fname); - - /* create the dup database file */ - DB_ENV *env; - r = db_env_create(&env, 0); assert(r == 0); - r = env->open(env, annotated_envdir, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); - - DB *db; - r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); - r = db->set_pagesize(db, 4096); assert(r == 0); - r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); - - /* insert n unique kv pairs */ - int i; - for (i=0; icursor(db, null_txn, &cursor, 0); assert(r == 0); - for (i=0; i<10*n; i++) { - int k = htonl(i); - int j; - for (j=0; j<10*n; j++) { - int v = htonl(j); - DBT key, val; - r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), op); - if (r == 0) { - assert((i % 10) == 0); - int kk, vv; - r = cursor->c_get(cursor, dbt_init_user(&key, &kk, sizeof kk), dbt_init_user(&val, &vv, sizeof vv), DB_CURRENT); - assert(r == 0); - assert(key.size == sizeof kk); - kk = htonl(kk); - assert(val.size == sizeof vv); - vv = htonl(vv); - if (verbose > 1) printf("%d %d -> %d %d\n", i, j, kk, vv); - assert(kk == i); - assert(vv == ((j+9)/10)*10); - } else if (r == DB_NOTFOUND) { - if ((i%10) != 0 || j > 0) - ; - else - printf("nf %d %d\n", i, j); - } else - assert(0); - } - } - r = cursor->c_close(cursor); assert(r == 0); - - r = db->close(db, 0); assert(r == 0); - r = env->close(env, 0); assert(r == 0); -} - - -int -test_main(int argc, char *const argv[]) { - unsigned long doi=0; - int i; - char flags = 0; - for (i=1; i4); - //printf("envdir=%s\n(size=%ld) -5 char=%c\n", ENVDIR, sizeof(ENVDIR), envdir_without_suffix[sizeof(ENVDIR)-5]); - assert(envdir_without_suffix[sizeof(ENVDIR)-5]=='.'); - assert(envdir_without_suffix[sizeof(ENVDIR)-4]=='t' || envdir_without_suffix[sizeof(ENVDIR)-4]=='b'); - assert(envdir_without_suffix[sizeof(ENVDIR)-3]=='d'); - assert(envdir_without_suffix[sizeof(ENVDIR)-2]=='b'); - assert(envdir_without_suffix[sizeof(ENVDIR)-1]==0); - envdir_without_suffix[sizeof(ENVDIR)-5]=0; - - char doi_string[10]; - if (doi==0) doi_string[0]=0; - else snprintf(doi_string, sizeof(doi_string), ".%lu", doi); - - char flags_string[10]; - switch (flags) { - case 0: flags_string[0]=0; break; - case 'a': case 'b': case 'c': snprintf(flags_string, sizeof(flags_string), ".%c", flags); break; - default: assert(0); - } - - #ifdef USE_TDB - char bdb_tdb_char='t'; - #else - char bdb_tdb_char='b'; - #endif - - snprintf(annotated_envdir, sizeof(annotated_envdir), "%s%s%s.%cdb", - envdir_without_suffix, doi_string, flags_string, bdb_tdb_char); - } - { - char rmcmd[sizeof(annotated_envdir)+10]; - snprintf(rmcmd, sizeof(rmcmd), "rm -rf %s", annotated_envdir); - int r; - r = system(rmcmd); - CKERR(r); - } - toku_os_mkdir(annotated_envdir, S_IRWXU+S_IRWXG+S_IRWXO); - - if (doi==0) { - for (i=1; i <= 256; i *= 2) { - if (flags==0 || flags=='a') test_get_both(i, 0, DB_GET_BOTH); - if (flags==0 || flags=='b') test_get_both(i, 0, DB_GET_BOTH_RANGE); - if (flags==0 || flags=='c') test_get_both(i, DB_DUP + DB_DUPSORT, DB_GET_BOTH_RANGE); - } - } else { - if (flags==0 || flags=='a') test_get_both(doi, 0, DB_GET_BOTH); - if (flags==0 || flags=='b') test_get_both(doi, 0, DB_GET_BOTH_RANGE); - if (flags==0 || flags=='c') test_get_both(doi, DB_DUP + DB_DUPSORT, DB_GET_BOTH_RANGE); - } - - return 0; -} diff --git a/src/tests/test_get_zeroed_dbt.c b/src/tests/test_get_zeroed_dbt.c index 2fbab88a97b..df8e7c49c95 100644 --- a/src/tests/test_get_zeroed_dbt.c +++ b/src/tests/test_get_zeroed_dbt.c @@ -12,20 +12,17 @@ static void -test_get (int dup_mode) { +test_get (void) { DB_TXN * const null_txn = 0; DBT key,data; - int fnamelen = sizeof(ENVDIR) + 30; - char fname[fnamelen]; + char fname[] = "test.db"; int r; - snprintf(fname, fnamelen, "test%d.db", dup_mode); DB_ENV *env; r = db_env_create(&env, 0); assert(r == 0); r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0); DB *db; r = db_create (&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); dbt_init(&key, "a", 2); r = db->put(db, null_txn, &key, dbt_init(&data, "b", 2), DB_YESOVERWRITE); assert(r==0); @@ -44,7 +41,6 @@ test_main (int argc, char *const argv[]) { CKERR(r); toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - test_get(0); - test_get(DB_DUP + DB_DUPSORT); + test_get(); return 0; } diff --git a/src/tests/test_hsoc.c b/src/tests/test_hsoc.c index 9c627e754ea..c6043156df7 100644 --- a/src/tests/test_hsoc.c +++ b/src/tests/test_hsoc.c @@ -35,8 +35,8 @@ db_put (DB *db, DB_TXN *txn, int k, int v) { the magic number where found via experimentation */ static void -test_hsoc (int pagesize, int dup_mode) { - if (verbose) printf("test_hsoc:%d %d\n", pagesize, dup_mode); +test_hsoc (int pagesize) { + if (verbose) printf("test_hsoc:%d\n", pagesize); int npp = pagesize / 16; int n = npp + 13*npp/2; @@ -56,7 +56,6 @@ test_hsoc (int pagesize, int dup_mode) { DB *db; r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_pagesize(db, pagesize); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); @@ -84,7 +83,6 @@ test_hsoc (int pagesize, int dup_mode) { if (verbose) printf("reopen\n"); r = db->close(db, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_pagesize(db, pagesize); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); @@ -117,7 +115,7 @@ int test_main(int argc, char *const argv[]) { parse_args(argc, argv); - test_hsoc(4096, DB_DUP + DB_DUPSORT); + test_hsoc(4096); return 0; } diff --git a/src/tests/test_insert_cursor_delete_insert.c b/src/tests/test_insert_cursor_delete_insert.c index 7399df75612..3cf2da71d5d 100644 --- a/src/tests/test_insert_cursor_delete_insert.c +++ b/src/tests/test_insert_cursor_delete_insert.c @@ -12,13 +12,13 @@ static void -test_insert_delete_insert (int dup_mode) { +test_insert_delete_insert (void) { int r; r = system("rm -rf " ENVDIR); CKERR(r); toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); - if (verbose) printf("test_insert_delete_insert:%d\n", dup_mode); + if (verbose) printf("test_insert_delete_insert:\n"); DB_TXN * const null_txn = 0; const char * const fname = "test.cursor.insert.delete.insert.brt"; @@ -30,7 +30,6 @@ test_insert_delete_insert (int dup_mode) { DB *db; r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); DBC *cursor; @@ -73,8 +72,7 @@ test_main(int argc, char *const argv[]) { parse_args(argc, argv); - test_insert_delete_insert(0); - test_insert_delete_insert(DB_DUP + DB_DUPSORT); + test_insert_delete_insert(); return 0; } diff --git a/src/tests/test_kv_limits.c b/src/tests/test_kv_limits.c index 7ba3d44ad52..ed6a60ef2f6 100644 --- a/src/tests/test_kv_limits.c +++ b/src/tests/test_kv_limits.c @@ -15,8 +15,8 @@ u_int64_t lorange = 0; u_int64_t hirange = 1<<24; static void -test_key_size_limit (int dup_mode) { - if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode); +test_key_size_limit (void) { + if (verbose > 1) printf("%s\n", __FUNCTION__); DB_TXN * const null_txn = 0; const char * const fname = "test.rand.insert.brt"; @@ -34,8 +34,6 @@ test_key_size_limit (int dup_mode) { DB *db; r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); @@ -75,8 +73,8 @@ test_key_size_limit (int dup_mode) { } static void -test_data_size_limit (int dup_mode) { - if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode); +test_data_size_limit (void) { + if (verbose > 1) printf("%s\n", __FUNCTION__); DB_TXN * const null_txn = 0; const char * const fname = "test.rand.insert.brt"; @@ -94,8 +92,6 @@ test_data_size_limit (int dup_mode) { DB *db; r = db_create(&db, env, 0); assert(r == 0); - r = db->set_flags(db, dup_mode); - assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); @@ -160,10 +156,8 @@ test_main(int argc, char *const argv[]) { } } - test_key_size_limit(0); - test_data_size_limit(0); - test_key_size_limit(DB_DUP + DB_DUPSORT); - test_data_size_limit(DB_DUP + DB_DUPSORT); + test_key_size_limit(); + test_data_size_limit(); return 0; } diff --git a/src/tests/test_reverse_compare_fun.c b/src/tests/test_reverse_compare_fun.c index 1f65fd59ab2..3a2504bdecf 100644 --- a/src/tests/test_reverse_compare_fun.c +++ b/src/tests/test_reverse_compare_fun.c @@ -53,8 +53,8 @@ expect (DBC *cursor, int k, int v) { } static void -test_reverse_compare (int n, int dup_flags) { - if (verbose) printf("test_reverse_compare:%d %d\n", n, dup_flags); +test_reverse_compare (int n) { + if (verbose) printf("test_reverse_compare:%d\n", n); DB_TXN * const null_txn = 0; const char * const fname = "reverse.compare.db"; @@ -74,14 +74,10 @@ test_reverse_compare (int n, int dup_flags) { DB *db; r = db_create(&db, env, 0); CKERR(r); - r = db->set_flags(db, dup_flags); - CKERR(r); r = db->set_pagesize(db, 4096); CKERR(r); r = db->set_bt_compare(db, reverse_compare); CKERR(r); - r = db->set_dup_compare(db, reverse_compare); - CKERR(r); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r); @@ -89,7 +85,7 @@ test_reverse_compare (int n, int dup_flags) { for (i=0; iset_flags(db, dup_flags); - CKERR(r); r = db->set_pagesize(db, 4096); CKERR(r); r = db->set_bt_compare(db, reverse_compare); CKERR(r); - r = db->set_dup_compare(db, reverse_compare); - CKERR(r); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); CKERR(r); @@ -117,7 +109,7 @@ test_reverse_compare (int n, int dup_flags) { for (i=n; i<2*n; i++) { DBT key, val; int k, v; - k = htonl(dup_flags ? n : i); + k = htonl(i); dbt_init(&key, &k, sizeof k); v = htonl(i); dbt_init(&val, &v, sizeof v); @@ -132,7 +124,7 @@ test_reverse_compare (int n, int dup_flags) { //for (i=0; i<2*n; i++) for (i=2*n-1; i>=0; i--) - expect(cursor, htonl(dup_flags ? n : i), htonl(i)); + expect(cursor, htonl(i), htonl(i)); r = cursor->c_close(cursor); CKERR(r); @@ -148,8 +140,7 @@ test_main(int argc, char *const argv[]) { int i; for (i = 1; i <= (1<<16); i *= 2) { - test_reverse_compare(i, 0); - test_reverse_compare(i, DB_DUP + DB_DUPSORT); + test_reverse_compare(i); } return 0; } diff --git a/src/tests/test_txn_nested1.c b/src/tests/test_txn_nested1.c index a083b81293f..5b0f2e51c53 100644 --- a/src/tests/test_txn_nested1.c +++ b/src/tests/test_txn_nested1.c @@ -48,7 +48,6 @@ setup_db (void) { r = db_create(&db, env, 0); CKERR(r); r = db->set_bt_compare(db, int_dbt_cmp); CKERR(r); - r = db->set_dup_compare(db, int_dbt_cmp); CKERR(r); r = db->open(db, txn, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = txn->commit(txn, 0); CKERR(r); } diff --git a/src/tests/test_zero_length_keys.c b/src/tests/test_zero_length_keys.c index 1bd1987f282..ebf2c90e620 100644 --- a/src/tests/test_zero_length_keys.c +++ b/src/tests/test_zero_length_keys.c @@ -149,7 +149,6 @@ test_main(int argc, char *const argv[]) { test_insert_zero_length(32, 0, "test0"); test_insert_zero_length_keys(32, 0, "test0keys"); - test_insert_zero_length_keys(32, DB_DUP+DB_DUPSORT, "test0keys_dupsort"); CLOSE_TRACE_FILE(); diff --git a/src/ydb-internal.h b/src/ydb-internal.h index 7d1ac35cc9c..70fdd6a1d8c 100644 --- a/src/ydb-internal.h +++ b/src/ydb-internal.h @@ -30,7 +30,6 @@ struct __toku_db_internal { struct __toku_lock_tree* lt; struct simple_dbt skey, sval; // static key and value BOOL key_compare_was_set; // true if a comparison function was provided before call to db->open() (if false, use environment's comparison function) - BOOL val_compare_was_set; char *dname; // dname is constant for this handle (handle must be closed before file is renamed) BOOL is_zombie; // True if DB->close has been called on this DB struct toku_list dbs_that_must_close_before_abort; @@ -57,7 +56,6 @@ struct __toku_db_env_internal { char *lg_dir; char *data_dir; int (*bt_compare) (DB *, const DBT *, const DBT *); - int (*dup_compare) (DB *, const DBT *, const DBT *); generate_row_for_put_func generate_row_for_put; generate_row_for_del_func generate_row_for_del; //void (*noticecall)(DB_ENV *, db_notices); diff --git a/src/ydb.c b/src/ydb.c index e861b9a38c7..7141f55e904 100644 --- a/src/ydb.c +++ b/src/ydb.c @@ -333,12 +333,8 @@ static int toku_c_getf_first(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, vo static int toku_c_getf_last(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); static int toku_c_getf_next(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); -static int toku_c_getf_next_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); -static int toku_c_getf_next_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); static int toku_c_getf_prev(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); -static int toku_c_getf_prev_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); -static int toku_c_getf_prev_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); static int toku_c_getf_current(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); static int toku_c_getf_current_binding(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra); @@ -346,9 +342,6 @@ static int toku_c_getf_current_binding(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNC static int toku_c_getf_set(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, void *extra); static int toku_c_getf_set_range(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, void *extra); static int toku_c_getf_set_range_reverse(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, void *extra); -static int toku_c_getf_get_both(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra); -static int toku_c_getf_get_both_range(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra); -static int toku_c_getf_get_both_range_reverse(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra); // Effect: Lightweight cursor get @@ -391,7 +384,7 @@ static int ydb_do_recovery (DB_ENV *env) { assert(env->i->real_log_dir); toku_ydb_unlock(); - int r = tokudb_recover(env->i->dir, env->i->real_log_dir, env->i->bt_compare, env->i->dup_compare, + int r = tokudb_recover(env->i->dir, env->i->real_log_dir, env->i->bt_compare, env->i->generate_row_for_put, env->i->generate_row_for_del, env->i->cachetable_size); toku_ydb_lock(); @@ -406,7 +399,6 @@ static int needs_recovery (DB_ENV *env) { static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags); static int toku_db_set_bt_compare(DB * db, int (*bt_compare) (DB *, const DBT *, const DBT *)); -static int toku_db_set_dup_compare(DB *db, int (*dup_compare)(DB *, const DBT *, const DBT *)); static int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYPE dbtype, u_int32_t flags, int mode); static int toku_env_txn_checkpoint(DB_ENV * env, u_int32_t kbyte, u_int32_t min, u_int32_t flags); static int toku_db_close(DB * db, u_int32_t flags); @@ -439,28 +431,6 @@ db_use_builtin_key_cmp(DB *db) { return r; } -static int -db_use_builtin_val_cmp(DB *db) { - HANDLE_PANICKED_DB(db); - int r; - if (db_opened(db)) - r = toku_ydb_do_error(db->dbenv, EINVAL, "Comparison functions cannot be set after DB open.\n"); - else if (db->i->val_compare_was_set) - r = toku_ydb_do_error(db->dbenv, EINVAL, "Val comparison function already set.\n"); - else { - u_int32_t tflags; - r = toku_brt_get_flags(db->i->brt, &tflags); - if (r!=0) return r; - - tflags |= TOKU_DB_VALCMP_BUILTIN; - r = toku_brt_set_flags(db->i->brt, tflags); - if (!r) - db->i->val_compare_was_set = TRUE; - } - return r; -} - - static const char * curr_env_ver_key = "current_version"; static const char * orig_env_ver_key = "original_version"; @@ -799,8 +769,6 @@ toku_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode) { assert(r==0); r = db_use_builtin_key_cmp(env->i->persistent_environment); assert(r==0); - r = db_use_builtin_val_cmp(env->i->persistent_environment); - assert(r==0); r = db_open_iname(env->i->persistent_environment, txn, environmentdictionary, DB_CREATE, mode); assert(r==0); if (newenv) { @@ -826,8 +794,6 @@ toku_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode) { assert(r==0); r = db_use_builtin_key_cmp(env->i->directory); assert(r==0); - r = db_use_builtin_val_cmp(env->i->directory); - assert(r==0); r = db_open_iname(env->i->directory, txn, fileopsdirectory, DB_CREATE, mode); assert(r==0); } @@ -1353,25 +1319,6 @@ env_checkpointing_end_atomic_operation(DB_ENV * env) { return r; } -static int -env_set_default_dup_compare(DB_ENV * env, int (*dup_compare) (DB *, const DBT *, const DBT *)) { - HANDLE_PANICKED_ENV(env); - int r = 0; - if (env_opened(env)) r = EINVAL; - else { - env->i->dup_compare = dup_compare; - } - return r; -} - -static int -locked_env_set_default_dup_compare(DB_ENV * env, int (*dup_compare) (DB *, const DBT *, const DBT *)) { - toku_ydb_lock(); - int r = env_set_default_dup_compare(env, dup_compare); - toku_ydb_unlock(); - return r; -} - static int env_set_default_bt_compare(DB_ENV * env, int (*bt_compare) (DB *, const DBT *, const DBT *)) { HANDLE_PANICKED_ENV(env); @@ -1765,8 +1712,6 @@ static int toku_db_lt_panic(DB* db, int r); static toku_dbt_cmp toku_db_get_compare_fun(DB* db); -static toku_dbt_cmp toku_db_get_dup_compare(DB* db); - static int toku_env_create(DB_ENV ** envp, u_int32_t flags) { int r = ENOSYS; DB_ENV* result = NULL; @@ -1780,7 +1725,6 @@ static int toku_env_create(DB_ENV ** envp, u_int32_t flags) { SENV(dbremove); SENV(dbrename); SENV(set_default_bt_compare); - SENV(set_default_dup_compare); SENV(set_generate_row_callback_for_put); SENV(set_generate_row_callback_for_del); SENV(put_multiple); @@ -1839,7 +1783,7 @@ static int toku_env_create(DB_ENV ** envp, u_int32_t flags) { r = toku_ltm_create(&result->i->ltm, __toku_env_default_max_locks, toku_db_lt_panic, - toku_db_get_compare_fun, toku_db_get_dup_compare, + toku_db_get_compare_fun, toku_malloc, toku_free, toku_realloc); if (r!=0) { goto cleanup; } @@ -2530,23 +2474,6 @@ static inline u_int32_t get_prelocked_flags(u_int32_t flags, DB_TXN* txn, DB* db return lock_flags; } -//Return true for NODUP database, false for DUPSORT -static BOOL -db_is_nodup(DB *db) { - unsigned int brtflags; - - int r = toku_brt_get_flags(db->i->brt, &brtflags); - assert(r==0); - BOOL rval = (BOOL)(!(brtflags&TOKU_DB_DUPSORT)); - return rval; -} - -static BOOL -c_db_is_nodup(DBC *c) { - BOOL rval = db_is_nodup(c->dbp); - return rval; -} - static int toku_c_get(DBC* c, DBT* key, DBT* val, u_int32_t flag) { //This function exists for legacy (test compatibility) purposes/parity with bdb. @@ -2574,18 +2501,12 @@ toku_c_get(DBC* c, DBT* key, DBT* val, u_int32_t flag) { r = toku_c_getf_last(c, remaining_flags, c_get_wrapper_callback, &context); break; case (DB_NEXT): + case (DB_NEXT_NODUP): query_context_wrapped_init(&context, c, key, val); r = toku_c_getf_next(c, remaining_flags, c_get_wrapper_callback, &context); break; - case (DB_NEXT_DUP): - query_context_wrapped_init(&context, c, key, val); - r = toku_c_getf_next_dup(c, remaining_flags, c_get_wrapper_callback, &context); - break; - case (DB_NEXT_NODUP): - query_context_wrapped_init(&context, c, key, val); - r = toku_c_getf_next_nodup(c, remaining_flags, c_get_wrapper_callback, &context); - break; case (DB_PREV): + case (DB_PREV_NODUP): query_context_wrapped_init(&context, c, key, val); r = toku_c_getf_prev(c, remaining_flags, c_get_wrapper_callback, &context); break; @@ -2595,10 +2516,6 @@ toku_c_get(DBC* c, DBT* key, DBT* val, u_int32_t flag) { r = toku_c_getf_prev_dup(c, remaining_flags, c_get_wrapper_callback, &context); break; #endif - case (DB_PREV_NODUP): - query_context_wrapped_init(&context, c, key, val); - r = toku_c_getf_prev_nodup(c, remaining_flags, c_get_wrapper_callback, &context); - break; case (DB_CURRENT): query_context_wrapped_init(&context, c, key, val); r = toku_c_getf_current(c, remaining_flags, c_get_wrapper_callback, &context); @@ -2620,24 +2537,6 @@ toku_c_get(DBC* c, DBT* key, DBT* val, u_int32_t flag) { query_context_wrapped_init(&context, c, key, val); r = toku_c_getf_set_range_reverse(c, remaining_flags, key, c_get_wrapper_callback, &context); break; - case (DB_GET_BOTH): - query_context_wrapped_init(&context, c, NULL, NULL); - r = toku_c_getf_get_both(c, remaining_flags, key, val, c_get_wrapper_callback, &context); - break; - case (DB_GET_BOTH_RANGE): - //For a nodup database, DB_GET_BOTH_RANGE is an alias for DB_GET_BOTH. - //DB_GET_BOTH(_RANGE) require different contexts (see case(DB_GET_BOTH)). - if (c_db_is_nodup(c)) query_context_wrapped_init(&context, c, NULL, NULL); - else query_context_wrapped_init(&context, c, NULL, val); - r = toku_c_getf_get_both_range(c, remaining_flags, key, val, c_get_wrapper_callback, &context); - break; - case (DB_GET_BOTH_RANGE_REVERSE): - //For a nodup database, DB_GET_BOTH_RANGE_REVERSE is an alias for DB_GET_BOTH. - //DB_GET_BOTH(_RANGE_REVERSE) require different contexts (see case(DB_GET_BOTH)). - if (c_db_is_nodup(c)) query_context_wrapped_init(&context, c, NULL, NULL); - else query_context_wrapped_init(&context, c, NULL, val); - r = toku_c_getf_get_both_range_reverse(c, remaining_flags, key, val, c_get_wrapper_callback, &context); - break; default: r = EINVAL; break; @@ -2657,26 +2556,10 @@ static int locked_c_getf_next(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, v toku_ydb_lock(); int r = toku_c_getf_next(c, flag, f, extra); toku_ydb_unlock(); return r; } -static int locked_c_getf_next_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { - toku_ydb_lock(); int r = toku_c_getf_next_nodup(c, flag, f, extra); toku_ydb_unlock(); return r; -} - -static int locked_c_getf_next_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { - toku_ydb_lock(); int r = toku_c_getf_next_dup(c, flag, f, extra); toku_ydb_unlock(); return r; -} - static int locked_c_getf_prev(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { toku_ydb_lock(); int r = toku_c_getf_prev(c, flag, f, extra); toku_ydb_unlock(); return r; } -static int locked_c_getf_prev_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { - toku_ydb_lock(); int r = toku_c_getf_prev_nodup(c, flag, f, extra); toku_ydb_unlock(); return r; -} - -static int locked_c_getf_prev_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { - toku_ydb_lock(); int r = toku_c_getf_prev_dup(c, flag, f, extra); toku_ydb_unlock(); return r; -} - static int locked_c_getf_current(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { toku_ydb_lock(); int r = toku_c_getf_current(c, flag, f, extra); toku_ydb_unlock(); return r; } @@ -2697,27 +2580,13 @@ static int locked_c_getf_set_range_reverse(DBC *c, u_int32_t flag, DBT * key, YD toku_ydb_lock(); int r = toku_c_getf_set_range_reverse(c, flag, key, f, extra); toku_ydb_unlock(); return r; } -static int locked_c_getf_get_both(DBC *c, u_int32_t flag, DBT * key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - toku_ydb_lock(); int r = toku_c_getf_get_both(c, flag, key, val, f, extra); toku_ydb_unlock(); return r; -} - -static int locked_c_getf_get_both_range(DBC *c, u_int32_t flag, DBT * key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - toku_ydb_lock(); int r = toku_c_getf_get_both_range(c, flag, key, val, f, extra); toku_ydb_unlock(); return r; -} - -static int locked_c_getf_get_both_range_reverse(DBC *c, u_int32_t flag, DBT * key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - toku_ydb_lock(); int r = toku_c_getf_get_both_range_reverse(c, flag, key, val, f, extra); toku_ydb_unlock(); return r; -} - typedef struct { BOOL is_read_lock; DB_TXN *txn; DB *db; toku_lock_tree *lt; DBT const *left_key; - DBT const *left_val; DBT const *right_key; - DBT const *right_val; } *RANGE_LOCK_REQUEST, RANGE_LOCK_REQUEST_S; static void @@ -2726,17 +2595,13 @@ range_lock_request_init(RANGE_LOCK_REQUEST request, DB_TXN *txn, DB *db, DBT const *left_key, - DBT const *left_val, - DBT const *right_key, - DBT const *right_val) { + DBT const *right_key) { request->is_read_lock = is_read_lock; request->txn = txn; request->db = db; request->lt = db->i->lt; request->left_key = left_key; - request->left_val = left_val; request->right_key = right_key; - request->right_val = right_val; } @@ -2745,12 +2610,9 @@ read_lock_request_init(RANGE_LOCK_REQUEST request, DB_TXN *txn, DB *db, DBT const *left_key, - DBT const *left_val, - DBT const *right_key, - DBT const *right_val) { + DBT const *right_key) { range_lock_request_init(request, TRUE, txn, db, - left_key, left_val, - right_key, right_val); + left_key, right_key); } static void @@ -2758,12 +2620,9 @@ write_lock_request_init(RANGE_LOCK_REQUEST request, DB_TXN *txn, DB *db, DBT const *left_key, - DBT const *left_val, - DBT const *right_key, - DBT const *right_val) { + DBT const *right_key) { range_lock_request_init(request, FALSE, txn, db, - left_key, left_val, - right_key, right_val); + left_key, right_key); } static int @@ -2776,12 +2635,10 @@ grab_range_lock(RANGE_LOCK_REQUEST request) { TXNID txn_anc_id = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn); if (request->is_read_lock) r = toku_lt_acquire_range_read_lock(request->lt, request->db, txn_anc_id, - request->left_key, request->left_val, - request->right_key, request->right_val); + request->left_key, request->right_key); else r = toku_lt_acquire_range_write_lock(request->lt, request->db, txn_anc_id, - request->left_key, request->left_val, - request->right_key, request->right_val); + request->left_key, request->right_key); } //TODO: (Multithreading) Release lock protecting lock tree return r; @@ -2905,8 +2762,7 @@ c_del_callback(DBT const *key, DBT const *val, void *extra) { // left(key,val)==right(key,val) == (key, val); RANGE_LOCK_REQUEST_S request; write_lock_request_init(&request, context->txn, context->db, - key, val, - key, val); + key, key); r = grab_range_lock(&request); //Give brt-layer an error (if any) to return from toku_c_getf_current_binding @@ -2945,13 +2801,11 @@ c_getf_first_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, RANGE_LOCK_REQUEST_S request; if (key!=NULL) { read_lock_request_init(&request, context->txn, context->db, - toku_lt_neg_infinity, toku_lt_neg_infinity, - &found_key, &found_val); + toku_lt_neg_infinity, &found_key); } else { read_lock_request_init(&request, context->txn, context->db, - toku_lt_neg_infinity, toku_lt_neg_infinity, - toku_lt_infinity, toku_lt_infinity); + toku_lt_neg_infinity, toku_lt_infinity); } r = grab_range_lock(&request); } @@ -2999,13 +2853,11 @@ c_getf_last_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, v RANGE_LOCK_REQUEST_S request; if (key!=NULL) { read_lock_request_init(&request, context->txn, context->db, - &found_key, &found_val, - toku_lt_infinity, toku_lt_infinity); + &found_key, toku_lt_infinity); } else { read_lock_request_init(&request, context->txn, context->db, - toku_lt_neg_infinity, toku_lt_neg_infinity, - toku_lt_infinity, toku_lt_infinity); + toku_lt_neg_infinity, toku_lt_infinity); } r = grab_range_lock(&request); } @@ -3028,8 +2880,7 @@ toku_c_getf_next(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { int r; HANDLE_PANICKED_DB(c->dbp); HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - if (c_db_is_nodup(c)) r = toku_c_getf_next_nodup(c, flag, f, extra); - else if (toku_c_uninitialized(c)) r = toku_c_getf_first(c, flag, f, extra); + if (toku_c_uninitialized(c)) r = toku_c_getf_first(c, flag, f, extra); else { QUERY_CONTEXT_S context; //Describes the context of this query. num_sequential_queries++; // accountability @@ -3059,12 +2910,11 @@ c_getf_next_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, v const DBT *prevkey; const DBT *prevval; const DBT *right_key = key==NULL ? toku_lt_infinity : &found_key; - const DBT *right_val = key==NULL ? toku_lt_infinity : &found_val; toku_brt_cursor_peek(context->c, &prevkey, &prevval); read_lock_request_init(&request, context->txn, context->db, - prevkey, prevval, - right_key, right_val); + prevkey, + right_key); r = grab_range_lock(&request); } else r = 0; @@ -3079,77 +2929,6 @@ c_getf_next_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, v return r; } -static int -toku_c_getf_next_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { - int r; - HANDLE_PANICKED_DB(c->dbp); - HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - if (toku_c_uninitialized(c)) r = toku_c_getf_first(c, flag, f, extra); - else { - QUERY_CONTEXT_S context; //Describes the context of this query. - num_sequential_queries++; // accountability - query_context_init(&context, c, flag, f, extra); - //toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful) - r = toku_brt_cursor_next_nodup(dbc_struct_i(c)->c, c_getf_next_callback, &context); - if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; - } - return r; -} - -static int c_getf_next_dup_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra); - -static int -toku_c_getf_next_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { - HANDLE_PANICKED_DB(c->dbp); - HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - if (toku_c_uninitialized(c)) return EINVAL; - - QUERY_CONTEXT_S context; //Describes the context of this query. - num_sequential_queries++; // accountability - query_context_init(&context, c, flag, f, extra); - //toku_brt_cursor_next_dup will call c_getf_next_dup_callback(..., context) (if query is successful) - int r = toku_brt_cursor_next_dup(dbc_struct_i(c)->c, c_getf_next_dup_callback, &context); - if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; - return r; -} - -//result is the result of the query (i.e. 0 means found, DB_NOTFOUND, etc..) -static int -c_getf_next_dup_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra) { - QUERY_CONTEXT super_context = extra; - QUERY_CONTEXT_BASE context = &super_context->base; - - int r; - - DBT found_key; - DBT found_val; - toku_fill_dbt(&found_key, key, keylen); - toku_fill_dbt(&found_val, val, vallen); - - if (context->do_locking) { - RANGE_LOCK_REQUEST_S request; - const DBT *prevkey; - const DBT *prevval; - const DBT *right_val = key==NULL ? toku_lt_infinity : &found_val; - - toku_brt_cursor_peek(context->c, &prevkey, &prevval); - read_lock_request_init(&request, context->txn, context->db, - prevkey, prevval, - prevkey, right_val); //found_key is same as prevkey for this case - r = grab_range_lock(&request); - } - else r = 0; - - //Call application-layer callback if found and locks were successfully obtained. - if (r==0 && key!=NULL) { - context->r_user_callback = super_context->f(&found_key, &found_val, context->f_extra); - if (context->r_user_callback) r = TOKUDB_USER_CALLBACK_ERROR; - } - - //Give brt-layer an error (if any) to return from toku_brt_cursor_next_dup - return r; -} - static int c_getf_prev_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra); static int @@ -3157,8 +2936,7 @@ toku_c_getf_prev(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { int r; HANDLE_PANICKED_DB(c->dbp); HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - if (c_db_is_nodup(c)) r = toku_c_getf_prev_nodup(c, flag, f, extra); - else if (toku_c_uninitialized(c)) r = toku_c_getf_last(c, flag, f, extra); + if (toku_c_uninitialized(c)) r = toku_c_getf_last(c, flag, f, extra); else { QUERY_CONTEXT_S context; //Describes the context of this query. num_sequential_queries++; // accountability @@ -3188,12 +2966,11 @@ c_getf_prev_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, v const DBT *prevkey; const DBT *prevval; const DBT *left_key = key==NULL ? toku_lt_neg_infinity : &found_key; - const DBT *left_val = key==NULL ? toku_lt_neg_infinity : &found_val; toku_brt_cursor_peek(context->c, &prevkey, &prevval); read_lock_request_init(&request, context->txn, context->db, - left_key, left_val, - prevkey, prevval); + left_key, + prevkey); r = grab_range_lock(&request); } else r = 0; @@ -3208,77 +2985,6 @@ c_getf_prev_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, v return r; } -static int -toku_c_getf_prev_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { - int r; - HANDLE_PANICKED_DB(c->dbp); - HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - if (toku_c_uninitialized(c)) r = toku_c_getf_last(c, flag, f, extra); - else { - QUERY_CONTEXT_S context; //Describes the context of this query. - num_sequential_queries++; // accountability - query_context_init(&context, c, flag, f, extra); - //toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful) - r = toku_brt_cursor_prev_nodup(dbc_struct_i(c)->c, c_getf_prev_callback, &context); - if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; - } - return r; -} - -static int c_getf_prev_dup_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra); - -static int -toku_c_getf_prev_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { - HANDLE_PANICKED_DB(c->dbp); - HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - if (toku_c_uninitialized(c)) return EINVAL; - - QUERY_CONTEXT_S context; //Describes the context of this query. - num_sequential_queries++; // accountability - query_context_init(&context, c, flag, f, extra); - //toku_brt_cursor_prev_dup will call c_getf_prev_dup_callback(..., context) (if query is successful) - int r = toku_brt_cursor_prev_dup(dbc_struct_i(c)->c, c_getf_prev_dup_callback, &context); - if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; - return r; -} - -//result is the result of the query (i.e. 0 means found, DB_NOTFOUND, etc..) -static int -c_getf_prev_dup_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra) { - QUERY_CONTEXT super_context = extra; - QUERY_CONTEXT_BASE context = &super_context->base; - - int r; - - DBT found_key; - DBT found_val; - toku_fill_dbt(&found_key, key, keylen); - toku_fill_dbt(&found_val, val, vallen); - - if (context->do_locking) { - RANGE_LOCK_REQUEST_S request; - const DBT *prevkey; - const DBT *prevval; - const DBT *left_val = key==NULL ? toku_lt_neg_infinity : &found_val; - - toku_brt_cursor_peek(context->c, &prevkey, &prevval); - read_lock_request_init(&request, context->txn, context->db, - prevkey, left_val, //found_key is same as prevkey for this case - prevkey, prevval); - r = grab_range_lock(&request); - } - else r = 0; - - //Call application-layer callback if found and locks were successfully obtained. - if (r==0 && key!=NULL) { - context->r_user_callback = super_context->f(&found_key, &found_val, context->f_extra); - if (context->r_user_callback) r = TOKUDB_USER_CALLBACK_ERROR; - } - - //Give brt-layer an error (if any) to return from toku_brt_cursor_prev_dup - return r; -} - static int c_getf_current_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra); static int @@ -3342,7 +3048,7 @@ toku_c_getf_set(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, void num_point_queries++; // accountability query_context_with_input_init(&context, c, flag, key, NULL, f, extra); //toku_brt_cursor_set will call c_getf_set_callback(..., context) (if query is successful) - int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, NULL, c_getf_set_callback, &context); + int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, c_getf_set_callback, &context); if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; return r; } @@ -3367,13 +3073,13 @@ c_getf_set_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, vo RANGE_LOCK_REQUEST_S request; if (key!=NULL) { read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, toku_lt_neg_infinity, - super_context->input_key, &found_val); + super_context->input_key, + super_context->input_key); } else { read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, toku_lt_neg_infinity, - super_context->input_key, toku_lt_infinity); + super_context->input_key, + super_context->input_key); } r = grab_range_lock(&request); } @@ -3426,13 +3132,13 @@ c_getf_set_range_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec v RANGE_LOCK_REQUEST_S request; if (key!=NULL) { read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, toku_lt_neg_infinity, - &found_key, &found_val); + super_context->input_key, + &found_key); } else { read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, toku_lt_neg_infinity, - toku_lt_infinity, toku_lt_infinity); + super_context->input_key, + toku_lt_infinity); } r = grab_range_lock(&request); } @@ -3485,13 +3191,13 @@ c_getf_set_range_reverse_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, b RANGE_LOCK_REQUEST_S request; if (key!=NULL) { read_lock_request_init(&request, context->txn, context->db, - &found_key, &found_val, - super_context->input_key, toku_lt_infinity); + &found_key, + super_context->input_key); } else { read_lock_request_init(&request, context->txn, context->db, - toku_lt_neg_infinity, toku_lt_neg_infinity, - super_context->input_key, toku_lt_infinity); + toku_lt_neg_infinity, + super_context->input_key); } r = grab_range_lock(&request); } @@ -3507,179 +3213,6 @@ c_getf_set_range_reverse_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, b return r; } -static int c_getf_get_both_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra); - -static int -toku_c_getf_get_both(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - HANDLE_PANICKED_DB(c->dbp); - HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - - QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. - num_point_queries++; // accountability - query_context_with_input_init(&context, c, flag, key, val, f, extra); - //toku_brt_cursor_get_both will call c_getf_get_both_callback(..., context) (if query is successful) - int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, val, c_getf_get_both_callback, &context); - if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; - return r; -} - -//result is the result of the query (i.e. 0 means found, DB_NOTFOUND, etc..) -static int -c_getf_get_both_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra) { - QUERY_CONTEXT_WITH_INPUT super_context = extra; - QUERY_CONTEXT_BASE context = &super_context->base; - - int r; - - DBT found_key; - DBT found_val; - toku_fill_dbt(&found_key, key, keylen); - toku_fill_dbt(&found_val, val, vallen); - - //Lock: - // left(key,val) = (input_key, input_val) - // right==left - if (context->do_locking) { - RANGE_LOCK_REQUEST_S request; - read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, super_context->input_val, - super_context->input_key, super_context->input_val); - r = grab_range_lock(&request); - } - else r = 0; - - //Call application-layer callback if found and locks were successfully obtained. - if (r==0 && key!=NULL) { - context->r_user_callback = super_context->f(&found_key, &found_val, context->f_extra); - if (context->r_user_callback) r = TOKUDB_USER_CALLBACK_ERROR; - } - - //Give brt-layer an error (if any) to return from toku_brt_cursor_get_both - return r; -} - -static int c_getf_get_both_range_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra); - -static int -toku_c_getf_get_both_range(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - HANDLE_PANICKED_DB(c->dbp); - HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - int r; - if (c_db_is_nodup(c)) r = toku_c_getf_get_both(c, flag, key, val, f, extra); - else { - QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. - num_point_queries++; // accountability - query_context_with_input_init(&context, c, flag, key, val, f, extra); - //toku_brt_cursor_get_both_range will call c_getf_get_both_range_callback(..., context) (if query is successful) - r = toku_brt_cursor_get_both_range(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_callback, &context); - if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; - } - return r; -} - -//result is the result of the query (i.e. 0 means found, DB_NOTFOUND, etc..) -static int -c_getf_get_both_range_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra) { - QUERY_CONTEXT_WITH_INPUT super_context = extra; - QUERY_CONTEXT_BASE context = &super_context->base; - - int r; - - DBT found_key; - DBT found_val; - toku_fill_dbt(&found_key, key, keylen); - toku_fill_dbt(&found_val, val, vallen); - - //Lock: - // left(key,val) = (input_key, input_val) - // right(key,val) = (input_key, found ? found_val : infinity) - if (context->do_locking) { - RANGE_LOCK_REQUEST_S request; - if (key!=NULL) { - read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, super_context->input_val, - super_context->input_key, &found_val); - } - else { - read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, super_context->input_val, - super_context->input_key, toku_lt_infinity); - } - r = grab_range_lock(&request); - } - else r = 0; - - //Call application-layer callback if found and locks were successfully obtained. - if (r==0 && key!=NULL) { - context->r_user_callback = super_context->f(&found_key, &found_val, context->f_extra); - if (context->r_user_callback) r = TOKUDB_USER_CALLBACK_ERROR; - } - - //Give brt-layer an error (if any) to return from toku_brt_cursor_get_both_range - return r; -} - -static int c_getf_get_both_range_reverse_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra); - -static int -toku_c_getf_get_both_range_reverse(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - HANDLE_PANICKED_DB(c->dbp); - HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - int r; - if (c_db_is_nodup(c)) r = toku_c_getf_get_both(c, flag, key, val, f, extra); - else { - QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. - num_point_queries++; // accountability - query_context_with_input_init(&context, c, flag, key, val, f, extra); - //toku_brt_cursor_get_both_range_reverse will call c_getf_get_both_range_reverse_callback(..., context) (if query is successful) - r = toku_brt_cursor_get_both_range_reverse(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_reverse_callback, &context); - if (r == TOKUDB_USER_CALLBACK_ERROR) r = context.base.r_user_callback; - } - return r; -} - -//result is the result of the query (i.e. 0 means found, DB_NOTFOUND, etc..) -static int -c_getf_get_both_range_reverse_callback(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra) { - QUERY_CONTEXT_WITH_INPUT super_context = extra; - QUERY_CONTEXT_BASE context = &super_context->base; - - int r; - - DBT found_key; - DBT found_val; - toku_fill_dbt(&found_key, key, keylen); - toku_fill_dbt(&found_val, val, vallen); - - //Lock: - // left(key,val) = (input_key, found ? found_val : -infinity) - // right(key,val) = (input_key, input_val) - if (context->do_locking) { - RANGE_LOCK_REQUEST_S request; - if (key!=NULL) { - read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, &found_val, - super_context->input_key, super_context->input_val); - } - else { - read_lock_request_init(&request, context->txn, context->db, - super_context->input_key, toku_lt_neg_infinity, - super_context->input_key, super_context->input_val); - } - r = grab_range_lock(&request); - } - else r = 0; - - //Call application-layer callback if found and locks were successfully obtained. - if (r==0 && key!=NULL) { - context->r_user_callback = super_context->f(&found_key, &found_val, context->f_extra); - if (context->r_user_callback) r = TOKUDB_USER_CALLBACK_ERROR; - } - - //Give brt-layer an error (if any) to return from toku_brt_cursor_get_both_range_reverse - return r; -} - static int toku_c_close(DBC * c) { HANDLE_PANICKED_DB(c->dbp); HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); @@ -3727,18 +3260,13 @@ toku_c_count(DBC *cursor, db_recno_t *count, u_int32_t flags) { r = toku_db_cursor(cursor->dbp, dbc_struct_i(cursor)->txn, &count_cursor, 0, 0); if (r != 0) goto finish; - *count = 0; r = toku_c_getf_set(count_cursor, lock_flags, ¤tkey, ydb_getf_do_nothing, NULL); - if (r != 0) { - r = 0; goto finish; /* success, the current key must be deleted and there are no more */ + if (r==0) { + *count = 1; // there is a key, so the count is one (since we don't have DUP dbs anymore, the only answers are 0 or 1. + } else { + *count = 0; } - - for (;;) { - *count += 1; - r = toku_c_getf_next_dup(count_cursor, lock_flags, ydb_getf_do_nothing, NULL); - if (r != 0) break; - } - r = 0; /* success, we found at least one before the end */ + r = 0; finish: if (currentkey.data) toku_free(currentkey.data); if (count_cursor) { @@ -3765,19 +3293,6 @@ db_getf_set(DB *db, DB_TXN *txn, u_int32_t flags, DBT *key, YDB_CALLBACK_FUNCTIO return r; } -static int -db_getf_get_both(DB *db, DB_TXN *txn, u_int32_t flags, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - HANDLE_PANICKED_DB(db); - HANDLE_DB_ILLEGAL_WORKING_PARENT_TXN(db, txn); - DBC *c; - int r = toku_db_cursor(db, txn, &c, 0, 1); - if (r==0) { - r = toku_c_getf_get_both(c, flags, key, val, f, extra); - int r2 = toku_c_close(c); - if (r==0) r = r2; - } - return r; -} //////////// static int @@ -3803,8 +3318,8 @@ toku_db_del(DB *db, DB_TXN *txn, DBT *key, u_int32_t flags) { RANGE_LOCK_REQUEST_S request; //Left end of range == right end of range (point lock) write_lock_request_init(&request, txn, db, - key, toku_lt_neg_infinity, - key, toku_lt_infinity); + key, + key); r = grab_range_lock(&request); } if (r==0) { @@ -3857,8 +3372,8 @@ env_del_multiple(DB_ENV *env, DB *src_db, DB_TXN *txn, const DBT *key, const DBT RANGE_LOCK_REQUEST_S request; //Left end of range == right end of range (point lock) write_lock_request_init(&request, txn, db, - &keys[which_db], toku_lt_neg_infinity, - &keys[which_db], toku_lt_infinity); + &keys[which_db], + &keys[which_db]); r = grab_range_lock(&request); if (r!=0) goto cleanup; } @@ -3917,19 +3432,12 @@ static int toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags, int SCRS(c_getf_first); SCRS(c_getf_last); SCRS(c_getf_next); - SCRS(c_getf_next_nodup); - SCRS(c_getf_next_dup); SCRS(c_getf_prev); - SCRS(c_getf_prev_nodup); - SCRS(c_getf_prev_dup); SCRS(c_getf_current); SCRS(c_getf_current_binding); SCRS(c_getf_set); SCRS(c_getf_set_range); SCRS(c_getf_set_range_reverse); - SCRS(c_getf_get_both); - SCRS(c_getf_get_both_range); - SCRS(c_getf_get_both_range_reverse); #undef SCRS #if !TOKUDB_NATIVE_H @@ -3967,40 +3475,6 @@ static int toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags, int return 0; } -static int -toku_db_delboth(DB *db, DB_TXN *txn, DBT *key, DBT *val, u_int32_t flags) { - HANDLE_PANICKED_DB(db); - HANDLE_DB_ILLEGAL_WORKING_PARENT_TXN(db, txn); - num_deletes++; // accountability - u_int32_t unchecked_flags = flags; - //DB_DELETE_ANY means delete regardless of whether it exists in the db. - BOOL error_if_missing = (BOOL)(!(flags&DB_DELETE_ANY)); - unchecked_flags &= ~DB_DELETE_ANY; - u_int32_t lock_flags = get_prelocked_flags(flags, txn, db); - unchecked_flags &= ~lock_flags; - BOOL do_locking = (BOOL)(db->i->lt && !(lock_flags&DB_PRELOCKED_WRITE)); - int r = 0; - if (unchecked_flags!=0) r = EINVAL; - if (r==0 && error_if_missing) { - //Check if the key exists in the db. - r = db_getf_get_both(db, txn, lock_flags, key, val, ydb_getf_do_nothing, NULL); - } - if (r==0 && do_locking) { - //Do locking if necessary. - RANGE_LOCK_REQUEST_S request; - //Left end of range == right end of range (point lock) - write_lock_request_init(&request, txn, db, - key, val, - key, val); - r = grab_range_lock(&request); - } - if (r==0) { - //Do the actual deleting. - r = toku_brt_delete_both(db->i->brt, key, val, txn ? db_txn_struct_i(txn)->tokutxn : NULL); - } - return r; -} - static inline int db_thread_need_flags(DBT *dbt) { return (dbt->flags & (DB_DBT_MALLOC+DB_DBT_REALLOC+DB_DBT_USERMEM)) == 0; } @@ -4015,13 +3489,15 @@ static int toku_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t u_int32_t lock_flags = get_prelocked_flags(flags, txn, db); flags &= ~lock_flags; - if (flags != 0 && flags != DB_GET_BOTH) return EINVAL; // We aren't ready to handle flags such as DB_READ_COMMITTED or DB_READ_UNCOMMITTED or DB_RMW + // And DB_GET_BOTH is no longer supported. #2862. + if (flags != 0) return EINVAL; + DBC *dbc; r = toku_db_cursor(db, txn, &dbc, 0, 1); if (r!=0) return r; - u_int32_t c_get_flags = (flags == 0) ? DB_SET : DB_GET_BOTH; + u_int32_t c_get_flags = DB_SET; r = toku_c_get(dbc, key, data, c_get_flags | lock_flags); int r2 = toku_c_close(dbc); return r ? r : r2; @@ -4074,10 +3550,6 @@ static toku_dbt_cmp toku_db_get_compare_fun(DB* db) { return db->i->brt->compare_fun; } -static toku_dbt_cmp toku_db_get_dup_compare(DB* db) { - return db->i->brt->dup_compare; -} - /***** TODO 2216 delete this static int toku_db_fd(DB *db, int *fdp) { HANDLE_PANICKED_DB(db); @@ -4196,8 +3668,6 @@ toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYP r = toku_brt_get_flags(db->i->brt, &tflags); if (r != 0) return r; - if ((tflags & TOKU_DB_DUP) && !(tflags & TOKU_DB_DUPSORT)) - return EINVAL; if (db_opened(db)) return EINVAL; /* It was already open. */ @@ -4275,11 +3745,6 @@ db_open_iname(DB * db, DB_TXN * txn, const char *iname_in_env, u_int32_t flags, assert(r==0); db->i->key_compare_was_set = TRUE; } - if (!db->i->val_compare_was_set && db->dbenv->i->dup_compare) { - r = toku_brt_set_dup_compare(db->i->brt, db->dbenv->i->dup_compare); - assert(r==0); - db->i->val_compare_was_set = TRUE; - } BOOL need_locktree = (BOOL)((db->dbenv->i->open_flags & DB_INIT_LOCK) && (db->dbenv->i->open_flags & DB_INIT_TXN)); @@ -4297,8 +3762,6 @@ db_open_iname(DB * db, DB_TXN * txn, const char *iname_in_env, u_int32_t flags, r = toku_brt_get_flags(db->i->brt, &tflags); if (r != 0) return r; - if ((tflags & TOKU_DB_DUP) && !(tflags & TOKU_DB_DUPSORT)) - return EINVAL; if (db_opened(db)) return EINVAL; /* It was already open. */ @@ -4316,12 +3779,8 @@ db_open_iname(DB * db, DB_TXN * txn, const char *iname_in_env, u_int32_t flags, db->i->opened = 1; if (need_locktree) { - unsigned int brtflags; - BOOL dups; - toku_brt_get_flags(db->i->brt, &brtflags); - dups = (BOOL)((brtflags & TOKU_DB_DUPSORT || brtflags & TOKU_DB_DUP)); db->i->dict_id = toku_brt_get_dictionary_id(db->i->brt); - r = toku_ltm_get_lt(db->dbenv->i->ltm, &db->i->lt, dups, db->i->dict_id); + r = toku_ltm_get_lt(db->dbenv->i->ltm, &db->i->lt, db->i->dict_id); if (r!=0) { goto error_cleanup; } } //Add to transaction's list of 'must close' if necessary. @@ -4350,23 +3809,16 @@ static int db_put_check_size_constraints(DB *db, DBT *key, DBT *val) { int r; - BOOL dupsort = (BOOL)(!db_is_nodup(db)); //Check limits on size of key and val. unsigned int nodesize; r = toku_brt_get_nodesize(db->i->brt, &nodesize); assert(r == 0); - u_int32_t limit; - if (dupsort) { - limit = nodesize / BRT_FANOUT; - if (key->size + val->size > limit) - r = toku_ydb_do_error(db->dbenv, EINVAL, "The largest row (key + val) allowed is %u bytes", limit); - } else { - limit = nodesize / BRT_FANOUT; - if (key->size > limit) - r = toku_ydb_do_error(db->dbenv, EINVAL, "The largest key allowed is %u bytes", limit); - else if (val->size > nodesize) - r = toku_ydb_do_error(db->dbenv, EINVAL, "The largest value allowed is %u bytes", nodesize); - } + u_int32_t limit = nodesize / BRT_FANOUT; + if (key->size > limit) + r = toku_ydb_do_error(db->dbenv, EINVAL, "The largest key allowed is %u bytes", limit); + else if (val->size > nodesize) + r = toku_ydb_do_error(db->dbenv, EINVAL, "The largest value allowed is %u bytes", nodesize); + return r; } @@ -4410,10 +3862,7 @@ db_put_check_overwrite_constraint(DB *db, DB_TXN *txn, DBT *key, DBT *UU(val), else if (overwrite_flag==0) { //in a nodup db: overwrite_flag==0 is an alias for DB_YESOVERWRITE //in a dupsort db: overwrite_flag==0 is an error - if (db_is_nodup(db)) r = 0; - else { - r = toku_ydb_do_error(db->dbenv, EINVAL, "Tokudb requires that db->put specify DB_YESOVERWRITE or DB_NOOVERWRITE on DB_DUPSORT databases"); - } + r = 0; } else if (overwrite_flag==DB_NOOVERWRITE_NO_ERROR) { r = 0; @@ -4446,8 +3895,8 @@ toku_db_put(DB *db, DB_TXN *txn, DBT *key, DBT *val, u_int32_t flags) { RANGE_LOCK_REQUEST_S request; //Left end of range == right end of range (point lock) write_lock_request_init(&request, txn, db, - key, val, - key, val); + key, + key); r = grab_range_lock(&request); } if (r==0) { @@ -4502,8 +3951,8 @@ env_put_multiple(DB_ENV *env, DB *src_db, DB_TXN *txn, const DBT *key, const DBT RANGE_LOCK_REQUEST_S request; //Left end of range == right end of range (point lock) write_lock_request_init(&request, txn, db, - &keys[which_db], &vals[which_db], - &keys[which_db], &vals[which_db]); + &keys[which_db], + &keys[which_db]); r = grab_range_lock(&request); if (r!=0) goto cleanup; } @@ -4784,25 +4233,6 @@ toku_db_set_bt_compare(DB * db, int (*bt_compare) (DB *, const DBT *, const DBT return r; } -// set val comparison function to function provided by user (pre-empting environment val comparison function) -static int -toku_db_set_dup_compare(DB *db, int (*dup_compare)(DB *, const DBT *, const DBT *)) { - HANDLE_PANICKED_DB(db); - int r; - if (db_opened(db)) - r = toku_ydb_do_error(db->dbenv, EINVAL, "Comparison functions cannot be set after DB open.\n"); - else if (!dup_compare) - r = toku_ydb_do_error(db->dbenv, EINVAL, "Comparison functions cannot be NULL.\n"); - else if (db->i->val_compare_was_set) - r = toku_ydb_do_error(db->dbenv, EINVAL, "Val comparison function already set.\n"); - else { - r = toku_brt_set_dup_compare(db->i->brt, dup_compare); - if (!r) - db->i->val_compare_was_set = TRUE; - } - return r; -} - static int toku_db_set_descriptor(DB *db, u_int32_t version, const DBT* descriptor) { HANDLE_PANICKED_DB(db); int r; @@ -4819,39 +4249,13 @@ static int toku_db_set_flags(DB *db, u_int32_t flags) { /* the following matches BDB */ if (db_opened(db) && flags != 0) return EINVAL; - u_int32_t tflags; - int r = toku_brt_get_flags(db->i->brt, &tflags); - if (r!=0) return r; - - if (flags & DB_DUP) - tflags |= TOKU_DB_DUP; - if (flags & DB_DUPSORT) - tflags |= TOKU_DB_DUPSORT; - r = toku_brt_set_flags(db->i->brt, tflags); - return r; + return 0; } static int toku_db_get_flags(DB *db, u_int32_t *pflags) { HANDLE_PANICKED_DB(db); if (!pflags) return EINVAL; - u_int32_t tflags; - u_int32_t flags = 0; - int r = toku_brt_get_flags(db->i->brt, &tflags); - if (r!=0) return r; - if (tflags & TOKU_DB_DUP) { - tflags &= ~TOKU_DB_DUP; - flags |= DB_DUP; - } - if (tflags & TOKU_DB_DUPSORT) { - tflags &= ~TOKU_DB_DUPSORT; - flags |= DB_DUPSORT; - } - { // ignore internal flags - tflags &= ~TOKU_DB_KEYCMP_BUILTIN; - tflags &= ~TOKU_DB_VALCMP_BUILTIN; - } - assert(tflags == 0); - *pflags = flags; + *pflags = 0; return 0; } @@ -4897,7 +4301,7 @@ cleanup: return r; } -static int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) { +static int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *key_right) { HANDLE_PANICKED_DB(db); if (!db->i->lt || !txn) return EINVAL; //READ_UNCOMMITTED and READ_COMMITTED transactions do not need read locks. @@ -4907,8 +4311,8 @@ static int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_lef { RANGE_LOCK_REQUEST_S request; read_lock_request_init(&request, txn, db, - key_left, val_left, - key_right, val_right); + key_left, + key_right); r = grab_range_lock(&request); } return r; @@ -4925,15 +4329,14 @@ int toku_db_pre_acquire_table_lock(DB *db, DB_TXN *txn, BOOL just_lock) { { RANGE_LOCK_REQUEST_S request; write_lock_request_init(&request, txn, db, - toku_lt_neg_infinity, toku_lt_neg_infinity, - toku_lt_infinity, toku_lt_infinity); + toku_lt_neg_infinity, + toku_lt_infinity); r = grab_range_lock(&request); } if (r==0 && !just_lock && !toku_brt_is_recovery_logging_suppressed(db->i->brt) && - toku_brt_is_empty(db->i->brt) && - db_is_nodup(db) //TODO: Remove this check once we kill dupsort support. + toku_brt_is_empty(db->i->brt) ) { //Try to suppress both rollback and recovery logs DB_LOADER *loader; @@ -5041,19 +4444,6 @@ static int locked_db_del(DB * db, DB_TXN * txn, DBT * key, u_int32_t flags) { toku_ydb_lock(); int r = autotxn_db_del(db, txn, key, flags); toku_ydb_unlock(); return r; } -static inline int autotxn_db_delboth(DB* db, DB_TXN* txn, DBT* key, DBT* val, - u_int32_t flags) { - BOOL changed; int r; - r = toku_db_construct_autotxn(db, &txn, &changed, FALSE); - if (r!=0) return r; - r = toku_db_delboth(db, txn, key, val, flags); - return toku_db_destruct_autotxn(txn, r, changed); -} - -static int locked_db_delboth(DB *db, DB_TXN *txn, DBT *key, DBT *val, u_int32_t flags) { - toku_ydb_lock(); int r = autotxn_db_delboth(db, txn, key, val, flags); toku_ydb_unlock(); return r; -} - static inline int autotxn_db_get(DB* db, DB_TXN* txn, DBT* key, DBT* data, u_int32_t flags) { BOOL changed; int r; @@ -5079,21 +4469,9 @@ static int locked_db_getf_set (DB *db, DB_TXN *txn, u_int32_t flags, DBT *key, Y toku_ydb_lock(); int r = autotxn_db_getf_set(db, txn, flags, key, f, extra); toku_ydb_unlock(); return r; } -static inline int autotxn_db_getf_get_both (DB *db, DB_TXN *txn, u_int32_t flags, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - BOOL changed; int r; - r = toku_db_construct_autotxn(db, &txn, &changed, FALSE); - if (r!=0) return r; - r = db_getf_get_both(db, txn, flags, key, val, f, extra); - return toku_db_destruct_autotxn(txn, r, changed); -} - -static int locked_db_getf_get_both (DB *db, DB_TXN *txn, u_int32_t flags, DBT *key, DBT *val, YDB_CALLBACK_FUNCTION f, void *extra) { - toku_ydb_lock(); int r = autotxn_db_getf_get_both(db, txn, flags, key, val, f, extra); toku_ydb_unlock(); return r; -} - -static int locked_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) { +static int locked_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *key_right) { toku_ydb_lock(); - int r = toku_db_pre_acquire_read_lock(db, txn, key_left, val_left, key_right, val_right); + int r = toku_db_pre_acquire_read_lock(db, txn, key_left, key_right); toku_ydb_unlock(); return r; } @@ -5197,10 +4575,6 @@ static int locked_db_set_bt_compare(DB * db, int (*bt_compare) (DB *, const DBT toku_ydb_lock(); int r = toku_db_set_bt_compare(db, bt_compare); toku_ydb_unlock(); return r; } -static int locked_db_set_dup_compare(DB * db, int (*dup_compare) (DB *, const DBT *, const DBT *)) { - toku_ydb_lock(); int r = toku_db_set_dup_compare(db, dup_compare); toku_ydb_unlock(); return r; -} - static int locked_db_set_descriptor(DB *db, u_int32_t version, const DBT* descriptor) { toku_ydb_lock(); int r = toku_db_set_descriptor(db, version, descriptor); @@ -5317,7 +4691,6 @@ static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) { SDB(close); SDB(cursor); SDB(del); - SDB(delboth); SDB(get); // SDB(key_range); SDB(open); @@ -5325,7 +4698,6 @@ static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) { SDB(remove); SDB(rename); SDB(set_bt_compare); - SDB(set_dup_compare); SDB(set_descriptor); SDB(set_errfile); SDB(set_pagesize); @@ -5338,7 +4710,6 @@ static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) { SDB(truncate); SDB(row_size_supported); SDB(getf_set); - SDB(getf_get_both); SDB(flatten); SDB(get_fragmentation); #undef SDB diff --git a/utils/Makefile b/utils/Makefile index 624225be9b4..ba63efa98f2 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -14,8 +14,8 @@ include $(TOKUROOT)toku_include/Makefile.include ifndef BDBDIR BDBDIR=/usr/local/BerkeleyDB.4.6 endif -BDB_DUMP=$(BDBDIR)/bin/db_dump$(BINSUF) -h dir.$@.bdb -BDB_LOAD=$(BDBDIR)/bin/db_load$(BINSUF) -h dir.$@.bdb +BDB_DUMP= LD_LIBRARY_PATH=$(BDBDIR)/lib $(BDBDIR)/bin/db_dump$(BINSUF) -h dir.$@.bdb +BDB_LOAD= LD_LIBRARY_PATH=$(BDBDIR)/lib $(BDBDIR)/bin/db_load$(BINSUF) -h dir.$@.bdb DIFF=diff -q -I 'db_pagesize=' @@ -125,9 +125,9 @@ coverage: $(UTILS) strip: $(STATIC_UTILS) strip $(STATIC_UTILS) -check: build test_gen test_load test_dump test_nodup test_dupsort +check: build test_gen test_load test_dump test_nodup -test-coverage: $(UTILS) test_gen test_load test_dump test_nodup test_dupsort +test-coverage: $(UTILS) test_gen test_load test_dump test_nodup test_gen: test_gen_hex @@ -235,21 +235,6 @@ test_nodup: build $(DIFF) -q $@.dump.bdb.temp $@.dump.tdb.temp \ $(SUMMARIZE_CMD) -test_dupsort: build - rm -rf dir.$@.* - mkdir dir.$@.tdb - mkdir dir.$@.bdb - $(TDB_GEN) $(TEST_GEN_HEX_FLAGS) -D -S >$@.gen.temp && \ - $(BDB_LOAD) $@.bdb.temp <$@.gen.temp && \ - $(BDB_DUMP) $@.bdb.temp >$@.dump.bdb.temp && \ - $(TDB_LOAD) $@.tdb.temp <$@.gen.temp && \ - $(TDB_DUMP) $@.tdb.temp >$@.dump.tdb.temp && \ - $(DIFF) -q $@.dump.bdb.temp $@.dump.tdb.temp && \ - $(TDB_LOAD) $@.tdb.temp <$@.gen.temp && \ - $(TDB_DUMP) $@.tdb.temp >$@.dump.tdb.temp && \ - $(DIFF) -q $@.dump.bdb.temp $@.dump.tdb.temp \ - $(SUMMARIZE_CMD) - #if $(DIFF) -q <(echo "foo") <(echo "foo") > /dev/null; then echo yes; else echo no; fi clean: rm -rf *.so *.o $(UTILS) $(BDB_UTILS) $(STATIC_UTILS) *.temp *.gcno *.gcda *.gcov *.temp.clean *.temp.dirty diff --git a/utils/tokudb_dump.c b/utils/tokudb_dump.c index c6742068025..e8c26a0b3a6 100644 --- a/utils/tokudb_dump.c +++ b/utils/tokudb_dump.c @@ -333,8 +333,6 @@ int dump_header() goto error; } DUMP_IGNORED_FLAG(DB_CHKSUM, "chksum=1\n"); - DUMP_FLAG( DB_DUP, "duplicates=1\n"); - DUMP_FLAG( DB_DUPSORT, "dupsort=1\n"); DUMP_IGNORED_FLAG(DB_RECNUM, "recnum=1\n"); printf("HEADER=END\n"); diff --git a/utils/tokudb_gen.c b/utils/tokudb_gen.c index 244908cce5c..eb8fe551a7b 100644 --- a/utils/tokudb_gen.c +++ b/utils/tokudb_gen.c @@ -50,7 +50,6 @@ bool set_seed = false; bool printableonly = false; bool leadingspace = true; bool force_unique = true; -bool duplicates = false; bool dupsort = false; static int test_main (int argc, char *const argv[]) { @@ -182,8 +181,14 @@ static int test_main (int argc, char *const argv[]) { printf("%s\n", db_version(NULL, NULL, NULL)); return EXIT_SUCCESS; } - case 'D': duplicates = true; break; - case 'S': dupsort = true; break; + case 'D': { + fprintf(stderr, "Duplicates no longer supported by tokudb\n"); + return EXIT_FAILURE; + } + case 'S': { + fprintf(stderr, "Dupsort no longer supported by tokudb\n"); + return EXIT_FAILURE; + } case ('?'): default: { return (usage()); @@ -254,8 +259,6 @@ static int test_main (int argc, char *const argv[]) { printf("format=%s\n", g.plaintext ? "print" : "bytevalue"); printf("type=btree\n"); // printf("db_pagesize=%d\n", 4096); //Don't write pagesize which would be useless. - if (duplicates) - printf("duplicates=%d\n", duplicates); if (dupsort) printf("dupsort=%d\n", dupsort); printf("HEADER=END\n"); diff --git a/utils/tokudb_load.c b/utils/tokudb_load.c index 43844abd25f..9956875ebf4 100644 --- a/utils/tokudb_load.c +++ b/utils/tokudb_load.c @@ -368,8 +368,6 @@ if (!strcmp(field, match)) { \ PARSE_IGNOREDFLAG( "chksum", DB_CHKSUM); \ PARSE_IGNOREDNUMBER( "db_lorder", db->set_lorder); \ PARSE_IGNOREDNUMBER( "db_pagesize", db->set_pagesize); \ - PARSE_FLAG( "duplicates", DB_DUP); \ - PARSE_FLAG( "dupsort", DB_DUPSORT); \ PARSE_UNSUPPORTEDNUMBER("extentsize", db->set_q_extentsize); \ PARSE_UNSUPPORTEDNUMBER("h_ffactor", db->set_h_ffactor); \ PARSE_UNSUPPORTEDNUMBER("h_nelem", db->set_h_nelem); \ @@ -389,7 +387,6 @@ int read_header() int ch; int32_t num; int retval; - DB* db = g.db; int r; assert(g.header); @@ -513,7 +510,6 @@ int apply_commandline_options() char* value = NULL; int32_t num; int retval; - DB* db = g.db; for (idx = 0; g.config_options[idx]; idx++) { if (value) {