From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Kirill Shcherbatov <kshcherbatov@tarantool.org> Cc: tarantool-patches@freelists.org Subject: Re: [PATCH v4 10/14] box: introduce JSON indexes Date: Tue, 16 Oct 2018 12:33:32 +0300 [thread overview] Message-ID: <20181016093332.vocmxag2dwbbr6uy@esperanza> (raw) In-Reply-To: <a39e6b722b3dba1d2fd6d0d3a8f05916a8b58223.1539244271.git.kshcherbatov@tarantool.org> On Thu, Oct 11, 2018 at 10:58:42AM +0300, Kirill Shcherbatov wrote: > @@ -477,34 +833,39 @@ tuple_init_field_map(struct tuple_format *format, uint32_t *field_map, > } > > /* first field is simply accessible, so we do not store offset to it */ > - enum mp_type mp_type = mp_typeof(*pos); > - const struct tuple_field *field = &format->fields[0]; > - if (key_mp_type_validate(field->type, mp_type, ER_FIELD_TYPE, > - TUPLE_INDEX_BASE, field->is_nullable)) > - return -1; > - mp_next(&pos); > - /* other fields...*/ > - ++field; > - uint32_t i = 1; > - uint32_t defined_field_count = MIN(field_count, format->field_count); > - if (field_count < format->index_field_count) { > + struct tuple_field *field = &format->fields[0]; > + uint32_t i = 0; > + if (field_count < format->index_field_count || > + json_tree_node_children_count(&field->path_tree_node) == 0) { > /* > - * Nullify field map to be able to detect by 0, > - * which key fields are absent in tuple_field(). > - */ > + * Nullify field map to be able to detect by 0, > + * which key fields are absent in tuple_field(). > + */ > memset((char *)field_map - format->field_map_size, 0, > - format->field_map_size); > + format->field_map_size); > } > - for (; i < defined_field_count; ++i, ++field) { > - mp_type = mp_typeof(*pos); > + if (json_tree_node_children_count(&field->path_tree_node) == 0) { > + enum mp_type mp_type = mp_typeof(*pos); > if (key_mp_type_validate(field->type, mp_type, ER_FIELD_TYPE, > - i + TUPLE_INDEX_BASE, > - field->is_nullable)) > + TUPLE_INDEX_BASE, field->is_nullable)) > + return -1; > + mp_next(&pos); > + ++field; > + ++i; > + } > + size_t off_stack_size = > + format->max_path_tree_depth * sizeof(const char *); > + const char **off_stack = region_alloc(&fiber()->gc, off_stack_size); > + if (off_stack == NULL) { > + diag_set(OutOfMemory, off_stack_size, "region_alloc", > + "off_stack"); > + return -1; > + } > + uint32_t defined_field_count = MIN(field_count, format->field_count); > + for (; i < defined_field_count; ++i, ++field) { > + if (tuple_field_tree_parse_raw(field, pos, tuple, i, field_map, > + off_stack) != 0) > return -1; > - if (field->offset_slot != TUPLE_OFFSET_SLOT_NIL) { > - field_map[field->offset_slot] = > - (uint32_t) (pos - tuple); > - } > mp_next(&pos); > } > return 0; > @@ -108,6 +109,10 @@ struct tuple_field { > bool is_key_part; > /** True, if a field can store NULL. */ > bool is_nullable; > + /** JSON path tree max depth. */ > + uint32_t path_tree_depth; > + /** JSON root path tree node for registered indexes. */ > + struct json_tree_node path_tree_node; > }; For the record. After discussion with Kostja, we agreed that a json tree should be rooted at struct tuple_format rather than tuple_field so that top level fields are accessed in the same fashion as nested fields. Also, a tuple field map should be initialized as msgpack gets parsed rather than walking over a json tree and looking up fields in msgpack, because that would be more efficient.
next prev parent reply other threads:[~2018-10-16 9:33 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-11 7:58 [PATCH v4 00/14] box: indexes by JSON path Kirill Shcherbatov 2018-10-11 7:58 ` [PATCH v4 01/14] box: refactor key_def_find routine Kirill Shcherbatov 2018-10-15 17:27 ` Vladimir Davydov 2018-10-11 7:58 ` [PATCH v4 10/14] box: introduce JSON indexes Kirill Shcherbatov 2018-10-16 9:33 ` Vladimir Davydov [this message] 2018-10-11 7:58 ` [PATCH v4 11/14] box: introduce has_json_paths flag in templates Kirill Shcherbatov 2018-10-11 7:58 ` [PATCH v4 12/14] box: tune tuple_field_raw_by_path for indexed data Kirill Shcherbatov 2018-10-11 7:58 ` [PATCH v4 13/14] box: introduce offset slot cache in key_part Kirill Shcherbatov 2018-10-11 7:58 ` [PATCH v4 14/14] box: specify indexes in user-friendly form Kirill Shcherbatov 2018-10-11 7:58 ` [PATCH v4 02/14] box: introduce key_def_parts_are_sequential Kirill Shcherbatov 2018-10-15 17:29 ` Vladimir Davydov 2018-10-11 7:58 ` [PATCH v4 03/14] box: introduce tuple_field_by_relative_path Kirill Shcherbatov 2018-10-15 17:46 ` Vladimir Davydov 2018-10-11 7:58 ` [PATCH v4 04/14] box: introduce tuple_format_add_key_part Kirill Shcherbatov 2018-10-15 19:39 ` Vladimir Davydov 2018-10-11 7:58 ` [tarantool-patches] [PATCH v4 05/14] box: introduce tuple_format_sizeof routine Kirill Shcherbatov 2018-10-15 17:52 ` Vladimir Davydov 2018-10-11 7:58 ` [PATCH v4 06/14] box: move tuple_field_go_to_{index,key} definition Kirill Shcherbatov 2018-10-16 8:15 ` Vladimir Davydov 2018-10-11 7:58 ` [PATCH v4 07/14] box: drop format const qualifier in *init_field_map Kirill Shcherbatov 2018-10-11 7:58 ` [PATCH v4 08/14] lib: implement JSON tree class for json library Kirill Shcherbatov 2018-10-16 8:26 ` Vladimir Davydov 2018-10-11 7:58 ` [PATCH v4 09/14] lib: introduce json_path_normalize routine Kirill Shcherbatov 2018-10-16 8:39 ` Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20181016093332.vocmxag2dwbbr6uy@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v4 10/14] box: introduce JSON indexes' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox