Commit 3b3d4c6d authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5206 address review comments: only use refs when ref-to-const, otherwise use ptr


git-svn-id: file:///svn/toku/tokudb@45941 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3d6e8bef
......@@ -2643,10 +2643,11 @@ set_filenum_in_array(OMTVALUE hv, u_int32_t index, void*arrayv) {
}
int
log_open_txn (const TOKUTXN &txn, const uint32_t UU(index), CACHETABLE &ct);
log_open_txn (const TOKUTXN &txn, const uint32_t UU(index), CACHETABLE *const ctp);
int
log_open_txn (const TOKUTXN &txn, const uint32_t UU(index), CACHETABLE &ct) {
log_open_txn (const TOKUTXN &txn, const uint32_t UU(index), CACHETABLE *const ctp) {
int r;
CACHETABLE ct = *ctp;
TOKULOGGER logger = txn->logger;
FILENUMS open_filenums;
uint32_t num_filenums = toku_omt_size(txn->open_fts);
......@@ -2767,7 +2768,7 @@ toku_cachetable_begin_checkpoint (CACHETABLE ct, TOKULOGGER logger) {
{
int r = toku_txn_manager_iter_over_live_txns<CACHETABLE, log_open_txn>(
logger->txn_manager,
ct
&ct
);
assert(r==0);
}
......
......@@ -3775,16 +3775,16 @@ struct copy_to_stale_extra {
};
// template-only function, but must be extern
int copy_to_stale(const long &offset, const uint32_t UU(idx), struct copy_to_stale_extra &extra);
int
copy_to_stale(const long &offset, const uint32_t UU(idx), struct copy_to_stale_extra &extra)
int copy_to_stale(const long &offset, const uint32_t UU(idx), struct copy_to_stale_extra *const extra)
__attribute__((nonnull(3)));
int copy_to_stale(const long &offset, const uint32_t UU(idx), struct copy_to_stale_extra *const extra)
{
struct fifo_entry *entry = (struct fifo_entry *) toku_fifo_get_entry(extra.bnc->buffer, offset);
struct fifo_entry *entry = (struct fifo_entry *) toku_fifo_get_entry(extra->bnc->buffer, offset);
entry->is_fresh = false;
DBT keydbt;
DBT *key = fill_dbt_for_fifo_entry(&keydbt, entry);
struct toku_fifo_entry_key_msn_heaviside_extra heaviside_extra = { .desc = &extra.ft_handle->ft->cmp_descriptor, .cmp = extra.ft_handle->ft->compare_fun, .fifo = extra.bnc->buffer, .key = key, .msn = entry->msn };
int r = extra.bnc->stale_message_tree.insert<struct toku_fifo_entry_key_msn_heaviside_extra, toku_fifo_entry_key_msn_heaviside>(offset, heaviside_extra, nullptr);
struct toku_fifo_entry_key_msn_heaviside_extra heaviside_extra = { .desc = &extra->ft_handle->ft->cmp_descriptor, .cmp = extra->ft_handle->ft->compare_fun, .fifo = extra->bnc->buffer, .key = key, .msn = entry->msn };
int r = extra->bnc->stale_message_tree.insert<struct toku_fifo_entry_key_msn_heaviside_extra, toku_fifo_entry_key_msn_heaviside>(offset, heaviside_extra, nullptr);
assert_zero(r);
return r;
}
......@@ -3795,12 +3795,12 @@ struct store_fifo_offset_extra {
};
// template-only function, but must be extern
int store_fifo_offset(const long &offset, const uint32_t UU(idx), struct store_fifo_offset_extra &extra);
int
store_fifo_offset(const long &offset, const uint32_t UU(idx), struct store_fifo_offset_extra &extra)
int store_fifo_offset(const long &offset, const uint32_t UU(idx), struct store_fifo_offset_extra *const extra)
__attribute__((nonnull(3)));
int store_fifo_offset(const long &offset, const uint32_t UU(idx), struct store_fifo_offset_extra *const extra)
{
extra.offsets[extra.i] = offset;
extra.i++;
extra->offsets[extra->i] = offset;
extra->i++;
return 0;
}
......@@ -3873,13 +3873,13 @@ struct iterate_do_bn_apply_cmd_extra {
};
// template-only function, but must be extern
int iterate_do_bn_apply_cmd(const long &offset, const uint32_t UU(idx), struct iterate_do_bn_apply_cmd_extra &e);
int
iterate_do_bn_apply_cmd(const long &offset, const uint32_t UU(idx), struct iterate_do_bn_apply_cmd_extra &e)
int iterate_do_bn_apply_cmd(const long &offset, const uint32_t UU(idx), struct iterate_do_bn_apply_cmd_extra *const e)
__attribute__((nonnull(3)));
int iterate_do_bn_apply_cmd(const long &offset, const uint32_t UU(idx), struct iterate_do_bn_apply_cmd_extra *const e)
{
NONLEAF_CHILDINFO bnc = BNC(e.ancestor, e.childnum);
NONLEAF_CHILDINFO bnc = BNC(e->ancestor, e->childnum);
const struct fifo_entry *entry = toku_fifo_get_entry(bnc->buffer, offset);
do_bn_apply_cmd(e.t, e.bn, e.ancestor, e.childnum, entry, e.stats_to_update);
do_bn_apply_cmd(e->t, e->bn, e->ancestor, e->childnum, entry, e->stats_to_update);
return 0;
}
......@@ -4032,15 +4032,15 @@ bnc_apply_messages_to_basement_node(
struct store_fifo_offset_extra sfo_extra = { .offsets = offsets, .i = 0 };
// Populate offsets array with offsets to stale messages
r = bnc->stale_message_tree.iterate_on_range<struct store_fifo_offset_extra, store_fifo_offset>(stale_lbi, stale_ube, sfo_extra);
r = bnc->stale_message_tree.iterate_on_range<struct store_fifo_offset_extra, store_fifo_offset>(stale_lbi, stale_ube, &sfo_extra);
assert_zero(r);
// Then store fresh offsets
r = bnc->fresh_message_tree.iterate_on_range<struct store_fifo_offset_extra, store_fifo_offset>(fresh_lbi, fresh_ube, sfo_extra);
r = bnc->fresh_message_tree.iterate_on_range<struct store_fifo_offset_extra, store_fifo_offset>(fresh_lbi, fresh_ube, &sfo_extra);
assert_zero(r);
// Store offsets of all broadcast messages.
r = bnc->broadcast_list.iterate<struct store_fifo_offset_extra, store_fifo_offset>(sfo_extra);
r = bnc->broadcast_list.iterate<struct store_fifo_offset_extra, store_fifo_offset>(&sfo_extra);
assert_zero(r);
invariant(sfo_extra.i == buffer_size);
......@@ -4060,7 +4060,7 @@ bnc_apply_messages_to_basement_node(
// No stale messages to apply, we just apply fresh messages.
struct iterate_do_bn_apply_cmd_extra iter_extra = { .t = t, .bn = bn, .ancestor = ancestor, .childnum = childnum, .stats_to_update = &stats_delta};
if (fresh_ube - fresh_lbi > 0) *msgs_applied = TRUE;
r = bnc->fresh_message_tree.iterate_on_range<struct iterate_do_bn_apply_cmd_extra, iterate_do_bn_apply_cmd>(fresh_lbi, fresh_ube, iter_extra);
r = bnc->fresh_message_tree.iterate_on_range<struct iterate_do_bn_apply_cmd_extra, iterate_do_bn_apply_cmd>(fresh_lbi, fresh_ube, &iter_extra);
assert_zero(r);
} else if (fresh_lbi == fresh_ube) {
// No fresh messages to apply, we just apply stale messages.
......@@ -4068,7 +4068,7 @@ bnc_apply_messages_to_basement_node(
if (stale_ube - stale_lbi > 0) *msgs_applied = TRUE;
struct iterate_do_bn_apply_cmd_extra iter_extra = { .t = t, .bn = bn, .ancestor = ancestor, .childnum = childnum , .stats_to_update = &stats_delta};
r = bnc->stale_message_tree.iterate_on_range<struct iterate_do_bn_apply_cmd_extra, iterate_do_bn_apply_cmd>(stale_lbi, stale_ube, iter_extra);
r = bnc->stale_message_tree.iterate_on_range<struct iterate_do_bn_apply_cmd_extra, iterate_do_bn_apply_cmd>(stale_lbi, stale_ube, &iter_extra);
assert_zero(r);
} else {
// We have stale and fresh messages but no broadcasts. We can
......@@ -4157,7 +4157,7 @@ bnc_apply_messages_to_basement_node(
// procedures because we're still looking at the fresh tree. Instead
// we have to move messages after we're done looking at it.
struct copy_to_stale_extra cts_extra = { .ft_handle = t, .bnc = bnc };
r = bnc->fresh_message_tree.iterate_on_range<struct copy_to_stale_extra, copy_to_stale>(fresh_lbi, fresh_ube, cts_extra);
r = bnc->fresh_message_tree.iterate_on_range<struct copy_to_stale_extra, copy_to_stale>(fresh_lbi, fresh_ube, &cts_extra);
assert_zero(r);
for (uint32_t ube = fresh_ube; fresh_lbi < ube; --ube) {
// When we delete the message at the fresh_lbi index, everything
......
......@@ -106,13 +106,13 @@ struct count_msgs_extra {
};
// template-only function, but must be extern
int count_msgs(const long &offset, const uint32_t UU(idx), struct count_msgs_extra &e);
int
count_msgs(const long &offset, const uint32_t UU(idx), struct count_msgs_extra &e)
int count_msgs(const long &offset, const uint32_t UU(idx), struct count_msgs_extra *const e)
__attribute__((nonnull(3)));
int count_msgs(const long &offset, const uint32_t UU(idx), struct count_msgs_extra *const e)
{
const struct fifo_entry *entry = toku_fifo_get_entry(e.fifo, offset);
if (entry->msn.msn == e.msn.msn) {
e.count++;
const struct fifo_entry *entry = toku_fifo_get_entry(e->fifo, offset);
if (entry->msn.msn == e->msn.msn) {
e->count++;
}
return 0;
}
......@@ -128,27 +128,27 @@ struct verify_message_tree_extra {
};
// template-only function, but must be extern
int verify_message_tree(const long &offset, const uint32_t UU(idx), struct verify_message_tree_extra &e);
int
verify_message_tree(const long &offset, const uint32_t UU(idx), struct verify_message_tree_extra &e)
int verify_message_tree(const long &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e)
__attribute__((nonnull(3)));
int verify_message_tree(const long &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e)
{
int verbose = e.verbose;
BLOCKNUM blocknum = e.blocknum;
int keep_going_on_failure = e.keep_going_on_failure;
int verbose = e->verbose;
BLOCKNUM blocknum = e->blocknum;
int keep_going_on_failure = e->keep_going_on_failure;
int result = 0;
const struct fifo_entry *entry = toku_fifo_get_entry(e.fifo, offset);
if (e.broadcast) {
const struct fifo_entry *entry = toku_fifo_get_entry(e->fifo, offset);
if (e->broadcast) {
VERIFY_ASSERTION(ft_msg_type_applies_all((enum ft_msg_type) entry->type) || ft_msg_type_does_nothing((enum ft_msg_type) entry->type),
e.i, "message found in broadcast list that is not a broadcast");
e->i, "message found in broadcast list that is not a broadcast");
} else {
VERIFY_ASSERTION(ft_msg_type_applies_once((enum ft_msg_type) entry->type),
e.i, "message found in fresh or stale message tree that does not apply once");
if (e.is_fresh) {
e->i, "message found in fresh or stale message tree that does not apply once");
if (e->is_fresh) {
VERIFY_ASSERTION(entry->is_fresh,
e.i, "message found in fresh message tree that is not fresh");
e->i, "message found in fresh message tree that is not fresh");
} else {
VERIFY_ASSERTION(!entry->is_fresh,
e.i, "message found in stale message tree that is fresh");
e->i, "message found in stale message tree that is fresh");
}
}
done:
......@@ -296,19 +296,19 @@ toku_verify_ftnode (FT_HANDLE brt,
} else {
VERIFY_ASSERTION(ft_msg_type_applies_all(type) || ft_msg_type_does_nothing(type), i, "a message was found that does not apply either to all or to only one key");
struct count_msgs_extra extra = { .count = 0, .msn = msn, .fifo = bnc->buffer };
bnc->broadcast_list.iterate<struct count_msgs_extra, count_msgs>(extra);
bnc->broadcast_list.iterate<struct count_msgs_extra, count_msgs>(&extra);
VERIFY_ASSERTION(extra.count == 1, i, "a broadcast message was not found in the broadcast list");
}
last_msn = msn;
}));
struct verify_message_tree_extra extra = { .fifo = bnc->buffer, .broadcast = false, .is_fresh = true, .i = i, .verbose = verbose, .blocknum = node->thisnodename, .keep_going_on_failure = keep_going_on_failure };
int r = bnc->fresh_message_tree.iterate<struct verify_message_tree_extra, verify_message_tree>(extra);
int r = bnc->fresh_message_tree.iterate<struct verify_message_tree_extra, verify_message_tree>(&extra);
if (r != 0) { result = r; goto done; }
extra.is_fresh = false;
r = bnc->stale_message_tree.iterate<struct verify_message_tree_extra, verify_message_tree>(extra);
r = bnc->stale_message_tree.iterate<struct verify_message_tree_extra, verify_message_tree>(&extra);
if (r != 0) { result = r; goto done; }
extra.broadcast = true;
r = bnc->broadcast_list.iterate<struct verify_message_tree_extra, verify_message_tree>(extra);
r = bnc->broadcast_list.iterate<struct verify_message_tree_extra, verify_message_tree>(&extra);
if (r != 0) { result = r; goto done; }
}
else {
......
......@@ -971,13 +971,13 @@ deserialize_child_buffer(NONLEAF_CHILDINFO bnc, struct rbuf *rbuf,
r = toku::sort<long, const struct toku_fifo_entry_key_msn_cmp_extra, toku_fifo_entry_key_msn_cmp>::mergesort_r(fresh_offsets, nfresh, extra);
assert_zero(r);
bnc->fresh_message_tree.destroy();
bnc->fresh_message_tree.create_steal_sorted_array(fresh_offsets, nfresh, n_in_this_buffer);
bnc->fresh_message_tree.create_steal_sorted_array(&fresh_offsets, nfresh, n_in_this_buffer);
r = toku::sort<long, const struct toku_fifo_entry_key_msn_cmp_extra, toku_fifo_entry_key_msn_cmp>::mergesort_r(stale_offsets, nstale, extra);
assert_zero(r);
bnc->stale_message_tree.destroy();
bnc->stale_message_tree.create_steal_sorted_array(stale_offsets, nstale, n_in_this_buffer);
bnc->stale_message_tree.create_steal_sorted_array(&stale_offsets, nstale, n_in_this_buffer);
bnc->broadcast_list.destroy();
bnc->broadcast_list.create_steal_sorted_array(broadcast_offsets, nbroadcast_offsets, n_in_this_buffer);
bnc->broadcast_list.create_steal_sorted_array(&broadcast_offsets, nbroadcast_offsets, n_in_this_buffer);
}
}
......@@ -1862,9 +1862,9 @@ deserialize_and_upgrade_internal_node(FTNODE node,
r = key_msn_sort::mergesort_r(fresh_offsets, nfresh, extra);
assert_zero(r);
bnc->fresh_message_tree.destroy();
bnc->fresh_message_tree.create_steal_sorted_array(fresh_offsets, nfresh, n_in_this_buffer);
bnc->fresh_message_tree.create_steal_sorted_array(&fresh_offsets, nfresh, n_in_this_buffer);
bnc->broadcast_list.destroy();
bnc->broadcast_list.create_steal_sorted_array(broadcast_offsets, nbroadcast_offsets, n_in_this_buffer);
bnc->broadcast_list.create_steal_sorted_array(&broadcast_offsets, nbroadcast_offsets, n_in_this_buffer);
}
}
......
This diff is collapsed.
......@@ -1243,11 +1243,11 @@ static uint32_t recover_get_num_live_txns(RECOVER_ENV renv) {
}
// template-only function, but must be extern
int is_txn_unprepared (const TOKUTXN &txn, const uint32_t UU(index), TOKUTXN &extra);
int
is_txn_unprepared (const TOKUTXN &txn, const uint32_t UU(index), TOKUTXN &extra) {
int is_txn_unprepared(const TOKUTXN &txn, const uint32_t UU(index), TOKUTXN *const extra)
__attribute__((nonnull(3)));
int is_txn_unprepared(const TOKUTXN &txn, const uint32_t UU(index), TOKUTXN *const extra) {
if (txn->state != TOKUTXN_PREPARING) {
extra = txn;
*extra = txn;
return -1; // return -1 to get iterator to return
}
return 0;
......@@ -1255,13 +1255,13 @@ is_txn_unprepared (const TOKUTXN &txn, const uint32_t UU(index), TOKUTXN &extra)
static int find_an_unprepared_txn (RECOVER_ENV renv, TOKUTXN *txnp) {
TOKUTXN txn = NULL;
TOKUTXN txn = nullptr;
int r = toku_txn_manager_iter_over_live_txns<TOKUTXN, is_txn_unprepared>(
renv->logger->txn_manager,
txn
&txn
);
assert(r == 0 || r == -1);
if (txn != NULL) {
if (txn != nullptr) {
*txnp = txn;
return 0;
}
......@@ -1269,10 +1269,10 @@ static int find_an_unprepared_txn (RECOVER_ENV renv, TOKUTXN *txnp) {
}
// template-only function, but must be extern
int call_prepare_txn_callback_iter (const TOKUTXN &txn, const uint32_t UU(index), RECOVER_ENV &renv);
int
call_prepare_txn_callback_iter (const TOKUTXN &txn, const uint32_t UU(index), RECOVER_ENV &renv) {
renv->prepared_txn_callback(renv->env, txn);
int call_prepare_txn_callback_iter(const TOKUTXN &txn, const uint32_t UU(index), RECOVER_ENV *const renv)
__attribute__((nonnull(3)));
int call_prepare_txn_callback_iter(const TOKUTXN &txn, const uint32_t UU(index), RECOVER_ENV *const renv) {
(*renv)->prepared_txn_callback((*renv)->env, txn);
return 0;
}
......@@ -1285,7 +1285,7 @@ static void recover_abort_live_txns(RECOVER_ENV renv) {
// abort the transaction
r = toku_txn_abort_txn(txn, NULL, NULL);
assert(r == 0);
// close the transaction
toku_txn_close_txn(txn);
} else if (r==DB_NOTFOUND) {
......@@ -1298,7 +1298,7 @@ static void recover_abort_live_txns(RECOVER_ENV renv) {
// Now we have only prepared txns. These prepared txns don't have full DB_TXNs in them, so we need to make some.
int r = toku_txn_manager_iter_over_live_txns<RECOVER_ENV, call_prepare_txn_callback_iter>(
renv->logger->txn_manager,
renv
&renv
);
assert_zero(r);
}
......
......@@ -417,22 +417,22 @@ toku_get_youngest_live_list_txnid_for(TXNID xc, const xid_omt_t &snapshot_txnids
}
// template-only function, but must be extern
int referenced_xids_note_snapshot_txn_end_iter(const TXNID &live_xid, const uint32_t UU(index), rx_omt_t &referenced_xids);
int
referenced_xids_note_snapshot_txn_end_iter(const TXNID &live_xid, const uint32_t UU(index), rx_omt_t &referenced_xids)
int referenced_xids_note_snapshot_txn_end_iter(const TXNID &live_xid, const uint32_t UU(index), rx_omt_t *const referenced_xids)
__attribute__((nonnull(3)));
int referenced_xids_note_snapshot_txn_end_iter(const TXNID &live_xid, const uint32_t UU(index), rx_omt_t *const referenced_xids)
{
int r;
uint32_t idx;
struct referenced_xid_tuple *tuple;
r = referenced_xids.find_zero<TXNID, find_tuple_by_xid>(live_xid, &tuple, &idx);
r = referenced_xids->find_zero<TXNID, find_tuple_by_xid>(live_xid, &tuple, &idx);
if (r == DB_NOTFOUND) {
goto done;
}
invariant_zero(r);
invariant(tuple->references > 0);
if (--tuple->references == 0) {
r = referenced_xids.delete_at(idx);
r = referenced_xids->delete_at(idx);
lazy_assert_zero(r);
}
done:
......@@ -443,7 +443,7 @@ referenced_xids_note_snapshot_txn_end_iter(const TXNID &live_xid, const uint32_t
static int
referenced_xids_note_snapshot_txn_end(TXN_MANAGER mgr, const xid_omt_t &live_root_txn_list) {
int r;
r = live_root_txn_list.iterate<rx_omt_t, referenced_xids_note_snapshot_txn_end_iter>(mgr->referenced_xids);
r = live_root_txn_list.iterate<rx_omt_t, referenced_xids_note_snapshot_txn_end_iter>(&mgr->referenced_xids);
invariant_zero(r);
return r;
}
......
......@@ -73,10 +73,10 @@ uint32_t toku_txn_manager_num_live_txns(TXN_MANAGER txn_manager);
template<typename iterate_extra_t,
int (*f)(const TOKUTXN &, const uint32_t, iterate_extra_t &)>
int (*f)(const TOKUTXN &, const uint32_t, iterate_extra_t *const)>
int toku_txn_manager_iter_over_live_txns(
TXN_MANAGER txn_manager,
iterate_extra_t &v
iterate_extra_t *const v
)
{
int r = 0;
......
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