From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 05/12] vinyl: move vy_tuple_key_contains_null to generic code
Date: Thu, 21 Feb 2019 13:26:05 +0300 [thread overview]
Message-ID: <51872a8755aa2bc223103ab76f839b7df38f1fcb.1550744027.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1550744027.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1550744027.git.vdavydov.dev@gmail.com>
The function doesn't require any knowledge of vinyl statement layout and
can work on regular tuples. Let's rename it to tuple_key_contains_null,
move its implementation to tuple_extract_key.cc, and declare it in
key_def.h, as we do with other similar functions.
---
src/box/key_def.h | 9 +++++++++
| 16 ++++++++++++++++
src/box/vinyl.c | 2 +-
src/box/vy_stmt.h | 22 ----------------------
4 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/src/box/key_def.h b/src/box/key_def.h
index 788a200d..dd62f6a3 100644
--- a/src/box/key_def.h
+++ b/src/box/key_def.h
@@ -464,6 +464,15 @@ key_part_cmp(const struct key_part *parts1, uint32_t part_count1,
const struct key_part *parts2, uint32_t part_count2);
/**
+ * Check if a key of @a tuple contains NULL.
+ * @param tuple Tuple to check.
+ * @param def Key def to check by.
+ * @retval Does the key contain NULL or not?
+ */
+bool
+tuple_key_contains_null(const struct tuple *tuple, struct key_def *def);
+
+/**
* Extract key from tuple by given key definition and return
* buffer allocated on box_txn_alloc with this key. This function
* has O(n) complexity, where n is the number of key parts.
--git a/src/box/tuple_extract_key.cc b/src/box/tuple_extract_key.cc
index 915b6bae..fead2328 100644
--- a/src/box/tuple_extract_key.cc
+++ b/src/box/tuple_extract_key.cc
@@ -399,3 +399,19 @@ tuple_extract_key_func_set(struct key_def *key_def)
}
}
}
+
+bool
+tuple_key_contains_null(const struct tuple *tuple, struct key_def *def)
+{
+ struct tuple_format *format = tuple_format(tuple);
+ const char *data = tuple_data(tuple);
+ const uint32_t *field_map = tuple_field_map(tuple);
+ for (struct key_part *part = def->parts, *end = part + def->part_count;
+ part < end; ++part) {
+ const char *field =
+ tuple_field_raw_by_part(format, data, field_map, part);
+ if (field == NULL || mp_typeof(*field) == MP_NIL)
+ return true;
+ }
+ return false;
+}
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 23c5b9c3..428bae1d 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -1503,7 +1503,7 @@ vy_check_is_unique_secondary(struct vy_tx *tx, const struct vy_read_view **rv,
if (!lsm->check_is_unique)
return 0;
if (lsm->key_def->is_nullable &&
- vy_tuple_key_contains_null(stmt, lsm->key_def))
+ tuple_key_contains_null(stmt, lsm->key_def))
return 0;
struct tuple *key = vy_stmt_extract_key(stmt, lsm->key_def,
lsm->env->key_format);
diff --git a/src/box/vy_stmt.h b/src/box/vy_stmt.h
index dd1f2460..3efad12c 100644
--- a/src/box/vy_stmt.h
+++ b/src/box/vy_stmt.h
@@ -669,28 +669,6 @@ vy_stmt_snprint(char *buf, int size, const struct tuple *stmt);
const char *
vy_stmt_str(const struct tuple *stmt);
-/**
- * Check if a key of @a tuple contains NULL.
- * @param tuple Tuple to check.
- * @param def Key def to check by.
- * @retval Does the key contain NULL or not?
- */
-static inline bool
-vy_tuple_key_contains_null(const struct tuple *tuple, struct key_def *def)
-{
- struct tuple_format *format = tuple_format(tuple);
- const char *data = tuple_data(tuple);
- const uint32_t *field_map = tuple_field_map(tuple);
- for (struct key_part *part = def->parts, *end = part + def->part_count;
- part < end; ++part) {
- const char *field =
- tuple_field_raw_by_part(format, data, field_map, part);
- if (field == NULL || mp_typeof(*field) == MP_NIL)
- return true;
- }
- return false;
-}
-
#if defined(__cplusplus)
} /* extern "C" */
#endif /* defined(__cplusplus) */
--
2.11.0
next prev parent reply other threads:[~2019-02-21 10:26 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 10:26 [PATCH 00/12] vinyl: do not fill secondary tuples with nulls Vladimir Davydov
2019-02-21 10:26 ` [PATCH 01/12] vinyl: use vy_lsm_env::empty_key where appropriate Vladimir Davydov
2019-02-21 10:59 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 02/12] vinyl: make vy_tuple_delete static Vladimir Davydov
2019-02-21 11:00 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 03/12] key_def: cleanup virtual function initialization Vladimir Davydov
2019-02-21 11:01 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 12:05 ` Vladimir Davydov
2019-02-21 10:26 ` [PATCH 04/12] key_def: move cmp and hash functions declarations to key_def.h Vladimir Davydov
2019-02-21 11:02 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` Vladimir Davydov [this message]
2019-02-21 11:02 ` [tarantool-patches] Re: [PATCH 05/12] vinyl: move vy_tuple_key_contains_null to generic code Konstantin Osipov
2019-02-21 10:26 ` [PATCH 06/12] vinyl: move vy_key_dup " Vladimir Davydov
2019-02-21 11:04 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 11:52 ` Vladimir Davydov
2019-02-21 10:26 ` [PATCH 07/12] vinyl: sanitize full/empty key stmt detection Vladimir Davydov
2019-02-21 11:10 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 12:11 ` Vladimir Davydov
2019-03-01 12:57 ` Vladimir Davydov
2019-02-21 10:26 ` [PATCH 08/12] vinyl: remove optimized comparators Vladimir Davydov
2019-02-21 11:11 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 09/12] vinyl: introduce statement environment Vladimir Davydov
2019-02-21 11:14 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 10/12] vinyl: rename key stmt construction routine Vladimir Davydov
2019-02-21 11:15 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 12:14 ` Vladimir Davydov
2019-02-21 10:26 ` [PATCH 11/12] vinyl: don't use IPROTO_SELECT type for key statements Vladimir Davydov
2019-02-21 11:16 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 12/12] vinyl: do not fill secondary tuples with nulls when decoded Vladimir Davydov
2019-02-21 15:39 ` [PATCH 00/12] 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=51872a8755aa2bc223103ab76f839b7df38f1fcb.1550744027.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH 05/12] vinyl: move vy_tuple_key_contains_null to generic code' \
/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