[tarantool/dump] Add dump and restore filters

Vladimir Davydov vdavydov.dev at gmail.com
Mon Feb 5 13:19:28 MSK 2018


On Fri, Feb 02, 2018 at 11:42:20PM +0300, Konstantin Osipov wrote:
> * 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?

Hmm, I think it would be OK if we simply reported the progress
to the log at the INFO level.

> 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.

To spare the filter function from doing this by itself.
(a filter function will probably use box.tuple.update,
which does not work for raw Lua table).



More information about the Tarantool-patches mailing list