1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-30 05:23:50 +03:00

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
This commit is contained in:
Bradley C. Kuszmaul
2013-04-16 23:59:21 -04:00
committed by Yoni Fogel
parent 87c3c1de3f
commit 1bfd207e32
170 changed files with 1099 additions and 8708 deletions

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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)");

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;

View File

@@ -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; i<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);
@@ -101,21 +97,17 @@ void test_reverse_compare(int n, int dup_flags) {
db = new Db(&env, 0);
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, 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;
}

View File

@@ -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)

View File

@@ -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];

View File

@@ -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;

View File

@@ -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);

View File

@@ -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<len; i++) {
input |= ((u_int64_t)(cbuf[i]))<<(8*i);
}
c = c*17 + input;
}
return (c&0xFFFFFFFF) ^ (c>>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; i<n; i++)
uncompressed_size += sizes[i].uncompressed_size;
return uncompressed_size;
}
static inline void ignore_int (int UU(ignore_me)) {}
static void deserialize_descriptor_from_rbuf_11(struct rbuf *rb, DESCRIPTOR desc, BOOL temporary);
static int
deserialize_brtnode_nonleaf_from_rbuf_11 (BRTNODE result, bytevec magic, struct rbuf *rb) {
int r;
int i;
if (memcmp(magic, "tokunode", 8)!=0) {
r = toku_db_badformat();
return r;
}
result->u.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; i<result->u.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; i<result->u.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; i<result->u.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; i<result->u.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; j<i; j++) toku_fifo_free(&BNC_BUFFER(result,j));
return toku_db_badformat();
}
}
{
int cnum;
u_int32_t check_local_fingerprint = 0;
for (cnum=0; cnum<result->u.n.n_children; cnum++) {
int n_in_this_hash = rbuf_int(rb);
//printf("%d in hash\n", n_in_hash);
for (i=0; i<n_in_this_hash; i++) {
int diff;
bytevec key; ITEMLEN keylen;
bytevec val; ITEMLEN vallen;
//toku_verify_counts_11(result);
int type = rbuf_char(rb);
XIDS xids;
xids_create_from_buffer(rb, &xids);
rbuf_bytes(rb, &key, &keylen); /* Returns a pointer into the rbuf. */
rbuf_bytes(rb, &val, &vallen);
check_local_fingerprint += result->rand4fingerprint * 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; i<n_in_buf; i++) {
LEAFENTRY le = (LEAFENTRY)(&rb->buf[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<n_sub_blocks; i++) {
u_int32_t compressed_size = toku_dtoh32(*(u_int32_t*)(&raw_block[compression_header_offset+8*i]));
if (compressed_size<=0 || compressed_size>(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; i<n_sub_blocks; i++) {
init_decompress_work(&decompress_work_11[i], compressed_data, sub_block_sizes[i].compressed_size, uncompressed_data, sub_block_sizes[i].uncompressed_size);
if (i>0) {
#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; i<n_sub_blocks; i++)
wait_decompress_work(&decompress_work_11[i]);
#endif
#endif
toku_trace("decompress done");
if (0) printf("First 4 bytes of uncompressed data are %02x%02x%02x%02x\n",
rb->buf[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;
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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; i<node->u.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; i<result->u.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(result, result->u.n.childkeys[i]);
result->u.n.totalchildkeylens+=toku_brt_pivot_key_len(result->u.n.childkeys[i]);
}
for (int i=0; i<result->u.n.n_children; i++) {
BNC_BLOCKNUM(result,i) = rbuf_blocknum(rb);
@@ -758,17 +739,10 @@ 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);
}
}
// deserialize the partition map
struct sub_block_map part_map[npartitions];
@@ -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,22 +1642,9 @@ 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 {
toku_brt_pivot_key_len (struct kv_pair *pk) {
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);
}
}
int
toku_db_badformat(void) {
@@ -1943,8 +1885,3 @@ cleanup:
}
// NOTE: Backwards compatibility functions are in the included .c file(s):
#include "backwards_11.c"

View File

@@ -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();

View File

@@ -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);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -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);

View File

@@ -94,10 +94,8 @@ dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) {
for (i=0; i<n->u.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;

View File

@@ -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).

View File

@@ -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) {

View File

@@ -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

View File

@@ -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},

View File

@@ -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);

View File

@@ -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);

View File

@@ -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,

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -57,12 +57,11 @@ static void test_multiple_brt_cursor_dbts(int n, DB *db) {
void *ptrs[n];
for (i=0; i<n; i++) {
DBT kbt, vbt;
DBT kbt;
char key[10];
snprintf(key, sizeof key, "k%04d", i);
r = toku_brt_cursor_get(cursors[i],
toku_fill_dbt(&kbt, key, 1+strlen(key)),
toku_init_dbt(&vbt),
save_data,
&ptrs[i],
DB_SET);

View File

@@ -23,7 +23,7 @@ static void assert_cursor_notfound(BRT brt, int position) {
assert(r==0);
struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, position);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, position);
assert(r == DB_NOTFOUND);
assert(pair.call_count==0);
@@ -40,7 +40,7 @@ static void assert_cursor_value(BRT brt, int position, long long value) {
if (test_cursor_debug && verbose) printf("key: ");
struct check_pair pair = {len_ignore, 0, sizeof(value), &value, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, position);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, position);
assert(r == 0);
assert(pair.call_count==1);
@@ -58,7 +58,7 @@ static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv)
if (test_cursor_debug && verbose) printf("first key: ");
{
struct check_pair pair = {len_ignore, 0, sizeof(firstv), &firstv, 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);
}
@@ -66,7 +66,7 @@ static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv)
if (test_cursor_debug && verbose) printf("last key:");
{
struct check_pair pair = {len_ignore, 0, sizeof(lastv), &lastv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_LAST);
assert(r == 0);
assert(pair.call_count==1);
}
@@ -257,7 +257,7 @@ static void assert_cursor_walk(BRT brt, int n) {
for (i=0; ; i++) {
long long v = i;
struct check_pair pair = {len_ignore, 0, sizeof(v), &v, 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;
@@ -323,7 +323,7 @@ static void assert_cursor_rwalk(BRT brt, int n) {
for (i=n-1; ; i--) {
long long v = i;
struct check_pair pair = {len_ignore, 0, sizeof v, &v, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_PREV);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_PREV);
if (r != 0) {
assert(pair.call_count==0);
break;
@@ -407,7 +407,7 @@ static void assert_cursor_walk_inorder(BRT brt, int n) {
if (test_cursor_debug && verbose) printf("key: ");
for (i=0; ; i++) {
r = toku_brt_cursor_get(cursor, NULL, NULL, ascending_key_string_checkf, &prevkey, DB_NEXT);
r = toku_brt_cursor_get(cursor, NULL, ascending_key_string_checkf, &prevkey, DB_NEXT);
if (r != 0) {
break;
}
@@ -449,7 +449,7 @@ static void test_brt_cursor_rand(int n, DB *db) {
v = i;
toku_fill_dbt(&vbt, &v, sizeof v);
struct check_pair pair = {kbt.size, key, len_ignore, 0, 0};
r = toku_brt_lookup(brt, &kbt, &vbt, lookup_checkf, &pair);
r = toku_brt_lookup(brt, &kbt, lookup_checkf, &pair);
if (r == 0) {
assert(pair.call_count==1);
if (verbose) printf("dup");
@@ -510,7 +510,7 @@ static void test_brt_cursor_split(int n, DB *db) {
if (test_cursor_debug && verbose) printf("key: ");
for (i=0; i<n/2; i++) {
struct check_pair pair = {len_ignore, 0, len_ignore, 0, 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);
assert(r==0);
assert(pair.call_count==1);
}
@@ -532,7 +532,7 @@ static void test_brt_cursor_split(int n, DB *db) {
// Just loop through the cursor
for (;;) {
struct check_pair pair = {len_ignore, 0, len_ignore, 0, 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;
@@ -642,7 +642,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) {
if ((i % cursor_gap) == 0) {
c = i / cursor_gap;
struct check_pair pair = {len_ignore, 0, len_ignore, 0, 0};
r = toku_brt_cursor_get(cursors[c], NULL, NULL, lookup_checkf, &pair, DB_LAST);
r = toku_brt_cursor_get(cursors[c], NULL, lookup_checkf, &pair, DB_LAST);
assert(r == 0);
assert(pair.call_count==1);
}
@@ -653,7 +653,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) {
for (c=0; c<ncursors; c++) {
int vv = c*cursor_gap + i + 1;
struct check_pair pair = {len_ignore, 0, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursors[c], NULL, NULL, lookup_checkf, &pair, DB_NEXT);
r = toku_brt_cursor_get(cursors[c], NULL, lookup_checkf, &pair, DB_NEXT);
if (r == DB_NOTFOUND) {
/* we already consumed 1 previously */
assert(pair.call_count==0);
@@ -719,7 +719,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
toku_fill_dbt(&key, &k, sizeof k);
struct check_pair pair = {sizeof k, 0, sizeof vv, &v, 0};
if (cursor_op == DB_SET) pair.key = &k; // if it is a set operation, make sure that the result we get is the right one.
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);
}
@@ -732,7 +732,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
DBT key;
toku_fill_dbt(&key, &k, sizeof 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);
CKERR2(r,DB_NOTFOUND);
assert(pair.call_count==0);
assert(key.data == &k); // make sure that no side effect happened on key
@@ -792,7 +792,7 @@ static void test_brt_cursor_set_range(int n, DB *db) {
toku_fill_dbt(&key, &k, sizeof k);
int vv = ((v+9)/10)*10;
struct check_pair pair = {sizeof k, 0, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, &key, NULL, lookup_checkf, &pair, DB_SET_RANGE);
r = toku_brt_cursor_get(cursor, &key, lookup_checkf, &pair, DB_SET_RANGE);
if (v > 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<n; i++) {
int k = toku_htonl(i);
int v = i;
DBT key, val;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
error = toku_brt_insert(brt, &key, &val, 0);
assert(error == 0);
}
{
/* verify that keys not in the tree fail */
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);
}
/* verify that key match but data mismatch fails */
for (i=0; i<n; i++) {
int k = toku_htonl(i);
int v = i+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);
}
/* verify that key and data matches succeeds */
for (i=0; i<n; i++) {
int k = toku_htonl(i);
int v = i;
{
DBT key, val;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
struct check_pair pair = {len_ignore,0,len_ignore,0,0};
error = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_GET_BOTH);
assert(error == 0);
assert(pair.call_count==1);
}
#ifdef DB_CURRENT
{
int vv = i;
struct check_pair pair = {len_ignore, 0, sizeof vv, &vv, 0};
error = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT);
assert(error == 0);
assert(pair.call_count==1);
}
#endif
error = toku_brt_cursor_delete(cursor, 0, null_txn);
assert(error == 0);
k = toku_htonl(i);
v = i;
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);
}
error = toku_brt_cursor_delete(cursor, 0, null_txn);
assert(error != 0);
error = toku_brt_cursor_close(cursor);
assert(error == 0);
error = toku_close_brt(brt, 0);
assert(error == 0);
error = toku_cachetable_close(&ct);
assert(error == 0);
}
static int test_brt_cursor_inc = 1000;
static int test_brt_cursor_limit = 10000;
@@ -1040,7 +919,6 @@ static void test_brt_cursor(DB *db) {
test_brt_cursor_delete(1000, db); toku_memory_check_all_free();
test_multiple_brt_cursor_walk(10000, db); toku_memory_check_all_free();
test_multiple_brt_cursor_walk(100000, db); toku_memory_check_all_free();
test_brt_cursor_get_both(1000, db); toku_memory_check_all_free();
}

View File

@@ -258,13 +258,13 @@ static void test_cursor_last_empty(void) {
r = toku_brt_cursor(brt, &cursor, NULL, TXNID_NONE, FALSE); assert(r==0);
{
struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_LAST);
assert(pair.call_count==0);
assert(r==DB_NOTFOUND);
}
{
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(pair.call_count==0);
assert(r==DB_NOTFOUND);
}
@@ -300,7 +300,7 @@ static void test_cursor_next (void) {
if (verbose) printf("%s:%d calling toku_brt_cursor_get(...)\n", __FILE__, __LINE__);
{
struct check_pair pair = {7, "byebye", 7, "byenow", 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 (verbose) printf("%s:%d called toku_brt_cursor_get(...)\n", __FILE__, __LINE__);
assert(r==0);
assert(pair.call_count==1);
@@ -308,13 +308,13 @@ static void test_cursor_next (void) {
{
struct check_pair pair = {6, "hello", 6, "there", 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);
assert(r==0);
assert(pair.call_count==1);
}
{
struct check_pair pair = {0, 0, 0, 0, 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);
assert(r==DB_NOTFOUND);
assert(pair.call_count==0);
}
@@ -392,7 +392,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);
}
@@ -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<n; i++) {
k = toku_htonl(0); v = toku_htonl(i);
r = toku_brt_insert(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0);
assert(r == 0);
}
for (i=0; i<n; i += 2) {
k = toku_htonl(0); v = toku_htonl(i);
r = toku_brt_delete_both(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), null_txn); assert(r == 0);
}
#if 0
for (i=1; i<n; i += 2) {
k = toku_htonl(0);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_lookup(t, &key, &val); assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) toku_htonl(i));
if (val.data) free(val.data);
r = toku_brt_delete_both(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &vv, sizeof vv), null_txn); assert(r == 0);
}
#endif
/* cursor should find only odd pairs */
BRT_CURSOR cursor=0;
r = toku_brt_cursor(t, &cursor, NULL, TXNID_NONE, FALSE); assert(r == 0);
for (i=1; ; i += 2) {
int kv = toku_htonl(0);
int vv = toku_htonl(i);
struct check_pair pair = {sizeof kv, &kv, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT);
if (r != 0) {
assert(pair.call_count==0);
break;
}
assert(pair.call_count==1);
}
r = toku_brt_cursor_close(cursor); assert(r == 0);
r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
static void test_brt_delete(void) {
test_brt_delete_empty(); toku_memory_check_all_free();
@@ -910,7 +843,7 @@ static void test_new_brt_cursor_first(int n, int dup_mode) {
int kv = toku_htonl(i);
int vv = toku_htonl(i);
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);
if (r != 0) {
assert(pair.call_count==0);
break;
@@ -963,7 +896,7 @@ static void test_new_brt_cursor_last(int n, int dup_mode) {
int kk = toku_htonl(i);
int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_LAST);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_LAST);
if (r != 0) {
assert(pair.call_count==0);
break;
@@ -1013,7 +946,7 @@ static void test_new_brt_cursor_next(int n, int dup_mode) {
int kk = toku_htonl(i);
int vv = toku_htonl(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;
@@ -1057,7 +990,7 @@ static void test_new_brt_cursor_prev(int n, int dup_mode) {
int kk = toku_htonl(i);
int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_PREV);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_PREV);
if (r != 0) {
assert(pair.call_count==0);
break;
@@ -1102,7 +1035,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk = toku_htonl(i);
int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, 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);
if (r != 0) {
assert(pair.call_count==0);
break;
@@ -1113,7 +1046,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk = toku_htonl(i);
int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_CURRENT);
assert(r == 0);
assert(pair.call_count==1);
}
@@ -1122,7 +1055,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk = toku_htonl(i);
int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT_BINDING);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_CURRENT_BINDING);
assert(r == 0);
assert(pair.call_count==1);
}
@@ -1133,7 +1066,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
static int count=0;
count++;
struct check_pair pair = {0,0,0,0,0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_CURRENT);
CKERR2(r,DB_NOTFOUND); // previous DB_KEYEMPTY
assert(pair.call_count==0);
}
@@ -1142,7 +1075,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk = toku_htonl(i);
int vv = toku_htonl(i);
struct check_pair pair = {sizeof kk, &kk, sizeof vv, &vv, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_CURRENT_BINDING);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_CURRENT_BINDING);
assert(r == 0);
assert(pair.call_count==1);
}
@@ -1189,14 +1122,13 @@ static void test_new_brt_cursor_set_range(int n, int dup_mode) {
int v = random() % (10*n);
int k = toku_htonl(v);
DBT key = {.size=sizeof k, .data=&k};
DBT val = {.size=sizeof v, .data=&v};
int vv = (((v+9)/10)*10); // This is the value we should actually find.
struct check_pair pair = {sizeof k, NULL, // NULL data means don't check it
sizeof vv, &vv,
0};
r = toku_brt_cursor_get(cursor, &key, &val, lookup_checkf, &pair, DB_SET_RANGE);
r = toku_brt_cursor_get(cursor, &key, lookup_checkf, &pair, DB_SET_RANGE);
if (v > 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();

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -259,7 +259,7 @@ static void verify_dbfile(int n, int sorted_keys[], const char *sorted_vals[], c
int i;
for (i=0; i<n; i++) {
struct check_pair pair = {sizeof sorted_keys[i], &sorted_keys[i], strlen(sorted_vals[i]), sorted_vals[i], 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;
@@ -268,7 +268,7 @@ static void verify_dbfile(int n, int sorted_keys[], const char *sorted_vals[], c
}
struct check_pair pair; memset(&pair, 0, sizeof pair);
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);
r = toku_brt_cursor_close(cursor); assert(r == 0);

View File

@@ -1,105 +0,0 @@
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2008 Tokutek Inc. All rights reserved."
/* Insert N duplicates into a BRT.
* Delete them with a single delete.
* Close the BRT.
* Check to see that the BRT is empty.
*/
#include "includes.h"
#include "test.h"
#include <unistd.h>
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<limit; i++) {
char key[100];
char val[100];
snprintf(key, 100, "%03u", limit/2);
snprintf(val, 100, "%03u", i);
DBT k,v;
r = toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v,val, 1+strlen(val)), null_txn);
assert(r == 0);
}
//printf("Initial insert done\n"); toku_dump_brt(stdout, t);
// Now reopen the DB to force non-leaf buffering.
r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_brt_create(&t); assert(r==0);
r = toku_brt_open(t, fname, 0, 0, ct, null_txn, (DB*)0); assert(r==0);
// Don't do a dump here, because that will warm the cachetable. We want subsequent inserts to be buffered at the root.
// Insert some more stuff
if (1) {
u_int32_t j;
for (j=0; j<1; j++) {
char key[100];
char val[100];
snprintf(key, 100, "%03u", limit/2);
snprintf(val, 100, "%03u", limit+j);
DBT k,v;
r = toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v,val, 1+strlen(val)), null_txn);
assert(r == 0);
}
}
// Don't do a dump here, because that will warm the cachetable.
// Delete everything
{
char key[100];
DBT k;
snprintf(key, 100, "%03u", limit/2);
r = toku_brt_delete(t, toku_fill_dbt(&k, key, 1+strlen(key)), null_txn);
assert(r == 0);
}
//printf("Deleted\n"); toku_dump_brt(stdout, t);
// Now use a cursor to see if it is all empty
{
BRT_CURSOR cursor = 0;
r = toku_brt_cursor(t, &cursor, 0, TXNID_NONE, FALSE); assert(r==0);
struct check_pair pair = {len_ignore, NULL, len_ignore, NULL, 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_FIRST);
assert(r == DB_NOTFOUND);
r = toku_brt_cursor_close(cursor);
assert(r==0);
}
//printf("Looked\n"); toku_dump_brt(stdout, t);
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_delete_all();
if (verbose) printf("test ok\n");
return 0;
}

