Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH v2 08/14] vinyl: do not pass format to vy_apply_upsert
Date: Wed, 13 Mar 2019 11:52:54 +0300	[thread overview]
Message-ID: <fadead554fab6cbe90a336e2d7130a78c05783cc.1552464666.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1552464666.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1552464666.git.vdavydov.dev@gmail.com>

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

  parent reply	other threads:[~2019-03-13  8:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  8:52 [PATCH v2 00/14] vinyl: do not fill secondary tuples with nulls Vladimir Davydov
2019-03-13  8:52 ` [PATCH v2 01/14] vinyl: remove optimized comparators Vladimir Davydov
2019-03-13  8:55   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 02/14] vinyl: introduce statement environment Vladimir Davydov
2019-03-13  8:58   ` Konstantin Osipov
2019-03-13  9:19     ` Vladimir Davydov
2019-03-13  8:52 ` [PATCH v2 03/14] vinyl: rename key stmt construction routine Vladimir Davydov
2019-03-13  8:59   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 04/14] vinyl: don't use IPROTO_SELECT type for key statements Vladimir Davydov
2019-03-13  9:00   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 05/14] bloom: do not use tuple_common_key_parts when constructing tuple bloom Vladimir Davydov
2019-03-13 11:52   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 06/14] bloom: factor out helper to add tuple hash to bloom builder Vladimir Davydov
2019-03-13 11:52   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 07/14] vinyl: add helpers to add/check statement with bloom Vladimir Davydov
2019-03-13 11:59   ` Konstantin Osipov
2019-03-13 12:25     ` Vladimir Davydov
2019-03-13  8:52 ` Vladimir Davydov [this message]
2019-03-13 12:00   ` [PATCH v2 08/14] vinyl: do not pass format to vy_apply_upsert Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 09/14] vinyl: clean up write iterator source destruction Vladimir Davydov
2019-03-13 12:05   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 10/14] vinyl: zap vy_write_iterator->format Vladimir Davydov
2019-03-13 12:06   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 11/14] vinyl: do not fill secondary tuples with nulls when decoded Vladimir Davydov
2019-03-13 12:25   ` Konstantin Osipov
2019-03-13 12:45     ` Vladimir Davydov
2019-03-13 12:56       ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 12/14] vinyl: zap vy_stmt_new_surrogate_from_key Vladimir Davydov
2019-03-13 12:27   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 13/14] vinyl: don't use vy_stmt_new_surrogate_delete if not necessary Vladimir Davydov
2019-03-13 12:28   ` Konstantin Osipov
2019-03-13  8:53 ` [PATCH v2 14/14] tuple_format: zap min_tuple_size Vladimir Davydov
2019-03-13 12:28   ` Konstantin Osipov
2019-03-13 15:54 ` [PATCH v2 00/14] vinyl: do not fill secondary tuples with nulls 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=fadead554fab6cbe90a336e2d7130a78c05783cc.1552464666.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2 08/14] vinyl: do not pass format to vy_apply_upsert' \
    /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