Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH 06/13] tuple: expose JSON go_to_key and go_to_index functions
Date: Tue, 13 Aug 2019 01:05:16 +0200	[thread overview]
Message-ID: <643278ac757e94711bba2c100c329ef2c611acd0.1565649886.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1565649886.git.v.shpilevoy@tarantool.org>

They are needed in JSON path update for a case, when a final part
of the path may not exist, and go_to_path returns an error.

That case is '=' and '!' on not existing fields. For example,
in {'=', '[1][2][3]', 20} field [3] can be not existing.

For these cases JSON update will have its own implementation of
go_to_path allowing optional last field.

Needed for #1261
---
 src/box/tuple.c | 21 ++-------------------
 src/box/tuple.h | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/src/box/tuple.c b/src/box/tuple.c
index bf4ea711d..261505f9a 100644
--- a/src/box/tuple.c
+++ b/src/box/tuple.c
@@ -385,15 +385,7 @@ tuple_free(void)
 
 /* {{{ tuple_field_* getters */
 
-/**
- * Propagate @a field to MessagePack(field)[index].
- * @param[in][out] field Field to propagate.
- * @param index 0-based index to propagate to.
- *
- * @retval  0 Success, the index was found.
- * @retval -1 Not found.
- */
-static inline int
+int
 tuple_field_go_to_index(const char **field, uint64_t index)
 {
 	enum mp_type type = mp_typeof(**field);
@@ -428,16 +420,7 @@ tuple_field_go_to_index(const char **field, uint64_t index)
 	return -1;
 }
 
-/**
- * Propagate @a field to MessagePack(field)[key].
- * @param[in][out] field Field to propagate.
- * @param key Key to propagate to.
- * @param len Length of @a key.
- *
- * @retval  0 Success, the index was found.
- * @retval -1 Not found.
- */
-static inline int
+int
 tuple_field_go_to_key(const char **field, const char *key, int len)
 {
 	enum mp_type type = mp_typeof(**field);
diff --git a/src/box/tuple.h b/src/box/tuple.h
index 4c4050ca8..ab0c7a99b 100644
--- a/src/box/tuple.h
+++ b/src/box/tuple.h
@@ -551,6 +551,29 @@ int
 tuple_go_to_path(const char **data, const char *path, uint32_t path_len,
 		 int multikey_idx);
 
+/**
+ * Propagate @a field to MessagePack(field)[index].
+ * @param[in][out] field Field to propagate.
+ * @param index 0-based index to propagate to.
+ *
+ * @retval  0 Success, the index was found.
+ * @retval -1 Not found.
+ */
+int
+tuple_field_go_to_index(const char **field, uint64_t index);
+
+/**
+ * Propagate @a field to MessagePack(field)[key].
+ * @param[in][out] field Field to propagate.
+ * @param key Key to propagate to.
+ * @param len Length of @a key.
+ *
+ * @retval  0 Success, the index was found.
+ * @retval -1 Not found.
+ */
+int
+tuple_field_go_to_key(const char **field, const char *key, int len);
+
 /**
  * Get tuple field by field index, relative JSON path and
  * multikey_idx.
-- 
2.20.1 (Apple Git-117)

  parent reply	other threads:[~2019-08-12 23:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-12 23:05 [tarantool-patches] [PATCH 00/13] JSON updates Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 01/13] tuple: remove alloc and alloc_ctx args from update() Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 10/13] tuple: enable JSON bar updates Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 11/13] tuple: make update operation tokens consumable Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 12/13] tuple: JSON updates support intersection by arrays Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 13/13] tuple: JSON updates support intersection by maps Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 02/13] rope: make rope library macro template Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 03/13] tuple: relax struct tuple_update dependency on rope Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 04/13] int96: add a missing header Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 05/13] tuple: implement update by field name Vladislav Shpilevoy
2019-08-12 23:05 ` Vladislav Shpilevoy [this message]
2019-08-12 23:05 ` [tarantool-patches] [PATCH 07/13] tuple: rework updates to improve code extendibility Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 08/13] json: lexer_eof and token_cmp helper functions Vladislav Shpilevoy
2019-08-12 23:05 ` [tarantool-patches] [PATCH 09/13] tuple: account the whole array in field.data and size Vladislav Shpilevoy
2019-08-20 18:49 ` [tarantool-patches] Re: [PATCH 00/13] JSON updates Vladislav Shpilevoy

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=643278ac757e94711bba2c100c329ef2c611acd0.1565649886.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 06/13] tuple: expose JSON go_to_key and go_to_index functions' \
    /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