From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id B68F8469719 for ; Fri, 9 Oct 2020 04:46:38 +0300 (MSK) Date: Fri, 9 Oct 2020 04:46:55 +0300 From: Alexander Turenko Message-ID: <20201009014655.mznosa4hvuzesumd@tkn_work_nb> References: <51245d8c-9fe4-b185-ecaf-93e1144115f5@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <51245d8c-9fe4-b185-ecaf-93e1144115f5@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 12/14] WIP: module api: expose box_key_def_merge() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org On Sat, Sep 26, 2020 at 12:58:21AM +0200, Vladislav Shpilevoy wrote: > Thanks for the patch! > > Why would a module need that function? Its usage case is very > specific - merge primary and secondary parts to create a > unique key def for non-unique indexes. Is there a case outside > of the storage engines for that function? Sure. At least I can give a case from merger usage: if we have several sources of tuples that are sorted in the order of a secondary key + primary key and want to merge them keeping the order, we need to construct a key_def that is union of those key parts. The functions does exactly this, that is very convenient. Usage example: https://github.com/Totktonada/tarantool-merger-examples/blob/557c15a191b465e8e9673203dd0e388a3345f625/chunked_example_fast/frontend.lua#L32-L36 Here we create a key_def object to pass it to merger as a tuple comparator. The main function of this example, mr_call(), selects tuples from given vshard cluster using given space, index and key (just like usual box select). If an index is not unique, we call :merge() to mix primary key parts into secondary ones. A predicatable order may be important in different tasks, but first example that I have in the mind is pagination. It does not work, if the order is not strictly defined (say, depend on how storages -- and so merge source -- are enumerated when passed to merger).