Skip to content
Snippets Groups Projects
Commit ab5010c6 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

tuple: add helper for creating runtime tuple format with field names

Currently, the helper is used only for creation of a tuple format for
Lua (needed for net.box schema). Later on, we will reuse this helper for
creating tuple formats for user read views.

Needed for https://github.com/tarantool/tarantool-ee/issues/207

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring
parent 48950020
No related branches found
No related tags found
No related merge requests found
......@@ -313,9 +313,7 @@ lbox_tuple_format_new(struct lua_State *L)
region_truncate(region, region_svp);
if (dict == NULL)
return luaT_error(L);
struct tuple_format *format =
tuple_format_new(&tuple_format_runtime->vtab, NULL, NULL, 0,
NULL, 0, 0, dict, false, true, NULL, 0);
struct tuple_format *format = runtime_tuple_format_new(dict);
/*
* Since dictionary reference counter is 1 from the
* beginning and after creation of the tuple_format
......
......@@ -284,6 +284,17 @@ tuple_bigref_tuple_count()
return tuple_uploaded_refs->size;
}
struct tuple_format *
runtime_tuple_format_new(struct tuple_dictionary *dict)
{
return tuple_format_new(&tuple_format_runtime_vtab, /*engine=*/NULL,
/*keys=*/NULL, /*key_count=*/0,
/*space_field_count=*/NULL,
/*exact_field_count=*/0, 0, dict,
/*is_temporary=*/false, /*is_reusable=*/true,
/*contraint_def=*/NULL, /*constraint_count=*/0);
}
int
tuple_init(field_name_hash_f hash)
{
......@@ -292,9 +303,7 @@ tuple_init(field_name_hash_f hash)
/*
* Create a format for runtime tuples
*/
tuple_format_runtime =
simple_tuple_format_new(&tuple_format_runtime_vtab,
NULL, NULL, 0);
tuple_format_runtime = runtime_tuple_format_new(/*dict=*/NULL);
if (tuple_format_runtime == NULL)
return -1;
......
......@@ -75,6 +75,18 @@ tuple_arena_create(struct slab_arena *arena, struct quota *quota,
void
tuple_arena_destroy(struct slab_arena *arena);
/**
* Creates a new format for standalone tuples.
*
* Tuples created with the new format are allocated from the runtime arena.
* In contrast to the preallocated tuple_format_runtime, which has no field
* names, the new format uses the provided field name dictionary.
*
* On success, returns the new format. On error, returns NULL and sets diag.
*/
struct tuple_format *
runtime_tuple_format_new(struct tuple_dictionary *dict);
/** \cond public */
typedef struct tuple_format box_tuple_format_t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment