From f9129fc1f9284bceef6ad542e4867aa63c549386 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 4 Oct 2020 10:21:28 +0300 Subject: [PATCH 1/5] utils: to_range(): relax constraint The input range to utils::to_range() should be indeed a range, but clang has trouble compiling which causes it to fail. Relax the constraint until this is fixed. --- utils/ranges.hh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/ranges.hh b/utils/ranges.hh index e7ca890700..f533cd203c 100644 --- a/utils/ranges.hh +++ b/utils/ranges.hh @@ -25,7 +25,13 @@ namespace ranges { +#ifndef __clang__ template +#else +// 'Range' should be constrained to std::ranges::range, but due to +// problems between clang and , it cannot be +template +#endif Container to(const Range& range) { return Container(range.begin(), range.end()); } From 951b4d1541b247add16fffbc80fc39bb50ec2600 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 11 Oct 2020 19:14:56 +0300 Subject: [PATCH 2/5] sstables: leveled_compaction_strategy: drop use of Clang has trouble with some parts of . Replace with iterators for now. --- sstables/leveled_compaction_strategy.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sstables/leveled_compaction_strategy.cc b/sstables/leveled_compaction_strategy.cc index 88a2fc5919..d0f96e5bba 100644 --- a/sstables/leveled_compaction_strategy.cc +++ b/sstables/leveled_compaction_strategy.cc @@ -168,7 +168,9 @@ leveled_compaction_strategy::get_reshaping_job(std::vector input level_info[sst_level].push_back(sst); } - for (auto& level : level_info | std::ranges::views::drop(1)) { + // Can't use std::ranges::views::drop due to https://bugs.llvm.org/show_bug.cgi?id=47509 + for (auto i = level_info.begin() + 1; i != level_info.end(); ++i) { + auto& level = *i; std::sort(level.begin(), level.end(), [&schema] (const shared_sstable& a, const shared_sstable& b) { return dht::ring_position(a->get_first_decorated_key()).less_compare(*schema, dht::ring_position(b->get_first_decorated_key())); }); From bd6855ed6277571d8bf06c5f4110541ef1c73fb7 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 28 Sep 2020 19:00:33 +0300 Subject: [PATCH 3/5] cql3: expression: drop Clang has trouble with some parts of . Replace with boost range adaptors for now. --- cql3/expr/expression.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cql3/expr/expression.cc b/cql3/expr/expression.cc index b6445ff4c0..bd30c1fe3a 100644 --- a/cql3/expr/expression.cc +++ b/cql3/expr/expression.cc @@ -555,28 +555,28 @@ bytes_opt get_kth(size_t k, const query_options& options, const ::shared_ptr -requires std::ranges::forward_range +// Clang doesn't compile this, and boost ranges aren't std::ranges +// requires std::ranges::forward_range value_list to_sorted_vector(Range r, const serialized_compare& comparator) { value_list tmp(r.begin(), r.end()); // Need random-access range to sort (r is not necessarily random-access). const auto unique = boost::unique(boost::sort(tmp, comparator)); return value_list(unique.begin(), unique.end()); } -const auto non_null = std::views::filter([] (const bytes_opt& b) { return b.has_value(); }); +const auto non_null = boost::adaptors::filtered([] (const bytes_opt& b) { return b.has_value(); }); -const auto deref = std::views::transform([] (const bytes_opt& b) { return b.value(); }); +const auto deref = boost::adaptors::transformed([] (const bytes_opt& b) { return b.value(); }); /// Returns possible values from t, which must be RHS of IN. value_list get_IN_values( const ::shared_ptr& t, const query_options& options, const serialized_compare& comparator) { - using std::views::transform; // RHS is prepared differently for different CQL cases. Cast it dynamically to discern which case this is. if (auto dv = dynamic_pointer_cast(t)) { // Case `a IN (1,2,3)`. const auto result_range = dv->get_elements() - | transform([&] (const ::shared_ptr& t) { return to_bytes_opt(t->bind_and_get(options)); }) + | boost::adaptors::transformed([&] (const ::shared_ptr& t) { return to_bytes_opt(t->bind_and_get(options)); }) | non_null | deref; - return to_sorted_vector(move(result_range), comparator); + return to_sorted_vector(std::move(result_range), comparator); } else if (auto mkr = dynamic_pointer_cast(t)) { // Case `a IN ?`. Collect all list-element values. const auto val = static_pointer_cast(mkr->bind(options)); @@ -588,20 +588,19 @@ value_list get_IN_values( /// Returns possible values for k-th column from t, which must be RHS of IN. value_list get_IN_values(const ::shared_ptr& t, size_t k, const query_options& options, const serialized_compare& comparator) { - using std::views::transform; // RHS is prepared differently for different CQL cases. Cast it dynamically to discern which case this is. if (auto dv = dynamic_pointer_cast(t)) { // Case `(a,b) in ((1,1),(2,2),(3,3))`. Get kth value from each term element. const auto result_range = dv->get_elements() - | transform(std::bind_front(get_kth, k, options)) | non_null | deref; - return to_sorted_vector(move(result_range), comparator); + | boost::adaptors::transformed(std::bind_front(get_kth, k, options)) | non_null | deref; + return to_sorted_vector(std::move(result_range), comparator); } else if (auto mkr = dynamic_pointer_cast(t)) { // Case `(a,b) IN ?`. Get kth value from each vector element. const auto val = static_pointer_cast(mkr->bind(options)); const auto split_values = val->get_split_values(); // Need lvalue from which to make std::view. const auto result_range = split_values - | transform([k] (const std::vector& v) { return v[k]; }) | non_null | deref; - return to_sorted_vector(move(result_range), comparator); + | boost::adaptors::transformed([k] (const std::vector& v) { return v[k]; }) | non_null | deref; + return to_sorted_vector(std::move(result_range), comparator); } throw std::logic_error(format("get_IN_values(multi-column) on invalid term {}", *t)); } From 1041521eb8a122601853f0bee9320bb9b1fbdfd2 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 28 Sep 2020 19:00:33 +0300 Subject: [PATCH 4/5] test: mutation_reader_test: drop Clang has trouble with some parts of . Replace with boost range adaptors for now. --- test/boost/mutation_reader_test.cc | 76 +++++++++++++++--------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/test/boost/mutation_reader_test.cc b/test/boost/mutation_reader_test.cc index ef9bd5229d..e076f9de38 100644 --- a/test/boost/mutation_reader_test.cc +++ b/test/boost/mutation_reader_test.cc @@ -155,10 +155,10 @@ SEASTAR_THREAD_TEST_CASE(combined_reader_galloping_within_partition_test) { }; std::vector v; - v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), {make_partition(std::views::iota(0, 5))})); - v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), {make_partition(std::views::iota(5, 10))})); + v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), {make_partition(boost::irange(0, 5))})); + v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), {make_partition(boost::irange(5, 10))})); assert_that(make_combined_reader(s.schema(), tests::make_permit(), std::move(v), streamed_mutation::forwarding::no, mutation_reader::forwarding::no)) - .produces(make_partition(std::views::iota(0, 10))) + .produces(make_partition(boost::irange(0, 10))) .produces_end_of_stream(); } @@ -178,16 +178,16 @@ SEASTAR_THREAD_TEST_CASE(combined_mutation_reader_galloping_over_multiple_partit std::vector v; v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), { - make_partition_with_clustering_rows(s, k[0], std::views::iota(5, 10)), - make_partition_with_clustering_rows(s, k[1], std::views::iota(0, 5)) + make_partition_with_clustering_rows(s, k[0], boost::irange(5, 10)), + make_partition_with_clustering_rows(s, k[1], boost::irange(0, 5)) })); v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), { - make_partition_with_clustering_rows(s, k[0], std::views::iota(0, 5)), - make_partition_with_clustering_rows(s, k[1], std::views::iota(5, 10)) + make_partition_with_clustering_rows(s, k[0], boost::irange(0, 5)), + make_partition_with_clustering_rows(s, k[1], boost::irange(5, 10)) })); assert_that(make_combined_reader(s.schema(), tests::make_permit(), std::move(v), streamed_mutation::forwarding::no, mutation_reader::forwarding::no)) - .produces(make_partition_with_clustering_rows(s, k[0], std::views::iota(0, 10))) - .produces(make_partition_with_clustering_rows(s, k[1], std::views::iota(0, 10))) + .produces(make_partition_with_clustering_rows(s, k[0], boost::irange(0, 10))) + .produces(make_partition_with_clustering_rows(s, k[1], boost::irange(0, 10))) .produces_end_of_stream(); } @@ -198,16 +198,16 @@ SEASTAR_THREAD_TEST_CASE(combined_reader_galloping_changing_multiple_partitions_ std::vector v; v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), { - make_partition_with_clustering_rows(s, k[0], std::views::iota(0, 5)), - make_partition_with_clustering_rows(s, k[1], std::views::iota(0, 5)) + make_partition_with_clustering_rows(s, k[0], boost::irange(0, 5)), + make_partition_with_clustering_rows(s, k[1], boost::irange(0, 5)) })); v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), { - make_partition_with_clustering_rows(s, k[0], std::views::iota(5, 10)), - make_partition_with_clustering_rows(s, k[1], std::views::iota(5, 10)), + make_partition_with_clustering_rows(s, k[0], boost::irange(5, 10)), + make_partition_with_clustering_rows(s, k[1], boost::irange(5, 10)), })); assert_that(make_combined_reader(s.schema(), tests::make_permit(), std::move(v), streamed_mutation::forwarding::no, mutation_reader::forwarding::no)) - .produces(make_partition_with_clustering_rows(s, k[0], std::views::iota(0, 10))) - .produces(make_partition_with_clustering_rows(s, k[1], std::views::iota(0, 10))) + .produces(make_partition_with_clustering_rows(s, k[0], boost::irange(0, 10))) + .produces(make_partition_with_clustering_rows(s, k[1], boost::irange(0, 10))) .produces_end_of_stream(); } @@ -320,7 +320,7 @@ SEASTAR_TEST_CASE(test_combining_one_empty_reader) { std::vector generate_keys(schema_ptr s, int count) { auto keys = ranges::to>( - std::views::iota(0, count) | std::views::transform([s] (int key) { + boost::irange(0, count) | boost::adaptors::transformed([s] (int key) { auto pk = partition_key::from_single_value(*s, int32_type->decompose(data_value(key))); return dht::decorate_key(*s, std::move(pk)); })); @@ -329,7 +329,7 @@ std::vector generate_keys(schema_ptr s, int count) { } std::vector to_ring_positions(const std::vector& keys) { - return ranges::to>(keys | std::views::transform([] (const dht::decorated_key& key) { + return ranges::to>(keys | boost::adaptors::transformed([] (const dht::decorated_key& key) { return dht::ring_position(key); })); } @@ -365,7 +365,7 @@ SEASTAR_TEST_CASE(test_fast_forwarding_combining_reader) { }; auto make_reader = [&] (const dht::partition_range& pr) { - return make_combined_reader(s, tests::make_permit(), ranges::to>(mutations | std::views::transform([&pr] (auto& ms) { + return make_combined_reader(s, tests::make_permit(), ranges::to>(mutations | boost::adaptors::transformed([&pr] (auto& ms) { return flat_mutation_reader_from_mutations(tests::make_permit(), {ms}, pr); }))); }; @@ -416,22 +416,22 @@ SEASTAR_THREAD_TEST_CASE(test_fast_forwarding_combining_reader_with_galloping) { auto pr = dht::partition_range::make(ring[0], ring[0]); std::vector v; - v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), make_n_mutations(std::views::iota(0, 5), 7), pr)); - v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), make_n_mutations(std::views::iota(5, 10), 7), pr)); + v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), make_n_mutations(boost::irange(0, 5), 7), pr)); + v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), make_n_mutations(boost::irange(5, 10), 7), pr)); assert_that(make_combined_reader(s.schema(), tests::make_permit(), std::move(v), streamed_mutation::forwarding::no, mutation_reader::forwarding::yes)) - .produces(make_partition_with_clustering_rows(s, pkeys[0], std::views::iota(0, 10))) + .produces(make_partition_with_clustering_rows(s, pkeys[0], boost::irange(0, 10))) .produces_end_of_stream() .fast_forward_to(dht::partition_range::make(ring[1], ring[1])) - .produces(make_partition_with_clustering_rows(s, pkeys[1], std::views::iota(0, 10))) + .produces(make_partition_with_clustering_rows(s, pkeys[1], boost::irange(0, 10))) .produces_end_of_stream() .fast_forward_to(dht::partition_range::make(ring[3], ring[4])) - .produces(make_partition_with_clustering_rows(s, pkeys[3], std::views::iota(0, 10))) + .produces(make_partition_with_clustering_rows(s, pkeys[3], boost::irange(0, 10))) .fast_forward_to(dht::partition_range::make({ ring[4], false }, ring[5])) - .produces(make_partition_with_clustering_rows(s, pkeys[5], std::views::iota(0, 10))) + .produces(make_partition_with_clustering_rows(s, pkeys[5], boost::irange(0, 10))) .produces_end_of_stream() .fast_forward_to(dht::partition_range::make_starting_with(ring[6])) - .produces(make_partition_with_clustering_rows(s, pkeys[6], std::views::iota(0, 10))) + .produces(make_partition_with_clustering_rows(s, pkeys[6], boost::irange(0, 10))) .produces_end_of_stream(); } @@ -511,8 +511,8 @@ SEASTAR_THREAD_TEST_CASE(test_sm_fast_forwarding_combining_reader_with_galloping auto pr = dht::partition_range::make(ring[0], ring[0]); std::vector v; - v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), make_n_mutations(std::views::iota(0, 5), 3), streamed_mutation::forwarding::yes)); - v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), make_n_mutations(std::views::iota(5, 10), 3), streamed_mutation::forwarding::yes)); + v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), make_n_mutations(boost::irange(0, 5), 3), streamed_mutation::forwarding::yes)); + v.push_back(flat_mutation_reader_from_mutations(tests::make_permit(), make_n_mutations(boost::irange(5, 10), 3), streamed_mutation::forwarding::yes)); auto reader = make_combined_reader(s.schema(), tests::make_permit(), std::move(v), streamed_mutation::forwarding::yes, mutation_reader::forwarding::no); auto assertions = assert_that(std::move(reader)); @@ -1563,7 +1563,7 @@ SEASTAR_THREAD_TEST_CASE(test_foreign_reader_as_mutation_source) { const auto remote_shard = (this_shard_id() + 1) % smp::count; auto frozen_mutations = ranges::to>( mutations - | std::views::transform([] (const mutation& m) { return freeze(m); })); + | boost::adaptors::transformed([] (const mutation& m) { return freeze(m); })); auto remote_mt = smp::submit_to(remote_shard, [s = global_schema_ptr(s), &frozen_mutations] { auto mt = make_lw_shared(s.get()); @@ -1690,12 +1690,12 @@ SEASTAR_TEST_CASE(test_trim_clustering_row_ranges_to) { const auto check = [&schema] (std::vector ranges, key key, std::vector output_ranges, bool reversed = false, std::experimental::source_location sl = std::experimental::source_location::current()) { - auto actual_ranges = ranges::to(ranges | std::views::transform( + auto actual_ranges = ranges::to(ranges | boost::adaptors::transformed( [&] (const range& r) { return r.to_clustering_range(*schema); })); query::trim_clustering_row_ranges_to(*schema, actual_ranges, key.to_clustering_key(*schema), reversed); - const auto expected_ranges = ranges::to(output_ranges | std::views::transform( + const auto expected_ranges = ranges::to(output_ranges | boost::adaptors::transformed( [&] (const range& r) { return r.to_clustering_range(*schema); })); if (!std::equal(actual_ranges.begin(), actual_ranges.end(), expected_ranges.begin(), expected_ranges.end(), @@ -2180,7 +2180,7 @@ multishard_reader_for_read_ahead prepare_multishard_reader_for_read_ahead_test(s remote_controls.emplace_back(nullptr); } - parallel_for_each(std::views::iota(0u, smp::count), [&remote_controls] (unsigned shard) mutable { + parallel_for_each(boost::irange(0u, smp::count), [&remote_controls] (unsigned shard) mutable { return smp::submit_to(shard, [] { return make_foreign(std::make_unique()); }).then([shard, &remote_controls] (foreign_ptr>&& ctr) mutable { @@ -2196,7 +2196,7 @@ multishard_reader_for_read_ahead prepare_multishard_reader_for_read_ahead_test(s auto shard_pkeys = std::vector>(smp::count, std::vector{}); auto i = unsigned(0); - for (auto pkey : pkeys_by_tokens | std::views::values) { + for (auto pkey : pkeys_by_tokens | boost::adaptors::map_values) { shard_pkeys[i++ % smp::count].push_back(pkey); } @@ -2297,14 +2297,14 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_combining_reader_destroyed_with_pending // Destroy reader. reader = flat_mutation_reader(nullptr); - parallel_for_each(std::views::iota(0u, smp::count), [&remote_controls] (unsigned shard) mutable { + parallel_for_each(boost::irange(0u, smp::count), [&remote_controls] (unsigned shard) mutable { return smp::submit_to(shard, [control = remote_controls.at(shard).get()] { control->buffer_filled.set_value(); }); }).get(); BOOST_REQUIRE(eventually_true([&] { - return map_reduce(std::views::iota(0u, smp::count), [&] (unsigned shard) { + return map_reduce(boost::irange(0u, smp::count), [&] (unsigned shard) { return smp::submit_to(shard, [&remote_controls, shard] { return remote_controls.at(shard)->destroyed; }); @@ -2363,7 +2363,7 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_combining_reader_fast_forwarded_with_pe fut.get(); const auto all_shard_fast_forwarded = map_reduce( - std::views::iota(0u, multishard_reader_for_read_ahead::blocked_shard + 1u), + boost::irange(0u, multishard_reader_for_read_ahead::blocked_shard + 1u), [&] (unsigned shard) { return smp::submit_to(shard, [control = remote_controls.at(shard).get()] { return control->fast_forward_to == 1; @@ -2382,7 +2382,7 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_combining_reader_fast_forwarded_with_pe reader = flat_mutation_reader(nullptr); BOOST_REQUIRE(eventually_true([&] { - return map_reduce(std::views::iota(0u, smp::count), [&] (unsigned shard) { + return map_reduce(boost::irange(0u, smp::count), [&] (unsigned shard) { return smp::submit_to(shard, [&remote_controls, shard] { return remote_controls.at(shard)->destroyed; }); @@ -2417,8 +2417,8 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_combining_reader_next_partition) { auto& partitioner = schema->get_partitioner(); auto pkeys = ranges::to>( - std::views::iota(0, partition_count) | - std::views::transform([schema, &partitioner] (int i) { + boost::irange(0, partition_count) | + boost::adaptors::transformed([schema, &partitioner] (int i) { return partitioner.decorate_key(*schema, partition_key::from_singular(*schema, i)); })); From 3249516f2e6ff641ff8d9c94e1ee3ed8b4dfca02 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 28 Sep 2020 19:00:33 +0300 Subject: [PATCH 5/5] test: view_build_test: drop Clang has trouble with some parts of . Replace with boost range adaptors for now. --- test/boost/view_build_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/boost/view_build_test.cc b/test/boost/view_build_test.cc index 9064d4f064..8c1bb937f1 100644 --- a/test/boost/view_build_test.cc +++ b/test/boost/view_build_test.cc @@ -805,7 +805,7 @@ SEASTAR_THREAD_TEST_CASE(test_view_update_generator_buffering) { const auto partition_size_sets = std::vector>{{12}, {8, 4}, {8, 16}, {22}, {8, 8, 8, 8}, {8, 8, 8, 16, 8}, {8, 20, 16, 16}, {50}, {21}, {21, 2}}; const auto max_partition_set_size = std::ranges::max_element(partition_size_sets, [] (const std::vector& a, const std::vector& b) { return a.size() < b.size(); })->size(); - auto pkeys = ranges::to>(std::views::iota(size_t{0}, max_partition_set_size) | std::views::transform([schema] (int i) { + auto pkeys = ranges::to>(boost::irange(size_t{0}, max_partition_set_size) | boost::adaptors::transformed([schema] (int i) { return dht::decorate_key(*schema, partition_key::from_single_value(*schema, int32_type->decompose(data_value(i)))); })); std::ranges::sort(pkeys, dht::ring_position_less_comparator(*schema));