From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 2/4] vinyl: use rlist for iterating over objects recovered from vylog Date: Tue, 27 Mar 2018 18:03:01 +0300 [thread overview] Message-ID: <55b2af4c04bd950732973b4a3181db565fe42733.1522162296.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1522162296.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1522162296.git.vdavydov.dev@gmail.com> Currently, we use mh_foreach, but each object is on an rlist, which suits better for iteration. --- src/box/vy_log.c | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/src/box/vy_log.c b/src/box/vy_log.c index 626ce122..720c9491 100644 --- a/src/box/vy_log.c +++ b/src/box/vy_log.c @@ -1942,39 +1942,37 @@ vy_recovery_new(int64_t signature, bool only_checkpoint) return recovery; } -/** Helper to delete mh_i64ptr_t along with all its records. */ -static void -vy_recovery_delete_hash(struct mh_i64ptr_t *h) -{ - mh_int_t i; - mh_foreach(h, i) - free(mh_i64ptr_node(h, i)->val); - mh_i64ptr_delete(h); -} - void vy_recovery_delete(struct vy_recovery *recovery) { - if (recovery->index_id_hash != NULL) { - mh_int_t i; - mh_foreach(recovery->index_id_hash, i) { - struct vy_lsm_recovery_info *lsm; - lsm = mh_i64ptr_node(recovery->index_id_hash, i)->val; - free(lsm->key_parts); - free(lsm); + struct vy_lsm_recovery_info *lsm, *next_lsm; + struct vy_range_recovery_info *range, *next_range; + struct vy_slice_recovery_info *slice, *next_slice; + struct vy_run_recovery_info *run, *next_run; + + rlist_foreach_entry_safe(lsm, &recovery->lsms, in_recovery, next_lsm) { + rlist_foreach_entry_safe(range, &lsm->ranges, + in_lsm, next_range) { + rlist_foreach_entry_safe(slice, &range->slices, + in_range, next_slice) + free(slice); + free(range); } - mh_i64ptr_delete(recovery->index_id_hash); + rlist_foreach_entry_safe(run, &lsm->runs, in_lsm, next_run) + free(run); + free(lsm->key_parts); + free(lsm); } - if (recovery->lsm_hash != NULL) { - /* Hash entries were deleted along with index_id_hash. */ + if (recovery->index_id_hash != NULL) + mh_i64ptr_delete(recovery->index_id_hash); + if (recovery->lsm_hash != NULL) mh_i64ptr_delete(recovery->lsm_hash); - } if (recovery->range_hash != NULL) - vy_recovery_delete_hash(recovery->range_hash); + mh_i64ptr_delete(recovery->range_hash); if (recovery->run_hash != NULL) - vy_recovery_delete_hash(recovery->run_hash); + mh_i64ptr_delete(recovery->run_hash); if (recovery->slice_hash != NULL) - vy_recovery_delete_hash(recovery->slice_hash); + mh_i64ptr_delete(recovery->slice_hash); TRASH(recovery); free(recovery); } @@ -2096,10 +2094,8 @@ vy_log_create(const struct vclock *vclock, struct vy_recovery *recovery) struct xlog xlog; xlog_clear(&xlog); - mh_int_t i; - mh_foreach(recovery->index_id_hash, i) { - struct vy_lsm_recovery_info *lsm; - lsm = mh_i64ptr_node(recovery->index_id_hash, i)->val; + struct vy_lsm_recovery_info *lsm; + rlist_foreach_entry(lsm, &recovery->lsms, in_recovery) { /* * Purge dropped LSM trees that are not referenced by runs * (and thus not needed for garbage collection) from the -- 2.11.0
next prev parent reply other threads:[~2018-03-27 15:03 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-03-27 15:02 [PATCH 0/4] Introduce VY_LOG_PREPARE_LSM vylog record Vladimir Davydov 2018-03-27 15:03 ` [PATCH 1/4] index: add abort_create virtual method Vladimir Davydov 2018-03-27 15:03 ` Vladimir Davydov [this message] 2018-03-27 15:03 ` [PATCH 3/4] vinyl: fix discrepancy between vy_log.tx_size and actual tx len Vladimir Davydov 2018-03-27 15:03 ` [PATCH 4/4] vinyl: log new index before WAL write on DDL Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=55b2af4c04bd950732973b4a3181db565fe42733.1522162296.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 2/4] vinyl: use rlist for iterating over objects recovered from vylog' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox