From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 25 Jul 2019 11:40:15 +0300 From: Konstantin Osipov Subject: Re: [tarantool-patches] Re: [PATCH v4 4/4] box: introduce functional indexes Message-ID: <20190725084015.GG15185@atlas> References: <20190724210731.GA11790@atlas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: Kirill Shcherbatov Cc: tarantool-patches@freelists.org, Vladimir Davydov List-ID: * Kirill Shcherbatov [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