[patches] [PATCH v2 2/5] Move tuple_compare wrappers to key_def.h/.cc
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Feb 18 23:59:36 MSK 2018
They have no sense without key_def.h.
Signed-off-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
---
src/CMakeLists.txt | 1 -
src/box/key_def.cc | 16 ++++++++++
src/box/key_def.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++
src/box/memtx_hash.c | 1 -
src/box/memtx_space.c | 1 -
src/box/memtx_tree.c | 1 +
src/box/memtx_tree.h | 1 -
src/box/space.c | 1 -
src/box/tuple_compare.cc | 16 ----------
src/box/tuple_compare.h | 82 ------------------------------------------------
src/box/vy_range.c | 1 -
src/box/vy_stmt.h | 1 -
12 files changed, 96 insertions(+), 105 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b947a67c0..5cb2c359a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -184,7 +184,6 @@ set(api_headers
${CMAKE_SOURCE_DIR}/src/box/field_def.h
${CMAKE_SOURCE_DIR}/src/box/tuple.h
${CMAKE_SOURCE_DIR}/src/box/tuple_format.h
- ${CMAKE_SOURCE_DIR}/src/box/tuple_compare.h
${CMAKE_SOURCE_DIR}/src/box/tuple_extract_key.h
${CMAKE_SOURCE_DIR}/src/box/schema_def.h
${CMAKE_SOURCE_DIR}/src/box/box.h
diff --git a/src/box/key_def.cc b/src/box/key_def.cc
index 7f00b82df..3b3dff800 100644
--- a/src/box/key_def.cc
+++ b/src/box/key_def.cc
@@ -190,6 +190,22 @@ box_key_def_delete(box_key_def_t *key_def)
free(key_def);
}
+int
+box_tuple_compare(const box_tuple_t *tuple_a, const box_tuple_t *tuple_b,
+ const box_key_def_t *key_def)
+{
+ return tuple_compare(tuple_a, tuple_b, key_def);
+}
+
+int
+box_tuple_compare_with_key(const box_tuple_t *tuple_a, const char *key_b,
+ const box_key_def_t *key_def)
+{
+ uint32_t part_count = mp_decode_array(&key_b);
+ return tuple_compare_with_key(tuple_a, key_b, part_count, key_def);
+
+}
+
int
key_part_cmp(const struct key_part *parts1, uint32_t part_count1,
const struct key_part *parts2, uint32_t part_count2)
diff --git a/src/box/key_def.h b/src/box/key_def.h
index d90859196..96f4cdbf9 100644
--- a/src/box/key_def.h
+++ b/src/box/key_def.h
@@ -147,6 +147,7 @@ key_def_dup(const struct key_def *src);
/** \cond public */
typedef struct key_def box_key_def_t;
+typedef struct tuple box_tuple_t;
/**
* Create key definition with key fields with passed typed on passed positions.
@@ -168,6 +169,34 @@ box_key_def_new(uint32_t *fields, uint32_t *types, uint32_t part_count);
void
box_key_def_delete(box_key_def_t *key_def);
+/**
+ * Compare tuples using the key definition.
+ * @param tuple_a first tuple
+ * @param tuple_b second tuple
+ * @param key_def key definition
+ * @retval 0 if key_fields(tuple_a) == key_fields(tuple_b)
+ * @retval <0 if key_fields(tuple_a) < key_fields(tuple_b)
+ * @retval >0 if key_fields(tuple_a) > key_fields(tuple_b)
+ */
+int
+box_tuple_compare(const box_tuple_t *tuple_a, const box_tuple_t *tuple_b,
+ const box_key_def_t *key_def);
+
+/**
+ * @brief Compare tuple with key using the key definition.
+ * @param tuple tuple
+ * @param key key with MessagePack array header
+ * @param key_def key definition
+ *
+ * @retval 0 if key_fields(tuple) == parts(key)
+ * @retval <0 if key_fields(tuple) < parts(key)
+ * @retval >0 if key_fields(tuple) > parts(key)
+ */
+
+int
+box_tuple_compare_with_key(const box_tuple_t *tuple_a, const char *key_b,
+ const box_key_def_t *key_def);
+
/** \endcond public */
static inline size_t
@@ -413,6 +442,56 @@ tuple_extract_key_raw(const char *data, const char *data_end,
key_size);
}
+/**
+ * Compare keys using the key definition.
+ * @param key_a key parts with MessagePack array header
+ * @param part_count_a the number of parts in the key_a
+ * @param key_b key_parts with MessagePack array header
+ * @param part_count_b the number of parts in the key_b
+ * @param key_def key definition
+ *
+ * @retval 0 if key_a == key_b
+ * @retval <0 if key_a < key_b
+ * @retval >0 if key_a > key_b
+ */
+int
+key_compare(const char *key_a, const char *key_b,
+ const struct key_def *key_def);
+
+/**
+ * Compare tuples using the key definition.
+ * @param tuple_a first tuple
+ * @param tuple_b second tuple
+ * @param key_def key definition
+ * @retval 0 if key_fields(tuple_a) == key_fields(tuple_b)
+ * @retval <0 if key_fields(tuple_a) < key_fields(tuple_b)
+ * @retval >0 if key_fields(tuple_a) > key_fields(tuple_b)
+ */
+static inline int
+tuple_compare(const struct tuple *tuple_a, const struct tuple *tuple_b,
+ const struct key_def *key_def)
+{
+ return key_def->tuple_compare(tuple_a, tuple_b, key_def);
+}
+
+/**
+ * @brief Compare tuple with key using the key definition.
+ * @param tuple tuple
+ * @param key key parts without MessagePack array header
+ * @param part_count the number of parts in @a key
+ * @param key_def key definition
+ *
+ * @retval 0 if key_fields(tuple) == parts(key)
+ * @retval <0 if key_fields(tuple) < parts(key)
+ * @retval >0 if key_fields(tuple) > parts(key)
+ */
+static inline int
+tuple_compare_with_key(const struct tuple *tuple, const char *key,
+ uint32_t part_count, const struct key_def *key_def)
+{
+ return key_def->tuple_compare_with_key(tuple, key, part_count, key_def);
+}
+
#if defined(__cplusplus)
} /* extern "C" */
#endif /* defined(__cplusplus) */
diff --git a/src/box/memtx_hash.c b/src/box/memtx_hash.c
index 78f55eb7d..70b114d7d 100644
--- a/src/box/memtx_hash.c
+++ b/src/box/memtx_hash.c
@@ -32,7 +32,6 @@
#include "say.h"
#include "fiber.h"
#include "tuple.h"
-#include "tuple_compare.h"
#include "tuple_hash.h"
#include "memtx_engine.h"
#include "space.h"
diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c
index 92b7a468c..2d94597ac 100644
--- a/src/box/memtx_space.c
+++ b/src/box/memtx_space.c
@@ -32,7 +32,6 @@
#include "space.h"
#include "iproto_constants.h"
#include "txn.h"
-#include "tuple_compare.h"
#include "tuple_update.h"
#include "xrow.h"
#include "memtx_hash.h"
diff --git a/src/box/memtx_tree.c b/src/box/memtx_tree.c
index 6ebdc90f5..07294d220 100644
--- a/src/box/memtx_tree.c
+++ b/src/box/memtx_tree.c
@@ -35,6 +35,7 @@
#include "errinj.h"
#include "memory.h"
#include "fiber.h"
+#include "tuple.h"
#include <third_party/qsort_arg.h>
#include <small/mempool.h>
diff --git a/src/box/memtx_tree.h b/src/box/memtx_tree.h
index a8a688ef1..28b6fbd66 100644
--- a/src/box/memtx_tree.h
+++ b/src/box/memtx_tree.h
@@ -35,7 +35,6 @@
#include "index.h"
#include "memtx_engine.h"
-#include "tuple_compare.h"
#if defined(__cplusplus)
extern "C" {
diff --git a/src/box/space.c b/src/box/space.c
index 11fd2c17d..967778698 100644
--- a/src/box/space.c
+++ b/src/box/space.c
@@ -38,7 +38,6 @@
#include "session.h"
#include "txn.h"
#include "tuple.h"
-#include "tuple_compare.h"
#include "tuple_update.h"
#include "request.h"
#include "xrow.h"
diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc
index cf8fc130e..dcfb4f636 100644
--- a/src/box/tuple_compare.cc
+++ b/src/box/tuple_compare.cc
@@ -1152,19 +1152,3 @@ tuple_compare_with_key_create(const struct key_def *def)
}
/* }}} tuple_compare_with_key */
-
-int
-box_tuple_compare(const box_tuple_t *tuple_a, const box_tuple_t *tuple_b,
- const box_key_def_t *key_def)
-{
- return tuple_compare(tuple_a, tuple_b, key_def);
-}
-
-int
-box_tuple_compare_with_key(const box_tuple_t *tuple_a, const char *key_b,
- const box_key_def_t *key_def)
-{
- uint32_t part_count = mp_decode_array(&key_b);
- return tuple_compare_with_key(tuple_a, key_b, part_count, key_def);
-
-}
diff --git a/src/box/tuple_compare.h b/src/box/tuple_compare.h
index e6ac6166a..3888bbb93 100644
--- a/src/box/tuple_compare.h
+++ b/src/box/tuple_compare.h
@@ -56,88 +56,6 @@ tuple_compare_create(const struct key_def *key_def);
tuple_compare_with_key_t
tuple_compare_with_key_create(const struct key_def *key_def);
-/**
- * Compare keys using the key definition.
- * @param key_a key parts with MessagePack array header
- * @param part_count_a the number of parts in the key_a
- * @param key_b key_parts with MessagePack array header
- * @param part_count_b the number of parts in the key_b
- * @param key_def key definition
- *
- * @retval 0 if key_a == key_b
- * @retval <0 if key_a < key_b
- * @retval >0 if key_a > key_b
- */
-int
-key_compare(const char *key_a, const char *key_b,
- const struct key_def *key_def);
-
-/**
- * Compare tuples using the key definition.
- * @param tuple_a first tuple
- * @param tuple_b second tuple
- * @param key_def key definition
- * @retval 0 if key_fields(tuple_a) == key_fields(tuple_b)
- * @retval <0 if key_fields(tuple_a) < key_fields(tuple_b)
- * @retval >0 if key_fields(tuple_a) > key_fields(tuple_b)
- */
-static inline int
-tuple_compare(const struct tuple *tuple_a, const struct tuple *tuple_b,
- const struct key_def *key_def)
-{
- return key_def->tuple_compare(tuple_a, tuple_b, key_def);
-}
-
-/**
- * @brief Compare tuple with key using the key definition.
- * @param tuple tuple
- * @param key key parts without MessagePack array header
- * @param part_count the number of parts in @a key
- * @param key_def key definition
- *
- * @retval 0 if key_fields(tuple) == parts(key)
- * @retval <0 if key_fields(tuple) < parts(key)
- * @retval >0 if key_fields(tuple) > parts(key)
- */
-static inline int
-tuple_compare_with_key(const struct tuple *tuple, const char *key,
- uint32_t part_count, const struct key_def *key_def)
-{
- return key_def->tuple_compare_with_key(tuple, key, part_count, key_def);
-}
-
-/** \cond public */
-
-/**
- * Compare tuples using the key definition.
- * @param tuple_a first tuple
- * @param tuple_b second tuple
- * @param key_def key definition
- * @retval 0 if key_fields(tuple_a) == key_fields(tuple_b)
- * @retval <0 if key_fields(tuple_a) < key_fields(tuple_b)
- * @retval >0 if key_fields(tuple_a) > key_fields(tuple_b)
- */
-int
-box_tuple_compare(const box_tuple_t *tuple_a, const box_tuple_t *tuple_b,
- const box_key_def_t *key_def);
-
-/**
- * @brief Compare tuple with key using the key definition.
- * @param tuple tuple
- * @param key key with MessagePack array header
- * @param key_def key definition
- *
- * @retval 0 if key_fields(tuple) == parts(key)
- * @retval <0 if key_fields(tuple) < parts(key)
- * @retval >0 if key_fields(tuple) > parts(key)
- */
-
-int
-box_tuple_compare_with_key(const box_tuple_t *tuple_a, const char *key_b,
- const box_key_def_t *key_def);
-
-/** \endcond public */
-
#if defined(__cplusplus)
} /* extern "C" */
#endif /* defined(__cplusplus) */
diff --git a/src/box/vy_range.c b/src/box/vy_range.c
index 9f29a5e2c..baecf1782 100644
--- a/src/box/vy_range.c
+++ b/src/box/vy_range.c
@@ -46,7 +46,6 @@
#include "key_def.h"
#include "trivia/util.h"
#include "tuple.h"
-#include "tuple_compare.h"
#include "vy_run.h"
#include "vy_stat.h"
#include "vy_stmt.h"
diff --git a/src/box/vy_stmt.h b/src/box/vy_stmt.h
index 38c53216e..201c62487 100644
--- a/src/box/vy_stmt.h
+++ b/src/box/vy_stmt.h
@@ -40,7 +40,6 @@
#include <bit/bit.h>
#include "tuple.h"
-#include "tuple_compare.h"
#include "iproto_constants.h"
#if defined(__cplusplus)
--
2.14.3 (Apple Git-98)
More information about the Tarantool-patches
mailing list