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: [PATCH v1 1/4] lib: introduce BPS_TREE_EQUAL custom comparator
Date: Mon, 11 Feb 2019 18:46:39 +0300	[thread overview]
Message-ID: <20190211154639.focibqtwi5cztlut@esperanza> (raw)
In-Reply-To: <11600ac4b30c072b5b8c4132a658aaff13083504.1549367041.git.kshcherbatov@tarantool.org>

On Tue, Feb 05, 2019 at 02:58:36PM +0300, Kirill Shcherbatov wrote:
> Introduce a macro BPS_TREE_EQUAL for BPS TREE class. This makes
> possible to define custom comparators for stucture-based leafs.
> Previously, a C++ comparison operator "!=" override was used for
> this purpose. Due to the fact that we are not going to rework on
> C++ C-only components of Tarantool like memtx_tree, we needed a
> way to make complex structures comparisons using preprocessor.
> 
> Needed for #3961
> ---
>  src/lib/salad/bps_tree.h       | 74 +++++++++++++++++++++-------------
>  test/unit/bps_tree_iterator.cc | 15 ++++---
>  2 files changed, 56 insertions(+), 33 deletions(-)
> 
> diff --git a/src/lib/salad/bps_tree.h b/src/lib/salad/bps_tree.h
> index 8d1a62108..1419af3f7 100644
> --- a/src/lib/salad/bps_tree.h
> +++ b/src/lib/salad/bps_tree.h
> @@ -1035,6 +1035,10 @@ struct bps_leaf_path_elem {
>  	bps_tree_pos_t max_elem_pos;
>  };
>  
> +#ifndef BPS_TREE_EQUAL
> +#define BPS_TREE_EQUAL(a, b) (a == b)
> +#endif
> +

Funny thing, this is only needed for self checks and only used in unit
tests. The patch is unobtrusive so I guess it's OK.

Please move this macro to the place where other BPS_TREE macros are
defined and augment the definition with a comment.

Also, I'm not quite sure about the name, because if we have 'compare'
operation, why do we need to define 'equal' separately? What about
BPS_TREE_SELFSAeE or BPS_TREE_IDENTICAL?

Alternatively, we could define BPS_TREE_NO_DEBUG for each BPS tree
definition in the code. Then we wouldn't need this macro at all. I'm
inclined to think that would be the easiest way to deal with this
problem.

  reply	other threads:[~2019-02-11 15:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 11:58 [PATCH v1 0/4] box: introduce hint option for memtx tree index Kirill Shcherbatov
2019-02-05 11:58 ` [PATCH v1 1/4] lib: introduce BPS_TREE_EQUAL custom comparator Kirill Shcherbatov
2019-02-11 15:46   ` Vladimir Davydov [this message]
2019-02-05 11:58 ` [PATCH v1 2/4] box: rework memtx_tree class to be reusable Kirill Shcherbatov
2019-02-11 15:49   ` Vladimir Davydov
2019-02-05 11:58 ` [PATCH v1 3/4] box: introduce tuple compare hint Kirill Shcherbatov
2019-02-11 15:57   ` Vladimir Davydov
2019-02-05 11:58 ` [PATCH v1 4/4] box: introduce hint option for memtx tree index Kirill Shcherbatov
2019-02-11 16:12   ` Vladimir Davydov

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=20190211154639.focibqtwi5cztlut@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v1 1/4] lib: introduce BPS_TREE_EQUAL custom comparator' \
    /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