[PATCH 3/5] vinyl: zap vy_run_iterator->curr_stmt_pos

Vladimir Davydov vdavydov.dev at gmail.com
Sun Mar 4 22:52:26 MSK 2018


vy_run_iterator_get() remembers the position of the last statement
returned by the iterator in curr_stmt_pos. It then uses it to skip
a disk read in case it is called again for the same iterator position.
The code is left from the time when iterators had public virtual
method 'get', which could be called several times without advancing
the iterator. Nowadays, vy_run_iterator_get() is never called twice
for the same iterator position (check coverity scan) so we can zap
this logic.
---
 src/box/vy_run.c | 9 ---------
 src/box/vy_run.h | 2 --
 2 files changed, 11 deletions(-)

diff --git a/src/box/vy_run.c b/src/box/vy_run.c
index 72b24a72..f122e569 100644
--- a/src/box/vy_run.c
+++ b/src/box/vy_run.c
@@ -748,7 +748,6 @@ vy_run_iterator_stop(struct vy_run_iterator *itr)
 	if (itr->curr_stmt != NULL) {
 		tuple_unref(itr->curr_stmt);
 		itr->curr_stmt = NULL;
-		itr->curr_stmt_pos.page_no = UINT32_MAX;
 	}
 	if (itr->curr_page != NULL) {
 		vy_page_delete(itr->curr_page);
@@ -1450,7 +1449,6 @@ vy_run_iterator_open(struct vy_run_iterator *itr,
 
 	itr->curr_stmt = NULL;
 	itr->curr_pos.page_no = slice->run->info.page_count;
-	itr->curr_stmt_pos.page_no = UINT32_MAX;
 	itr->curr_page = NULL;
 	itr->prev_page = NULL;
 
@@ -1473,18 +1471,11 @@ vy_run_iterator_get(struct vy_run_iterator *itr, struct tuple **result)
 	if (itr->search_ended)
 		return 0;
 	if (itr->curr_stmt != NULL) {
-		if (itr->curr_stmt_pos.page_no == itr->curr_pos.page_no &&
-		    itr->curr_stmt_pos.pos_in_page == itr->curr_pos.pos_in_page) {
-			*result = itr->curr_stmt;
-			return 0;
-		}
 		tuple_unref(itr->curr_stmt);
 		itr->curr_stmt = NULL;
-		itr->curr_stmt_pos.page_no = UINT32_MAX;
 	}
 	int rc = vy_run_iterator_read(itr, itr->curr_pos, result);
 	if (rc == 0) {
-		itr->curr_stmt_pos = itr->curr_pos;
 		itr->curr_stmt = *result;
 		vy_stmt_counter_acct_tuple(&itr->stat->get, *result);
 	}
diff --git a/src/box/vy_run.h b/src/box/vy_run.h
index f2fec83b..7f583362 100644
--- a/src/box/vy_run.h
+++ b/src/box/vy_run.h
@@ -251,8 +251,6 @@ struct vy_run_iterator {
 	 * vy_run_iterator_get, when it's dereferenced.
 	 */
 	struct tuple *curr_stmt;
-	/** Position of record that spawned curr_stmt */
-	struct vy_run_iterator_pos curr_stmt_pos;
 	/**
 	 * Last two pages read by the iterator. We keep two pages
 	 * rather than just one, because we often probe a page for
-- 
2.11.0




More information about the Tarantool-patches mailing list