From 29fccd76eaaa0da641b91c8c64bd4957edbe5c9f Mon Sep 17 00:00:00 2001 From: Dejan Mircevski Date: Sat, 11 Jul 2020 15:17:48 +0200 Subject: [PATCH] cql/restrictions: Rename find_if to find_atom As requested in #5763 feedback, rename to avoid clashes with std::find_if and boost::find_if. Signed-off-by: Dejan Mircevski --- cql3/restrictions/restriction.hh | 14 +++++++------- .../single_column_primary_key_restrictions.hh | 2 +- cql3/restrictions/statement_restrictions.cc | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cql3/restrictions/restriction.hh b/cql3/restrictions/restriction.hh index ce0de4f2fc..8133d4002f 100644 --- a/cql3/restrictions/restriction.hh +++ b/cql3/restrictions/restriction.hh @@ -167,13 +167,13 @@ extern std::ostream& operator<<(std::ostream&, const expression&); /// If there is a binary_operator atom b for which f(b) is true, returns it. Otherwise returns null. template requires std::regular_invocable -const binary_operator* find_if(const expression& e, Fn f) { +const binary_operator* find_atom(const expression& e, Fn f) { return std::visit(overloaded_functor{ [&] (const binary_operator& op) { return f(op) ? &op : nullptr; }, [] (bool) -> const binary_operator* { return nullptr; }, [&] (const conjunction& conj) -> const binary_operator* { for (auto& child : conj.children) { - if (auto found = find_if(child, f)) { + if (auto found = find_atom(child, f)) { return found; } } @@ -197,23 +197,23 @@ size_t count_if(const expression& e, Fn f) { } inline const binary_operator* find(const expression& e, const operator_type& op) { - return find_if(e, [&] (const binary_operator& o) { return *o.op == op; }); + return find_atom(e, [&] (const binary_operator& o) { return *o.op == op; }); } inline bool needs_filtering(const expression& e) { - return find_if(e, [] (const binary_operator& o) { return o.op->needs_filtering(); }); + return find_atom(e, [] (const binary_operator& o) { return o.op->needs_filtering(); }); } inline bool has_slice(const expression& e) { - return find_if(e, [] (const binary_operator& o) { return o.op->is_slice(); }); + return find_atom(e, [] (const binary_operator& o) { return o.op->is_slice(); }); } inline bool has_token(const expression& e) { - return find_if(e, [] (const binary_operator& o) { return std::holds_alternative(o.lhs); }); + return find_atom(e, [] (const binary_operator& o) { return std::holds_alternative(o.lhs); }); } inline bool has_slice_or_needs_filtering(const expression& e) { - return find_if(e, [] (const binary_operator& o) { return o.op->is_slice() || o.op->needs_filtering(); }); + return find_atom(e, [] (const binary_operator& o) { return o.op->is_slice() || o.op->needs_filtering(); }); } /// True iff binary_operator involves a collection. diff --git a/cql3/restrictions/single_column_primary_key_restrictions.hh b/cql3/restrictions/single_column_primary_key_restrictions.hh index d4ed6f517d..4f4372bc6a 100644 --- a/cql3/restrictions/single_column_primary_key_restrictions.hh +++ b/cql3/restrictions/single_column_primary_key_restrictions.hh @@ -173,7 +173,7 @@ public: } virtual void merge_with(::shared_ptr restriction) override { - if (find_if(restriction->expression, [] (const binary_operator& b) { + if (find_atom(restriction->expression, [] (const binary_operator& b) { return std::holds_alternative>(b.lhs) && std::get>(b.lhs).size() > 1; })) { diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index 516eb2efeb..91110c08e2 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -249,7 +249,7 @@ statement_restrictions::statement_restrictions(database& db, if (_uses_secondary_indexing || _clustering_columns_restrictions->needs_filtering(*_schema)) { _index_restrictions.push_back(_clustering_columns_restrictions); - } else if (find_if(_clustering_columns_restrictions->expression, &is_on_collection)) { + } else if (find_atom(_clustering_columns_restrictions->expression, &is_on_collection)) { fail(unimplemented::cause::INDEXES); #if 0 _index_restrictions.push_back(new Forwardingprimary_key_restrictions() { @@ -463,7 +463,7 @@ void statement_restrictions::process_clustering_columns_restrictions(bool has_qu throw exceptions::invalid_request_exception( "Cannot restrict clustering columns by IN relations when a collection is selected by the query"); } - if (find_if(_clustering_columns_restrictions->expression, is_on_collection) + if (find_atom(_clustering_columns_restrictions->expression, is_on_collection) && !has_queriable_index && !allow_filtering) { throw exceptions::invalid_request_exception( "Cannot restrict clustering columns by a CONTAINS relation without a secondary index or filtering"); @@ -1153,7 +1153,7 @@ bool is_satisfied_by( std::vector first_multicolumn_bound( const expression& restr, const query_options& options, statements::bound bnd) { - auto found = find_if(restr, [bnd] (const binary_operator& oper) { + auto found = find_atom(restr, [bnd] (const binary_operator& oper) { return matches(oper.op, bnd) && std::holds_alternative>(oper.lhs); }); if (found) {