[tarantool-patches] Re: [PATCH v4 4/4] box: introduce functional indexes

Konstantin Osipov kostja at tarantool.org
Thu Jul 25 11:40:15 MSK 2019


* Kirill Shcherbatov <kshcherbatov at tarantool.org> [19/07/25 11:31]:
> > I don't understand why you force the user of this module to first
> > create a temporary buffer, then iterate over this buffer to create 
> > hint objects. Why can't this function return an iterator right
> > away, and the iterator itself could return hint_t objects already,
> > not individual keys?
> 
> E.g. in :replace/delete part we don't need a persistent memory chunk: we need to
> evaluate function and iterate over the returned keys to perform a deletion.
> 
> ===========================================
> 
> key_list = key_list_create(old_tuple, cmp_def->func_index_func,
> 			   &key_list_end, &key_cnt);
> if (key_list == NULL)
> 	goto end;
> struct memtx_tree_data data, deleted_data;
> data.tuple = old_tuple;
> key_list_iterator_create(&it, key_list, key_list_end, cmp_def, true);
> const char *key;
> uint32_t key_sz;
> while (key_list_iterator_next(&it, &key, &key_sz) == 0 &&
>        key != NULL) {
> 	data.hint = (hint_t) key; /* Raw data. */

Generally yes, you get the idea, but I don't
get why key is const char *, and why you need key_sz at all.
The iterator can return hint_t right away.
Plus, you can merge key_list_create and key_list_iterator_create
into a single function, there is no reason why one has to perform
two calls instead of one.

> 	deleted_data.tuple = NULL;
> 	memtx_tree_delete_value(&index->tree, data,
> 				&deleted_data);
> .....

-- 
Konstantin Osipov, Moscow, Russia



More information about the Tarantool-patches mailing list