[tarantool-patches] [PATCH 05/12] vinyl: do not reallocate tuple formats on alter

Vladimir Davydov vdavydov.dev at gmail.com
Sun Apr 1 14:24:18 MSK 2018


On Sun, Apr 01, 2018 at 02:12:26PM +0300, v.shpilevoy at tarantool.org wrote:
> > diff --git a/src/box/vinyl.c b/src/box/vinyl.c
> > index fc37283a..f3cef52f 100644
> > --- a/src/box/vinyl.c
> > +++ b/src/box/vinyl.c
> > +static void
> > +vinyl_space_swap_index(struct space *old_space, struct space *new_space,
> > +		       uint32_t old_index_id, uint32_t new_index_id)
> > +{
> > +	struct vy_lsm *old_lsm = vy_lsm(old_space->index_map[old_index_id]);
> > +	struct vy_lsm *new_lsm = vy_lsm(new_space->index_map[new_index_id]);
> > +
> > +	/*
> > +	 * Swap the two indexes between the two spaces,
> > +	 * but leave tuple formats.
> > +	 */
> > +	generic_space_swap_index(old_space, new_space,
> > +				 old_index_id, new_index_id);
> > +
> > +	SWAP(old_lsm->mem_format, new_lsm->mem_format);
> 
> How do you swap the formats, if they are variable length structures?
> 1) Their fields[] arrays are not swapped here, 2) even if you will try
> to swap - they can have different length.

I swap pointers, not objects:

struct vy_lsm {
  	...
	struct tuple_format *disk_format;
	struct tuple_format *mem_format;
	struct tuple_format *mem_format_with_colmask;
};

> 
> > +	SWAP(old_lsm->mem_format_with_colmask,
> > +	     new_lsm->mem_format_with_colmask);
> > +	SWAP(old_lsm->disk_format, new_lsm->disk_format);
> > +	SWAP(old_lsm->opts, new_lsm->opts);
> > }



More information about the Tarantool-patches mailing list