[tarantool-patches] [PATCH v3 7/7] Add merger for tuple streams (Lua part)

Alexander Turenko alexander.turenko at tarantool.org
Thu Apr 25 15:53:10 MSK 2019


On Thu, Apr 25, 2019 at 02:46:59PM +0300, Konstantin Osipov wrote:
> * Alexander Turenko <alexander.turenko at tarantool.org> [19/04/10 18:23]:
> > 
> The api is generally LGTM, one comment below:
> 
> > A merger is a special kind of a source, which is created from a key_def
> > object and a set of sources. It performs a kind of the merge sort:
> > chooses a source with a minimal / maximal tuple on each step, consumes
> > a tuple from this source and repeats. The API to create a merger is the
> > following:
> > 
> > ```lua
> > local ctx = merger.context.new(key_def.new(<...>))
> > local sources = {<...>}
> > local merger_inst = merger.new(ctx, sources, {
> 
>     Why do you need a separate object used only to construct a
>     merger? Why not pass all parameters into merger.new?

A user may want to cache key_def + format creation when a schema changes
rarely. The original merger allows it:
https://github.com/tarantool/shard/blob/180948e99148973e89f75f8e4784315e183e3fa2/shard/init.lua#L1215-L1224

Even if one doesn't cache a merger context, but runs several merges over
one data stream (see the multiplexed cases in examples) and a schema is
the same, it worth to reuse the context.



More information about the Tarantool-patches mailing list