[patches] [vtab 1/1] Add ephemeral truncate method to space vtab

Nikita Pettik korablev at tarantool.org
Thu Jan 25 19:05:49 MSK 2018


It turns out that it is not enough to simply call space_delete() on
ephemeral space in order to delete space. Tuples should also be
unreferred in case of memtx engine; other engines don't support
ephemeral tables yet, but additional actoins seem to be needed. In this
regard, truncate method for ephemeral spaces has been added to space
vtab. For memtx engine it just calls memtx_space_prune() which iterates
through primary index and unrefs all tuples.

Signed-off-by: Nikita Pettik <korablev at tarantool.org>
---
 src/box/memtx_space.c    | 7 +++++++
 src/box/space.h          | 2 ++
 src/box/sysview_engine.c | 8 ++++++++
 src/box/vinyl.c          | 8 ++++++++
 4 files changed, 25 insertions(+)

diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c
index 912dd2ea0..3e25692a5 100644
--- a/src/box/memtx_space.c
+++ b/src/box/memtx_space.c
@@ -942,6 +942,12 @@ fail:
 	panic("failed to prune space");
 }
 
+static void
+memtx_space_ephemeral_truncate(struct space *space)
+{
+	memtx_space_prune(space);
+}
+
 static void
 memtx_space_commit_truncate(struct space *old_space,
 			    struct space *new_space)
@@ -987,6 +993,7 @@ static const struct space_vtab memtx_space_vtab = {
 	/* .execute_upsert = */ memtx_space_execute_upsert,
 	/* .ephemeral_replace = */ memtx_space_ephemeral_replace,
 	/* .ephemeral_delete = */ memtx_space_ephemeral_delete,
+	/* .ephemeral_truncate = */ memtx_space_ephemeral_truncate,
 	/* .init_system_space = */ memtx_init_system_space,
 	/* .init_ephemeral_space = */ memtx_init_ephemeral_space,
 	/* .check_index_def = */ memtx_space_check_index_def,
diff --git a/src/box/space.h b/src/box/space.h
index 0e5ef2058..fc641614b 100644
--- a/src/box/space.h
+++ b/src/box/space.h
@@ -70,6 +70,8 @@ struct space_vtab {
 
 	int (*ephemeral_delete)(struct space *, const char *);
 
+	void (*ephemeral_truncate)(struct space *);
+
 	void (*init_system_space)(struct space *);
 	/**
 	 * Initialize an ephemeral space instance.
diff --git a/src/box/sysview_engine.c b/src/box/sysview_engine.c
index 0a5fce0fd..f85e4bf2b 100644
--- a/src/box/sysview_engine.c
+++ b/src/box/sysview_engine.c
@@ -119,6 +119,13 @@ sysview_space_ephemeral_delete(struct space *space, const char *key)
 	return -1;
 }
 
+static void
+sysview_space_ephemeral_truncate(struct space *space)
+{
+	(void)space;
+	unreachable();
+}
+
 static void
 sysview_init_system_space(struct space *space)
 {
@@ -222,6 +229,7 @@ static const struct space_vtab sysview_space_vtab = {
 	/* .execute_upsert = */ sysview_space_execute_upsert,
 	/* .ephemeral_replace = */ sysview_space_ephemeral_replace,
 	/* .ephemeral_delete = */ sysview_space_ephemeral_delete,
+	/* .ephemeral_truncate = */ sysview_space_ephemeral_truncate,
 	/* .init_system_space = */ sysview_init_system_space,
 	/* .init_ephemeral_space = */ sysview_init_ephemeral_space,
 	/* .check_index_def = */ sysview_space_check_index_def,
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 0a3629f69..96c935cbe 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -2305,6 +2305,13 @@ vinyl_space_ephemeral_delete(struct space *space, const char *key)
 	return -1;
 }
 
+static void
+vinyl_space_ephemeral_truncate(struct space *space)
+{
+	(void)space;
+	unreachable();
+}
+
 static inline void
 txn_stmt_unref_tuples(struct txn_stmt *stmt)
 {
@@ -4004,6 +4011,7 @@ static const struct space_vtab vinyl_space_vtab = {
 	/* .execute_upsert = */ vinyl_space_execute_upsert,
 	/* .ephemeral_replace = */ vinyl_space_ephemeral_replace,
 	/* .ephemeral_delete = */ vinyl_space_ephemeral_delete,
+	/* .ephemeral_truncate = */ vinyl_space_ephemeral_truncate,
 	/* .init_system_space = */ vinyl_init_system_space,
 	/* .init_ephemeral_space = */ vinyl_init_ephemeral_space,
 	/* .check_index_def = */ vinyl_space_check_index_def,
-- 
2.15.1




More information about the Tarantool-patches mailing list