From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 02/12] vinyl: factor out vy_history_apply from vy_point_lookup_apply_history Date: Sun, 15 Apr 2018 22:55:15 +0300 [thread overview] Message-ID: <d7cb0edaf06a741a016895d6a5064a5c9cf51e43.1523820298.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1523820298.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1523820298.git.vdavydov.dev@gmail.com> Apart from applying a key history, vy_point_lookup_apply_history also adds the resultant tuple to the cache and updates LSM stats. Let's factor out history manipulation into a separate function and put everything else in vy_point_lookup so that we can make vy_history an independent entity. --- src/box/vy_point_lookup.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/box/vy_point_lookup.c b/src/box/vy_point_lookup.c index 32048654..5d3076d9 100644 --- a/src/box/vy_point_lookup.c +++ b/src/box/vy_point_lookup.c @@ -328,15 +328,15 @@ vy_point_lookup_scan_slices(struct vy_lsm *lsm, const struct vy_read_view **rv, } /** - * Get a resultant statement from collected history. Add to cache if possible. + * Get a resultant statement from collected history. */ static int -vy_point_lookup_apply_history(struct vy_lsm *lsm, - const struct vy_read_view **rv, - struct tuple *key, struct rlist *history, - struct tuple **ret) +vy_history_apply(struct rlist *history, const struct key_def *cmp_def, + struct tuple_format *format, int *upserts_applied, + struct tuple **ret) { *ret = NULL; + *upserts_applied = 0; if (rlist_empty(history)) return 0; @@ -355,14 +355,9 @@ vy_point_lookup_apply_history(struct vy_lsm *lsm, node = rlist_prev_entry_safe(node, history, link); } while (node != NULL) { - assert(vy_stmt_type(node->stmt) == IPROTO_UPSERT); - /* We could not read the data that is invisible now */ - assert(node->src_type == ITER_SRC_TXW || - vy_stmt_lsn(node->stmt) <= (*rv)->vlsn); - struct tuple *stmt = vy_apply_upsert(node->stmt, curr_stmt, - lsm->cmp_def, lsm->mem_format, true); - lsm->stat.upsert.applied++; + cmp_def, format, true); + ++*upserts_applied; if (stmt == NULL) return -1; if (curr_stmt != NULL) @@ -370,15 +365,7 @@ vy_point_lookup_apply_history(struct vy_lsm *lsm, curr_stmt = stmt; node = rlist_prev_entry_safe(node, history, link); } - if (curr_stmt != NULL) { - vy_stmt_counter_acct_tuple(&lsm->stat.get, curr_stmt); - *ret = curr_stmt; - } - /** - * Add a statement to the cache - */ - if ((*rv)->vlsn == INT64_MAX) /* Do not store non-latest data */ - vy_cache_add(&lsm->cache, curr_stmt, NULL, key, ITER_EQ); + *ret = curr_stmt; return 0; } @@ -440,14 +427,22 @@ restart: done: if (rc == 0) { - rc = vy_point_lookup_apply_history(lsm, rv, key, - &history, ret); + int upserts_applied; + rc = vy_history_apply(&history, lsm->cmp_def, lsm->mem_format, + &upserts_applied, ret); + lsm->stat.upsert.applied += upserts_applied; } vy_history_cleanup(&history, region_svp); if (rc != 0) return -1; + if (*ret != NULL) { + vy_stmt_counter_acct_tuple(&lsm->stat.get, *ret); + if ((*rv)->vlsn == INT64_MAX) + vy_cache_add(&lsm->cache, *ret, NULL, key, ITER_EQ); + } + double latency = ev_monotonic_now(loop()) - start_time; latency_collect(&lsm->stat.latency, latency); -- 2.11.0
next prev parent reply other threads:[~2018-04-15 19:55 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-04-15 19:55 [PATCH 00/12] vinyl: prepare read iterator for index rebuild Vladimir Davydov 2018-04-15 19:55 ` [PATCH 01/12] vinyl: rename vy_stmt_history to vy_history Vladimir Davydov 2018-04-15 19:55 ` Vladimir Davydov [this message] 2018-05-14 18:19 ` [tarantool-patches] Re: [PATCH 02/12] vinyl: factor out vy_history_apply from vy_point_lookup_apply_history Vladislav Shpilevoy 2018-04-15 19:55 ` [PATCH 03/12] vinyl: add vy_history_append_stmt helper Vladimir Davydov 2018-04-15 19:55 ` [PATCH 04/12] vinyl: zap iterator_src_type enum Vladimir Davydov 2018-04-15 19:55 ` [PATCH 05/12] vinyl: encapsulate key history with struct Vladimir Davydov 2018-04-15 19:55 ` [PATCH 06/12] vinyl: refine vy_history_cleanup Vladimir Davydov 2018-04-15 19:55 ` [PATCH 07/12] vinyl: move vy_history to its own source file Vladimir Davydov 2018-04-15 19:55 ` [PATCH 08/12] vinyl: use mempool for vy_history_node allocations Vladimir Davydov 2018-04-15 19:55 ` [PATCH 09/12] vinyl: consolidate skip optimization checks in read iterator Vladimir Davydov 2018-05-14 18:25 ` [tarantool-patches] " Vladislav Shpilevoy 2018-05-15 15:00 ` Vladimir Davydov 2018-04-15 19:55 ` [PATCH 10/12] vinyl: refactor vy_read_iterator_next Vladimir Davydov 2018-04-15 19:55 ` [PATCH 11/12] vinyl: make read iterator always return newest tuple version Vladimir Davydov 2018-04-15 19:55 ` [PATCH 12/12] vinyl: zap vy_read_iterator::curr_stmt Vladimir Davydov 2018-05-04 18:05 ` [tarantool-patches] Re: [PATCH 00/12] vinyl: prepare read iterator for index rebuild Vladislav Shpilevoy
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=d7cb0edaf06a741a016895d6a5064a5c9cf51e43.1523820298.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 02/12] vinyl: factor out vy_history_apply from vy_point_lookup_apply_history' \ /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