View File

@@ -1,66 +0,0 @@
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2008 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include <unistd.h>
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<limit; i++) {
u_int64_t j;
for (j=0; j<ilimit; j++) {
char key[100],val[100];
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
snprintf(val, 100, "%08llu", (unsigned long long)2*j+1);
DBT k,v;
r = toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v,val, 1+strlen(val)), null_txn);
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;
r = toku_brt_keyrange(t, toku_fill_dbt(&k, key, 1+strlen(key)), &less, &equal, &greater);
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 = 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;
}

View File

@@ -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 <unistd.h>
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<limit; i++) {
u_int64_t j;
for (j=0; j<ilimit; j++) {
char key[100],val[100];
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
snprintf(val, 100, "%08llu", (unsigned long long)2*j+1);
DBT k,v;
r = toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v,val, 1+strlen(val)), null_txn);
assert(r == 0);
}
}
// flatten it.
for (i=0; i<limit; i++) {
u_int64_t j;
for (j=0; j<ilimit; j++) {
char key[100],val[100];
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
snprintf(val, 100, "%08llu", (unsigned long long)2*j+1);
DBT k,v;
struct check_pair pair = {1+strlen(key), key, 1+strlen(val), val, 0};
r = toku_brt_lookup(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)),
lookup_checkf, &pair);
assert(r==0);
assert(pair.call_count==1);
}
}
for (i=0; i<limit; i++) {
char key[100];
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
DBT k;
u_int64_t less,equal,greater;
r = toku_brt_keyrange(t, toku_fill_dbt(&k, key, 1+strlen(key)), &less, &equal, &greater);
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;
r = toku_brt_keyrange(t, toku_fill_dbt(&k, key, 1+strlen(key)), &less, &equal, &greater);
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 = 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;
}

