From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 01/12] index: add commit_modify virtual method Date: Sun, 1 Apr 2018 12:05:28 +0300 Message-Id: <9a5dbd10582f96364daaebae27b28bc5900f54fa.1522572160.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: The new method is called after successful update of index definition. It is passed the signature of the WAL record that committed the operation. It will be used by Vinyl to update key definition in vylog. --- src/box/alter.cc | 9 +++++++++ src/box/index.cc | 5 +++++ src/box/index.h | 15 +++++++++++++++ src/box/memtx_bitset.c | 1 + src/box/memtx_hash.c | 1 + src/box/memtx_rtree.c | 1 + src/box/memtx_tree.c | 1 + src/box/sysview_index.c | 1 + src/box/vinyl.c | 1 + 9 files changed, 35 insertions(+) diff --git a/src/box/alter.cc b/src/box/alter.cc index 6e5d6e52..eb548e0b 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -1109,6 +1109,7 @@ public: struct index_def *old_index_def; virtual void alter_def(struct alter_space *alter); virtual void alter(struct alter_space *alter); + virtual void commit(struct alter_space *alter, int64_t lsn); virtual void rollback(struct alter_space *alter); virtual ~ModifyIndex(); }; @@ -1142,6 +1143,14 @@ ModifyIndex::alter(struct alter_space *alter) } void +ModifyIndex::commit(struct alter_space *alter, int64_t signature) +{ + struct index *new_index = space_index(alter->new_space, + new_index_def->iid); + index_commit_modify(new_index, signature); +} + +void ModifyIndex::rollback(struct alter_space *alter) { assert(old_index_def->iid == new_index_def->iid); diff --git a/src/box/index.cc b/src/box/index.cc index d02cbbc5..11a6683d 100644 --- a/src/box/index.cc +++ b/src/box/index.cc @@ -546,6 +546,11 @@ generic_index_abort_create(struct index *) } void +generic_index_commit_modify(struct index *, int64_t) +{ +} + +void generic_index_commit_drop(struct index *) { } diff --git a/src/box/index.h b/src/box/index.h index b8b0feb2..2e43d999 100644 --- a/src/box/index.h +++ b/src/box/index.h @@ -356,6 +356,14 @@ struct index_vtab { */ void (*abort_create)(struct index *index); /** + * Called after WAL write to comit index definition update. + * Must not fail. + * + * @signature is the LSN that was assigned to the row + * that modified the index. + */ + void (*commit_modify)(struct index *index, int64_t signature); + /** * Called after WAL write to commit index drop. * Must not fail. */ @@ -480,6 +488,12 @@ index_abort_create(struct index *index) } static inline void +index_commit_modify(struct index *index, int64_t signature) +{ + index->vtab->commit_modify(index, signature); +} + +static inline void index_commit_drop(struct index *index) { index->vtab->commit_drop(index); @@ -599,6 +613,7 @@ index_end_build(struct index *index) */ void generic_index_commit_create(struct index *, int64_t); void generic_index_abort_create(struct index *); +void generic_index_commit_modify(struct index *, int64_t); void generic_index_commit_drop(struct index *); void generic_index_update_def(struct index *); ssize_t generic_index_size(struct index *); diff --git a/src/box/memtx_bitset.c b/src/box/memtx_bitset.c index c2685a65..0e546217 100644 --- a/src/box/memtx_bitset.c +++ b/src/box/memtx_bitset.c @@ -458,6 +458,7 @@ static const struct index_vtab memtx_bitset_index_vtab = { /* .destroy = */ memtx_bitset_index_destroy, /* .commit_create = */ generic_index_commit_create, /* .abort_create = */ generic_index_abort_create, + /* .commit_modify = */ generic_index_commit_modify, /* .commit_drop = */ generic_index_commit_drop, /* .update_def = */ generic_index_update_def, /* .size = */ memtx_bitset_index_size, diff --git a/src/box/memtx_hash.c b/src/box/memtx_hash.c index 4dab23cd..9c72af5d 100644 --- a/src/box/memtx_hash.c +++ b/src/box/memtx_hash.c @@ -382,6 +382,7 @@ static const struct index_vtab memtx_hash_index_vtab = { /* .destroy = */ memtx_hash_index_destroy, /* .commit_create = */ generic_index_commit_create, /* .abort_create = */ generic_index_abort_create, + /* .commit_modify = */ generic_index_commit_modify, /* .commit_drop = */ generic_index_commit_drop, /* .update_def = */ memtx_hash_index_update_def, /* .size = */ memtx_hash_index_size, diff --git a/src/box/memtx_rtree.c b/src/box/memtx_rtree.c index dea68897..373d658e 100644 --- a/src/box/memtx_rtree.c +++ b/src/box/memtx_rtree.c @@ -296,6 +296,7 @@ static const struct index_vtab memtx_rtree_index_vtab = { /* .destroy = */ memtx_rtree_index_destroy, /* .commit_create = */ generic_index_commit_create, /* .abort_create = */ generic_index_abort_create, + /* .commit_modify = */ generic_index_commit_modify, /* .commit_drop = */ generic_index_commit_drop, /* .update_def = */ generic_index_update_def, /* .size = */ memtx_rtree_index_size, diff --git a/src/box/memtx_tree.c b/src/box/memtx_tree.c index 06b74e11..7178a4bc 100644 --- a/src/box/memtx_tree.c +++ b/src/box/memtx_tree.c @@ -583,6 +583,7 @@ static const struct index_vtab memtx_tree_index_vtab = { /* .destroy = */ memtx_tree_index_destroy, /* .commit_create = */ generic_index_commit_create, /* .abort_create = */ generic_index_abort_create, + /* .commit_modify = */ generic_index_commit_modify, /* .commit_drop = */ generic_index_commit_drop, /* .update_def = */ memtx_tree_index_update_def, /* .size = */ memtx_tree_index_size, diff --git a/src/box/sysview_index.c b/src/box/sysview_index.c index be17fd32..e2b2fb96 100644 --- a/src/box/sysview_index.c +++ b/src/box/sysview_index.c @@ -162,6 +162,7 @@ static const struct index_vtab sysview_index_vtab = { /* .destroy = */ sysview_index_destroy, /* .commit_create = */ generic_index_commit_create, /* .abort_create = */ generic_index_abort_create, + /* .commit_modify = */ generic_index_commit_modify, /* .commit_drop = */ generic_index_commit_drop, /* .update_def = */ generic_index_update_def, /* .size = */ generic_index_size, diff --git a/src/box/vinyl.c b/src/box/vinyl.c index ce51fdd0..cebe1615 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -3935,6 +3935,7 @@ static const struct index_vtab vinyl_index_vtab = { /* .destroy = */ vinyl_index_destroy, /* .commit_create = */ vinyl_index_commit_create, /* .abort_create = */ generic_index_abort_create, + /* .commit_modify = */ generic_index_commit_modify, /* .commit_drop = */ vinyl_index_commit_drop, /* .update_def = */ generic_index_update_def, /* .size = */ vinyl_index_size, -- 2.11.0