Skip to content

Commit

Permalink
crimson/onode-staged-tree: fix Cursor operator==
Browse files Browse the repository at this point in the history
Signed-off-by: Yingxin Cheng <[email protected]>
  • Loading branch information
cyx1231st committed Feb 24, 2021
1 parent bb17a4f commit ba5c0fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/crimson/os/seastore/onode_manager/staged-fltree/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class Btree {
bool operator>=(const Cursor& o) const { return (int)compare_to(o) >= 0; }
bool operator<(const Cursor& o) const { return (int)compare_to(o) < 0; }
bool operator<=(const Cursor& o) const { return (int)compare_to(o) <= 0; }
bool operator==(const Cursor& o) const { return (int)compare_to(o) != 0; }
bool operator!=(const Cursor& o) const { return (int)compare_to(o) == 0; }
bool operator==(const Cursor& o) const { return (int)compare_to(o) == 0; }
bool operator!=(const Cursor& o) const { return (int)compare_to(o) != 0; }

btree_future<Cursor> get_next(Transaction& t) {
assert(!is_end());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,9 @@ class TreeBuilder {
#ifndef NDEBUG
auto [key, value] = kv_iter.get_kv();
Values::validate_cursor(cursor, key, value);
return tree->lower_bound(t, key
return tree->find(t, key
).safe_then([this, cursor](auto cursor_) mutable {
assert(!cursor_.is_end());
auto [key, value] = kv_iter.get_kv();
ceph_assert(cursor_.get_ghobj() == key);
ceph_assert(cursor_.value() == cursor.value());
Expand Down Expand Up @@ -315,7 +316,7 @@ class TreeBuilder {
assert(c_iter != cursors->end());
auto [k, v] = kv_iter.get_kv();
// validate values in tree keep intact
return tree->lower_bound(t, k).safe_then([this, &c_iter](auto cursor) {
return tree->find(t, k).safe_then([this, &c_iter](auto cursor) {
auto [k, v] = kv_iter.get_kv();
Values::validate_cursor(cursor, k, v);
// validate values in cursors keep intact
Expand Down Expand Up @@ -349,7 +350,7 @@ class TreeBuilder {
auto iter = kvs.begin();
while (!iter.is_end()) {
auto [k, v] = iter.get_kv();
auto cursor = tree->lower_bound(t, k).unsafe_get0();
auto cursor = tree->find(t, k).unsafe_get0();
Values::validate_cursor(cursor, k, v);
++iter;
}
Expand Down
12 changes: 8 additions & 4 deletions src/test/crimson/seastore/onode_tree/test_staged_fltree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ TEST_F(b_dummy_tree_test_t, 3_random_insert_leaf_node)
ceph_assert(cursor.get_ghobj() == key);
Values::initialize_cursor(t, cursor, value);
insert_history.emplace_back(key, value, cursor);
auto cursor_ = tree.lower_bound(t, key).unsafe_get0();
auto cursor_ = tree.find(t, key).unsafe_get0();
ceph_assert(cursor_ != tree.end());
ceph_assert(cursor_.value() == cursor.value());
Values::validate_cursor(cursor_, key, value);
return cursor.value();
Expand Down Expand Up @@ -327,7 +328,8 @@ TEST_F(b_dummy_tree_test_t, 3_random_insert_leaf_node)

for (auto& [k, v, c] : insert_history) {
// validate values in tree keep intact
auto cursor = tree.lower_bound(t, k).unsafe_get0();
auto cursor = tree.find(t, k).unsafe_get0();
EXPECT_NE(cursor, tree.end());
Values::validate_cursor(cursor, k, v);
// validate values in cursors keep intact
Values::validate_cursor(c, k, v);
Expand Down Expand Up @@ -472,10 +474,12 @@ class TestTree {
EXPECT_EQ(tree_clone.height(t_clone).unsafe_get0(), 2);

for (auto& [k, v, c] : insert_history) {
auto result = tree_clone.lower_bound(t_clone, k).unsafe_get0();
auto result = tree_clone.find(t_clone, k).unsafe_get0();
EXPECT_NE(result, tree_clone.end());
Values::validate_cursor(result, k, v);
}
auto result = tree_clone.lower_bound(t_clone, key).unsafe_get0();
auto result = tree_clone.find(t_clone, key).unsafe_get0();
EXPECT_NE(result, tree_clone.end());
Values::validate_cursor(result, key, value);
EXPECT_TRUE(last_split.match(expected));
});
Expand Down

0 comments on commit ba5c0fa

Please sign in to comment.