[tarantool-patches] [PATCH 21/25] vinyl: add function to create surrogate deletes from raw msgpack

  • From: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
  • To: kostja@xxxxxxxxxxxxx
  • Date: Fri, 27 Jul 2018 14:30:01 +0300

Currently, there's only vy_stmt_new_surrogate_delete(), which takes a
tuple. Let's add vy_stmt_new_surrogate_delete_raw(), which takes raw
msgpack data.

Needed for #2129
---
 src/box/vy_stmt.c |  7 +++----
 src/box/vy_stmt.h | 12 +++++++++++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c
index 09daa7f4..f4c3dd18 100644
--- a/src/box/vy_stmt.c
+++ b/src/box/vy_stmt.c
@@ -388,11 +388,10 @@ vy_stmt_new_surrogate_delete_from_key(const char *key,
 }
 
 struct tuple *
-vy_stmt_new_surrogate_delete(struct tuple_format *format,
-                            const struct tuple *src)
+vy_stmt_new_surrogate_delete_raw(struct tuple_format *format,
+                                const char *src_data, const char *src_data_end)
 {
-       uint32_t src_size;
-       const char *src_data = tuple_data_range(src, &src_size);
+       uint32_t src_size = src_data_end - src_data;
        uint32_t total_size = src_size + format->field_map_size;
        /* Surrogate tuple uses less memory than the original tuple */
        char *data = region_alloc(&fiber()->gc, total_size);
diff --git a/src/box/vy_stmt.h b/src/box/vy_stmt.h
index 878a27f7..273d5e84 100644
--- a/src/box/vy_stmt.h
+++ b/src/box/vy_stmt.h
@@ -496,8 +496,18 @@ vy_stmt_new_surrogate_delete_from_key(const char *key,
  * @retval     NULL Memory or fields format error.
  */
 struct tuple *
+vy_stmt_new_surrogate_delete_raw(struct tuple_format *format,
+                                const char *data, const char *data_end);
+
+/** @copydoc vy_stmt_new_surrogate_delete_raw. */
+static inline struct tuple *
 vy_stmt_new_surrogate_delete(struct tuple_format *format,
-                            const struct tuple *tuple);
+                            const struct tuple *tuple)
+{
+       uint32_t size;
+       const char *data = tuple_data_range(tuple, &size);
+       return vy_stmt_new_surrogate_delete_raw(format, data, data + size);
+}
 
 /**
  * Create the REPLACE statement from raw MessagePack data.
-- 
2.11.0


Other related posts:

  • » [tarantool-patches] [PATCH 21/25] vinyl: add function to create surrogate deletes from raw msgpack - Vladimir Davydov