Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH v2 0/2] Make tree hint optional
@ 2020-10-21 10:23 Aleksandr Lyapunov
  2020-10-21 10:23 ` [Tarantool-patches] [PATCH v2 1/2] memtx: move memtx_tree.c to memtx_tree.cc Aleksandr Lyapunov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Aleksandr Lyapunov @ 2020-10-21 10:23 UTC (permalink / raw)
  To: tarantool-patches, Nikita Pettik, Ilya Kosarev

Add an option that disables hints in tree indexes.

https://github.com/tarantool/tarantool/issues/4927
https://github.com/tarantool/tarantool/tree/alyapunov/gh-4927-optional-hints

v2 changes:
 * int template parameter was replaced by bool.
 * fix compilation error, just a couple of casts added:

@@ -542,7 +542,7 @@ tree_iterator_start(struct iterator *iterator, struct tuple **ret)
        struct txn *txn = in_txn();
        struct space *space = space_by_id(iterator->space_id);
        bool is_rw = txn != NULL;
-       uint32_t mk_index = is_multikey ? res->hint : 0;
+       uint32_t mk_index = is_multikey ? (uint32_t)res->hint : 0;
        *ret = memtx_tx_tuple_clarify(txn, space, *ret, iid, mk_index, is_rw);
        if (*ret == NULL) {
                return iterator->next(iterator, ret);
@@ -734,13 +734,14 @@ memtx_tree_index_get(struct index *base, const char *key,
        struct txn *txn = in_txn();
        struct space *space = space_by_id(base->def->space_id);
        bool is_rw = txn != NULL;
-       uint32_t mk_index = base->def->key_def->is_multikey ? res->hint : 0;
+       bool is_multikey = base->def->key_def->is_multikey;
+       uint32_t mk_index = is_multikey ? (uint32_t)res->hint : 0;
        *result = memtx_tx_tuple_clarify(txn, space, res->tuple, base->def->iid,
                                         mk_index, is_rw);
        return 0;
 }
 


Aleksandr Lyapunov (1):
  memtx: make tuple compare hints optional

Ilya Kosarev (1):
  memtx: move memtx_tree.c to memtx_tree.cc

 src/box/CMakeLists.txt              |    2 +-
 src/box/index_def.c                 |    2 +
 src/box/index_def.h                 |    6 +
 src/box/lua/schema.lua              |   53 ++
 src/box/lua/space.cc                |    7 +
 src/box/memtx_engine.c              |    2 +
 src/box/memtx_tree.c                | 1523 -------------------------------
 src/box/memtx_tree.cc               | 1726 +++++++++++++++++++++++++++++++++++
 src/lib/salad/bps_tree.h            |   19 +
 test/box/alter.result               |  103 ++-
 test/box/alter.test.lua             |   34 +
 test/box/errinj.result              |    3 +-
 test/box/tree_pk.result             |  314 +++++++
 test/box/tree_pk.test.lua           |  115 +++
 test/box/tree_pk_multipart.result   |  153 ++++
 test/box/tree_pk_multipart.test.lua |   64 ++
 16 files changed, 2598 insertions(+), 1528 deletions(-)
 delete mode 100644 src/box/memtx_tree.c
 create mode 100644 src/box/memtx_tree.cc

-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [Tarantool-patches] [PATCH v2 1/2] memtx: move memtx_tree.c to memtx_tree.cc
@ 2020-10-21 16:34 Aleksandr Lyapunov
  0 siblings, 0 replies; 7+ messages in thread
From: Aleksandr Lyapunov @ 2020-10-21 16:34 UTC (permalink / raw)
  To: tarantool-patches, Nikita Pettik, Ilya Kosarev

From: Ilya Kosarev <i.kosarev@tarantool.org>

It is needed for the further c++ implementation in memtx_tree.cc. To
see the file diff properly it should not be renamed and reworked
in one commit. Some not c++ comparable casts were fixed.

Prerequisites: #4927
---
 src/box/CMakeLists.txt                  |  2 +-
 src/box/{memtx_tree.c => memtx_tree.cc} | 19 +++++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)
 rename src/box/{memtx_tree.c => memtx_tree.cc} (98%)

diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt
index fbcfbe4..df243ac 100644
--- a/src/box/CMakeLists.txt
+++ b/src/box/CMakeLists.txt
@@ -126,7 +126,7 @@ add_library(box STATIC
     index_def.c
     iterator_type.c
     memtx_hash.c
-    memtx_tree.c
+    memtx_tree.cc
     memtx_rtree.c
     memtx_bitset.c
     memtx_tx.c
diff --git a/src/box/memtx_tree.c b/src/box/memtx_tree.cc
similarity index 98%
rename from src/box/memtx_tree.c
rename to src/box/memtx_tree.cc
index 5af482f..d3b993b 100644
--- a/src/box/memtx_tree.c
+++ b/src/box/memtx_tree.cc
@@ -126,9 +126,9 @@ memtx_tree_cmp_def(struct memtx_tree *tree)
 static int
 memtx_tree_qcompare(const void* a, const void *b, void *c)
 {
-	const struct memtx_tree_data *data_a = a;
-	const struct memtx_tree_data *data_b = b;
-	struct key_def *key_def = c;
+	const struct memtx_tree_data *data_a = (struct memtx_tree_data *)a;
+	const struct memtx_tree_data *data_b = (struct memtx_tree_data *)b;
+	struct key_def *key_def = (struct key_def *)c;
 	return tuple_compare(data_a->tuple, data_a->hint, data_b->tuple,
 			     data_b->hint, key_def);
 }
@@ -852,7 +852,7 @@ func_index_key_dummy_alloc(struct tuple *tuple, const char *key,
 {
 	(void) tuple;
 	(void) key_sz;
-	return (void*) key;
+	return key;
 }
 
 /**
@@ -1064,7 +1064,8 @@ memtx_tree_index_create_iterator(struct index *base, enum iterator_type type,
 		key = NULL;
 	}
 
-	struct tree_iterator *it = mempool_alloc(&memtx->iterator_pool);
+	struct tree_iterator *it = (struct tree_iterator *)
+		mempool_alloc(&memtx->iterator_pool);
 	if (it == NULL) {
 		diag_set(OutOfMemory, sizeof(struct tree_iterator),
 			 "memtx_tree_index", "iterator");
@@ -1098,7 +1099,8 @@ memtx_tree_index_reserve(struct index *base, uint32_t size_hint)
 	if (size_hint < index->build_array_alloc_size)
 		return 0;
 	struct memtx_tree_data *tmp =
-		realloc(index->build_array, size_hint * sizeof(*tmp));
+		(struct memtx_tree_data *)
+			realloc(index->build_array, size_hint * sizeof(*tmp));
 	if (tmp == NULL) {
 		diag_set(OutOfMemory, size_hint * sizeof(*tmp),
 			 "memtx_tree_index", "reserve");
@@ -1115,7 +1117,8 @@ memtx_tree_index_build_array_append(struct memtx_tree_index *index,
 				    struct tuple *tuple, hint_t hint)
 {
 	if (index->build_array == NULL) {
-		index->build_array = malloc(MEMTX_EXTENT_SIZE);
+		index->build_array =
+			(struct memtx_tree_data *)malloc(MEMTX_EXTENT_SIZE);
 		if (index->build_array == NULL) {
 			diag_set(OutOfMemory, MEMTX_EXTENT_SIZE,
 				 "memtx_tree_index", "build_next");
@@ -1129,7 +1132,7 @@ memtx_tree_index_build_array_append(struct memtx_tree_index *index,
 		index->build_array_alloc_size = index->build_array_alloc_size +
 				DIV_ROUND_UP(index->build_array_alloc_size, 2);
 		struct memtx_tree_data *tmp =
-			realloc(index->build_array,
+			(struct memtx_tree_data *)realloc(index->build_array,
 				index->build_array_alloc_size * sizeof(*tmp));
 		if (tmp == NULL) {
 			diag_set(OutOfMemory, index->build_array_alloc_size *
-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-10-21 16:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 10:23 [Tarantool-patches] [PATCH v2 0/2] Make tree hint optional Aleksandr Lyapunov
2020-10-21 10:23 ` [Tarantool-patches] [PATCH v2 1/2] memtx: move memtx_tree.c to memtx_tree.cc Aleksandr Lyapunov
2020-10-21 16:12   ` Cyrill Gorcunov
2020-10-21 10:23 ` [Tarantool-patches] [PATCH v2 2/2] memtx: make tuple compare hints optional Aleksandr Lyapunov
2020-10-21 15:28 ` [Tarantool-patches] [PATCH v2 0/2] Make tree hint optional Nikita Pettik
2020-10-21 16:38   ` Ilya Kosarev
2020-10-21 16:34 [Tarantool-patches] [PATCH v2 1/2] memtx: move memtx_tree.c to memtx_tree.cc Aleksandr Lyapunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox