[PATCH 11/13] xrow: factor out helper for setting REPLACE request body

Vladimir Davydov vdavydov.dev at gmail.com
Sat Aug 10 13:03:38 MSK 2019


We will reuse it to relay a snapshot to a newly joined replica.
---
 src/box/iproto_constants.h | 11 +++++++++++
 src/box/memtx_engine.c     |  6 +-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h
index 126d7335..724cce53 100644
--- a/src/box/iproto_constants.h
+++ b/src/box/iproto_constants.h
@@ -343,6 +343,17 @@ struct PACKED request_replace_body {
 	uint8_t k_tuple;
 };
 
+static inline void
+request_replace_body_create(struct request_replace_body *body,
+			    uint32_t space_id)
+{
+	body->m_body = 0x82; /* map of two elements. */
+	body->k_space_id = IPROTO_SPACE_ID;
+	body->m_space_id = 0xce; /* uint32 */
+	body->v_space_id = mp_bswap_u32(space_id);
+	body->k_tuple = IPROTO_TUPLE;
+}
+
 /**
  * Xrow keys for Vinyl run information.
  * @sa struct vy_run_info.
diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
index c92ed82b..ea197cad 100644
--- a/src/box/memtx_engine.c
+++ b/src/box/memtx_engine.c
@@ -432,11 +432,7 @@ checkpoint_write_tuple(struct xlog *l, uint32_t space_id, uint32_t group_id,
 		       const char *data, uint32_t size)
 {
 	struct request_replace_body body;
-	body.m_body = 0x82; /* map of two elements. */
-	body.k_space_id = IPROTO_SPACE_ID;
-	body.m_space_id = 0xce; /* uint32 */
-	body.v_space_id = mp_bswap_u32(space_id);
-	body.k_tuple = IPROTO_TUPLE;
+	request_replace_body_create(&body, space_id);
 
 	struct xrow_header row;
 	memset(&row, 0, sizeof(struct xrow_header));
-- 
2.20.1




More information about the Tarantool-patches mailing list