Commit 12b0208d authored by Yoni Fogel's avatar Yoni Fogel

[t:4875] Removed cruft from ft (dictionary_opened). Moved options in...

[t:4875] Removed cruft from ft (dictionary_opened).  Moved options in ft_handle to an options struct

git-svn-id: file:///svn/toku/tokudb@43769 c7de825b-a66e-492c-adef-691d508d4ae1
parent 8aa19fbf
...@@ -350,7 +350,6 @@ struct ft { ...@@ -350,7 +350,6 @@ struct ft {
// counter is effectively a boolean which alternates with each checkpoint. // counter is effectively a boolean which alternates with each checkpoint.
LSN checkpoint_lsn; // LSN of creation of "checkpoint-begin" record in log. LSN checkpoint_lsn; // LSN of creation of "checkpoint-begin" record in log.
int dirty; int dirty;
BOOL dictionary_opened; // True once this header has been associated with a dictionary (a brt fully opened)
DICTIONARY_ID dict_id; // unique id for dictionary DICTIONARY_ID dict_id; // unique id for dictionary
int panic; // If nonzero there was a write error. Don't write any more, because it probably only gets worse. This is the error code. int panic; // If nonzero there was a write error. Don't write any more, because it probably only gets worse. This is the error code.
char *panic_string; // A malloced string that can indicate what went wrong. char *panic_string; // A malloced string that can indicate what went wrong.
...@@ -409,21 +408,25 @@ static inline void setup_fake_db (DB *fake_db, DESCRIPTOR orig_desc) { ...@@ -409,21 +408,25 @@ static inline void setup_fake_db (DB *fake_db, DESCRIPTOR orig_desc) {
} }
#define FAKE_DB(db, desc) struct __toku_db db; setup_fake_db(&db, (desc)) #define FAKE_DB(db, desc) struct __toku_db db; setup_fake_db(&db, (desc))
struct ft_handle { struct ft_options {
// The header is shared. It is also ephemeral.
FT h;
unsigned int nodesize; unsigned int nodesize;
unsigned int basementnodesize; unsigned int basementnodesize;
enum toku_compression_method compression_method; enum toku_compression_method compression_method;
unsigned int flags; unsigned int flags;
BOOL did_set_flags;
ft_compare_func compare_fun; ft_compare_func compare_fun;
ft_update_func update_fun; ft_update_func update_fun;
on_redirect_callback redirect_callback; };
void* redirect_callback_extra;
struct ft_handle {
// The header is shared. It is also ephemeral.
FT h;
on_redirect_callback redirect_callback;
void *redirect_callback_extra;
struct toku_list live_ft_handle_link; struct toku_list live_ft_handle_link;
BOOL did_set_flags;
struct ft_options options;
}; };
// FIXME needs toku prefix // FIXME needs toku prefix
......
This diff is collapsed.
...@@ -203,7 +203,7 @@ int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM blocknum, enum ft_ ...@@ -203,7 +203,7 @@ int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM blocknum, enum ft_
DBT k; DBT k;
int childnum = toku_ftnode_which_child(node, int childnum = toku_ftnode_which_child(node,
toku_fill_dbt(&k, key, keylen), toku_fill_dbt(&k, key, keylen),
&brt->h->cmp_descriptor, brt->compare_fun); &brt->h->cmp_descriptor, brt->h->compare_fun);
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = xids_get_root_xids();
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
static int static int
compare_pairs (FT_HANDLE brt, const DBT *a, const DBT *b) { compare_pairs (FT_HANDLE brt, const DBT *a, const DBT *b) {
FAKE_DB(db, &brt->h->cmp_descriptor); FAKE_DB(db, &brt->h->cmp_descriptor);
int cmp = brt->compare_fun(&db, a, b); int cmp = brt->h->compare_fun(&db, a, b);
return cmp; return cmp;
} }
...@@ -27,7 +27,7 @@ static int ...@@ -27,7 +27,7 @@ static int
compare_leafentries (FT_HANDLE brt, LEAFENTRY a, LEAFENTRY b) { compare_leafentries (FT_HANDLE brt, LEAFENTRY a, LEAFENTRY b) {
DBT x,y; DBT x,y;
FAKE_DB(db, &brt->h->cmp_descriptor); FAKE_DB(db, &brt->h->cmp_descriptor);
int cmp = brt->compare_fun(&db, int cmp = brt->h->compare_fun(&db,
toku_fill_dbt(&x, le_key(a), le_keylen(a)), toku_fill_dbt(&x, le_key(a), le_keylen(a)),
toku_fill_dbt(&y, le_key(b), le_keylen(b))); toku_fill_dbt(&y, le_key(b), le_keylen(b)));
return cmp; return cmp;
...@@ -37,7 +37,7 @@ static int ...@@ -37,7 +37,7 @@ static int
compare_pair_to_leafentry (FT_HANDLE brt, const DBT *a, LEAFENTRY b) { compare_pair_to_leafentry (FT_HANDLE brt, const DBT *a, LEAFENTRY b) {
DBT y; DBT y;
FAKE_DB(db, &brt->h->cmp_descriptor); FAKE_DB(db, &brt->h->cmp_descriptor);
int cmp = brt->compare_fun(&db, a, toku_fill_dbt(&y, le_key(b), le_keylen(b))); int cmp = brt->h->compare_fun(&db, a, toku_fill_dbt(&y, le_key(b), le_keylen(b)));
return cmp; return cmp;
} }
...@@ -45,7 +45,7 @@ static int ...@@ -45,7 +45,7 @@ static int
compare_pair_to_key (FT_HANDLE brt, const DBT *a, bytevec key, ITEMLEN keylen) { compare_pair_to_key (FT_HANDLE brt, const DBT *a, bytevec key, ITEMLEN keylen) {
DBT y; DBT y;
FAKE_DB(db, &brt->h->cmp_descriptor); FAKE_DB(db, &brt->h->cmp_descriptor);
int cmp = brt->compare_fun(&db, a, toku_fill_dbt(&y, key, keylen)); int cmp = brt->h->compare_fun(&db, a, toku_fill_dbt(&y, key, keylen));
return cmp; return cmp;
} }
...@@ -171,7 +171,7 @@ verify_sorted_by_key_msn(FT_HANDLE brt, FIFO fifo, OMT mt) { ...@@ -171,7 +171,7 @@ verify_sorted_by_key_msn(FT_HANDLE brt, FIFO fifo, OMT mt) {
assert_zero(r); assert_zero(r);
size_t offset = (size_t) v; size_t offset = (size_t) v;
if (i > 0) { if (i > 0) {
struct toku_fifo_entry_key_msn_cmp_extra extra = { .desc = &brt->h->cmp_descriptor, .cmp = brt->compare_fun, .fifo = fifo }; struct toku_fifo_entry_key_msn_cmp_extra extra = { .desc = &brt->h->cmp_descriptor, .cmp = brt->h->compare_fun, .fifo = fifo };
if (toku_fifo_entry_key_msn_cmp(&extra, &last_offset, &offset) >= 0) { if (toku_fifo_entry_key_msn_cmp(&extra, &last_offset, &offset) >= 0) {
result = TOKUDB_NEEDS_REPAIR; result = TOKUDB_NEEDS_REPAIR;
break; break;
...@@ -185,7 +185,7 @@ verify_sorted_by_key_msn(FT_HANDLE brt, FIFO fifo, OMT mt) { ...@@ -185,7 +185,7 @@ verify_sorted_by_key_msn(FT_HANDLE brt, FIFO fifo, OMT mt) {
static int static int
count_eq_key_msn(FT_HANDLE brt, FIFO fifo, OMT mt, const DBT *key, MSN msn) { count_eq_key_msn(FT_HANDLE brt, FIFO fifo, OMT mt, const DBT *key, MSN msn) {
struct toku_fifo_entry_key_msn_heaviside_extra extra = { struct toku_fifo_entry_key_msn_heaviside_extra extra = {
.desc = &brt->h->cmp_descriptor, .cmp = brt->compare_fun, .fifo = fifo, .key = key, .msn = msn .desc = &brt->h->cmp_descriptor, .cmp = brt->h->compare_fun, .fifo = fifo, .key = key, .msn = msn
}; };
OMTVALUE v; u_int32_t idx; OMTVALUE v; u_int32_t idx;
int r = toku_omt_find_zero(mt, toku_fifo_entry_key_msn_heaviside, &extra, &v, &idx); int r = toku_omt_find_zero(mt, toku_fifo_entry_key_msn_heaviside, &extra, &v, &idx);
...@@ -311,7 +311,7 @@ toku_verify_ftnode (FT_HANDLE brt, ...@@ -311,7 +311,7 @@ toku_verify_ftnode (FT_HANDLE brt,
} }
struct count_msgs_extra extra = { .count = 0, .key = &keydbt, struct count_msgs_extra extra = { .count = 0, .key = &keydbt,
.msn = msn, .fifo = bnc->buffer, .msn = msn, .fifo = bnc->buffer,
.desc = &brt->h->cmp_descriptor, .cmp = brt->compare_fun }; .desc = &brt->h->cmp_descriptor, .cmp = brt->h->compare_fun };
extra.count = 0; extra.count = 0;
toku_omt_iterate(bnc->broadcast_list, count_msgs, &extra); toku_omt_iterate(bnc->broadcast_list, count_msgs, &extra);
if (ft_msg_type_applies_all(type) || ft_msg_type_does_nothing(type)) { if (ft_msg_type_applies_all(type) || ft_msg_type_does_nothing(type)) {
......
...@@ -254,7 +254,7 @@ ft_close (CACHEFILE cachefile, int fd, void *header_v, char **malloced_error_str ...@@ -254,7 +254,7 @@ ft_close (CACHEFILE cachefile, int fd, void *header_v, char **malloced_error_str
int r = 0; int r = 0;
if (h->panic) { if (h->panic) {
r = h->panic; r = h->panic;
} else if (h->dictionary_opened) { //Otherwise header has never fully been created. } else {
assert(h->cf == cachefile); assert(h->cf == cachefile);
TOKULOGGER logger = toku_cachefile_logger(cachefile); TOKULOGGER logger = toku_cachefile_logger(cachefile);
LSN lsn = ZERO_LSN; LSN lsn = ZERO_LSN;
...@@ -357,33 +357,40 @@ static int setup_initial_ft_root_node (FT h, BLOCKNUM blocknum) { ...@@ -357,33 +357,40 @@ static int setup_initial_ft_root_node (FT h, BLOCKNUM blocknum) {
return r; return r;
} }
// TODO: (Zardosht) move this functionality to ft_init
// No need in having ft_init call this function
static int static int
ft_init_partial (FT_HANDLE t, CACHEFILE cf, TOKUTXN txn) { ft_init (FT ft, FT_OPTIONS options, CACHEFILE cf, TOKUTXN txn) {
int r; ft->type = FT_CURRENT;
t->h->flags = t->flags; ft->checkpoint_header = NULL;
if (t->h->cf!=NULL) assert(t->h->cf == cf); toku_ft_init_treelock(ft);
t->h->cf = cf; toku_blocktable_create_new(&ft->blocktable);
t->h->nodesize = t->nodesize; //Assign blocknum for root block, also dirty the header
t->h->basementnodesize = t->basementnodesize; toku_allocate_blocknum(ft->blocktable, &ft->root_blocknum, ft);
t->h->compression_method = t->compression_method;
t->h->root_xid_that_created = txn ? txn->ancestor_txnid64 : TXNID_NONE; toku_list_init(&ft->live_ft_handles);
t->h->compare_fun = t->compare_fun; int r = toku_omt_create(&ft->txns);
t->h->update_fun = t->update_fun; assert_zero(r);
t->h->in_memory_stats = ZEROSTATS; ft->flags = options->flags;
t->h->on_disk_stats = ZEROSTATS; ft->nodesize = options->nodesize;
t->h->checkpoint_staging_stats = ZEROSTATS; ft->basementnodesize = options->basementnodesize;
t->h->highest_unused_msn_for_upgrade.msn = MIN_MSN.msn - 1; ft->compression_method = options->compression_method;
ft->compare_fun = options->compare_fun;
BLOCKNUM root = t->h->root_blocknum; ft->update_fun = options->update_fun;
r = setup_initial_ft_root_node(t->h, root);
if (ft->cf!=NULL) assert(ft->cf == cf);
ft->cf = cf;
ft->root_xid_that_created = txn ? txn->ancestor_txnid64 : TXNID_NONE;
ft->in_memory_stats = ZEROSTATS;
ft->on_disk_stats = ZEROSTATS;
ft->checkpoint_staging_stats = ZEROSTATS;
ft->highest_unused_msn_for_upgrade.msn = MIN_MSN.msn - 1;
r = setup_initial_ft_root_node(ft, ft->root_blocknum);
if (r != 0) { if (r != 0) {
goto exit; goto exit;
} }
//printf("%s:%d putting %p (%d)\n", __FILE__, __LINE__, t->h, 0); //printf("%s:%d putting %p (%d)\n", __FILE__, __LINE__, ft, 0);
toku_cachefile_set_userdata(t->h->cf, toku_cachefile_set_userdata(ft->cf,
t->h, ft,
ft_log_fassociate_during_checkpoint, ft_log_fassociate_during_checkpoint,
ft_log_suppress_rollback_during_checkpoint, ft_log_suppress_rollback_during_checkpoint,
ft_close, ft_close,
...@@ -392,67 +399,51 @@ ft_init_partial (FT_HANDLE t, CACHEFILE cf, TOKUTXN txn) { ...@@ -392,67 +399,51 @@ ft_init_partial (FT_HANDLE t, CACHEFILE cf, TOKUTXN txn) {
ft_end_checkpoint, ft_end_checkpoint,
ft_note_pin_by_checkpoint, ft_note_pin_by_checkpoint,
ft_note_unpin_by_checkpoint); ft_note_unpin_by_checkpoint);
exit:
return r;
}
static int toku_block_verify_no_free_blocknums(ft->blocktable);
ft_init (FT_HANDLE t, CACHEFILE cf, TOKUTXN txn) { r = 0;
t->h->type = FT_CURRENT; exit:
t->h->checkpoint_header = NULL;
toku_ft_init_treelock(t->h);
toku_blocktable_create_new(&t->h->blocktable);
BLOCKNUM root;
//Assign blocknum for root block, also dirty the header
toku_allocate_blocknum(t->h->blocktable, &root, t->h);
t->h->root_blocknum = root;
toku_list_init(&t->h->live_ft_handles);
int r = toku_omt_create(&t->h->txns);
assert_zero(r);
r = ft_init_partial(t, cf, txn);
if (r==0) toku_block_verify_no_free_blocknums(t->h->blocktable);
return r; return r;
} }
// allocate and initialize a brt header. // allocate and initialize a brt header.
// t->h->cf is not set to anything. // t->h->cf is not set to anything.
// TODO: (Zardosht) make this function return a header and set
// it to t->h in the caller
int int
toku_create_new_ft(FT_HANDLE t, CACHEFILE cf, TOKUTXN txn) { toku_create_new_ft(FT *ftp, FT_OPTIONS options, CACHEFILE cf, TOKUTXN txn) {
int r; int r;
invariant(ftp);
FT XCALLOC(ft);
assert (!t->h);
XCALLOC(t->h);
t->h->layout_version = FT_LAYOUT_VERSION; ft->layout_version = FT_LAYOUT_VERSION;
t->h->layout_version_original = FT_LAYOUT_VERSION; ft->layout_version_original = FT_LAYOUT_VERSION;
t->h->layout_version_read_from_disk = FT_LAYOUT_VERSION; // fake, prevent unnecessary upgrade logic ft->layout_version_read_from_disk = FT_LAYOUT_VERSION; // fake, prevent unnecessary upgrade logic
t->h->build_id = BUILD_ID; ft->build_id = BUILD_ID;
t->h->build_id_original = BUILD_ID; ft->build_id_original = BUILD_ID;
uint64_t now = (uint64_t) time(NULL); uint64_t now = (uint64_t) time(NULL);
t->h->time_of_creation = now; ft->time_of_creation = now;
t->h->time_of_last_modification = now; ft->time_of_last_modification = now;
t->h->time_of_last_verification = 0; ft->time_of_last_verification = 0;
memset(&t->h->descriptor, 0, sizeof(t->h->descriptor)); memset(&ft->descriptor, 0, sizeof(ft->descriptor));
memset(&t->h->cmp_descriptor, 0, sizeof(t->h->cmp_descriptor)); memset(&ft->cmp_descriptor, 0, sizeof(ft->cmp_descriptor));
r = ft_init(t, cf, txn); r = ft_init(ft, options, cf, txn);
if (r != 0) { if (r != 0) {
goto exit; goto exit;
} }
*ftp = ft;
r = 0; r = 0;
exit: exit:
if (r != 0) { if (r != 0) {
if (t->h) { if (ft) {
toku_free(t->h); toku_free(ft);
t->h = NULL; ft = NULL;
} }
return r; return r;
} }
...@@ -470,8 +461,8 @@ int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_ac ...@@ -470,8 +461,8 @@ int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_ac
if ((h=toku_cachefile_get_userdata(cf))!=0) { if ((h=toku_cachefile_get_userdata(cf))!=0) {
*header = h; *header = h;
*was_open = TRUE; *was_open = TRUE;
assert(brt->update_fun == h->update_fun); assert(brt->options.update_fun == h->update_fun);
assert(brt->compare_fun == h->compare_fun); assert(brt->options.compare_fun == h->compare_fun);
return 0; return 0;
} }
} }
...@@ -495,8 +486,8 @@ int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_ac ...@@ -495,8 +486,8 @@ int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_ac
} }
if (r!=0) return r; if (r!=0) return r;
h->cf = cf; h->cf = cf;
h->compare_fun = brt->compare_fun; h->compare_fun = brt->options.compare_fun;
h->update_fun = brt->update_fun; h->update_fun = brt->options.update_fun;
toku_cachefile_set_userdata(cf, toku_cachefile_set_userdata(cf,
(void*)h, (void*)h,
ft_log_fassociate_during_checkpoint, ft_log_fassociate_during_checkpoint,
...@@ -512,12 +503,11 @@ int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_ac ...@@ -512,12 +503,11 @@ int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_ac
} }
void void
toku_ft_note_ft_handle_open(FT_HANDLE live) { toku_ft_note_ft_handle_open(FT ft, FT_HANDLE live) {
FT h = live->h; toku_ft_lock(ft);
toku_ft_lock(h); live->h = ft;
toku_list_push(&h->live_ft_handles, &live->live_ft_handle_link); toku_list_push(&ft->live_ft_handles, &live->live_ft_handle_link);
h->dictionary_opened = TRUE; toku_ft_unlock(ft);
toku_ft_unlock(h);
} }
int int
...@@ -674,18 +664,16 @@ dictionary_redirect_internal(const char *dst_fname_in_env, FT src_h, TOKUTXN txn ...@@ -674,18 +664,16 @@ dictionary_redirect_internal(const char *dst_fname_in_env, FT src_h, TOKUTXN txn
// we want to change it to dummy_dst // we want to change it to dummy_dst
while (!toku_list_empty(&src_h->live_ft_handles)) { while (!toku_list_empty(&src_h->live_ft_handles)) {
list = src_h->live_ft_handles.next; list = src_h->live_ft_handles.next;
FT_HANDLE src_ft = NULL; FT_HANDLE src_handle = NULL;
src_ft = toku_list_struct(list, struct ft_handle, live_ft_handle_link); src_handle = toku_list_struct(list, struct ft_handle, live_ft_handle_link);
toku_ft_lock(src_h); toku_ft_lock(src_h);
toku_list_remove(&src_ft->live_ft_handle_link); toku_list_remove(&src_handle->live_ft_handle_link);
toku_ft_unlock(src_h); toku_ft_unlock(src_h);
src_ft->h = dst_h; toku_ft_note_ft_handle_open(dst_h, src_handle);
if (src_handle->redirect_callback) {
toku_ft_note_ft_handle_open(src_ft); src_handle->redirect_callback(src_handle, src_handle->redirect_callback_extra);
if (src_ft->redirect_callback) {
src_ft->redirect_callback(src_ft, src_ft->redirect_callback_extra);
} }
} }
assert(dst_h); assert(dst_h);
......
...@@ -22,11 +22,11 @@ void toku_ft_destroy_treelock(FT h); ...@@ -22,11 +22,11 @@ void toku_ft_destroy_treelock(FT h);
void toku_ft_grab_treelock(FT h); void toku_ft_grab_treelock(FT h);
void toku_ft_release_treelock(FT h); void toku_ft_release_treelock(FT h);
int toku_create_new_ft(FT_HANDLE t, CACHEFILE cf, TOKUTXN txn); int toku_create_new_ft(FT *ftp, FT_OPTIONS options, CACHEFILE cf, TOKUTXN txn);
void toku_ft_free (FT h); void toku_ft_free (FT h);
int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_acceptable_lsn, FT *header, BOOL* was_open); int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_acceptable_lsn, FT *header, BOOL* was_open);
void toku_ft_note_ft_handle_open(FT_HANDLE live); void toku_ft_note_ft_handle_open(FT ft, FT_HANDLE live);
int toku_ft_needed(FT h); int toku_ft_needed(FT h);
int toku_remove_ft (FT h, char **error_string, BOOL oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result)); int toku_remove_ft (FT h, char **error_string, BOOL oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
......
...@@ -38,6 +38,7 @@ typedef struct ftnode_leaf_basement_node *BASEMENTNODE; ...@@ -38,6 +38,7 @@ typedef struct ftnode_leaf_basement_node *BASEMENTNODE;
typedef struct ftnode_nonleaf_childinfo *NONLEAF_CHILDINFO; typedef struct ftnode_nonleaf_childinfo *NONLEAF_CHILDINFO;
typedef struct sub_block *SUB_BLOCK; typedef struct sub_block *SUB_BLOCK;
typedef struct ft *FT; typedef struct ft *FT;
typedef struct ft_options *FT_OPTIONS;
struct wbuf; struct wbuf;
struct dbuf; struct dbuf;
......
...@@ -66,7 +66,7 @@ insert_into_child_buffer(FT_HANDLE brt, FTNODE node, int childnum, int minkey, i ...@@ -66,7 +66,7 @@ insert_into_child_buffer(FT_HANDLE brt, FTNODE node, int childnum, int minkey, i
unsigned int key = htonl(val); unsigned int key = htonl(val);
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key); DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
DBT theval; toku_fill_dbt(&theval, &val, sizeof val); DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
toku_ft_append_to_child_buffer(brt->compare_fun, NULL, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval); toku_ft_append_to_child_buffer(brt->h->compare_fun, NULL, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
node->max_msn_applied_to_node_on_disk = msn; node->max_msn_applied_to_node_on_disk = msn;
} }
} }
......
...@@ -48,7 +48,7 @@ append_leaf(FT_HANDLE brt, FTNODE leafnode, void *key, size_t keylen, void *val, ...@@ -48,7 +48,7 @@ append_leaf(FT_HANDLE brt, FTNODE leafnode, void *key, size_t keylen, void *val,
FT_MSG_S cmd = { FT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &theval } }; FT_MSG_S cmd = { FT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &theval } };
u_int64_t workdone=0; u_int64_t workdone=0;
toku_ft_leaf_apply_cmd(brt->compare_fun, brt->update_fun, &brt->h->cmp_descriptor, leafnode, &cmd, &workdone, NULL); toku_ft_leaf_apply_cmd(brt->h->compare_fun, brt->h->update_fun, &brt->h->cmp_descriptor, leafnode, &cmd, &workdone, NULL);
{ {
int r = toku_ft_lookup(brt, &thekey, lookup_checkf, &pair); int r = toku_ft_lookup(brt, &thekey, lookup_checkf, &pair);
assert(r==0); assert(r==0);
...@@ -56,7 +56,7 @@ append_leaf(FT_HANDLE brt, FTNODE leafnode, void *key, size_t keylen, void *val, ...@@ -56,7 +56,7 @@ append_leaf(FT_HANDLE brt, FTNODE leafnode, void *key, size_t keylen, void *val,
} }
FT_MSG_S badcmd = { FT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &badval } }; FT_MSG_S badcmd = { FT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &badval } };
toku_ft_leaf_apply_cmd(brt->compare_fun, brt->update_fun, &brt->h->cmp_descriptor, leafnode, &badcmd, &workdone, NULL); toku_ft_leaf_apply_cmd(brt->h->compare_fun, brt->h->update_fun, &brt->h->cmp_descriptor, leafnode, &badcmd, &workdone, NULL);
// message should be rejected for duplicate msn, row should still have original val // message should be rejected for duplicate msn, row should still have original val
...@@ -69,7 +69,7 @@ append_leaf(FT_HANDLE brt, FTNODE leafnode, void *key, size_t keylen, void *val, ...@@ -69,7 +69,7 @@ append_leaf(FT_HANDLE brt, FTNODE leafnode, void *key, size_t keylen, void *val,
// now verify that message with proper msn gets through // now verify that message with proper msn gets through
msn = next_dummymsn(); msn = next_dummymsn();
FT_MSG_S cmd2 = { FT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &val2 } }; FT_MSG_S cmd2 = { FT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &val2 } };
toku_ft_leaf_apply_cmd(brt->compare_fun, brt->update_fun, &brt->h->cmp_descriptor, leafnode, &cmd2, &workdone, NULL); toku_ft_leaf_apply_cmd(brt->h->compare_fun, brt->h->update_fun, &brt->h->cmp_descriptor, leafnode, &cmd2, &workdone, NULL);
// message should be accepted, val should have new value // message should be accepted, val should have new value
{ {
...@@ -81,7 +81,7 @@ append_leaf(FT_HANDLE brt, FTNODE leafnode, void *key, size_t keylen, void *val, ...@@ -81,7 +81,7 @@ append_leaf(FT_HANDLE brt, FTNODE leafnode, void *key, size_t keylen, void *val,
// now verify that message with lesser (older) msn is rejected // now verify that message with lesser (older) msn is rejected
msn.msn = msn.msn - 10; msn.msn = msn.msn - 10;
FT_MSG_S cmd3 = { FT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &badval } }; FT_MSG_S cmd3 = { FT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &badval } };
toku_ft_leaf_apply_cmd(brt->compare_fun, brt->update_fun, &brt->h->cmp_descriptor, leafnode, &cmd3, &workdone, NULL); toku_ft_leaf_apply_cmd(brt->h->compare_fun, brt->h->update_fun, &brt->h->cmp_descriptor, leafnode, &cmd3, &workdone, NULL);
// message should be rejected, val should still have value in pair2 // message should be rejected, val should still have value in pair2
{ {
......
...@@ -126,7 +126,7 @@ insert_random_message_to_bn(FT_HANDLE t, BASEMENTNODE blb, LEAFENTRY *save, XIDS ...@@ -126,7 +126,7 @@ insert_random_message_to_bn(FT_HANDLE t, BASEMENTNODE blb, LEAFENTRY *save, XIDS
int64_t numbytes; int64_t numbytes;
int r = apply_msg_to_leafentry(&msg, NULL, &memsize, save, NULL, NULL, NULL, &numbytes); int r = apply_msg_to_leafentry(&msg, NULL, &memsize, save, NULL, NULL, NULL, &numbytes);
assert_zero(r); assert_zero(r);
toku_ft_bn_apply_cmd(t->compare_fun, t->update_fun, NULL, blb, &msg, NULL, NULL); toku_ft_bn_apply_cmd(t->h->compare_fun, t->h->update_fun, NULL, blb, &msg, NULL, NULL);
if (msn.msn > blb->max_msn_applied.msn) { if (msn.msn > blb->max_msn_applied.msn) {
blb->max_msn_applied = msn; blb->max_msn_applied = msn;
} }
...@@ -167,11 +167,11 @@ insert_same_message_to_bns(FT_HANDLE t, BASEMENTNODE blb1, BASEMENTNODE blb2, LE ...@@ -167,11 +167,11 @@ insert_same_message_to_bns(FT_HANDLE t, BASEMENTNODE blb1, BASEMENTNODE blb2, LE
int64_t numbytes; int64_t numbytes;
int r = apply_msg_to_leafentry(&msg, NULL, &memsize, save, NULL, NULL, NULL, &numbytes); int r = apply_msg_to_leafentry(&msg, NULL, &memsize, save, NULL, NULL, NULL, &numbytes);
assert_zero(r); assert_zero(r);
toku_ft_bn_apply_cmd(t->compare_fun, t->update_fun, NULL, blb1, &msg, NULL, NULL); toku_ft_bn_apply_cmd(t->h->compare_fun, t->h->update_fun, NULL, blb1, &msg, NULL, NULL);
if (msn.msn > blb1->max_msn_applied.msn) { if (msn.msn > blb1->max_msn_applied.msn) {
blb1->max_msn_applied = msn; blb1->max_msn_applied = msn;
} }
toku_ft_bn_apply_cmd(t->compare_fun, t->update_fun, NULL, blb2, &msg, NULL, NULL); toku_ft_bn_apply_cmd(t->h->compare_fun, t->h->update_fun, NULL, blb2, &msg, NULL, NULL);
if (msn.msn > blb2->max_msn_applied.msn) { if (msn.msn > blb2->max_msn_applied.msn) {
blb2->max_msn_applied = msn; blb2->max_msn_applied = msn;
} }
...@@ -583,7 +583,7 @@ flush_to_leaf(FT_HANDLE t, bool make_leaf_up_to_date, bool use_flush) { ...@@ -583,7 +583,7 @@ flush_to_leaf(FT_HANDLE t, bool make_leaf_up_to_date, bool use_flush) {
if (make_leaf_up_to_date) { if (make_leaf_up_to_date) {
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
if (!parent_messages_is_fresh[i]) { if (!parent_messages_is_fresh[i]) {
toku_ft_leaf_apply_cmd(t->compare_fun, t->update_fun, &t->h->descriptor, child, parent_messages[i], NULL, NULL); toku_ft_leaf_apply_cmd(t->h->compare_fun, t->h->update_fun, &t->h->descriptor, child, parent_messages[i], NULL, NULL);
} }
} }
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
...@@ -807,7 +807,7 @@ flush_to_leaf_with_keyrange(FT_HANDLE t, bool make_leaf_up_to_date) { ...@@ -807,7 +807,7 @@ flush_to_leaf_with_keyrange(FT_HANDLE t, bool make_leaf_up_to_date) {
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
if (dummy_cmp(NULL, parent_messages[i]->u.id.key, &childkeys[7]) <= 0 && if (dummy_cmp(NULL, parent_messages[i]->u.id.key, &childkeys[7]) <= 0 &&
!parent_messages_is_fresh[i]) { !parent_messages_is_fresh[i]) {
toku_ft_leaf_apply_cmd(t->compare_fun, t->update_fun, &t->h->descriptor, child, parent_messages[i], NULL, NULL); toku_ft_leaf_apply_cmd(t->h->compare_fun, t->h->update_fun, &t->h->descriptor, child, parent_messages[i], NULL, NULL);
} }
} }
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
...@@ -1000,8 +1000,8 @@ compare_apply_and_flush(FT_HANDLE t, bool make_leaf_up_to_date) { ...@@ -1000,8 +1000,8 @@ compare_apply_and_flush(FT_HANDLE t, bool make_leaf_up_to_date) {
if (make_leaf_up_to_date) { if (make_leaf_up_to_date) {
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
if (!parent_messages_is_fresh[i]) { if (!parent_messages_is_fresh[i]) {
toku_ft_leaf_apply_cmd(t->compare_fun, t->update_fun, &t->h->descriptor, child1, parent_messages[i], NULL, NULL); toku_ft_leaf_apply_cmd(t->h->compare_fun, t->h->update_fun, &t->h->descriptor, child1, parent_messages[i], NULL, NULL);
toku_ft_leaf_apply_cmd(t->compare_fun, t->update_fun, &t->h->descriptor, child2, parent_messages[i], NULL, NULL); toku_ft_leaf_apply_cmd(t->h->compare_fun, t->h->update_fun, &t->h->descriptor, child2, parent_messages[i], NULL, NULL);
} }
} }
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
......
...@@ -59,7 +59,7 @@ doit (void) { ...@@ -59,7 +59,7 @@ doit (void) {
assert(r==0); assert(r==0);
toku_free(fname); toku_free(fname);
brt->update_fun = update_func; brt->h->update_fun = update_func;
brt->h->update_fun = update_func; brt->h->update_fun = update_func;
toku_testsetup_initialize(); // must precede any other toku_testsetup calls toku_testsetup_initialize(); // must precede any other toku_testsetup calls
......
...@@ -59,7 +59,7 @@ doit (BOOL keep_other_bn_in_memory) { ...@@ -59,7 +59,7 @@ doit (BOOL keep_other_bn_in_memory) {
assert(r==0); assert(r==0);
toku_free(fname); toku_free(fname);
brt->update_fun = update_func; brt->options.update_fun = update_func;
brt->h->update_fun = update_func; brt->h->update_fun = update_func;
toku_testsetup_initialize(); // must precede any other toku_testsetup calls toku_testsetup_initialize(); // must precede any other toku_testsetup calls
......
...@@ -58,7 +58,7 @@ doit (void) { ...@@ -58,7 +58,7 @@ doit (void) {
assert(r==0); assert(r==0);
toku_free(fname); toku_free(fname);
brt->update_fun = update_func; brt->options.update_fun = update_func;
brt->h->update_fun = update_func; brt->h->update_fun = update_func;
toku_testsetup_initialize(); // must precede any other toku_testsetup calls toku_testsetup_initialize(); // must precede any other toku_testsetup calls
......
...@@ -70,7 +70,7 @@ insert_into_child_buffer(FT_HANDLE brt, FTNODE node, int childnum, int minkey, i ...@@ -70,7 +70,7 @@ insert_into_child_buffer(FT_HANDLE brt, FTNODE node, int childnum, int minkey, i
unsigned int key = htonl(val); unsigned int key = htonl(val);
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key); DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
DBT theval; toku_fill_dbt(&theval, &val, sizeof val); DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
toku_ft_append_to_child_buffer(brt->compare_fun, NULL, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval); toku_ft_append_to_child_buffer(brt->h->compare_fun, NULL, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
// Create bad tree (don't do following): // Create bad tree (don't do following):
// node->max_msn_applied_to_node = msn; // node->max_msn_applied_to_node = msn;
......
...@@ -58,7 +58,7 @@ insert_into_child_buffer(FT_HANDLE brt, FTNODE node, int childnum, int minkey, i ...@@ -58,7 +58,7 @@ insert_into_child_buffer(FT_HANDLE brt, FTNODE node, int childnum, int minkey, i
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key); DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
DBT theval; toku_fill_dbt(&theval, &val, sizeof val); DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
toku_ft_append_to_child_buffer(brt->compare_fun, NULL, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval); toku_ft_append_to_child_buffer(brt->h->compare_fun, NULL, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
} }
} }
......
...@@ -34,7 +34,7 @@ static inline int db_opened(DB *db) { ...@@ -34,7 +34,7 @@ static inline int db_opened(DB *db) {
static inline toku_dbt_cmp static inline toku_dbt_cmp
toku_db_get_compare_fun(DB* db) { toku_db_get_compare_fun(DB* db) {
return db->i->ft_handle->compare_fun; return db->i->ft_handle->h->compare_fun;
} }
int toku_db_pre_acquire_fileops_lock(DB *db, DB_TXN *txn); int toku_db_pre_acquire_fileops_lock(DB *db, DB_TXN *txn);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment