From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org, kostja@tarantool.org
Subject: Re: [PATCH v7 5/5] box: specify indexes in user-friendly form
Date: Thu, 10 Jan 2019 13:21:06 +0300 [thread overview]
Message-ID: <20190110102106.5kb6y7hhyifpsehy@esperanza> (raw)
In-Reply-To: <6e7ca7dcfd69ce7f9cc787490f2c32a1ab2ad37c.1547022001.git.kshcherbatov@tarantool.org>
On Wed, Jan 09, 2019 at 11:29:40AM +0300, Kirill Shcherbatov wrote:
> Implemented a more convenient interface for creating an index
> by JSON path. Instead of specifying fieldno and relative path
> it comes possible to pass full JSON path to data.
>
> Closes #1012
>
> @TarantoolBot document
> Title: Indexes by JSON path
> Sometimes field data could have complex document structure.
> When this structure is consistent across whole document,
> you are able to create an index by JSON path.
>
> Example:
> s = box.schema.space.create('sample')
> format = {{'id', 'unsigned'}, {'data', 'map'}}
> s:format(format)
> -- explicit JSON index creation
> age_idx = s:create_index('age', {{2, 'number', path = ".age"}})
> -- user-friendly syntax for JSON index creation
> parts = {{'data.FIO["fname"]', 'str'}, {'data.FIO["sname"]', 'str'},
> {'data.age', 'number'}}
> info_idx = s:create_index('info', {parts = parts}})
> s:insert({1, {FIO={fname="James", sname="Bond"}, age=35}})
> ---
> src/box/lua/index.c | 64 +++++++++++++++++++++++++++++++++++++++
> src/box/lua/schema.lua | 22 +++++++-------
> test/engine/json.result | 28 +++++++++++++++++
> test/engine/json.test.lua | 8 +++++
> 4 files changed, 111 insertions(+), 11 deletions(-)
>
> diff --git a/src/box/lua/index.c b/src/box/lua/index.c
> index 6265c044a..9b04c5d9a 100644
> --- a/src/box/lua/index.c
> +++ b/src/box/lua/index.c
> @@ -35,6 +35,9 @@
> #include "box/box.h"
> #include "box/index.h"
> #include "box/lua/tuple.h"
> +#include "box/schema.h"
> +#include "box/tuple_format.h"
> +#include "json/json.h"
> #include "box/lua/misc.h" /* lbox_encode_tuple_on_gc() */
>
> /** {{{ box.index Lua library: access to spaces and indexes
> @@ -328,6 +331,66 @@ lbox_index_compact(lua_State *L)
> return 0;
> }
>
> +/**
> + * Resolve field index by absolute JSON path first component and
> + * return relative JSON path.
> + */
> +static int
> +lbox_index_path_resolve(struct lua_State *L)
> +{
> + if (lua_gettop(L) != 3 ||
> + !lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isstring(L, 3)) {
> + return luaL_error(L, "Usage box.internal."
> + "path_resolve(part_id, space_id, path)");
> + }
> + uint32_t part_id = lua_tonumber(L, 1);
> + uint32_t space_id = lua_tonumber(L, 2);
Are you kidding me? You silently ignored my comments to this patch
TWICE!
https://www.freelists.org/post/tarantool-patches/PATCH-v6-88-box-specify-indexes-in-userfriendly-form,1
prev parent reply other threads:[~2019-01-10 10:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 8:29 [PATCH v7 0/5] box: Indexes by JSON path Kirill Shcherbatov
2019-01-09 8:29 ` [PATCH v7 1/5] box: introduce JSON Indexes Kirill Shcherbatov
2019-01-10 10:16 ` Vladimir Davydov
2019-01-09 8:29 ` [PATCH v7 2/5] box: introduce has_json_paths flag in templates Kirill Shcherbatov
2019-01-09 8:29 ` [PATCH v7 3/5] box: tune tuple_field_raw_by_path for indexed data Kirill Shcherbatov
2019-01-09 8:29 ` [PATCH v7 4/5] box: introduce offset_slot cache in key_part Kirill Shcherbatov
2019-01-10 11:28 ` Vladimir Davydov
2019-01-09 8:29 ` [PATCH v7 5/5] box: specify indexes in user-friendly form Kirill Shcherbatov
2019-01-10 10:21 ` Vladimir Davydov [this message]
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=20190110102106.5kb6y7hhyifpsehy@esperanza \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=kshcherbatov@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH v7 5/5] box: specify indexes in user-friendly form' \
/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