View File

@@ -32,7 +32,7 @@ static void test_flat (void) {
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
DBT k;
struct check_pair pair = {1+strlen(key), key, 1+strlen(key), key, 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);
}

View File

@@ -56,7 +56,7 @@ run_test(void) {
else
break;
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r == 0);
trim += 1;

View File

@@ -41,7 +41,7 @@ run_test(void) {
r = close(devnul); assert(r==0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r == 0);
r = system("rm -rf " TESTDIR);

View File

@@ -26,7 +26,7 @@ run_test(void) {
r = toku_logger_close(&logger); assert(r == 0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r == 0);
r = system("rm -rf " TESTDIR);

View File

@@ -32,7 +32,7 @@ run_test(void) {
r = close(devnul);
assert(r==0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r == 0);
r = system("rm -rf " TESTDIR);

View File

@@ -35,7 +35,7 @@ run_test(void) {
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR,
toku_builtin_compare_fun, toku_builtin_compare_fun,
toku_builtin_compare_fun,
NULL, NULL,
0);
assert(r == 0);

View File

@@ -29,7 +29,7 @@ run_test(void) {
}
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r == DB_RUNRECOVERY);
r = system("rm -rf " TESTDIR);

View File

@@ -35,7 +35,7 @@ run_test(void) {
r = close(devnul); assert(r==0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r == 0);
r = system("rm -rf " TESTDIR);

View File

@@ -35,7 +35,7 @@ run_test(void) {
r = close(devnul); assert(r==0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r == 0);
r = system("rm -rf " TESTDIR);

View File

@@ -65,7 +65,7 @@ run_test(void) {
toku_recover_set_callback(recover_callback_at_turnaround, NULL);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r != 0);
r = system("rm -rf " TESTDIR);

View File

@@ -29,7 +29,7 @@ run_test(void) {
r = close(devnul); assert(r==0);
// run recovery
r = tokudb_recover("/junk", TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover("/junk", TESTDIR, 0, 0, NULL, 0);
assert(r != 0);
r = system("rm -rf " TESTDIR);

View File

@@ -21,7 +21,7 @@ run_test(void) {
r = close(devnul); assert(r==0);
// run recovery
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, NULL, 0);
r = tokudb_recover(TESTDIR, TESTDIR, 0, 0, NULL, 0);
assert(r != 0);
r = system("rm -rf " TESTDIR);

View File

@@ -15,7 +15,7 @@ run_test(void) {
r = toku_os_mkdir(TESTDIR, S_IRWXU); assert(r == 0);
// run recovery
r = tokudb_recover(NULL, NULL, 0, 0, NULL, NULL, 0);
r = tokudb_recover(NULL, NULL, 0, 0, NULL, 0);
assert(r != 0);
r = system("rm -rf " TESTDIR);

View File

@@ -34,11 +34,11 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute
{
struct check_pair pair = {5, "0000", 5, "0000", 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
}
{
struct check_pair pair = {5, "0001", 5, "0001", 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
}
// This will invalidate due to the root counter bumping, but the OMT itself will still be valid.
@@ -49,7 +49,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute
{
struct check_pair pair = {5, "0002", 5, "0002", 0};
r = toku_brt_cursor_get(cursor, NULL, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
r = toku_brt_cursor_get(cursor, NULL, lookup_checkf, &pair, DB_NEXT); assert(r==0); assert(pair.call_count==1);
}
r = toku_brt_cursor_close(cursor); assert(r==0);

View File

@@ -1,60 +0,0 @@
/* Check to see that delete_both works on both dup and nodup databases. *
* For recovery to work right, delete_both must work on both cases.
* Specifically, for a nodup database delete_both must not remove pairs unless
* they match both key and value.
*/
#include "includes.h"
#include "test.h"
static TOKUTXN const null_txn = 0;
static void
doit (void) {
int r;
CACHETABLE ct;
BRT t;
char fname[] = __FILE__ ".tdb";
DBT k,v;
if (verbose) printf("%s\n", __FUNCTION__);
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_open(t, fname, 1, 1, ct, null_txn, (DB*)0); assert(r==0);
r = toku_brt_insert(t, toku_fill_dbt(&k, "a", 2), toku_fill_dbt(&v, "x", 2), null_txn);
assert(r==0);
r = toku_brt_delete_both(t, toku_fill_dbt(&k, "a", 2), toku_fill_dbt(&v, "y", 2), null_txn);
assert(r==0);
{
struct check_pair pair = {len_ignore, 0, 2, "x", 0};
r = toku_brt_lookup(t, toku_fill_dbt(&k, "a", 2), NULL, lookup_checkf, &pair);
assert(r==0);
assert(pair.call_count==1);
}
r = toku_brt_delete_both(t, toku_fill_dbt(&k, "a", 2), toku_fill_dbt(&v, "x", 2), null_txn);
assert(r==0);
{
struct check_pair pair = {0,0,0,0,0};
r = toku_brt_lookup(t, toku_fill_dbt(&k, "a", 2), NULL, lookup_checkf, &pair);
assert(r==DB_NOTFOUND);
assert(pair.call_count==0);
}
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);
doit();
if (verbose) printf("test ok\n");
toku_malloc_cleanup();
return 0;
}

View File

@@ -54,7 +54,7 @@ doit (void) {
memset(&v, 0, sizeof(v));
struct check_pair pair = {6, "hello", 6, "there", 0};
r = toku_brt_lookup(t, &k, &v, lookup_checkf, &pair);
r = toku_brt_lookup(t, &k, lookup_checkf, &pair);
assert(r==0);
assert(pair.call_count == 1);

View File

@@ -549,15 +549,11 @@ test_le_empty_apply(void) {
msg_init(&msg, BRT_COMMIT_ANY, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_COMMIT_BOTH, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_COMMIT_BROADCAST_TXN, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_ABORT_ANY, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_ABORT_BOTH, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_ABORT_BROADCAST_TXN, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
}
@@ -567,8 +563,6 @@ test_le_empty_apply(void) {
msg_init(&msg, BRT_DELETE_ANY, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_DELETE_BOTH, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
}
{
msg_init(&msg, BRT_INSERT, msg_xids, &key, &val);
@@ -670,15 +664,11 @@ test_le_committed_apply(void) {
ULE_S ule_expected = ule_initial;
msg_init(&msg, BRT_COMMIT_ANY, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_COMMIT_BOTH, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_COMMIT_BROADCAST_TXN, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_ABORT_ANY, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_ABORT_BOTH, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_ABORT_BROADCAST_TXN, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
}
@@ -688,8 +678,6 @@ test_le_committed_apply(void) {
ULE_S ule_expected;
generate_provdel_for(&ule_expected, &msg);
test_le_apply(&ule_initial, &msg, &ule_expected);
msg_init(&msg, BRT_DELETE_BOTH, msg_xids, &key, &val);
test_le_apply(&ule_initial, &msg, &ule_expected);
}
{

View File

@@ -60,7 +60,7 @@ brt_lookup_and_check_nodup (BRT t, char *keystring, char *valstring)
struct check_pair pair = {1+strlen(keystring), keystring,
1+strlen(valstring), valstring,
0};
int r = toku_brt_lookup(t, &k, 0, lookup_checkf, &pair);
int r = toku_brt_lookup(t, &k, lookup_checkf, &pair);
assert(r==0);
assert(pair.call_count==1);
}
@@ -76,7 +76,7 @@ brt_lookup_and_fail_nodup (BRT t, char *keystring)
struct check_pair pair = {1+strlen(keystring), keystring,
0, 0,
0};
int r = toku_brt_lookup(t, &k, 0, lookup_checkf, &pair);
int r = toku_brt_lookup(t, &k, lookup_checkf, &pair);
assert(r!=0);
assert(pair.call_count==0);
}

View File

@@ -170,16 +170,13 @@ msg_modify_ule(ULE ule, BRT_MSG msg) {
ule_apply_insert(ule, xids, vallen, valp);
break;
case BRT_DELETE_ANY:
case BRT_DELETE_BOTH:
ule_apply_delete(ule, xids);
break;
case BRT_ABORT_ANY:
case BRT_ABORT_BOTH:
case BRT_ABORT_BROADCAST_TXN:
ule_apply_abort(ule, xids);
break;
case BRT_COMMIT_ANY:
case BRT_COMMIT_BOTH:
case BRT_COMMIT_BROADCAST_TXN:
ule_apply_commit(ule, xids);
break;

View File

@@ -444,9 +444,6 @@ int main (int argc, const char *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];

View File

@@ -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

View File

@@ -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,
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));
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));
}
/* 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);
}
@@ -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,
@@ -929,10 +893,8 @@ 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__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,14 +1690,14 @@ 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,
key_left,
key_right,
&out_of_locks);
if (r != 0) { goto cleanup; }
@@ -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,12 +1833,12 @@ 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,
key,
&out_of_locks);
if (r != 0) { goto cleanup; }
@@ -1918,7 +1853,7 @@ 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,
key,
&out_of_locks);
if (r != 0) { goto cleanup; }
}
@@ -1934,24 +1869,23 @@ 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,
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,
key_left,
key_right,
&left, &right,
&query, out_of_locks);
if (r!=0) { goto cleanup; }
@@ -1981,14 +1915,14 @@ 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,
key_left,
key_right,
&out_of_locks);
if (r != 0) { goto cleanup; }
@@ -2003,8 +1937,8 @@ 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,
key_left,
key_right,
&out_of_locks);
if (r != 0) { goto cleanup; }
}

View File

@@ -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));

View File

@@ -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(&lt, duplicates, dbpanic, mgr,
get_compare_fun_from_db, get_dup_compare_from_db,
{
r = toku_lt_create(&lt, dbpanic, mgr,
get_compare_fun_from_db,
toku_malloc, toku_free, toku_realloc);
CKERR(r);
assert(lt);

View File

@@ -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(&lt, duplicates, dbpanic, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
{
r = toku_lt_create(&lt, 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(&lt, duplicates, dbpanic, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
{
r = toku_lt_create(&lt, 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(&ltm, 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(&ltm, 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(&ltm, 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(&ltm, 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(&ltm, 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(&lt, duplicates, NULL, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
r = toku_lt_create(&lt, NULL, ltm,
get_compare_fun_from_db,
toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
r = toku_lt_create(&lt, duplicates, dbpanic, NULL,
get_compare_fun_from_db, get_dup_compare_from_db,
r = toku_lt_create(&lt, dbpanic, NULL,
get_compare_fun_from_db,
toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
r = toku_lt_create(&lt, duplicates, dbpanic, ltm,
NULL, get_dup_compare_from_db,
r = toku_lt_create(&lt, dbpanic, ltm,
NULL,
toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
r = toku_lt_create(&lt, duplicates, dbpanic, ltm,
get_compare_fun_from_db, NULL,
toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
r = toku_lt_create(&lt, duplicates, dbpanic, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
r = toku_lt_create(&lt, dbpanic, ltm,
get_compare_fun_from_db,
NULL, toku_free, toku_realloc);
CKERR2(r, EINVAL);
r = toku_lt_create(&lt, duplicates, dbpanic, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
r = toku_lt_create(&lt, dbpanic, ltm,
get_compare_fun_from_db,
toku_malloc, NULL, toku_realloc);
CKERR2(r, EINVAL);
r = toku_lt_create(&lt, duplicates, dbpanic, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
r = toku_lt_create(&lt, dbpanic, ltm,
get_compare_fun_from_db,
toku_malloc, toku_free, NULL);
CKERR2(r, EINVAL);
}

View File

@@ -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(&ltm, 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(&lt, dups, dbpanic, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
r = toku_lt_create(&lt, 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,22 +107,19 @@ 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,
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);
@@ -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;

View File

@@ -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(&ltm, 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(&lt, dups, dbpanic, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
r = toku_lt_create(&lt, 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();

View File

@@ -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(&ltm, 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(&lt, dups, dbpanic, ltm,
get_compare_fun_from_db, get_dup_compare_from_db,
r = toku_lt_create(&lt, 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();

View File

@@ -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(&ltm, 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, &lt[index], dups, dict_id);
r = toku_ltm_get_lt(ltm, &lt[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;
}

View File

@@ -19,18 +19,18 @@ int nums[10000];
static void setup_ltm(void) {
assert(!ltm);
r = toku_ltm_create(&ltm, 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, &lts[index], dups, dict_ids[db_id_index]);
r = toku_ltm_get_lt(ltm, &lts[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;

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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);
}
}
@@ -372,12 +364,13 @@ insert_n(DB *db1, DB *db2, DB_TXN *txn, int firstkey, int n, int offset) {
// 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; i<n; i++) {
k = firstkey + i;
v = generate_val(k) + offset;
int64_t kk = firstkey+i;
v = generate_val(kk) + offset;
k = (kk<<32) + v;
//printf("I(%32lx,%32lx)\n", k, v);
dbt_init(&key, &k, sizeof(k));
dbt_init(&val, &v, sizeof(v));
if (db1) {
@@ -410,7 +403,6 @@ verify_sequential_rows(DB* compare_db, int64_t firstkey, int64_t numkeys) {
//This does not lock the dbs/grab table locks.
//This means that you CANNOT CALL THIS while another thread is modifying the db.
//You CAN call it while a txn is open however.
int rval = 0;
DB_TXN *compare_txn;
int r, r1;
@@ -434,20 +426,19 @@ verify_sequential_rows(DB* compare_db, int64_t firstkey, int64_t numkeys) {
dbt_init(&key2, &k, sizeof(k));
dbt_init(&val2, &v, sizeof(v));
k = firstkey;
v = generate_val(k);
r1 = c1->c_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; i<numkeys; i++) {
k = i + firstkey;
v = generate_val(k);
int64_t kk = firstkey+i;
v = generate_val(kk);
k = (kk<<32) + v;
r1 = c1->c_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);

View File

@@ -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);
}

View File

@@ -1,75 +0,0 @@
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include "test.h"
#include <db.h>
#include <unistd.h>
#include <sys/stat.h>
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; i<limit; i++) {
u_int64_t j;
for (j=0; j<ilimit; j++) {
char key[100],val[100];
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
snprintf(val, 100, "%08llu", (unsigned long long)2*j+1);
DBT k,v;
r = db->put(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;
}

View File

@@ -1,98 +0,0 @@
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include "test.h"
#include <db.h>
#include <unistd.h>
#include <sys/stat.h>
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; i<limit; i++) {
u_int64_t j;
for (j=0; j<ilimit; j++) {
char key[100],val[100];
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
snprintf(val, 100, "%08llu", (unsigned long long)2*j+1);
DBT k,v;
r = db->put(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; i<limit; i++) {
u_int64_t j;
for (j=0; j<ilimit; j++) {
char key[100],val[100];
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
snprintf(val, 100, "%08llu", (unsigned long long)2*j+1);
DBT k,v;
r = db->get(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; i<limit; i++) {
char key[100];
snprintf(key, 100, "%08llu", (unsigned long long)2*i+1);
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);
}
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;
}

View File

@@ -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);

View File

@@ -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;

Some files were not shown because too many files have changed in this diff Show More