Commit 739e2dcc authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Addresses #1987 refs[t:1987] Fully replace (rename) BRT_CMD with BRT_MSG (same...

Addresses #1987 refs[t:1987] Fully replace (rename) BRT_CMD with BRT_MSG (same struct) for consistency

git-svn-id: file:///svn/toku/tokudb@14372 c7de825b-a66e-492c-adef-691d508d4ae1
parent ba698907
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#ident "Copyright (c) 2007, 2008, 2009 Tokutek Inc. All rights reserved." #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." #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."
static int brt_root_put_cmd_XY (BRT brt, BRT_CMD *md, TOKUTXN txn) { static int brt_root_put_cmd_XY (BRT brt, BRT_MSG *md, TOKUTXN txn) {
int r; int r;
if ((r = toku_read_and_pin_brt_header(brt->cf, &brt->h))) { if ((r = toku_read_and_pin_brt_header(brt->cf, &brt->h))) {
if (0) { died0: toku_unpin_brt_header(brt); } if (0) { died0: toku_unpin_brt_header(brt); }
......
...@@ -245,7 +245,7 @@ static const BRTNODE null_brtnode=0; ...@@ -245,7 +245,7 @@ static const BRTNODE null_brtnode=0;
//extern u_int32_t toku_calccrc32_kvpair (const void *key, int keylen, const void *val, int vallen); //extern u_int32_t toku_calccrc32_kvpair (const void *key, int keylen, const void *val, int vallen);
//extern u_int32_t toku_calccrc32_kvpair_struct (const struct kv_pair *kvp); //extern u_int32_t toku_calccrc32_kvpair_struct (const struct kv_pair *kvp);
extern 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); extern 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);
extern u_int32_t toku_calc_fingerprint_cmdstruct (BRT_CMD cmd); extern u_int32_t toku_calc_fingerprint_cmdstruct (BRT_MSG cmd);
// How long is the pivot key? // How long is the pivot key?
unsigned int toku_brt_pivot_key_len (BRT, struct kv_pair *); // Given the tree unsigned int toku_brt_pivot_key_len (BRT, struct kv_pair *); // Given the tree
...@@ -293,17 +293,17 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *diskoff, int n_childr ...@@ -293,17 +293,17 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *diskoff, int n_childr
int toku_testsetup_root(BRT brt, BLOCKNUM); int toku_testsetup_root(BRT brt, BLOCKNUM);
int toku_testsetup_get_sersize(BRT brt, BLOCKNUM); // Return the size on disk. int toku_testsetup_get_sersize(BRT brt, BLOCKNUM); // Return the size on disk.
int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM, char *key, int keylen, char *val, int vallen, u_int32_t *leaf_fingerprint); int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM, char *key, int keylen, char *val, int vallen, u_int32_t *leaf_fingerprint);
int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM, enum brt_cmd_type, char *key, int keylen, char *val, int vallen, u_int32_t *subtree_fingerprint); int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM, enum brt_msg_type, char *key, int keylen, char *val, int vallen, u_int32_t *subtree_fingerprint);
// These two go together to do lookups in a brtnode using the keys in a command. // These two go together to do lookups in a brtnode using the keys in a command.
struct cmd_leafval_heaviside_extra { struct cmd_leafval_heaviside_extra {
BRT t; BRT t;
BRT_CMD cmd; BRT_MSG cmd;
int compare_both_keys; // Set to 1 for DUPSORT databases that are not doing a DELETE_BOTH 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); int toku_cmd_leafval_heaviside (OMTVALUE leafentry, void *extra);
int toku_brt_root_put_cmd(BRT brt, BRT_CMD cmd, TOKULOGGER logger); int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd, TOKULOGGER logger);
void *mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size, void **maybe_free); void *mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size, void **maybe_free);
// Effect: Allocate a new object of size SIZE in MP. If MP runs out of space, allocate new a new mempool space, and copy all the items // Effect: Allocate a new object of size SIZE in MP. If MP runs out of space, allocate new a new mempool space, and copy all the items
......
...@@ -80,7 +80,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke ...@@ -80,7 +80,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
OMTVALUE storeddatav; OMTVALUE storeddatav;
u_int32_t idx; u_int32_t idx;
DBT keydbt,valdbt; DBT keydbt,valdbt;
BRT_CMD_S cmd = {BRT_INSERT, xids_get_root_xids(), BRT_MSG_S cmd = {BRT_INSERT, xids_get_root_xids(),
.u.id={toku_fill_dbt(&keydbt, key, keylen), .u.id={toku_fill_dbt(&keydbt, key, keylen),
toku_fill_dbt(&valdbt, val, vallen)}}; toku_fill_dbt(&valdbt, val, vallen)}};
//Generate a leafentry (committed insert key,val) //Generate a leafentry (committed insert key,val)
...@@ -119,7 +119,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke ...@@ -119,7 +119,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
return r; return r;
} }
int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_cmd_type cmdtype, char *key, int keylen, char *val, int vallen, u_int32_t *subtree_fingerprint) { int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_type cmdtype, char *key, int keylen, char *val, int vallen, u_int32_t *subtree_fingerprint) {
void *node_v; void *node_v;
int r; int r;
r = toku_cachetable_get_and_pin(brt->cf, blocknum, toku_cachetable_hash(brt->cf, blocknum), &node_v, NULL, r = toku_cachetable_get_and_pin(brt->cf, blocknum, toku_cachetable_hash(brt->cf, blocknum), &node_v, NULL,
......
...@@ -208,7 +208,7 @@ nonleaf_node_is_gorged (BRTNODE node) { ...@@ -208,7 +208,7 @@ nonleaf_node_is_gorged (BRTNODE node) {
} }
static int static int
brtnode_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, enum reactivity *re, BOOL *did_io); brtnode_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd, enum reactivity *re, BOOL *did_io);
static int static int
flush_this_child (BRT t, BRTNODE node, int childnum, enum reactivity *child_re, BOOL *did_io); flush_this_child (BRT t, BRTNODE node, int childnum, enum reactivity *child_re, BOOL *did_io);
...@@ -1229,7 +1229,7 @@ brt_split_child (BRT t, BRTNODE node, int childnum, BOOL *did_react) ...@@ -1229,7 +1229,7 @@ brt_split_child (BRT t, BRTNODE node, int childnum, BOOL *did_react)
//TODO: Rename this function //TODO: Rename this function
static int static int
should_compare_both_keys (BRTNODE node, BRT_CMD cmd) should_compare_both_keys (BRTNODE node, BRT_MSG cmd)
// Effect: Return nonzero if we need to compare both the key and the value. // Effect: Return nonzero if we need to compare both the key and the value.
{ {
switch (cmd->type) { switch (cmd->type) {
...@@ -1249,17 +1249,6 @@ should_compare_both_keys (BRTNODE node, BRT_CMD cmd) ...@@ -1249,17 +1249,6 @@ should_compare_both_keys (BRTNODE node, BRT_CMD cmd)
abort(); return 0; abort(); return 0;
} }
//TODO: #1125 remove scaffolding
static int
apply_cmd_to_leaf(BRT_CMD cmd,
void *stored_data, // NULL if there was no stored data.
size_t *newlen, size_t *disksize, LEAFENTRY *new_data,
OMT omt, struct mempool *mp, void **maybe_free) {
int r = apply_msg_to_leafentry(cmd, stored_data, newlen, disksize, new_data,
omt, mp, maybe_free);
return r;
}
static int static int
other_key_matches (BRTNODE node, u_int32_t idx, LEAFENTRY le) other_key_matches (BRTNODE node, u_int32_t idx, LEAFENTRY le)
{ {
...@@ -1374,7 +1363,7 @@ maybe_do_implicit_promotion_on_query (BRT_CURSOR UU(brtcursor), LEAFENTRY UU(le) ...@@ -1374,7 +1363,7 @@ maybe_do_implicit_promotion_on_query (BRT_CURSOR UU(brtcursor), LEAFENTRY UU(le)
} }
static int static int
brt_leaf_apply_cmd_once (BRTNODE node, BRT_CMD cmd, brt_leaf_apply_cmd_once (BRTNODE node, BRT_MSG cmd,
u_int32_t idx, LEAFENTRY le) u_int32_t idx, LEAFENTRY le)
// Effect: Apply cmd to leafentry // Effect: Apply cmd to leafentry
// idx is the location where it goes // idx is the location where it goes
...@@ -1388,7 +1377,7 @@ brt_leaf_apply_cmd_once (BRTNODE node, BRT_CMD cmd, ...@@ -1388,7 +1377,7 @@ brt_leaf_apply_cmd_once (BRTNODE node, BRT_CMD cmd,
// This function may call mempool_malloc_dont_release() to allocate more space. // This function may call mempool_malloc_dont_release() to allocate more space.
// That means the old pointers are guaranteed to still be good, but the data may have been copied into a new mempool. // That means the old pointers are guaranteed to still be good, but the data may have been copied into a new mempool.
// We'll have to release the old mempool later. // We'll have to release the old mempool later.
int r = apply_cmd_to_leaf(cmd, le, &newlen, &newdisksize, &new_le, node->u.l.buffer, &node->u.l.buffer_mempool, &maybe_free); int r = apply_msg_to_leafentry(cmd, le, &newlen, &newdisksize, &new_le, node->u.l.buffer, &node->u.l.buffer_mempool, &maybe_free);
if (r!=0) return r; if (r!=0) return r;
if (new_le) assert(newdisksize == leafentry_disksize(new_le)); if (new_le) assert(newdisksize == leafentry_disksize(new_le));
...@@ -1479,7 +1468,7 @@ brt_leaf_apply_cmd_once (BRTNODE node, BRT_CMD cmd, ...@@ -1479,7 +1468,7 @@ brt_leaf_apply_cmd_once (BRTNODE node, BRT_CMD cmd,
} }
static int static int
brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd,
enum reactivity *re /*OUT*/ enum reactivity *re /*OUT*/
) )
// Effect: Put a cmd into a leaf. // Effect: Put a cmd into a leaf.
...@@ -1626,7 +1615,7 @@ brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, ...@@ -1626,7 +1615,7 @@ brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd,
return 0; return 0;
} }
static int brt_nonleaf_cmd_once_to_child (BRT t, BRTNODE node, unsigned int childnum, BRT_CMD cmd, static int brt_nonleaf_cmd_once_to_child (BRT t, BRTNODE node, unsigned int childnum, BRT_MSG cmd,
enum reactivity re_array[], BOOL *did_io) enum reactivity re_array[], BOOL *did_io)
{ {
...@@ -1740,7 +1729,7 @@ unsigned int toku_brtnode_which_child (BRTNODE node , DBT *k, DBT *d, BRT t) { ...@@ -1740,7 +1729,7 @@ unsigned int toku_brtnode_which_child (BRTNODE node , DBT *k, DBT *d, BRT t) {
#endif #endif
} }
static int brt_nonleaf_cmd_once (BRT t, BRTNODE node, BRT_CMD cmd, static int brt_nonleaf_cmd_once (BRT t, BRTNODE node, BRT_MSG cmd,
enum reactivity re_array[], BOOL *did_io) enum reactivity re_array[], BOOL *did_io)
// Effect: Insert a message into a nonleaf. We may put it into a child, possibly causing the child to become reactive. // Effect: Insert a message into a nonleaf. We may put it into a child, possibly causing the child to become reactive.
// We don't do the splitting and merging. That's up to the caller after doing all the puts it wants to do. // We don't do the splitting and merging. That's up to the caller after doing all the puts it wants to do.
...@@ -1762,7 +1751,7 @@ static int brt_nonleaf_cmd_once (BRT t, BRTNODE node, BRT_CMD cmd, ...@@ -1762,7 +1751,7 @@ static int brt_nonleaf_cmd_once (BRT t, BRTNODE node, BRT_CMD cmd,
} }
static int static int
brt_nonleaf_cmd_many (BRT t, BRTNODE node, BRT_CMD cmd, brt_nonleaf_cmd_many (BRT t, BRTNODE node, BRT_MSG cmd,
enum reactivity re_array[], BOOL *did_io) enum reactivity re_array[], BOOL *did_io)
// Effect: Put the cmd into a nonleaf node. We may put it into several children, possibly causing the children to become reactive. // Effect: Put the cmd into a nonleaf node. We may put it into several children, possibly causing the children to become reactive.
// We don't do the splitting and merging. That's up to the caller after doing all the puts it wants to do. // We don't do the splitting and merging. That's up to the caller after doing all the puts it wants to do.
...@@ -1810,7 +1799,7 @@ brt_nonleaf_cmd_many (BRT t, BRTNODE node, BRT_CMD cmd, ...@@ -1810,7 +1799,7 @@ brt_nonleaf_cmd_many (BRT t, BRTNODE node, BRT_CMD cmd,
} }
static int static int
brt_nonleaf_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, brt_nonleaf_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd,
enum reactivity re_array[], BOOL *did_io) enum reactivity re_array[], BOOL *did_io)
// Effect: Put the cmd into a nonleaf node. We may put it into a child, possibly causing the child to become reactive. // Effect: Put the cmd into a nonleaf node. We may put it into a child, possibly causing the child to become reactive.
// We don't do the splitting and merging. That's up to the caller after doing all the puts it wants to do. // We don't do the splitting and merging. That's up to the caller after doing all the puts it wants to do.
...@@ -2319,7 +2308,7 @@ flush_this_child (BRT t, BRTNODE node, int childnum, enum reactivity *child_re, ...@@ -2319,7 +2308,7 @@ flush_this_child (BRT t, BRTNODE node, int childnum, enum reactivity *child_re,
DBT hk,hv; DBT hk,hv;
//TODO: Factor out (into a function) conversion of fifo_entry to message //TODO: Factor out (into a function) conversion of fifo_entry to message
BRT_CMD_S brtcmd = { (enum brt_cmd_type)type, xids, .u.id= {toku_fill_dbt(&hk, key, keylen), BRT_MSG_S brtcmd = { (enum brt_msg_type)type, xids, .u.id= {toku_fill_dbt(&hk, key, keylen),
toku_fill_dbt(&hv, val, vallen)} }; toku_fill_dbt(&hv, val, vallen)} };
int n_bytes_removed = (hk.size + hv.size + KEY_VALUE_OVERHEAD + BRT_CMD_OVERHEAD + xids_get_serialize_size(xids)); int n_bytes_removed = (hk.size + hv.size + KEY_VALUE_OVERHEAD + BRT_CMD_OVERHEAD + xids_get_serialize_size(xids));
...@@ -2368,7 +2357,7 @@ flush_some_child (BRT t, BRTNODE node, enum reactivity re_array[], BOOL *did_io) ...@@ -2368,7 +2357,7 @@ flush_some_child (BRT t, BRTNODE node, enum reactivity re_array[], BOOL *did_io)
static int static int
brtnode_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, enum reactivity *re, BOOL *did_io) brtnode_put_cmd (BRT t, BRTNODE node, BRT_MSG cmd, enum reactivity *re, BOOL *did_io)
// Effect: Push CMD into the subtree rooted at NODE, and indicate whether as a result NODE should split or should merge. // Effect: Push CMD into the subtree rooted at NODE, and indicate whether as a result NODE should split or should merge.
// If NODE is a leaf, then // If NODE is a leaf, then
// put CMD into leaf, applying it to the leafentries // put CMD into leaf, applying it to the leafentries
...@@ -2416,7 +2405,7 @@ brtnode_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, enum reactivity *re, BOOL *di ...@@ -2416,7 +2405,7 @@ brtnode_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, enum reactivity *re, BOOL *di
} }
} }
static int push_something_at_root (BRT brt, BRTNODE *nodep, CACHEKEY *rootp, BRT_CMD cmd, TOKULOGGER logger) static int push_something_at_root (BRT brt, BRTNODE *nodep, CACHEKEY *rootp, BRT_MSG cmd, TOKULOGGER logger)
// Effect: Put CMD into brt by descending into the tree as deeply as we can // Effect: Put CMD into brt by descending into the tree as deeply as we can
// without performing I/O (but we must fetch the root), // without performing I/O (but we must fetch the root),
// bypassing only empty FIFOs // bypassing only empty FIFOs
...@@ -2483,7 +2472,7 @@ CACHEKEY* toku_calculate_root_offset_pointer (BRT brt, u_int32_t *roothash) { ...@@ -2483,7 +2472,7 @@ CACHEKEY* toku_calculate_root_offset_pointer (BRT brt, u_int32_t *roothash) {
return &brt->h->root; return &brt->h->root;
} }
int toku_brt_root_put_cmd(BRT brt, BRT_CMD cmd, TOKULOGGER logger) int toku_brt_root_put_cmd(BRT brt, BRT_MSG cmd, TOKULOGGER logger)
// Effect: Flush the root fifo into the brt, and then push the cmd into the brt. // Effect: Flush the root fifo into the brt, and then push the cmd into the brt.
{ {
void *node_v; void *node_v;
...@@ -2552,7 +2541,7 @@ int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn) ...@@ -2552,7 +2541,7 @@ int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn)
if (r!=0) return r; if (r!=0) return r;
} }
BRT_CMD_S brtcmd = { BRT_INSERT, message_xids, .u.id={key,val}}; BRT_MSG_S brtcmd = { BRT_INSERT, message_xids, .u.id={key,val}};
r = toku_brt_root_put_cmd(brt, &brtcmd, logger); r = toku_brt_root_put_cmd(brt, &brtcmd, logger);
if (r!=0) return r; if (r!=0) return r;
return r; return r;
...@@ -2582,7 +2571,7 @@ int toku_brt_delete(BRT brt, DBT *key, TOKUTXN txn) { ...@@ -2582,7 +2571,7 @@ int toku_brt_delete(BRT brt, DBT *key, TOKUTXN txn) {
if (r!=0) return r; if (r!=0) return r;
} }
DBT val; DBT val;
BRT_CMD_S brtcmd = { BRT_DELETE_ANY, message_xids, .u.id={key, toku_init_dbt(&val)}}; BRT_MSG_S brtcmd = { BRT_DELETE_ANY, message_xids, .u.id={key, toku_init_dbt(&val)}};
r = toku_brt_root_put_cmd(brt, &brtcmd, logger); r = toku_brt_root_put_cmd(brt, &brtcmd, logger);
return r; return r;
} }
...@@ -4457,7 +4446,7 @@ int toku_brt_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn) { ...@@ -4457,7 +4446,7 @@ int toku_brt_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn) {
if (r!=0) return r; if (r!=0) return r;
} }
BRT_CMD_S brtcmd = { BRT_DELETE_BOTH, message_xids, .u.id={key,val}}; BRT_MSG_S brtcmd = { BRT_DELETE_BOTH, message_xids, .u.id={key,val}};
r = toku_brt_root_put_cmd(brt, &brtcmd, logger); r = toku_brt_root_put_cmd(brt, &brtcmd, logger);
return r; return r;
} }
...@@ -4537,7 +4526,7 @@ static void toku_brt_keyrange_internal (BRT brt, CACHEKEY nodename, u_int32_t fu ...@@ -4537,7 +4526,7 @@ static void toku_brt_keyrange_internal (BRT brt, CACHEKEY nodename, u_int32_t fu
} }
} }
} else { } else {
BRT_CMD_S cmd = { BRT_INSERT, 0, .u.id={key,0}}; BRT_MSG_S cmd = { BRT_INSERT, 0, .u.id={key,0}};
struct cmd_leafval_heaviside_extra be = {brt, &cmd, 0}; struct cmd_leafval_heaviside_extra be = {brt, &cmd, 0};
u_int32_t idx; u_int32_t idx;
int r = toku_omt_find_zero(node->u.l.buffer, toku_cmd_leafval_heaviside, &be, 0, &idx, NULL); int r = toku_omt_find_zero(node->u.l.buffer, toku_cmd_leafval_heaviside, &be, 0, &idx, NULL);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
void void
brt_msg_from_dbts(BRT_MSG brt_msg, brt_msg_from_dbts(BRT_MSG brt_msg,
DBT *key, DBT *val, DBT *key, DBT *val,
XIDS xids, brt_msg_type type) { XIDS xids, enum brt_msg_type type) {
brt_msg->u.id.key = key; brt_msg->u.id.key = key;
brt_msg->u.id.val = val; brt_msg->u.id.val = val;
brt_msg->xids = xids; brt_msg->xids = xids;
...@@ -66,9 +66,9 @@ brt_msg_get_val(BRT_MSG brt_msg) { ...@@ -66,9 +66,9 @@ brt_msg_get_val(BRT_MSG brt_msg) {
return rval; return rval;
} }
brt_msg_type enum brt_msg_type
brt_msg_get_type(BRT_MSG brt_msg) { brt_msg_get_type(BRT_MSG brt_msg) {
brt_msg_type rval = brt_msg->type; enum brt_msg_type rval = brt_msg->type;
return rval; return rval;
} }
...@@ -23,11 +23,11 @@ void * brt_msg_get_key(BRT_MSG brt_msg); ...@@ -23,11 +23,11 @@ void * brt_msg_get_key(BRT_MSG brt_msg);
void * brt_msg_get_val(BRT_MSG brt_msg); void * brt_msg_get_val(BRT_MSG brt_msg);
brt_msg_type brt_msg_get_type(BRT_MSG brt_msg); enum brt_msg_type brt_msg_get_type(BRT_MSG brt_msg);
void brt_msg_from_fifo_msg(BRT_MSG brt_msg, FIFO_MSG fifo_msg); void brt_msg_from_fifo_msg(BRT_MSG brt_msg, FIFO_MSG fifo_msg);
void brt_msg_from_dbts(BRT_MSG brt_msg, DBT *key, DBT *val, XIDS xids, brt_msg_type type); void brt_msg_from_dbts(BRT_MSG brt_msg, DBT *key, DBT *val, XIDS xids, enum brt_msg_type type);
#endif #endif
...@@ -103,7 +103,7 @@ dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) { ...@@ -103,7 +103,7 @@ dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) {
FIFO_ITERATE(BNC_BUFFER(n,i), key, keylen, data, datalen, typ, xids, FIFO_ITERATE(BNC_BUFFER(n,i), key, keylen, data, datalen, typ, xids,
{ {
printf(" TYPE="); printf(" TYPE=");
switch ((enum brt_cmd_type)typ) { switch ((enum brt_msg_type)typ) {
case BRT_NONE: printf("NONE"); goto ok; case BRT_NONE: printf("NONE"); goto ok;
case BRT_INSERT: printf("INSERT"); goto ok; case BRT_INSERT: printf("INSERT"); goto ok;
case BRT_DELETE_ANY: printf("DELETE_ANY"); goto ok; case BRT_DELETE_ANY: printf("DELETE_ANY"); goto ok;
......
...@@ -82,7 +82,7 @@ typedef struct cachetable *CACHETABLE; ...@@ -82,7 +82,7 @@ typedef struct cachetable *CACHETABLE;
typedef struct cachefile *CACHEFILE; typedef struct cachefile *CACHEFILE;
/* tree command types */ /* tree command types */
enum brt_cmd_type { enum brt_msg_type {
BRT_NONE = 0, BRT_NONE = 0,
BRT_INSERT = 1, BRT_INSERT = 1,
BRT_DELETE_ANY = 2, // Delete any matching key. This used to be called BRT_DELETE. BRT_DELETE_ANY = 2, // Delete any matching key. This used to be called BRT_DELETE.
...@@ -96,8 +96,8 @@ enum brt_cmd_type { ...@@ -96,8 +96,8 @@ enum brt_cmd_type {
typedef struct xids_t *XIDS; typedef struct xids_t *XIDS;
typedef struct fifo_msg_t *FIFO_MSG; typedef struct fifo_msg_t *FIFO_MSG;
/* tree commands */ /* tree commands */
struct brt_cmd { struct brt_msg {
enum brt_cmd_type type; enum brt_msg_type type;
XIDS xids; XIDS xids;
union { union {
/* insert or delete */ /* insert or delete */
...@@ -107,13 +107,9 @@ struct brt_cmd { ...@@ -107,13 +107,9 @@ struct brt_cmd {
} id; } id;
} u; } u;
}; };
typedef struct brt_cmd BRT_CMD_S, *BRT_CMD;
// TODO: replace brt_cmd_type when ready
typedef enum brt_cmd_type brt_msg_type;
// Message sent into brt to implement command (insert, delete, etc.) // Message sent into brt to implement command (insert, delete, etc.)
// This structure supports nested transactions, and obsoletes brt_cmd. // This structure supports nested transactions, and obsoletes brt_msg.
typedef struct brt_cmd BRT_MSG_S, *BRT_MSG; typedef struct brt_msg BRT_MSG_S, *BRT_MSG;
typedef int (*brt_compare_func)(DB *, const DBT *, const DBT *); typedef int (*brt_compare_func)(DB *, const DBT *, const DBT *);
......
...@@ -105,7 +105,7 @@ int toku_fifo_enq(FIFO fifo, const void *key, unsigned int keylen, const void *d ...@@ -105,7 +105,7 @@ int toku_fifo_enq(FIFO fifo, const void *key, unsigned int keylen, const void *d
return 0; return 0;
} }
int toku_fifo_enq_cmdstruct (FIFO fifo, const BRT_CMD cmd) { int toku_fifo_enq_cmdstruct (FIFO fifo, const BRT_MSG cmd) {
return toku_fifo_enq(fifo, cmd->u.id.key->data, cmd->u.id.key->size, cmd->u.id.val->data, cmd->u.id.val->size, cmd->type, cmd->xids); return toku_fifo_enq(fifo, cmd->u.id.key->data, cmd->u.id.key->size, cmd->u.id.val->data, cmd->u.id.val->size, cmd->type, cmd->xids);
} }
...@@ -123,14 +123,14 @@ int toku_fifo_peek(FIFO fifo, bytevec *key, unsigned int *keylen, bytevec *data, ...@@ -123,14 +123,14 @@ int toku_fifo_peek(FIFO fifo, bytevec *key, unsigned int *keylen, bytevec *data,
return 0; return 0;
} }
// fill in the BRT_CMD, using the two DBTs for the DBT part. // fill in the BRT_MSG, using the two DBTs for the DBT part.
int toku_fifo_peek_cmdstruct (FIFO fifo, BRT_CMD cmd, DBT*key, DBT*data) { int toku_fifo_peek_cmdstruct (FIFO fifo, BRT_MSG cmd, DBT*key, DBT*data) {
u_int32_t type; u_int32_t type;
bytevec keyb,datab; bytevec keyb,datab;
unsigned int keylen,datalen; unsigned int keylen,datalen;
int r = toku_fifo_peek(fifo, &keyb, &keylen, &datab, &datalen, &type, &cmd->xids); int r = toku_fifo_peek(fifo, &keyb, &keylen, &datab, &datalen, &type, &cmd->xids);
if (r!=0) return r; if (r!=0) return r;
cmd->type=(enum brt_cmd_type)type; cmd->type=(enum brt_msg_type)type;
toku_fill_dbt(key, keyb, keylen); toku_fill_dbt(key, keyb, keylen);
toku_fill_dbt(data, datab, datalen); toku_fill_dbt(data, datab, datalen);
cmd->u.id.key=key; cmd->u.id.key=key;
......
...@@ -20,17 +20,17 @@ typedef struct fifo *FIFO; ...@@ -20,17 +20,17 @@ typedef struct fifo *FIFO;
int toku_fifo_create(FIFO *); int toku_fifo_create(FIFO *);
void toku_fifo_free(FIFO *); void toku_fifo_free(FIFO *);
int toku_fifo_n_entries(FIFO); int toku_fifo_n_entries(FIFO);
int toku_fifo_enq_cmdstruct (FIFO fifo, const BRT_CMD cmd); int toku_fifo_enq_cmdstruct (FIFO fifo, const BRT_MSG cmd);
int toku_fifo_enq (FIFO, const void *key, ITEMLEN keylen, const void *data, ITEMLEN datalen, int type, XIDS xids); int toku_fifo_enq (FIFO, const void *key, ITEMLEN keylen, const void *data, ITEMLEN datalen, int type, XIDS xids);
int toku_fifo_peek (FIFO, bytevec *key, ITEMLEN *keylen, bytevec *data, ITEMLEN *datalen, u_int32_t *type, XIDS *xids); int toku_fifo_peek (FIFO, bytevec *key, ITEMLEN *keylen, bytevec *data, ITEMLEN *datalen, u_int32_t *type, XIDS *xids);
int toku_fifo_peek_cmdstruct (FIFO, BRT_CMD, DBT*, DBT*); // fill in the BRT_CMD, using the two DBTs for the DBT part. int toku_fifo_peek_cmdstruct (FIFO, BRT_MSG, DBT*, DBT*); // fill in the BRT_MSG, using the two DBTs for the DBT part.
int toku_fifo_deq(FIFO); int toku_fifo_deq(FIFO);
unsigned long toku_fifo_memory_size(FIFO); // return how much memory the fifo uses. unsigned long toku_fifo_memory_size(FIFO); // return how much memory the fifo uses.
//These two are problematic, since I don't want to malloc() the bytevecs, but dequeueing the fifo frees the memory. //These two are problematic, since I don't want to malloc() the bytevecs, but dequeueing the fifo frees the memory.
//int toku_fifo_peek_deq (FIFO, bytevec *key, ITEMLEN *keylen, bytevec *data, ITEMLEN *datalen, u_int32_t *type, TXNID *xid); //int toku_fifo_peek_deq (FIFO, bytevec *key, ITEMLEN *keylen, bytevec *data, ITEMLEN *datalen, u_int32_t *type, TXNID *xid);
//int toku_fifo_peek_deq_cmdstruct (FIFO, BRT_CMD, DBT*, DBT*); // fill in the BRT_CMD, using the two DBTs for the DBT part. //int toku_fifo_peek_deq_cmdstruct (FIFO, BRT_MSG, DBT*, DBT*); // fill in the BRT_MSG, using the two DBTs for the DBT part.
void toku_fifo_iterate (FIFO, void(*f)(bytevec key,ITEMLEN keylen,bytevec data,ITEMLEN datalen,int type, XIDS xids, void*), void*); void toku_fifo_iterate (FIFO, void(*f)(bytevec key,ITEMLEN keylen,bytevec data,ITEMLEN datalen,int type, XIDS xids, void*), void*);
#define FIFO_ITERATE(fifo,keyvar,keylenvar,datavar,datalenvar,typevar,xidsvar,body) do { \ #define FIFO_ITERATE(fifo,keyvar,keylenvar,datavar,datalenvar,typevar,xidsvar,body) do { \
......
...@@ -87,9 +87,9 @@ fifo_msg_get_val(FIFO_MSG fifo_msg) { ...@@ -87,9 +87,9 @@ fifo_msg_get_val(FIFO_MSG fifo_msg) {
return rval; return rval;
} }
brt_msg_type enum brt_msg_type
fifo_msg_get_type(FIFO_MSG fifo_msg) { fifo_msg_get_type(FIFO_MSG fifo_msg) {
brt_msg_type rval = (brt_msg_type) fifo_msg->type; enum brt_msg_type rval = (enum brt_msg_type) fifo_msg->type;
return rval; return rval;
} }
......
...@@ -25,7 +25,7 @@ void * fifo_msg_get_key(FIFO_MSG fifo_msg); ...@@ -25,7 +25,7 @@ void * fifo_msg_get_key(FIFO_MSG fifo_msg);
void * fifo_msg_get_val(FIFO_MSG fifo_msg); void * fifo_msg_get_val(FIFO_MSG fifo_msg);
brt_msg_type fifo_msg_get_type(FIFO_MSG fifo_msg); enum brt_msg_type fifo_msg_get_type(FIFO_MSG fifo_msg);
u_int32_t fifo_msg_get_size(FIFO_MSG fifo_msg); u_int32_t fifo_msg_get_size(FIFO_MSG fifo_msg);
......
...@@ -59,7 +59,7 @@ static int find_brt_from_filenum (OMTVALUE v, void *filenumvp) { ...@@ -59,7 +59,7 @@ static int find_brt_from_filenum (OMTVALUE v, void *filenumvp) {
return 0; return 0;
} }
static int do_insertion (enum brt_cmd_type type, FILENUM filenum, BYTESTRING key, BYTESTRING *data,TOKUTXN txn) { static int do_insertion (enum brt_msg_type type, FILENUM filenum, BYTESTRING key, BYTESTRING *data,TOKUTXN txn) {
CACHEFILE cf; CACHEFILE cf;
//printf("%s:%d committing insert %s %s\n", __FILE__, __LINE__, key.data, data.data); //printf("%s:%d committing insert %s %s\n", __FILE__, __LINE__, key.data, data.data);
int r = toku_cachefile_of_filenum(txn->logger->ct, filenum, &cf); int r = toku_cachefile_of_filenum(txn->logger->ct, filenum, &cf);
...@@ -67,7 +67,7 @@ static int do_insertion (enum brt_cmd_type type, FILENUM filenum, BYTESTRING key ...@@ -67,7 +67,7 @@ static int do_insertion (enum brt_cmd_type type, FILENUM filenum, BYTESTRING key
DBT key_dbt,data_dbt; DBT key_dbt,data_dbt;
XIDS xids = toku_txn_get_xids(txn); XIDS xids = toku_txn_get_xids(txn);
BRT_CMD_S brtcmd = { type, xids, BRT_MSG_S brtcmd = { type, xids,
.u.id={toku_fill_dbt(&key_dbt, key.data, key.len), .u.id={toku_fill_dbt(&key_dbt, key.data, key.len),
data data
? toku_fill_dbt(&data_dbt, data->data, data->len) ? toku_fill_dbt(&data_dbt, data->data, data->len)
......
...@@ -163,7 +163,7 @@ msg_modify_ule(ULE ule, BRT_MSG msg) { ...@@ -163,7 +163,7 @@ msg_modify_ule(ULE ule, BRT_MSG msg) {
XIDS xids = brt_msg_get_xids(msg); XIDS xids = brt_msg_get_xids(msg);
assert(xids_get_num_xids(xids) <= MAX_TRANSACTION_RECORDS); assert(xids_get_num_xids(xids) <= MAX_TRANSACTION_RECORDS);
ule_do_implicit_promotions(ule, xids); ule_do_implicit_promotions(ule, xids);
brt_msg_type type = brt_msg_get_type(msg); enum brt_msg_type type = brt_msg_get_type(msg);
switch (type) { switch (type) {
case BRT_INSERT: ; case BRT_INSERT: ;
u_int32_t vallen = brt_msg_get_vallen(msg); u_int32_t vallen = brt_msg_get_vallen(msg);
......
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