[Tarantool-patches] [PATCH v4 34/53] sql: introduce mem_set_*_map() and mem_set_*_array()

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Mar 30 02:05:54 MSK 2021


Thanks for the patch!

> diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> index 7885caaf5..583de00a2 100644
> --- a/src/box/sql/mem.c
> +++ b/src/box/sql/mem.c
> @@ -508,6 +508,86 @@ mem_append_to_binary(struct Mem *mem, const char *value, uint32_t size)
>  	return 0;
>  }
>  
> +void
> +mem_set_ephemeral_map(struct Mem *mem, char *value, uint32_t size)
> +{
> +	assert(mp_typeof(*value) == MP_MAP);
> +	mem_set_const_bin(mem, value, size, MEM_Ephem);
> +	mem->flags |= MEM_Subtype;
> +	mem->subtype = SQL_SUBTYPE_MSGPACK;
> +	mem->field_type = FIELD_TYPE_MAP;
> +}
> +
> +void
> +mem_set_static_map(struct Mem *mem, char *value, uint32_t size)
> +{
> +	assert(mp_typeof(*value) == MP_MAP);
> +	mem_set_const_bin(mem, value, size, MEM_Static);
> +	mem->flags |= MEM_Subtype;
> +	mem->subtype = SQL_SUBTYPE_MSGPACK;
> +	mem->field_type = FIELD_TYPE_MAP;
> +}
> +
> +void
> +mem_set_dynamic_map(struct Mem *mem, char *value, uint32_t size)

I think I lost the clue of what is the difference between dynamic
and allocated. Maybe worth adding a comment? Or find a better name?

For instance, if one of them is supposed to copy the map, and the
other one to steal its ownership, then you could call them
mem_set_map_copy() and mem_set_map_move(), where move is the same as
C++ move - steal the resource. The same for the others dynamic/allocated
terminology in the function names.

I think I also lost the understanding of static vs ephem by now.


More information about the Tarantool-patches mailing list