From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: tarantool-patches@freelists.org
Subject: [PATCH v2 5/7] vinyl: add wrapper around vy_tx_set
Date: Sat, 6 Apr 2019 23:01:52 +0300 [thread overview]
Message-ID: <a0348ec144f9057bd5eed8a5b5431cf6dfc1eb28.1554580275.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1554580275.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1554580275.git.vdavydov.dev@gmail.com>
This patch adds vy_set and vy_set_with_colmask functions. For now they
simply forward all arguments to vy_tx_set, but once comparison hints are
introduced, they will also compute a hint for the inserted statement.
Later, with the appearance of multikey indexes, they will also extract
multikey offsets.
---
src/box/vinyl.c | 56 +++++++++++++++++++++++++++++++++++++++-----------------
src/box/vy_tx.c | 4 ++--
src/box/vy_tx.h | 10 ++--------
3 files changed, 43 insertions(+), 27 deletions(-)
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 2029e112..eb331906 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -1682,6 +1682,29 @@ vy_unique_key_validate(struct vy_lsm *lsm, const char *key,
}
/**
+ * Insert a statement into a transaction write set.
+ * @param tx Transaction.
+ * @param lsm LSM tree the statement is for.
+ * @param stmt Statement.
+ * @param column_mask Mask of fields modified by the statement.
+ *
+ * @retval 0 Success
+ * @retval -1 Memory allocation error.
+ */
+static int
+vy_set_with_colmask(struct vy_tx *tx, struct vy_lsm *lsm,
+ struct tuple *stmt, uint64_t column_mask)
+{
+ return vy_tx_set(tx, lsm, stmt, column_mask);
+}
+
+static inline int
+vy_set(struct vy_tx *tx, struct vy_lsm *lsm, struct tuple *stmt)
+{
+ return vy_set_with_colmask(tx, lsm, stmt, UINT64_MAX);
+}
+
+/**
* Execute DELETE in a vinyl space.
* @param env Vinyl environment.
* @param tx Current transaction.
@@ -1735,7 +1758,7 @@ vy_delete(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt,
struct vy_lsm *lsm = vy_lsm(space->index[i]);
if (vy_is_committed_one(env, lsm))
continue;
- rc = vy_tx_set(tx, lsm, delete);
+ rc = vy_set(tx, lsm, delete);
if (rc != 0)
break;
}
@@ -1747,7 +1770,7 @@ vy_delete(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt,
return -1;
if (space->index_count > 1)
vy_stmt_set_flags(delete, VY_STMT_DEFERRED_DELETE);
- rc = vy_tx_set(tx, pk, delete);
+ rc = vy_set(tx, pk, delete);
}
tuple_unref(delete);
return rc;
@@ -1804,7 +1827,7 @@ vy_perform_update(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt,
vy_stmt_set_flags(stmt->new_tuple, VY_STMT_UPDATE);
- if (vy_tx_set_with_colmask(tx, pk, stmt->new_tuple, column_mask) != 0)
+ if (vy_set_with_colmask(tx, pk, stmt->new_tuple, column_mask) != 0)
return -1;
if (space->index_count == 1)
return 0;
@@ -1818,11 +1841,10 @@ vy_perform_update(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt,
struct vy_lsm *lsm = vy_lsm(space->index[i]);
if (vy_is_committed_one(env, lsm))
continue;
- if (vy_tx_set_with_colmask(tx, lsm, delete,
- column_mask) != 0)
+ if (vy_set_with_colmask(tx, lsm, delete, column_mask) != 0)
goto error;
- if (vy_tx_set_with_colmask(tx, lsm, stmt->new_tuple,
- column_mask) != 0)
+ if (vy_set_with_colmask(tx, lsm, stmt->new_tuple,
+ column_mask) != 0)
goto error;
}
tuple_unref(delete);
@@ -1924,11 +1946,11 @@ vy_insert_first_upsert(struct vy_env *env, struct vy_tx *tx,
return -1;
struct vy_lsm *pk = vy_lsm(space->index[0]);
assert(pk->index_id == 0);
- if (vy_tx_set(tx, pk, stmt) != 0)
+ if (vy_set(tx, pk, stmt) != 0)
return -1;
for (uint32_t i = 1; i < space->index_count; ++i) {
struct vy_lsm *lsm = vy_lsm(space->index[i]);
- if (vy_tx_set(tx, lsm, stmt) != 0)
+ if (vy_set(tx, lsm, stmt) != 0)
return -1;
}
return 0;
@@ -1961,7 +1983,7 @@ vy_lsm_upsert(struct vy_tx *tx, struct vy_lsm *lsm,
if (vystmt == NULL)
return -1;
assert(vy_stmt_type(vystmt) == IPROTO_UPSERT);
- int rc = vy_tx_set(tx, lsm, vystmt);
+ int rc = vy_set(tx, lsm, vystmt);
tuple_unref(vystmt);
return rc;
}
@@ -2183,14 +2205,14 @@ vy_insert(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt,
if (vy_check_is_unique(env, tx, space, stmt->new_tuple,
COLUMN_MASK_FULL) != 0)
return -1;
- if (vy_tx_set(tx, pk, stmt->new_tuple) != 0)
+ if (vy_set(tx, pk, stmt->new_tuple) != 0)
return -1;
for (uint32_t iid = 1; iid < space->index_count; ++iid) {
struct vy_lsm *lsm = vy_lsm(space->index[iid]);
if (vy_is_committed_one(env, lsm))
continue;
- if (vy_tx_set(tx, lsm, stmt->new_tuple) != 0)
+ if (vy_set(tx, lsm, stmt->new_tuple) != 0)
return -1;
}
return 0;
@@ -2259,7 +2281,7 @@ vy_replace(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt,
* Replace in the primary index without explicit deletion
* of the old tuple.
*/
- if (vy_tx_set(tx, pk, stmt->new_tuple) != 0)
+ if (vy_set(tx, pk, stmt->new_tuple) != 0)
return -1;
if (space->index_count == 1)
return 0;
@@ -2280,11 +2302,11 @@ vy_replace(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt,
if (vy_is_committed_one(env, lsm))
continue;
if (delete != NULL) {
- rc = vy_tx_set(tx, lsm, delete);
+ rc = vy_set(tx, lsm, delete);
if (rc != 0)
break;
}
- rc = vy_tx_set(tx, lsm, stmt->new_tuple);
+ rc = vy_set(tx, lsm, stmt->new_tuple);
if (rc != 0)
break;
}
@@ -3969,7 +3991,7 @@ vy_build_on_replace(struct trigger *trigger, void *event)
if (delete == NULL)
goto err;
vy_stmt_set_type(delete, IPROTO_DELETE);
- int rc = vy_tx_set(tx, lsm, delete);
+ int rc = vy_set(tx, lsm, delete);
tuple_unref(delete);
if (rc != 0)
goto err;
@@ -3981,7 +4003,7 @@ vy_build_on_replace(struct trigger *trigger, void *event)
data + data_len);
if (insert == NULL)
goto err;
- int rc = vy_tx_set(tx, lsm, insert);
+ int rc = vy_set(tx, lsm, insert);
tuple_unref(insert);
if (rc != 0)
goto err;
diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c
index 8dc56bc9..7ead3648 100644
--- a/src/box/vy_tx.c
+++ b/src/box/vy_tx.c
@@ -1017,8 +1017,8 @@ vy_tx_track_point(struct vy_tx *tx, struct vy_lsm *lsm, struct tuple *stmt)
}
int
-vy_tx_set_with_colmask(struct vy_tx *tx, struct vy_lsm *lsm,
- struct tuple *stmt, uint64_t column_mask)
+vy_tx_set(struct vy_tx *tx, struct vy_lsm *lsm,
+ struct tuple *stmt, uint64_t column_mask)
{
assert(vy_stmt_type(stmt) != 0);
/**
diff --git a/src/box/vy_tx.h b/src/box/vy_tx.h
index 39dc306f..6877090d 100644
--- a/src/box/vy_tx.h
+++ b/src/box/vy_tx.h
@@ -393,14 +393,8 @@ vy_tx_track_point(struct vy_tx *tx, struct vy_lsm *lsm, struct tuple *stmt);
/** Add a statement to a transaction. */
int
-vy_tx_set_with_colmask(struct vy_tx *tx, struct vy_lsm *lsm,
- struct tuple *stmt, uint64_t column_mask);
-
-static inline int
-vy_tx_set(struct vy_tx *tx, struct vy_lsm *lsm, struct tuple *stmt)
-{
- return vy_tx_set_with_colmask(tx, lsm, stmt, UINT64_MAX);
-}
+vy_tx_set(struct vy_tx *tx, struct vy_lsm *lsm,
+ struct tuple *stmt, uint64_t column_mask);
/**
* Iterator over the write set of a transaction.
--
2.11.0
next prev parent reply other threads:[~2019-04-06 20:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-06 20:01 [PATCH v2 0/7] Incorporate tuple comparison hints into Vinyl Vladimir Davydov
2019-04-06 20:01 ` [PATCH v2 1/7] Move hint_t definition to tuple_compare.h Vladimir Davydov
2019-04-08 12:08 ` [tarantool-patches] " Konstantin Osipov
2019-04-06 20:01 ` [PATCH v2 2/7] vinyl: rename vy_cache_entry to vy_cache_node Vladimir Davydov
2019-04-08 12:09 ` [tarantool-patches] " Konstantin Osipov
2019-04-06 20:01 ` [PATCH v2 3/7] vinyl: rename tree_mem_key to vy_mem_tree_key Vladimir Davydov
2019-04-08 12:09 ` [tarantool-patches] " Konstantin Osipov
2019-04-06 20:01 ` [PATCH v2 4/7] vinyl: zap vy_mem_iterator_curr_stmt helper Vladimir Davydov
2019-04-08 12:09 ` [tarantool-patches] " Konstantin Osipov
2019-04-06 20:01 ` Vladimir Davydov [this message]
2019-04-06 20:01 ` [PATCH v2 6/7] vinyl: prepare for storing hints in vinyl data structures Vladimir Davydov
2019-04-06 20:01 ` [PATCH v2 7/7] vinyl: incorporate tuple comparison hints into " Vladimir Davydov
2019-04-07 12:33 ` [PATCH v2 0/7] Incorporate tuple comparison hints into Vinyl 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=a0348ec144f9057bd5eed8a5b5431cf6dfc1eb28.1554580275.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH v2 5/7] vinyl: add wrapper around vy_tx_set' \
/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