From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2 3/5] vinyl: rename vy_log_record::index_id/space_id to index_def_id/space_def_id Date: Tue, 20 Mar 2018 14:29:03 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: I'm planning to assign a unique identifier to each vinyl index so that it could be used instead of lsn for identifying indexes in vylog. In order not to confuse it with the index ordinal number, let's rename vy_log_record::index_id to index_def_id and, for consistency, space_id to space_def_id. --- src/box/vy_log.c | 57 ++++++++++++++++++++++++++++---------------------------- src/box/vy_log.h | 10 +++++----- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/box/vy_log.c b/src/box/vy_log.c index 8b95282b..a6f03a55 100644 --- a/src/box/vy_log.c +++ b/src/box/vy_log.c @@ -73,8 +73,8 @@ enum vy_log_key { VY_LOG_KEY_RUN_ID = 2, VY_LOG_KEY_BEGIN = 3, VY_LOG_KEY_END = 4, - VY_LOG_KEY_INDEX_ID = 5, - VY_LOG_KEY_SPACE_ID = 6, + VY_LOG_KEY_INDEX_DEF_ID = 5, + VY_LOG_KEY_SPACE_DEF_ID = 6, VY_LOG_KEY_DEF = 7, VY_LOG_KEY_SLICE_ID = 8, VY_LOG_KEY_DUMP_LSN = 9, @@ -89,8 +89,8 @@ static const char *vy_log_key_name[] = { [VY_LOG_KEY_RUN_ID] = "run_id", [VY_LOG_KEY_BEGIN] = "begin", [VY_LOG_KEY_END] = "end", - [VY_LOG_KEY_INDEX_ID] = "index_id", - [VY_LOG_KEY_SPACE_ID] = "space_id", + [VY_LOG_KEY_INDEX_DEF_ID] = "index_def_id", + [VY_LOG_KEY_SPACE_DEF_ID] = "space_def_id", [VY_LOG_KEY_DEF] = "key_def", [VY_LOG_KEY_SLICE_ID] = "slice_id", [VY_LOG_KEY_DUMP_LSN] = "dump_lsn", @@ -231,13 +231,14 @@ vy_log_record_snprint(char *buf, int size, const struct vy_log_record *record) SNPRINT(total, mp_snprint, buf, size, record->end); SNPRINT(total, snprintf, buf, size, ", "); } - if (record->index_id > 0) + if (record->index_def_id > 0) SNPRINT(total, snprintf, buf, size, "%s=%"PRIu32", ", - vy_log_key_name[VY_LOG_KEY_INDEX_ID], record->index_id); - if (record->space_id > 0) + vy_log_key_name[VY_LOG_KEY_INDEX_DEF_ID], + record->index_def_id); + if (record->space_def_id > 0) SNPRINT(total, snprintf, buf, size, "%s=%"PRIu32", ", - vy_log_key_name[VY_LOG_KEY_SPACE_ID], - record->space_id); + vy_log_key_name[VY_LOG_KEY_SPACE_DEF_ID], + record->space_def_id); if (record->key_parts != NULL) { SNPRINT(total, snprintf, buf, size, "%s=", vy_log_key_name[VY_LOG_KEY_DEF]); @@ -335,14 +336,14 @@ vy_log_record_encode(const struct vy_log_record *record, size += p - record->end; n_keys++; } - if (record->index_id > 0) { - size += mp_sizeof_uint(VY_LOG_KEY_INDEX_ID); - size += mp_sizeof_uint(record->index_id); + if (record->index_def_id > 0) { + size += mp_sizeof_uint(VY_LOG_KEY_INDEX_DEF_ID); + size += mp_sizeof_uint(record->index_def_id); n_keys++; } - if (record->space_id > 0) { - size += mp_sizeof_uint(VY_LOG_KEY_SPACE_ID); - size += mp_sizeof_uint(record->space_id); + if (record->space_def_id > 0) { + size += mp_sizeof_uint(VY_LOG_KEY_SPACE_DEF_ID); + size += mp_sizeof_uint(record->space_def_id); n_keys++; } if (record->key_parts != NULL) { @@ -412,13 +413,13 @@ vy_log_record_encode(const struct vy_log_record *record, memcpy(pos, record->end, p - record->end); pos += p - record->end; } - if (record->index_id > 0) { - pos = mp_encode_uint(pos, VY_LOG_KEY_INDEX_ID); - pos = mp_encode_uint(pos, record->index_id); + if (record->index_def_id > 0) { + pos = mp_encode_uint(pos, VY_LOG_KEY_INDEX_DEF_ID); + pos = mp_encode_uint(pos, record->index_def_id); } - if (record->space_id > 0) { - pos = mp_encode_uint(pos, VY_LOG_KEY_SPACE_ID); - pos = mp_encode_uint(pos, record->space_id); + if (record->space_def_id > 0) { + pos = mp_encode_uint(pos, VY_LOG_KEY_SPACE_DEF_ID); + pos = mp_encode_uint(pos, record->space_def_id); } if (record->key_parts != NULL) { pos = mp_encode_uint(pos, VY_LOG_KEY_DEF); @@ -520,11 +521,11 @@ vy_log_record_decode(struct vy_log_record *record, record->end = mp_decode_array(&tmp) > 0 ? pos : NULL; mp_next(&pos); break; - case VY_LOG_KEY_INDEX_ID: - record->index_id = mp_decode_uint(&pos); + case VY_LOG_KEY_INDEX_DEF_ID: + record->index_def_id = mp_decode_uint(&pos); break; - case VY_LOG_KEY_SPACE_ID: - record->space_id = mp_decode_uint(&pos); + case VY_LOG_KEY_SPACE_DEF_ID: + record->space_def_id = mp_decode_uint(&pos); break; case VY_LOG_KEY_DEF: { uint32_t part_count = mp_decode_array(&pos); @@ -1765,7 +1766,7 @@ vy_recovery_process_record(struct vy_recovery *recovery, switch (record->type) { case VY_LOG_CREATE_INDEX: rc = vy_recovery_create_index(recovery, record->index_lsn, - record->index_id, record->space_id, + record->index_def_id, record->space_def_id, record->key_parts, record->key_part_count); break; case VY_LOG_DROP_INDEX: @@ -2013,8 +2014,8 @@ vy_log_append_index(struct xlog *xlog, struct vy_index_recovery_info *index) vy_log_record_init(&record); record.type = VY_LOG_CREATE_INDEX; record.index_lsn = index->index_lsn; - record.index_id = index->index_id; - record.space_id = index->space_id; + record.index_def_id = index->index_id; + record.space_def_id = index->space_id; record.key_parts = index->key_parts; record.key_part_count = index->key_part_count; if (vy_log_append_record(xlog, &record) != 0) diff --git a/src/box/vy_log.h b/src/box/vy_log.h index 8fbacd0f..ac9b987e 100644 --- a/src/box/vy_log.h +++ b/src/box/vy_log.h @@ -65,7 +65,7 @@ struct mh_i64ptr_t; enum vy_log_record_type { /** * Create a new vinyl index. - * Requires vy_log_record::index_lsn, index_id, space_id, + * Requires vy_log_record::index_lsn, index_def_id, space_def_id, * key_def (with primary key parts). */ VY_LOG_CREATE_INDEX = 0, @@ -185,9 +185,9 @@ struct vy_log_record { */ const char *end; /** Ordinal index number in the space. */ - uint32_t index_id; + uint32_t index_def_id; /** Space ID. */ - uint32_t space_id; + uint32_t space_def_id; /** Index key definition, as defined by the user. */ const struct key_def *key_def; /** Array of key part definitions. */ @@ -503,8 +503,8 @@ vy_log_create_index(int64_t index_lsn, uint32_t index_id, uint32_t space_id, vy_log_record_init(&record); record.type = VY_LOG_CREATE_INDEX; record.index_lsn = index_lsn; - record.index_id = index_id; - record.space_id = space_id; + record.index_def_id = index_id; + record.space_def_id = space_id; record.key_def = key_def; vy_log_write(&record); } -- 2.11.0