diff --git a/src/box/blackhole.c b/src/box/blackhole.c index 0412ffe89fbdaeb16a2e411d58a9867fde71957a..6ada7a586e6b3b5a0729ac88b8d7a28a48f5f92b 100644 --- a/src/box/blackhole.c +++ b/src/box/blackhole.c @@ -155,13 +155,13 @@ blackhole_engine_create_space(struct engine *engine, struct space_def *def, /* Allocate tuples on runtime arena, but check space format. */ struct tuple_format *format; - format = tuple_format_new(&tuple_format_runtime->vtab, NULL, 0, - def->fields, def->field_count, def->dict); + format = tuple_format_new(&tuple_format_runtime->vtab, NULL, NULL, 0, + def->fields, def->field_count, + def->exact_field_count, def->dict, false); if (format == NULL) { free(space); return NULL; } - format->exact_field_count = def->exact_field_count; tuple_format_ref(format); if (space_create(space, engine, &blackhole_space_vtab, diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c index eb790a6fe2e36816449cd55b5101fb6169ead2ea..4aad8da6c112b11657ed74fcc2e509374d6e76b4 100644 --- a/src/box/memtx_space.c +++ b/src/box/memtx_space.c @@ -990,15 +990,14 @@ memtx_space_new(struct memtx_engine *memtx, keys[key_count++] = index_def->key_def; struct tuple_format *format = - tuple_format_new(&memtx_tuple_format_vtab, keys, key_count, - def->fields, def->field_count, def->dict); + tuple_format_new(&memtx_tuple_format_vtab, memtx, keys, key_count, + def->fields, def->field_count, + def->exact_field_count, def->dict, + def->opts.is_temporary); if (format == NULL) { free(memtx_space); return NULL; } - format->engine = memtx; - format->is_temporary = def->opts.is_temporary; - format->exact_field_count = def->exact_field_count; tuple_format_ref(format); if (space_create((struct space *)memtx_space, (struct engine *)memtx, diff --git a/src/box/tuple.c b/src/box/tuple.c index 2343f0e3734a8d87db146f0310db78a1d9297ad5..a87b2bd20027966566a3b95ce84e3c337f1a63c8 100644 --- a/src/box/tuple.c +++ b/src/box/tuple.c @@ -207,8 +207,8 @@ tuple_init(field_name_hash_f hash) /* * Create a format for runtime tuples */ - tuple_format_runtime = tuple_format_new(&tuple_format_runtime_vtab, - NULL, 0, NULL, 0, NULL); + tuple_format_runtime = tuple_format_new(&tuple_format_runtime_vtab, NULL, + NULL, 0, NULL, 0, 0, NULL, false); if (tuple_format_runtime == NULL) return -1; @@ -379,8 +379,8 @@ box_tuple_format_t * box_tuple_format_new(struct key_def **keys, uint16_t key_count) { box_tuple_format_t *format = - tuple_format_new(&tuple_format_runtime_vtab, - keys, key_count, NULL, 0, NULL); + tuple_format_new(&tuple_format_runtime_vtab, NULL, + keys, key_count, NULL, 0, 0, NULL, false); if (format != NULL) tuple_format_ref(format); return format; diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c index e11b4e6f32d20c4c29e6eaa04e456a144f79d7dc..559c601f9087623ca9bd95bb24081f955c0dc984 100644 --- a/src/box/tuple_format.c +++ b/src/box/tuple_format.c @@ -398,17 +398,20 @@ tuple_format_delete(struct tuple_format *format) } struct tuple_format * -tuple_format_new(struct tuple_format_vtab *vtab, struct key_def * const *keys, - uint16_t key_count, const struct field_def *space_fields, - uint32_t space_field_count, struct tuple_dictionary *dict) +tuple_format_new(struct tuple_format_vtab *vtab, void *engine, + struct key_def * const *keys, uint16_t key_count, + const struct field_def *space_fields, + uint32_t space_field_count, uint32_t exact_field_count, + struct tuple_dictionary *dict, bool is_temporary) { struct tuple_format *format = tuple_format_alloc(keys, key_count, space_field_count, dict); if (format == NULL) return NULL; format->vtab = *vtab; - format->engine = NULL; - format->is_temporary = false; + format->engine = engine; + format->is_temporary = is_temporary; + format->exact_field_count = exact_field_count; if (tuple_format_register(format) < 0) { tuple_format_destroy(format); free(format); diff --git a/src/box/tuple_format.h b/src/box/tuple_format.h index 30b93b6108fa9a32d1551453c4f84d7a7c84ca14..d15fef267f8ae6926ad2d3d2dc46154afeaeb0a9 100644 --- a/src/box/tuple_format.h +++ b/src/box/tuple_format.h @@ -258,18 +258,23 @@ tuple_format_unref(struct tuple_format *format) /** * Allocate, construct and register a new in-memory tuple format. * @param vtab Virtual function table for specific engines. + * @param engine Pointer to storage engine. * @param keys Array of key_defs of a space. * @param key_count The number of keys in @a keys array. * @param space_fields Array of fields, defined in a space format. * @param space_field_count Length of @a space_fields. + * @param exact_field_count Exact field count for format. + * @param is_temporary Set if format belongs to temporary space. * * @retval not NULL Tuple format. * @retval NULL Memory error. */ struct tuple_format * -tuple_format_new(struct tuple_format_vtab *vtab, struct key_def * const *keys, - uint16_t key_count, const struct field_def *space_fields, - uint32_t space_field_count, struct tuple_dictionary *dict); +tuple_format_new(struct tuple_format_vtab *vtab, void *engine, + struct key_def * const *keys, uint16_t key_count, + const struct field_def *space_fields, + uint32_t space_field_count, uint32_t exact_field_count, + struct tuple_dictionary *dict, bool is_temporary); /** * Check, if @a format1 can store any tuples of @a format2. For diff --git a/src/box/vinyl.c b/src/box/vinyl.c index d6117f4444f65b93a4dab93aac01fae4a2d6b3e1..49e8372c67839e1c49c3ccb54f1b928b897d76bd 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -619,13 +619,13 @@ vinyl_engine_create_space(struct engine *engine, struct space_def *def, keys[key_count++] = index_def->key_def; struct tuple_format *format = - tuple_format_new(&vy_tuple_format_vtab, keys, key_count, - def->fields, def->field_count, def->dict); + tuple_format_new(&vy_tuple_format_vtab, NULL, keys, key_count, + def->fields, def->field_count, + def->exact_field_count, def->dict, false); if (format == NULL) { free(space); return NULL; } - format->exact_field_count = def->exact_field_count; tuple_format_ref(format); if (space_create(space, engine, &vinyl_space_vtab, @@ -3043,8 +3043,9 @@ vy_send_lsm(struct vy_join_ctx *ctx, struct vy_lsm_recovery_info *lsm_info) lsm_info->key_part_count); if (ctx->key_def == NULL) goto out; - ctx->format = tuple_format_new(&vy_tuple_format_vtab, &ctx->key_def, - 1, NULL, 0, NULL); + ctx->format = tuple_format_new(&vy_tuple_format_vtab, NULL, + &ctx->key_def, 1, NULL, 0, 0, NULL, + false); if (ctx->format == NULL) goto out_free_key_def; tuple_format_ref(ctx->format); diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c index 5eb3fd7709d88a248e89600ccd227ee12ca608a7..7a6ba6eda1023fcab3fa948e35e5caa00a235aff 100644 --- a/src/box/vy_lsm.c +++ b/src/box/vy_lsm.c @@ -60,8 +60,8 @@ vy_lsm_env_create(struct vy_lsm_env *env, const char *path, vy_upsert_thresh_cb upsert_thresh_cb, void *upsert_thresh_arg) { - env->key_format = tuple_format_new(&vy_tuple_format_vtab, - NULL, 0, NULL, 0, NULL); + env->key_format = tuple_format_new(&vy_tuple_format_vtab, NULL, + NULL, 0, NULL, 0, 0, NULL, false); if (env->key_format == NULL) return -1; tuple_format_ref(env->key_format); @@ -153,8 +153,9 @@ vy_lsm_new(struct vy_lsm_env *lsm_env, struct vy_cache_env *cache_env, */ lsm->disk_format = format; } else { - lsm->disk_format = tuple_format_new(&vy_tuple_format_vtab, - &cmp_def, 1, NULL, 0, NULL); + lsm->disk_format = tuple_format_new(&vy_tuple_format_vtab, NULL, + &cmp_def, 1, NULL, 0, 0, + NULL, false); if (lsm->disk_format == NULL) goto fail_format; } diff --git a/test/unit/vy_iterators_helper.c b/test/unit/vy_iterators_helper.c index 7fad5600c1fae0727120bab829928de6db6848c6..6808ff408e5d1c871bc00750707e55ee67816cf7 100644 --- a/test/unit/vy_iterators_helper.c +++ b/test/unit/vy_iterators_helper.c @@ -21,8 +21,8 @@ vy_iterator_C_test_init(size_t cache_size) tuple_init(NULL); vy_cache_env_create(&cache_env, cord_slab_cache()); vy_cache_env_set_quota(&cache_env, cache_size); - vy_key_format = tuple_format_new(&vy_tuple_format_vtab, NULL, 0, - NULL, 0, NULL); + vy_key_format = tuple_format_new(&vy_tuple_format_vtab, NULL, NULL, 0, + NULL, 0, 0, NULL, false); tuple_format_ref(vy_key_format); size_t mem_size = 64 * 1024 * 1024; @@ -201,8 +201,8 @@ create_test_mem(struct key_def *def) /* Create format */ struct key_def * const defs[] = { def }; struct tuple_format *format = - tuple_format_new(&vy_tuple_format_vtab, defs, def->part_count, - NULL, 0, NULL); + tuple_format_new(&vy_tuple_format_vtab, NULL, defs, + def->part_count, NULL, 0, 0, NULL, false); fail_if(format == NULL); /* Create mem */ @@ -219,8 +219,8 @@ create_test_cache(uint32_t *fields, uint32_t *types, *def = box_key_def_new(fields, types, key_cnt); assert(*def != NULL); vy_cache_create(cache, &cache_env, *def, true); - *format = tuple_format_new(&vy_tuple_format_vtab, def, 1, NULL, 0, - NULL); + *format = tuple_format_new(&vy_tuple_format_vtab, NULL, def, 1, NULL, 0, + 0, NULL, false); tuple_format_ref(*format); } diff --git a/test/unit/vy_mem.c b/test/unit/vy_mem.c index ebf3fbc77ecb26282f81f86772931ca70c6e8e9e..a13c58bbad5e844a54ce8c4509bf0374c6ffe237 100644 --- a/test/unit/vy_mem.c +++ b/test/unit/vy_mem.c @@ -77,8 +77,8 @@ test_iterator_restore_after_insertion() /* Create format */ struct tuple_format *format = tuple_format_new(&vy_tuple_format_vtab, - &key_def, 1, NULL, 0, - NULL); + NULL, &key_def, 1, NULL, + 0, 0, NULL, false); assert(format != NULL); tuple_format_ref(format); diff --git a/test/unit/vy_point_lookup.c b/test/unit/vy_point_lookup.c index 65dafcb233aec804982e8f87ddf3baaf871f3fa6..c19d3071ce1c4f2e3a87f3c7efb6a239f0fdbc7a 100644 --- a/test/unit/vy_point_lookup.c +++ b/test/unit/vy_point_lookup.c @@ -84,8 +84,8 @@ test_basic() vy_cache_create(&cache, &cache_env, key_def, true); struct tuple_format *format = tuple_format_new(&vy_tuple_format_vtab, - &key_def, 1, NULL, 0, - NULL); + NULL, &key_def, 1, NULL, + 0, 0, NULL, false); isnt(format, NULL, "tuple_format_new is not NULL"); tuple_format_ref(format);