From f02632aeb0d9560f4bc1e112d43f878424203d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Thu, 5 Aug 2021 12:27:00 +0300 Subject: [PATCH] range_tombstone_accumulator: drop _reversed flag --- db/view/view.hh | 4 ++-- mutation_compactor.hh | 4 ++-- range_tombstone.cc | 12 ++---------- range_tombstone.hh | 5 ++--- test/boost/mutation_test.cc | 2 +- test/boost/range_tombstone_list_test.cc | 25 +------------------------ 6 files changed, 10 insertions(+), 42 deletions(-) diff --git a/db/view/view.hh b/db/view/view.hh index 9371dad0b7..c6381fa8b8 100644 --- a/db/view/view.hh +++ b/db/view/view.hh @@ -192,8 +192,8 @@ public: , _view_updates(std::move(views_to_update)) , _updates(std::move(updates)) , _existings(std::move(existings)) - , _update_tombstone_tracker(*_schema, false) - , _existing_tombstone_tracker(*_schema, false) + , _update_tombstone_tracker(*_schema) + , _existing_tombstone_tracker(*_schema) , _now(now) { } view_update_builder(view_update_builder&& other) noexcept = default; diff --git a/mutation_compactor.hh b/mutation_compactor.hh index 9d0c92bb01..d5070ec244 100644 --- a/mutation_compactor.hh +++ b/mutation_compactor.hh @@ -224,7 +224,7 @@ public: , _row_limit(limit) , _partition_limit(partition_limit) , _partition_row_limit(_slice.options.contains(query::partition_slice::option::distinct) ? 1 : slice.partition_row_limit()) - , _range_tombstones(s, false) + , _range_tombstones(s) , _last_dk({dht::token(), partition_key::make_empty()}) { static_assert(!sstable_compaction(), "This constructor cannot be used for sstable compaction."); @@ -238,7 +238,7 @@ public: , _get_max_purgeable(std::move(get_max_purgeable)) , _can_gc([this] (tombstone t) { return can_gc(t); }) , _slice(s.full_slice()) - , _range_tombstones(s, false) + , _range_tombstones(s) , _last_dk({dht::token(), partition_key::make_empty()}) , _collector(std::make_unique(_schema)) { diff --git a/range_tombstone.cc b/range_tombstone.cc index ce6cb83761..ffcf45e5ae 100644 --- a/range_tombstone.cc +++ b/range_tombstone.cc @@ -73,10 +73,6 @@ void range_tombstone_accumulator::update_current_tombstone() { void range_tombstone_accumulator::drop_unneeded_tombstones(const clustering_key_prefix& ck, int w) { auto cmp = [&] (const range_tombstone& rt, const clustering_key_prefix& ck, int w) { - if (_reversed) { - auto bv = rt.start_bound(); - return _cmp(ck, w, bv.prefix(), weight(bv.kind())); - } auto bv = rt.end_bound(); return _cmp(bv.prefix(), weight(bv.kind()), ck, w); }; @@ -91,15 +87,11 @@ void range_tombstone_accumulator::drop_unneeded_tombstones(const clustering_key_ } void range_tombstone_accumulator::apply(range_tombstone rt) { - if (_reversed) { - drop_unneeded_tombstones(rt.end, weight(rt.end_kind)); - } else { - drop_unneeded_tombstones(rt.start, weight(rt.start_kind)); - } + drop_unneeded_tombstones(rt.start, weight(rt.start_kind)); _current_tombstone.apply(rt.tomb); auto cmp = [&] (const range_tombstone& rt1, const range_tombstone& rt2) { - return _reversed ? _cmp(rt2.start_bound(), rt1.start_bound()) : _cmp(rt1.end_bound(), rt2.end_bound()); + return _cmp(rt1.end_bound(), rt2.end_bound()); }; _range_tombstones.insert(boost::upper_bound(_range_tombstones, rt, cmp), std::move(rt)); } diff --git a/range_tombstone.hh b/range_tombstone.hh index e82c3528bc..6672ead65e 100644 --- a/range_tombstone.hh +++ b/range_tombstone.hh @@ -261,13 +261,12 @@ class range_tombstone_accumulator { tombstone _partition_tombstone; std::deque _range_tombstones; tombstone _current_tombstone; - bool _reversed; private: void update_current_tombstone(); void drop_unneeded_tombstones(const clustering_key_prefix& ck, int w = 0); public: - range_tombstone_accumulator(const schema& s, bool reversed) - : _cmp(s), _reversed(reversed) { } + explicit range_tombstone_accumulator(const schema& s) + : _cmp(s) { } void set_partition_tombstone(tombstone t) { _partition_tombstone = t; diff --git a/test/boost/mutation_test.cc b/test/boost/mutation_test.cc index a0af66d4e2..46e0943c88 100644 --- a/test/boost/mutation_test.cc +++ b/test/boost/mutation_test.cc @@ -2889,7 +2889,7 @@ void check_clustering_row_summaries(const schema& schema, const clustering_row_s } void check_clustering_summaries(const schema& schema, const partition_summary& actual, const partition_summary& expected) { - range_tombstone_accumulator range_tombstones(schema, false); + range_tombstone_accumulator range_tombstones(schema); range_tombstones.set_partition_tombstone(expected.tomb); for (auto [actual_frag, expected_frag] : iterate_over_in_ordered_lockstep(actual.clustering_fragments, expected.clustering_fragments, diff --git a/test/boost/range_tombstone_list_test.cc b/test/boost/range_tombstone_list_test.cc index 3840451b74..4de8311abd 100644 --- a/test/boost/range_tombstone_list_test.cc +++ b/test/boost/range_tombstone_list_test.cc @@ -884,8 +884,7 @@ BOOST_AUTO_TEST_CASE(test_accumulator) { auto ts1 = 1; auto ts2 = 2; - testlog.info("Forward"); - auto acc = range_tombstone_accumulator(*s, false); + auto acc = range_tombstone_accumulator(*s); acc.apply(rtie(0, 4, ts1)); BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 0 })), tombstone(ts1, gc_now)); acc.apply(rtie(1, 2, ts2)); @@ -904,26 +903,4 @@ BOOST_AUTO_TEST_CASE(test_accumulator) { BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 13 })), tombstone(ts2, gc_now)); BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 14 })), tombstone()); BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 15 })), tombstone()); - - testlog.info("Reversed"); - acc = range_tombstone_accumulator(*s, true); - - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 15 })), tombstone()); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 14 })), tombstone()); - acc.apply(rtie(11, 14, ts2)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 13 })), tombstone(ts2, gc_now)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 12 })), tombstone(ts2, gc_now)); - acc.apply(rtie(10, 12, ts1)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 11 })), tombstone(ts2, gc_now)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 10 })), tombstone(ts1, gc_now)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 9 })), tombstone()); - acc.apply(rtie(6, 8, ts2)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 5 })), tombstone()); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 4 })), tombstone()); - acc.apply(rtie(0, 4, ts1)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 3 })), tombstone(ts1, gc_now)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 2 })), tombstone(ts1, gc_now)); - acc.apply(rtie(1, 2, ts2)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 1 })), tombstone(ts2, gc_now)); - BOOST_REQUIRE_EQUAL(acc.tombstone_for_row(key({ 0 })), tombstone(ts1, gc_now)); }