From: Vladimir Davydov <vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org Subject: [PATCH 4/6] vinyl: run iterator: zap search_ended flag Date: Tue, 26 Mar 2019 18:50:32 +0300 [thread overview] Message-ID: <20ea713162290b1ef76bb3f999f28f4073d26baf.1553613748.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1553613748.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1553613748.git.vdavydov.dev@gmail.com> It's equivalent to (itr->search_started && itr->curr_stmt == NULL). --- src/box/vy_run.c | 35 ++++++++++++++--------------------- src/box/vy_run.h | 2 -- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/box/vy_run.c b/src/box/vy_run.c index 699941a8..c21e731f 100644 --- a/src/box/vy_run.c +++ b/src/box/vy_run.c @@ -738,7 +738,6 @@ vy_run_iterator_stop(struct vy_run_iterator *itr) vy_page_delete(itr->prev_page); itr->curr_page = itr->prev_page = NULL; } - itr->search_ended = true; } static int @@ -1071,6 +1070,7 @@ vy_run_iterator_search_in_page(struct vy_run_iterator *itr, * equal to given key (untouched otherwise) * * @retval 0 success + * @retval 1 EOF * @retval -1 read or memory error */ static NODISCARD int @@ -1082,10 +1082,8 @@ vy_run_iterator_search(struct vy_run_iterator *itr, pos->page_no = vy_page_index_find_page(itr->slice->run, key, itr->cmp_def, iterator_type, equal_key); - if (pos->page_no == itr->slice->run->info.page_count) { - itr->search_ended = true; - return 0; - } + if (pos->page_no == itr->slice->run->info.page_count) + return 1; struct vy_page *page; int rc = vy_run_iterator_load_page(itr, pos->page_no, &page); if (rc != 0) @@ -1155,7 +1153,7 @@ vy_run_iterator_next_pos(struct vy_run_iterator *itr, * (i.e. left for GE, right for LE). * @retval 0 success or EOF (*ret == NULL) * @retval -1 read or memory error - * Affects: curr_loaded_page, curr_pos, search_ended + * Affects: curr_loaded_page, curr_pos */ static NODISCARD int vy_run_iterator_find_lsn(struct vy_run_iterator *itr, @@ -1168,7 +1166,6 @@ vy_run_iterator_find_lsn(struct vy_run_iterator *itr, *ret = NULL; assert(itr->search_started); - assert(!itr->search_ended); assert(itr->curr_stmt != NULL); assert(itr->curr_pos.page_no < slice->run->info.page_count); @@ -1244,7 +1241,7 @@ vy_run_iterator_do_seek(struct vy_run_iterator *itr, struct key_def *key_def = itr->key_def; if (iterator_type == ITER_EQ && bloom != NULL && !vy_stmt_bloom_maybe_has(bloom, key, key_def)) { - itr->search_ended = true; + vy_run_iterator_stop(itr); itr->stat->bloom_hit++; return 0; } @@ -1257,8 +1254,12 @@ vy_run_iterator_do_seek(struct vy_run_iterator *itr, if (!vy_stmt_is_empty_key(key)) { rc = vy_run_iterator_search(itr, iterator_type, key, &itr->curr_pos, &equal_found); - if (rc != 0 || itr->search_ended) - return rc; + if (rc < 0) + return -1; + if (rc > 0) { + vy_run_iterator_stop(itr); + return 0; + } } else if (iterator_type == ITER_LE) { itr->curr_pos = end_pos; } else { @@ -1412,9 +1413,7 @@ vy_run_iterator_open(struct vy_run_iterator *itr, itr->curr_pos.page_no = slice->run->info.page_count; itr->curr_page = NULL; itr->prev_page = NULL; - itr->search_started = false; - itr->search_ended = false; /* * Make sure the format we use to create tuples won't @@ -1437,14 +1436,14 @@ vy_run_iterator_next_key(struct vy_run_iterator *itr, struct tuple **ret) { *ret = NULL; - if (itr->search_ended) - return 0; if (!itr->search_started) { itr->search_started = true; return vy_run_iterator_seek(itr, itr->iterator_type, itr->key, ret); } - assert(itr->curr_stmt != NULL); + if (itr->curr_stmt == NULL) + return 0; + assert(itr->curr_pos.page_no < itr->slice->run->info.page_count); struct tuple *next_key = NULL; @@ -1483,9 +1482,6 @@ vy_run_iterator_next_lsn(struct vy_run_iterator *itr, struct tuple **ret) *ret = NULL; assert(itr->search_started); - if (itr->search_ended) - return 0; - assert(itr->curr_stmt != NULL); assert(itr->curr_pos.page_no < itr->slice->run->info.page_count); @@ -1540,9 +1536,6 @@ vy_run_iterator_skip(struct vy_run_iterator *itr, const struct tuple *last_stmt, struct vy_history *history) { - if (itr->search_ended) - return 0; - /* * Check if the iterator is already positioned * at the statement following last_stmt. diff --git a/src/box/vy_run.h b/src/box/vy_run.h index beb87b78..cbc51c50 100644 --- a/src/box/vy_run.h +++ b/src/box/vy_run.h @@ -279,8 +279,6 @@ struct vy_run_iterator { struct vy_page *prev_page; /** Is false until first .._get or .._next_.. method is called */ bool search_started; - /** Search is finished, you will not get more values from iterator */ - bool search_ended; }; /** -- 2.11.0
next prev parent reply other threads:[~2019-03-26 15:50 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-26 15:50 [PATCH 0/6] vinyl: iterator cleanup Vladimir Davydov 2019-03-26 15:50 ` [PATCH 1/6] vinyl: txw iterator: fold eq check in seek method Vladimir Davydov 2019-03-28 14:25 ` [tarantool-patches] " Konstantin Osipov 2019-03-26 15:50 ` [PATCH 2/6] vinyl: cache " Vladimir Davydov 2019-03-28 14:27 ` [tarantool-patches] " Konstantin Osipov 2019-03-26 15:50 ` [PATCH 3/6] vinyl: cache iterator: consolidate curr_stmt updates Vladimir Davydov 2019-03-28 14:29 ` [tarantool-patches] " Konstantin Osipov 2019-03-28 14:47 ` Vladimir Davydov 2019-03-26 15:50 ` Vladimir Davydov [this message] 2019-03-28 14:35 ` [tarantool-patches] Re: [PATCH 4/6] vinyl: run iterator: zap search_ended flag Konstantin Osipov 2019-03-28 14:50 ` Vladimir Davydov 2019-03-26 15:50 ` [PATCH 5/6] vinyl: run iterator: refactor seek method Vladimir Davydov 2019-03-28 14:39 ` [tarantool-patches] " Konstantin Osipov 2019-03-28 14:58 ` Vladimir Davydov 2019-03-26 15:50 ` [PATCH 6/6] vinyl: simplify read iterator restoration behavior Vladimir Davydov 2019-03-28 14:47 ` [tarantool-patches] " Konstantin Osipov 2019-03-28 16:28 ` [PATCH 0/6] vinyl: iterator cleanup 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=20ea713162290b1ef76bb3f999f28f4073d26baf.1553613748.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 4/6] vinyl: run iterator: zap search_ended flag' \ /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