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 08/12] vinyl: remove pointless is_nullable initialization for disk_format
Date: Sun,  1 Apr 2018 12:05:35 +0300	[thread overview]
Message-ID: <cc600613131df1659401ed556e6c226d6da35610.1522572161.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1522572160.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1522572160.git.vdavydov.dev@gmail.com>

space->format and cmp_def must be compatible, i.e. space->format has
is_nullable flag set for a field iff it is set for all key parts
indexing this field. Therefore there's no point to set is_nullable for
disk_format as it must have been initialized by tuple_format_create().
Remove the pointless loop.

Also, while we are at it, fix the minor memory leak - disk_format is
referenced twice for the primary key.
---
 src/box/vy_lsm.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c
index 6cb722f4..88de1e61 100644
--- a/src/box/vy_lsm.c
+++ b/src/box/vy_lsm.c
@@ -147,18 +147,12 @@ vy_lsm_new(struct vy_lsm_env *lsm_env, struct vy_cache_env *cache_env,
 		 * definitions as well as space->format tuples.
 		 */
 		lsm->disk_format = format;
-		tuple_format_ref(format);
 	} else {
 		lsm->disk_format = tuple_format_new(&vy_tuple_format_vtab,
 						    &cmp_def, 1, 0, NULL, 0,
 						    NULL);
 		if (lsm->disk_format == NULL)
 			goto fail_format;
-		for (uint32_t i = 0; i < cmp_def->part_count; ++i) {
-			uint32_t fieldno = cmp_def->parts[i].fieldno;
-			lsm->disk_format->fields[fieldno].is_nullable =
-				format->fields[fieldno].is_nullable;
-		}
 	}
 	tuple_format_ref(lsm->disk_format);
 
@@ -167,11 +161,10 @@ vy_lsm_new(struct vy_lsm_env *lsm_env, struct vy_cache_env *cache_env,
 			vy_tuple_format_new_with_colmask(format);
 		if (lsm->mem_format_with_colmask == NULL)
 			goto fail_mem_format_with_colmask;
-		tuple_format_ref(lsm->mem_format_with_colmask);
 	} else {
 		lsm->mem_format_with_colmask = pk->mem_format_with_colmask;
-		tuple_format_ref(lsm->mem_format_with_colmask);
 	}
+	tuple_format_ref(lsm->mem_format_with_colmask);
 
 	if (vy_lsm_stat_create(&lsm->stat) != 0)
 		goto fail_stat;
-- 
2.11.0

  parent reply	other threads:[~2018-04-01  9:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-01  9:05 [PATCH 00/12] vinyl: allow to extend key def of non-empty index Vladimir Davydov
2018-04-01  9:05 ` [PATCH 01/12] index: add commit_modify virtual method Vladimir Davydov
2018-04-01  9:05 ` [PATCH 02/12] alter: require rebuild of all secondary vinyl indexes if pk changes Vladimir Davydov
2018-04-01  9:05 ` [PATCH 03/12] alter: do not rebuild secondary indexes on compatible " Vladimir Davydov
2018-04-05 12:30   ` Konstantin Osipov
2018-04-01  9:05 ` [PATCH 04/12] space: make space_swap_index method virtual Vladimir Davydov
2018-04-01  9:05 ` [PATCH 05/12] vinyl: do not reallocate tuple formats on alter Vladimir Davydov
2018-04-01 11:12   ` [tarantool-patches] " v.shpilevoy
2018-04-01 11:24     ` Vladimir Davydov
2018-04-01  9:05 ` [PATCH 06/12] vinyl: zap vy_lsm_validate_formats Vladimir Davydov
2018-04-01  9:05 ` [PATCH 07/12] vinyl: zap vy_mem_update_formats Vladimir Davydov
2018-04-01  9:05 ` Vladimir Davydov [this message]
2018-04-01  9:05 ` [PATCH 09/12] vinyl: use source tuple format when copying field map Vladimir Davydov
2018-04-01  9:05 ` [PATCH 10/12] vinyl: rename vy_log_record::commit_lsn to create_lsn Vladimir Davydov
2018-04-01  9:05 ` [PATCH 11/12] vinyl: do not write VY_LOG_DUMP_LSM record to snapshot Vladimir Davydov
2018-04-01  9:05 ` [PATCH 12/12] vinyl: allow to modify key definition if it does not require rebuild Vladimir Davydov
2018-04-02  8:46   ` Vladimir Davydov
2018-04-05 14:32     ` Konstantin Osipov
2018-04-05 14:45     ` Konstantin Osipov
2018-04-05 14:48       ` Konstantin Osipov

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=cc600613131df1659401ed556e6c226d6da35610.1522572161.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 08/12] vinyl: remove pointless is_nullable initialization for disk_format' \
    /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