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 03/12] key_def: cleanup virtual function initialization
Date: Thu, 21 Feb 2019 13:26:03 +0300	[thread overview]
Message-ID: <1aaf38421e27d3cfa4cdb949b8dce36aa8421cfb.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>

 - Rename key_def_set_cmp to key_def_func_set, because it sets not only
   comparators these days.
 - Rename tuple_extract_key_set to tuple_extract_key_func_set to match
   tuple_hash_func_set.
 - Introduce tuple_compare_func_set and use it instead of setting
   comparators explicitly in key_def.c.
---
 src/box/key_def.c            | 15 +++++++--------
 src/box/tuple_compare.cc     | 11 +++++++++--
 src/box/tuple_compare.h      | 24 +++++++-----------------
 src/box/tuple_extract_key.cc |  2 +-
 src/box/tuple_extract_key.h  |  2 +-
 5 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/src/box/key_def.c b/src/box/key_def.c
index 9411ade3..75e3a0be 100644
--- a/src/box/key_def.c
+++ b/src/box/key_def.c
@@ -129,12 +129,11 @@ key_def_delete(struct key_def *def)
 }
 
 static void
-key_def_set_cmp(struct key_def *def)
+key_def_func_set(struct key_def *def)
 {
-	def->tuple_compare = tuple_compare_create(def);
-	def->tuple_compare_with_key = tuple_compare_with_key_create(def);
+	tuple_compare_func_set(def);
 	tuple_hash_func_set(def);
-	tuple_extract_key_set(def);
+	tuple_extract_key_func_set(def);
 }
 
 static void
@@ -208,7 +207,7 @@ key_def_new(const struct key_part_def *parts, uint32_t part_count)
 				 &path_pool, TUPLE_OFFSET_SLOT_NIL, 0);
 	}
 	assert(path_pool == (char *)def + sz);
-	key_def_set_cmp(def);
+	key_def_func_set(def);
 	return def;
 }
 
@@ -261,7 +260,7 @@ box_key_def_new(uint32_t *fields, uint32_t *types, uint32_t part_count)
 				 NULL, COLL_NONE, SORT_ORDER_ASC, NULL, 0,
 				 NULL, TUPLE_OFFSET_SLOT_NIL, 0);
 	}
-	key_def_set_cmp(key_def);
+	key_def_func_set(key_def);
 	return key_def;
 }
 
@@ -333,7 +332,7 @@ key_def_update_optionality(struct key_def *def, uint32_t min_field_count)
 		if (def->has_optional_parts)
 			break;
 	}
-	key_def_set_cmp(def);
+	key_def_func_set(def);
 }
 
 int
@@ -686,7 +685,7 @@ key_def_merge(const struct key_def *first, const struct key_def *second)
 				 part->offset_slot_cache, part->format_epoch);
 	}
 	assert(path_pool == (char *)new_def + sz);
-	key_def_set_cmp(new_def);
+	key_def_func_set(new_def);
 	return new_def;
 }
 
diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc
index ded802c7..b8dc350f 100644
--- a/src/box/tuple_compare.cc
+++ b/src/box/tuple_compare.cc
@@ -1049,7 +1049,7 @@ static const tuple_compare_t compare_slowpath_funcs[] = {
 	tuple_compare_slowpath<true, true, true>
 };
 
-tuple_compare_t
+static tuple_compare_t
 tuple_compare_create(const struct key_def *def)
 {
 	int cmp_func_idx = (def->is_nullable ? 1 : 0) +
@@ -1277,7 +1277,7 @@ static const tuple_compare_with_key_t compare_with_key_slowpath_funcs[] = {
 	tuple_compare_with_key_slowpath<true, true, true>
 };
 
-tuple_compare_with_key_t
+static tuple_compare_with_key_t
 tuple_compare_with_key_create(const struct key_def *def)
 {
 	int cmp_func_idx = (def->is_nullable ? 1 : 0) +
@@ -1322,3 +1322,10 @@ tuple_compare_with_key_create(const struct key_def *def)
 }
 
 /* }}} tuple_compare_with_key */
+
+void
+tuple_compare_func_set(struct key_def *def)
+{
+	def->tuple_compare = tuple_compare_create(def);
+	def->tuple_compare_with_key = tuple_compare_with_key_create(def);
+}
diff --git a/src/box/tuple_compare.h b/src/box/tuple_compare.h
index e3a63204..baecbafe 100644
--- a/src/box/tuple_compare.h
+++ b/src/box/tuple_compare.h
@@ -30,17 +30,15 @@
  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#include <stddef.h>
 #include <stdint.h>
-#include <stdbool.h>
-
-#include "key_def.h"
-#include "tuple.h"
 
 #if defined(__cplusplus)
 extern "C" {
 #endif /* defined(__cplusplus) */
 
+struct tuple;
+struct key_def;
+
 /**
  * Return the length of the longest common prefix of two tuples.
  * @param tuple_a first tuple
@@ -53,19 +51,11 @@ tuple_common_key_parts(const struct tuple *tuple_a, const struct tuple *tuple_b,
 		       struct key_def *key_def);
 
 /**
- * Create a comparison function for the key_def
- *
- * @param key_def key_definition
- * @returns a comparision function
+ * Initialize comparator functions for the key_def.
+ * @param key_def key definition
  */
-tuple_compare_t
-tuple_compare_create(const struct key_def *key_def);
-
-/**
- * @copydoc tuple_compare_create()
- */
-tuple_compare_with_key_t
-tuple_compare_with_key_create(const struct key_def *key_def);
+void
+tuple_compare_func_set(struct key_def *def);
 
 #if defined(__cplusplus)
 } /* extern "C" */
diff --git a/src/box/tuple_extract_key.cc b/src/box/tuple_extract_key.cc
index 5cf46724..915b6bae 100644
--- a/src/box/tuple_extract_key.cc
+++ b/src/box/tuple_extract_key.cc
@@ -356,7 +356,7 @@ static const tuple_extract_key_t extract_key_slowpath_funcs[] = {
  * Initialize tuple_extract_key() and tuple_extract_key_raw()
  */
 void
-tuple_extract_key_set(struct key_def *key_def)
+tuple_extract_key_func_set(struct key_def *key_def)
 {
 	if (key_def_is_sequential(key_def)) {
 		if (key_def->has_optional_parts) {
diff --git a/src/box/tuple_extract_key.h b/src/box/tuple_extract_key.h
index 8a346595..129b0d82 100644
--- a/src/box/tuple_extract_key.h
+++ b/src/box/tuple_extract_key.h
@@ -41,7 +41,7 @@ struct key_def;
  * @param key_def key definition
  */
 void
-tuple_extract_key_set(struct key_def *key_def);
+tuple_extract_key_func_set(struct key_def *key_def);
 
 #if defined(__cplusplus)
 } /* extern "C" */
-- 
2.11.0

  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 ` Vladimir Davydov [this message]
2019-02-21 11:01   ` [tarantool-patches] Re: [PATCH 03/12] key_def: cleanup virtual function initialization 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 ` [PATCH 05/12] vinyl: move vy_tuple_key_contains_null to generic code Vladimir Davydov
2019-02-21 11:02   ` [tarantool-patches] " 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=1aaf38421e27d3cfa4cdb949b8dce36aa8421cfb.1550744027.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 03/12] key_def: cleanup virtual function initialization' \
    /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