Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] [PATCH v8 6/6] box: introduce has_json_paths flag in templates
Date: Wed, 23 Jan 2019 17:15:10 +0300	[thread overview]
Message-ID: <20190123141510.tlsket6ah5dof4yx@esperanza> (raw)
In-Reply-To: <6e7f31aa-0793-8cab-076a-c9967daff33c@tarantool.org>

On Wed, Jan 16, 2019 at 06:35:56PM +0300, Kirill Shcherbatov wrote:
> diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc
> index 7ab6e3bf6..dff3aebbd 100644
> --- a/src/box/tuple_compare.cc
> +++ b/src/box/tuple_compare.cc
> @@ -458,11 +458,12 @@ tuple_common_key_parts(const struct tuple *tuple_a, const struct tuple *tuple_b,
>  	return i;
>  }
>  
> -template<bool is_nullable, bool has_optional_parts>
> +template<bool is_nullable, bool has_optional_parts, bool has_json_path>
>  static inline int
>  tuple_compare_slowpath(const struct tuple *tuple_a, const struct tuple *tuple_b,
>  		       struct key_def *key_def)
>  {
> +	assert(has_json_path == key_def->has_json_paths);

Sometimes you use 'has_json_paths', sometimes 'has_json_path'
(without 's'). Please be consistent.

>  	assert(!has_optional_parts || is_nullable);
>  	assert(is_nullable == key_def->is_nullable);
>  	assert(has_optional_parts == key_def->has_optional_parts);
> @@ -508,10 +509,19 @@ tuple_compare_slowpath(const struct tuple *tuple_a, const struct tuple *tuple_b,
>  		end = part + key_def->part_count;
>  
>  	for (; part < end; part++) {
> -		field_a = tuple_field_by_part_raw(format_a, tuple_a_raw,
> -						  field_map_a, part);
> -		field_b = tuple_field_by_part_raw(format_b, tuple_b_raw,
> -						  field_map_b, part);
> +		if (!has_json_path) {
> +			field_a = tuple_field_raw(format_a, tuple_a_raw,
> +						  field_map_a,
> +						  part->fieldno);

No need to carry part->fieldno to the next line - it fits.

> +			field_b = tuple_field_raw(format_b, tuple_b_raw,
> +						  field_map_b,
> +						  part->fieldno);

Ditto.

> +		} else {
> +			field_a = tuple_field_by_part_raw(format_a, tuple_a_raw,
> +							  field_map_a, part);
> +			field_b = tuple_field_by_part_raw(format_b, tuple_b_raw,
> +							  field_map_b, part);
> +		}
>  		assert(has_optional_parts ||
>  		       (field_a != NULL && field_b != NULL));
>  		if (! is_nullable) {
> diff --git a/src/box/tuple_extract_key.cc b/src/box/tuple_extract_key.cc
> index c10ee8ce4..78462908d 100644
> --- a/src/box/tuple_extract_key.cc
> +++ b/src/box/tuple_extract_key.cc
> @@ -133,7 +145,8 @@ tuple_extract_key_slowpath(const struct tuple *tuple,
>  			 * minimize tuple_field_raw() calls.
>  			 */
>  			for (; i < part_count - 1; i++) {
> -				if (!key_def_parts_are_sequential(key_def, i)) {
> +				if (!key_def_parts_are_sequential
> +				        <has_json_paths>(key_def, i)) {

Bad alignment - looks like <has_json_paths>(key_def, i) isn't a part of
'if' condition. Please align by the parenthesis. Here and everywhere
else in the patch.

> diff --git a/src/box/tuple_hash.cc b/src/box/tuple_hash.cc
> index 3486ce11c..8ede29045 100644
> --- a/src/box/tuple_hash.cc
> +++ b/src/box/tuple_hash.cc
> @@ -347,9 +359,18 @@ tuple_hash_slowpath(const struct tuple *tuple, struct key_def *key_def)
>  		 * need of tuple_field
>  		 */
>  		if (prev_fieldno + 1 != key_def->parts[part_id].fieldno) {
> -			struct key_part *part = &key_def->parts[part_id];
> -			field = tuple_field_by_part_raw(format, tuple_raw,
> -							field_map, part);
> +			if (!has_json_paths) {
> +				field = tuple_field(tuple,
> +						    key_def->parts[part_id].
> +						    fieldno);

Please don't carry .fieldno over to the next line - it looks confusing.
If you didn't remove local variable 'part', you would avoid that.

> +			} else {
> +				struct key_part *part =
> +					&key_def->parts[part_id];
> +				field = tuple_field_by_part_raw(format,
> +								tuple_raw,
> +								field_map,
> +								part);
> +			}
>  		}
>  		if (has_optional_parts && (field == NULL || field >= end)) {
>  			total_size += tuple_hash_null(&h, &carry);

      reply	other threads:[~2019-01-23 14:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16 13:44 [PATCH v8 0/5] box: Indexes by JSON path Kirill Shcherbatov
2019-01-16 13:44 ` [PATCH v8 1/5] lib: updated msgpuck library version Kirill Shcherbatov
2019-01-23 12:53   ` Vladimir Davydov
2019-01-16 13:44 ` [PATCH v8 2/5] box: refactor tuple_field_raw_by_path routine Kirill Shcherbatov
2019-01-23 13:15   ` Vladimir Davydov
2019-01-16 13:44 ` [PATCH v8 3/5] box: introduce JSON Indexes Kirill Shcherbatov
2019-01-23 13:49   ` Vladimir Davydov
2019-01-16 13:44 ` [PATCH v8 4/5] box: introduce offset_slot cache in key_part Kirill Shcherbatov
2019-01-23 14:23   ` Vladimir Davydov
2019-01-16 13:44 ` [PATCH v8 5/5] box: specify indexes in user-friendly form Kirill Shcherbatov
2019-01-23 15:29   ` Vladimir Davydov
2019-01-16 15:35 ` [tarantool-patches] [PATCH v8 6/6] box: introduce has_json_paths flag in templates Kirill Shcherbatov
2019-01-23 14:15   ` Vladimir Davydov [this message]

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=20190123141510.tlsket6ah5dof4yx@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v8 6/6] box: introduce has_json_paths flag in templates' \
    /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