From 41e08261c51359a7d48273cb0a6d2e899b0e4004 Mon Sep 17 00:00:00 2001 From: Vladimir Davydov <vdavydov.dev@gmail.com> Date: Tue, 14 Nov 2017 18:43:56 +0300 Subject: [PATCH] vinyl: zap vy_key_snprint() and vy_key_str() Use generic tuple_snprint() and tuple_str() instead. --- src/box/vy_index.c | 5 ++--- src/box/vy_range.c | 6 ++---- src/box/vy_stmt.c | 28 ---------------------------- src/box/vy_stmt.h | 24 ++++-------------------- 4 files changed, 8 insertions(+), 55 deletions(-) diff --git a/src/box/vy_index.c b/src/box/vy_index.c index b99fcbcc38..a1f19fb2fc 100644 --- a/src/box/vy_index.c +++ b/src/box/vy_index.c @@ -999,8 +999,6 @@ vy_index_split_range(struct vy_index *index, struct vy_range *range) } part->compact_priority = range->compact_priority; } - tuple_unref(split_key); - split_key = NULL; /* * Log change in metadata. @@ -1036,11 +1034,12 @@ vy_index_split_range(struct vy_index *index, struct vy_range *range) index->range_tree_version++; say_info("%s: split range %s by key %s", vy_index_name(index), - vy_range_str(range), vy_key_str(split_key_raw)); + vy_range_str(range), tuple_str(split_key)); rlist_foreach_entry(slice, &range->slices, in_range) vy_slice_wait_pinned(slice); vy_range_delete(range); + tuple_unref(split_key); return true; fail: for (int i = 0; i < n_parts; i++) { diff --git a/src/box/vy_range.c b/src/box/vy_range.c index 68f1cae83a..9f29a5e2c7 100644 --- a/src/box/vy_range.c +++ b/src/box/vy_range.c @@ -224,14 +224,12 @@ vy_range_snprint(char *buf, int size, const struct vy_range *range) int total = 0; SNPRINT(total, snprintf, buf, size, "("); if (range->begin != NULL) - SNPRINT(total, vy_key_snprint, buf, size, - tuple_data(range->begin)); + SNPRINT(total, tuple_snprint, buf, size, range->begin); else SNPRINT(total, snprintf, buf, size, "-inf"); SNPRINT(total, snprintf, buf, size, ".."); if (range->end != NULL) - SNPRINT(total, vy_key_snprint, buf, size, - tuple_data(range->end)); + SNPRINT(total, tuple_snprint, buf, size, range->end); else SNPRINT(total, snprintf, buf, size, "inf"); SNPRINT(total, snprintf, buf, size, ")"); diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c index df545ac3be..cbbaee2a9b 100644 --- a/src/box/vy_stmt.c +++ b/src/box/vy_stmt.c @@ -599,25 +599,6 @@ vy_stmt_decode(struct xrow_header *xrow, const struct key_def *key_def, return stmt; } -int -vy_key_snprint(char *buf, int size, const char *key) -{ - if (key == NULL) - return snprintf(buf, size, "[]"); - - int total = 0; - SNPRINT(total, snprintf, buf, size, "["); - uint32_t count = mp_decode_array(&key); - for (uint32_t i = 0; i < count; i++) { - if (i > 0) - SNPRINT(total, snprintf, buf, size, ", "); - SNPRINT(total, mp_snprint, buf, size, key); - mp_next(&key); - } - SNPRINT(total, snprintf, buf, size, "]"); - return total; -} - int vy_stmt_snprint(char *buf, int size, const struct tuple *stmt) { @@ -640,15 +621,6 @@ vy_stmt_snprint(char *buf, int size, const struct tuple *stmt) return total; } -const char * -vy_key_str(const char *key) -{ - char *buf = tt_static_buf(); - if (vy_key_snprint(buf, TT_STATIC_BUF_LEN, key) < 0) - return "<failed to format key>"; - return buf; -} - const char * vy_stmt_str(const struct tuple *stmt) { diff --git a/src/box/vy_stmt.h b/src/box/vy_stmt.h index b5bd9ec210..98dfcae816 100644 --- a/src/box/vy_stmt.h +++ b/src/box/vy_stmt.h @@ -630,14 +630,6 @@ vy_stmt_decode(struct xrow_header *xrow, const struct key_def *key_def, struct tuple_format *upsert_format, bool is_primary); -/** - * Format a key into string. - * Example: [1, 2, "string"] - * \sa mp_snprint() - */ -int -vy_key_snprint(char *buf, int size, const char *key); - /** * Format a statement into string. * Example: REPLACE([1, 2, "string"], lsn=48) @@ -646,18 +638,10 @@ int vy_stmt_snprint(char *buf, int size, const struct tuple *stmt); /* -* Format a key into string using a static buffer. -* Useful for gdb and say_debug(). -* \sa vy_key_snprint() -*/ -const char * -vy_key_str(const char *key); - -/* -* Format a statement into string using a static buffer. -* Useful for gdb and say_debug(). -* \sa vy_stmt_snprint() -*/ + * Format a statement into string using a static buffer. + * Useful for gdb and say_debug(). + * \sa vy_stmt_snprint() + */ const char * vy_stmt_str(const struct tuple *stmt); -- GitLab