Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org,
	Vladimir Davydov <vdavydov.dev@gmail.com>
Subject: Re: [tarantool-patches] Re: [PATCH v5 3/4] salad: introduce bps_tree_delete_identical routine
Date: Mon, 6 May 2019 17:55:36 +0300	[thread overview]
Message-ID: <d083b455-b2dc-e3b3-ef9e-380dc48d945f@tarantool.org> (raw)
In-Reply-To: <20190506143445.redgeum66gy7onex@esperanza>


>>  #ifndef BPS_TREE_IDENTICAL
>>  #define BPS_TREE_IDENTICAL(a, b) (a == b)
>> +#define BPS_TREE_IDENTICAL_STD 1
> 
> This looks ugly. Let's require the caller to always define
> BPS_TREE_IDENTICAL - it's not a big deal.

I have considered this option, maybe it is better.
Done.

>> +/**
>> + * @brief Delete an identical element from a tree (unlike
>> + * bps_tree_delete this routine relies on BPS_TREE_IDENTICAL
>> + * instead of BPS_TREE_COMPARE).
>> + * @param tree - pointer to a tree
>> + * @param elem - the element tot delete
>> + * @return - true on success or false if the element was not found in tree
> 
> I guess it should also return -1 if the element was found but not
> deleted, in other words it should return 0 iff the element has been
> deleted.

	Done:

	struct bps_leaf *leaf = leaf_path_elem.block;
	if (!BPS_TREE_IDENTICAL(elem,
				leaf->elems[leaf_path_elem.insertion_point]))
		return -1;
	bps_tree_process_delete_leaf(tree, &leaf_path_elem);

> 
> Could you please reuse the existing tree for the test rather than
> introducing a new one?

Unfortunately, it is not possible. All other tests don't use structure as a leaf.
> Please check the return value as well.

	if (struct_tree_delete_identical(&tree, e2) == 0)
		fail("deletion of the non-identical element must fail", "false");
	if (struct_tree_find(&tree, 1) == NULL)
		fail("test non-identical element deletion failure", "false");
	if (struct_tree_delete_identical(&tree, e1) != 0)
		fail("deletion of the identical element must not fail", "false");
	if (struct_tree_find(&tree, 1) != NULL)
		fail("test identical element deletion completion", "false");

============================================

Updated on branch.

  reply	other threads:[~2019-05-06 14:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 11:57 [PATCH v5 0/4] box: introduce multikey indexes in memtx Kirill Shcherbatov
2019-05-06 11:57 ` [PATCH v5 1/4] box: introduce tuple_format_iterator class Kirill Shcherbatov
2019-05-06 13:55   ` Vladimir Davydov
2019-05-06 14:32     ` [tarantool-patches] " Kirill Shcherbatov
2019-05-06 11:57 ` [PATCH v5 2/4] box: introduce field_map_builder class Kirill Shcherbatov
2019-05-06 14:22   ` Vladimir Davydov
2019-05-06 11:57 ` [PATCH v5 3/4] salad: introduce bps_tree_delete_identical routine Kirill Shcherbatov
2019-05-06 14:34   ` Vladimir Davydov
2019-05-06 14:55     ` Kirill Shcherbatov [this message]
2019-05-06 11:57 ` [PATCH v5 4/4] box: introduce multikey indexes in memtx Kirill Shcherbatov
2019-05-06 15:46   ` Vladimir Davydov
2019-05-06 16:35     ` [tarantool-patches] " Kirill Shcherbatov
2019-05-07  8:11       ` Vladimir Davydov
2019-05-07  8:28         ` Kirill Shcherbatov
2019-05-07 11:30           ` Vladimir Davydov
2019-05-07 13:13     ` Vladimir Davydov
2019-05-06 15:52 ` [PATCH v5 0/4] " 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=d083b455-b2dc-e3b3-ef9e-380dc48d945f@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] Re: [PATCH v5 3/4] salad: introduce bps_tree_delete_identical routine' \
    /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