Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH v2 3/4] Rename space_opts::temporary to is_temporary
Date: Mon,  9 Jul 2018 18:40:11 +0300	[thread overview]
Message-ID: <b80d17d2d3ce71e9b54375dc6394de9d9a4cfaf1.1531150617.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1531150617.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1531150617.git.vdavydov.dev@gmail.com>

We typically prefix all boolean variables with 'is_', so let's rename
space_opts::temporary to is_temporary for consistency.

While we are at it, let's also rename tuple_format::temporary to
is_temporary and use space_is_temporary() helper wherever we have
a space pointer.
---
 src/box/alter.cc       | 2 +-
 src/box/box.cc         | 2 +-
 src/box/memtx_engine.c | 2 +-
 src/box/memtx_space.c  | 4 ++--
 src/box/space.h        | 5 ++++-
 src/box/space_def.c    | 4 ++--
 src/box/space_def.h    | 2 +-
 src/box/tuple_format.c | 2 +-
 src/box/tuple_format.h | 2 +-
 src/box/vinyl.c        | 2 +-
 10 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 509e4b7e..07dee7d9 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -390,7 +390,7 @@ space_opts_decode(struct space_opts *opts, const char *data)
 			while (isspace(*flags)) /* skip space */
 				flags++;
 			if (strncmp(flags, "temporary", strlen("temporary")) == 0)
-				opts->temporary = true;
+				opts->is_temporary = true;
 			flags = strchr(flags, ',');
 			if (flags)
 				flags++;
diff --git a/src/box/box.cc b/src/box/box.cc
index ec38886d..15b84374 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -976,7 +976,7 @@ box_process1(struct request *request, box_tuple_t **result)
 	struct space *space = space_cache_find(request->space_id);
 	if (space == NULL)
 		return -1;
-	if (!space->def->opts.temporary && box_check_writable() != 0)
+	if (!space_is_temporary(space) && box_check_writable() != 0)
 		return -1;
 	return process_rw(request, space, result);
 }
diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
index 06858a84..74c6be8d 100644
--- a/src/box/memtx_engine.c
+++ b/src/box/memtx_engine.c
@@ -1221,7 +1221,7 @@ memtx_tuple_delete(struct tuple_format *format, struct tuple *tuple)
 		container_of(tuple, struct memtx_tuple, base);
 	if (memtx->alloc.free_mode != SMALL_DELAYED_FREE ||
 	    memtx_tuple->version == memtx->snapshot_version ||
-	    format->temporary)
+	    format->is_temporary)
 		smfree(&memtx->alloc, memtx_tuple, total);
 	else
 		smfree_delayed(&memtx->alloc, memtx_tuple, total);
diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c
index aef7e788..32700071 100644
--- a/src/box/memtx_space.c
+++ b/src/box/memtx_space.c
@@ -830,7 +830,7 @@ memtx_space_prepare_alter(struct space *old_space, struct space *new_space)
 	struct memtx_space *new_memtx_space = (struct memtx_space *)new_space;
 
 	if (old_memtx_space->bsize != 0 &&
-	    old_space->def->opts.temporary != new_space->def->opts.temporary) {
+	    space_is_temporary(old_space) != space_is_temporary(new_space)) {
 		diag_set(ClientError, ER_ALTER_SPACE, old_space->def->name,
 			 "can not switch temporary flag on a non-empty space");
 		return -1;
@@ -896,7 +896,7 @@ memtx_space_new(struct memtx_engine *memtx,
 		return NULL;
 	}
 	format->engine = memtx;
-	format->temporary = def->opts.temporary;
+	format->is_temporary = def->opts.is_temporary;
 	format->exact_field_count = def->exact_field_count;
 	tuple_format_ref(format);
 
diff --git a/src/box/space.h b/src/box/space.h
index cbd46c9e..074e2462 100644
--- a/src/box/space.h
+++ b/src/box/space.h
@@ -193,7 +193,10 @@ space_name(const struct space *space)
 
 /** Return true if space is temporary. */
 static inline bool
-space_is_temporary(struct space *space) { return space->def->opts.temporary; }
+space_is_temporary(struct space *space)
+{
+	return space->def->opts.is_temporary;
+}
 
 void
 space_run_triggers(struct space *space, bool yesno);
diff --git a/src/box/space_def.c b/src/box/space_def.c
index 7349c214..ff35cb20 100644
--- a/src/box/space_def.c
+++ b/src/box/space_def.c
@@ -34,11 +34,11 @@
 #include "error.h"
 
 const struct space_opts space_opts_default = {
-	/* .temporary = */ false,
+	/* .is_temporary = */ false,
 };
 
 const struct opt_def space_opts_reg[] = {
-	OPT_DEF("temporary", OPT_BOOL, struct space_opts, temporary),
+	OPT_DEF("temporary", OPT_BOOL, struct space_opts, is_temporary),
 	OPT_END,
 };
 
diff --git a/src/box/space_def.h b/src/box/space_def.h
index 97c7e138..6cee6ad8 100644
--- a/src/box/space_def.h
+++ b/src/box/space_def.h
@@ -47,7 +47,7 @@ struct space_opts {
 	 * - changes are not written to WAL
 	 * - changes are not part of a snapshot
 	 */
-	bool temporary;
+	bool is_temporary;
 };
 
 extern const struct space_opts space_opts_default;
diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c
index 486646ea..2e19d2e3 100644
--- a/src/box/tuple_format.c
+++ b/src/box/tuple_format.c
@@ -270,7 +270,7 @@ tuple_format_new(struct tuple_format_vtab *vtab, struct key_def * const *keys,
 	format->vtab = *vtab;
 	format->engine = NULL;
 	format->extra_size = extra_size;
-	format->temporary = false;
+	format->is_temporary = false;
 	if (tuple_format_register(format) < 0) {
 		tuple_format_destroy(format);
 		free(format);
diff --git a/src/box/tuple_format.h b/src/box/tuple_format.h
index 9da9be3e..c7dc48ff 100644
--- a/src/box/tuple_format.h
+++ b/src/box/tuple_format.h
@@ -128,7 +128,7 @@ struct tuple_format {
 	 * hence can be freed immediately while checkpointing is
 	 * in progress.
 	 */
-	bool temporary;
+	bool is_temporary;
 	/**
 	 * The number of extra bytes to reserve in tuples before
 	 * field map.
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 10edbeda..08a83bb5 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -590,7 +590,7 @@ vy_lsm_find_unique(struct space *space, uint32_t index_id)
 static int
 vinyl_engine_check_space_def(struct space_def *def)
 {
-	if (def->opts.temporary) {
+	if (def->opts.is_temporary) {
 		diag_set(ClientError, ER_ALTER_SPACE,
 			 def->name, "engine does not support temporary flag");
 		return -1;
-- 
2.11.0

  parent reply	other threads:[~2018-07-09 15:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09 15:40 [PATCH v2 0/4] Introduce replica local spaces Vladimir Davydov
2018-07-09 15:40 ` [PATCH v2 1/4] txn: do not require space id for nop requests Vladimir Davydov
2018-07-10 18:57   ` Konstantin Osipov
2018-07-09 15:40 ` [PATCH v2 2/4] xrow: make NOP requests bodiless Vladimir Davydov
2018-07-09 15:40 ` Vladimir Davydov [this message]
2018-07-09 15:40 ` [PATCH v2 4/4] Introduce replica local spaces Vladimir Davydov
2018-07-09 18:05   ` [tarantool-patches] " Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b80d17d2d3ce71e9b54375dc6394de9d9a4cfaf1.1531150617.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2 3/4] Rename space_opts::temporary to is_temporary' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox