[tarantool/dump] Add dump and restore filters

Konstantin Osipov kostja at tarantool.org
Fri Feb 2 23:42:20 MSK 2018


* Vladimir Davydov <vdavydov.dev at gmail.com> [18/01/30 19:43]:
> This patch adds an optional argument to dump and restore functions that
> can be used for passing options. Currently, there's the only option
> available, 'filter', which is supposed to be a function that takes a
> space and a tuple and returns a tuple. This function is called for each
> dumped/restored tuple. It can be used to overwrite what is written to
> the dump file or restored. If it returns nil the tuple will be skipped.
> 
> The 'filter' option can be used to convert memtx spaces to vinyl as
> shown below:
> 
>     dump.restore('dump', {
>         filter = function(space, tuple)
>             if space.id == box.schema.SPACE_ID then
>                 return tuple:update{{'=', 4, 'vinyl'}}
>             else
>                 return tuple
>             end
>         end
>     })
> 
> Closes #1

OK to push.
You can use the same filter api to report progress, no?
But to report progress you need box.session.push() :)



> @@ -241,7 +248,7 @@ local function space_stream_next_tuple(stream)
>          return nil
>      end
>      stream.buf.rpos = rpos
> -    return tuple
> +    return box.tuple.new(tuple)
>  end

Why did you have to do this? This can slow things down quite a
bit, because of an extra object Lua needs to gc.


-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.org - www.twitter.com/kostja_osipov



More information about the Tarantool-patches mailing list