From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 2/3] vinyl: link all indexes of the same space Date: Fri, 13 Jul 2018 13:53:53 +0300 Message-Id: In-Reply-To: References: <22418dc475632b06aee6e8db562dc4467d6a0a31.1531065648.git.vdavydov.dev@gmail.com> In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: After generating a deferred DELETE, we need to insert it into all secondary indexes. Let's link all LSM trees of the same space into a list so that we can iterate over secondary indexes of a space given the primary index. Needed for #2129 --- src/box/vinyl.c | 1 + src/box/vy_lsm.c | 7 ++++++- src/box/vy_lsm.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 2d1a6fc0..ba875040 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -1148,6 +1148,7 @@ vinyl_space_swap_index(struct space *old_space, struct space *new_space, SWAP(old_lsm->opts, new_lsm->opts); key_def_swap(old_lsm->key_def, new_lsm->key_def); key_def_swap(old_lsm->cmp_def, new_lsm->cmp_def); + rlist_swap(&old_lsm->list, &new_lsm->list); /* Update pointer to the primary key. */ vy_lsm_update_pk(old_lsm, vy_lsm(old_space->index_map[0])); diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c index cb3c436f..2e3e7947 100644 --- a/src/box/vy_lsm.c +++ b/src/box/vy_lsm.c @@ -194,8 +194,12 @@ vy_lsm_new(struct vy_lsm_env *lsm_env, struct vy_cache_env *cache_env, vy_range_heap_create(&lsm->range_heap); rlist_create(&lsm->runs); lsm->pk = pk; - if (pk != NULL) + if (pk != NULL) { vy_lsm_ref(pk); + rlist_add_tail(&pk->list, &lsm->list); + } else { + rlist_create(&lsm->list); + } lsm->mem_format = format; tuple_format_ref(lsm->mem_format); lsm->in_dump.pos = UINT32_MAX; @@ -253,6 +257,7 @@ vy_lsm_delete(struct vy_lsm *lsm) lsm->env->lsm_count--; + rlist_del(&lsm->list); if (lsm->pk != NULL) vy_lsm_unref(lsm->pk); diff --git a/src/box/vy_lsm.h b/src/box/vy_lsm.h index f0b7ec9c..9849e455 100644 --- a/src/box/vy_lsm.h +++ b/src/box/vy_lsm.h @@ -204,6 +204,8 @@ struct vy_lsm { * by each secondary index. */ struct vy_lsm *pk; + /** List of all LSM trees of the same space. */ + struct rlist list; /** LSM tree statistics. */ struct vy_lsm_stat stat; /** -- 2.11.0