From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2 08/14] vinyl: do not pass format to vy_apply_upsert Date: Wed, 13 Mar 2019 11:52:54 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: Use the format of the given statement instead. Passing format is a legacy from the time when we have a separate format for UPSERTs. Nowadays it only obfuscates the code. --- src/box/vinyl.c | 2 +- src/box/vy_history.c | 5 ++--- src/box/vy_history.h | 3 +-- src/box/vy_lsm.c | 3 +-- src/box/vy_point_lookup.c | 4 ++-- src/box/vy_read_iterator.c | 2 +- src/box/vy_tx.c | 5 ++--- src/box/vy_upsert.c | 5 +++-- src/box/vy_upsert.h | 4 +--- src/box/vy_write_iterator.c | 4 ++-- 10 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 0146f62c..0e908cc5 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -4069,7 +4069,7 @@ vy_build_recover_stmt(struct vy_lsm *lsm, struct vy_lsm *pk, return -1; } else if (type == IPROTO_UPSERT) { struct tuple *new_tuple = vy_apply_upsert(mem_stmt, old_tuple, - pk->cmp_def, pk->mem_format, true); + pk->cmp_def, true); if (new_tuple == NULL) return -1; uint32_t data_len; diff --git a/src/box/vy_history.c b/src/box/vy_history.c index 0f3b7119..b45c6d51 100644 --- a/src/box/vy_history.c +++ b/src/box/vy_history.c @@ -74,8 +74,7 @@ vy_history_cleanup(struct vy_history *history) int vy_history_apply(struct vy_history *history, struct key_def *cmp_def, - struct tuple_format *format, bool keep_delete, - int *upserts_applied, struct tuple **ret) + bool keep_delete, int *upserts_applied, struct tuple **ret) { *ret = NULL; *upserts_applied = 0; @@ -101,7 +100,7 @@ vy_history_apply(struct vy_history *history, struct key_def *cmp_def, } while (node != NULL) { struct tuple *stmt = vy_apply_upsert(node->stmt, curr_stmt, - cmp_def, format, true); + cmp_def, true); ++*upserts_applied; if (curr_stmt != NULL) tuple_unref(curr_stmt); diff --git a/src/box/vy_history.h b/src/box/vy_history.h index e3c5a19e..458ea749 100644 --- a/src/box/vy_history.h +++ b/src/box/vy_history.h @@ -155,8 +155,7 @@ vy_history_cleanup(struct vy_history *history); */ int vy_history_apply(struct vy_history *history, struct key_def *cmp_def, - struct tuple_format *format, bool keep_delete, - int *upserts_applied, struct tuple **ret); + bool keep_delete, int *upserts_applied, struct tuple **ret); #if defined(__cplusplus) } /* extern "C" */ diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c index 171664d4..2dc8f639 100644 --- a/src/box/vy_lsm.c +++ b/src/box/vy_lsm.c @@ -977,8 +977,7 @@ vy_lsm_commit_upsert(struct vy_lsm *lsm, struct vy_mem *mem, older = vy_mem_older_lsn(mem, stmt); assert(older == NULL || vy_stmt_type(older) != IPROTO_UPSERT); struct tuple *upserted = - vy_apply_upsert(stmt, older, lsm->cmp_def, - lsm->mem_format, false); + vy_apply_upsert(stmt, older, lsm->cmp_def, false); lsm->stat.upsert.applied++; if (upserted == NULL) { diff --git a/src/box/vy_point_lookup.c b/src/box/vy_point_lookup.c index 18d5622b..51226ce8 100644 --- a/src/box/vy_point_lookup.c +++ b/src/box/vy_point_lookup.c @@ -272,7 +272,7 @@ done: if (rc == 0) { int upserts_applied; - rc = vy_history_apply(&history, lsm->cmp_def, lsm->mem_format, + rc = vy_history_apply(&history, lsm->cmp_def, false, &upserts_applied, ret); lsm->stat.upsert.applied += upserts_applied; } @@ -319,7 +319,7 @@ vy_point_lookup_mem(struct vy_lsm *lsm, const struct vy_read_view **rv, done: if (rc == 0) { int upserts_applied; - rc = vy_history_apply(&history, lsm->cmp_def, lsm->mem_format, + rc = vy_history_apply(&history, lsm->cmp_def, true, &upserts_applied, ret); lsm->stat.upsert.applied += upserts_applied; } diff --git a/src/box/vy_read_iterator.c b/src/box/vy_read_iterator.c index 94c5f4b9..cc884bec 100644 --- a/src/box/vy_read_iterator.c +++ b/src/box/vy_read_iterator.c @@ -805,7 +805,7 @@ vy_read_iterator_apply_history(struct vy_read_iterator *itr, } int upserts_applied = 0; - int rc = vy_history_apply(&history, lsm->cmp_def, lsm->mem_format, + int rc = vy_history_apply(&history, lsm->cmp_def, true, &upserts_applied, ret); lsm->stat.upsert.applied += upserts_applied; diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c index 3768b3bd..c4445505 100644 --- a/src/box/vy_tx.c +++ b/src/box/vy_tx.c @@ -481,7 +481,7 @@ vy_tx_write(struct vy_lsm *lsm, struct vy_mem *mem, vy_cache_on_write(&lsm->cache, stmt, &deleted); if (deleted != NULL) { struct tuple *applied = vy_apply_upsert(stmt, deleted, - mem->cmp_def, mem->format, false); + mem->cmp_def, false); tuple_unref(deleted); if (applied != NULL) { assert(vy_stmt_type(applied) == IPROTO_REPLACE); @@ -998,8 +998,7 @@ vy_tx_set_with_colmask(struct vy_tx *tx, struct vy_lsm *lsm, old_type == IPROTO_DELETE); (void) old_type; - applied = vy_apply_upsert(stmt, old->stmt, lsm->cmp_def, - lsm->mem_format, true); + applied = vy_apply_upsert(stmt, old->stmt, lsm->cmp_def, true); lsm->stat.upsert.applied++; if (applied == NULL) return -1; diff --git a/src/box/vy_upsert.c b/src/box/vy_upsert.c index 3c5a4abb..8cf0cc19 100644 --- a/src/box/vy_upsert.c +++ b/src/box/vy_upsert.c @@ -88,8 +88,7 @@ vy_upsert_try_to_squash(struct tuple_format *format, struct region *region, struct tuple * vy_apply_upsert(const struct tuple *new_stmt, const struct tuple *old_stmt, - struct key_def *cmp_def, struct tuple_format *format, - bool suppress_error) + struct key_def *cmp_def, bool suppress_error) { /* * old_stmt - previous (old) version of stmt @@ -107,6 +106,8 @@ vy_apply_upsert(const struct tuple *new_stmt, const struct tuple *old_stmt, return vy_stmt_replace_from_upsert(new_stmt); } + struct tuple_format *format = tuple_format(new_stmt); + /* * Unpack UPSERT operation from the new stmt */ diff --git a/src/box/vy_upsert.h b/src/box/vy_upsert.h index 5649961e..df3413d8 100644 --- a/src/box/vy_upsert.h +++ b/src/box/vy_upsert.h @@ -57,7 +57,6 @@ struct tuple_format; * @param new_stmt An UPSERT statement. * @param old_stmt An REPLACE/DELETE/UPSERT statement or NULL. * @param cmp_def Key definition of an index, with primary parts. - * @param format Format for REPLACE/DELETE tuples. * @param suppress_error True if ClientErrors must not be written to log. * * @retval NULL Memory allocation error. @@ -65,8 +64,7 @@ struct tuple_format; */ struct tuple * vy_apply_upsert(const struct tuple *new_stmt, const struct tuple *old_stmt, - struct key_def *cmp_def, struct tuple_format *format, - bool suppress_error); + struct key_def *cmp_def, bool suppress_error); #if defined(__cplusplus) } /* extern "C" */ diff --git a/src/box/vy_write_iterator.c b/src/box/vy_write_iterator.c index 0e804ac1..2c4dbf58 100644 --- a/src/box/vy_write_iterator.c +++ b/src/box/vy_write_iterator.c @@ -842,7 +842,7 @@ vy_read_view_merge(struct vy_write_iterator *stream, struct tuple *hint, assert(!stream->is_last_level || hint == NULL || vy_stmt_type(hint) != IPROTO_UPSERT); struct tuple *applied = vy_apply_upsert(h->tuple, hint, - stream->cmp_def, stream->format, false); + stream->cmp_def, false); if (applied == NULL) return -1; vy_stmt_unref_if_possible(h->tuple); @@ -856,7 +856,7 @@ vy_read_view_merge(struct vy_write_iterator *stream, struct tuple *hint, vy_stmt_type(h->tuple) == IPROTO_UPSERT); assert(result->tuple != NULL); struct tuple *applied = vy_apply_upsert(h->tuple, result->tuple, - stream->cmp_def, stream->format, false); + stream->cmp_def, false); if (applied == NULL) return -1; vy_stmt_unref_if_possible(result->tuple); -- 2.11.0