mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-29 11:10:40 +00:00
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 <dejan@scylladb.com>
This commit is contained in:
committed by
Avi Kivity
parent
9dac9a25e5
commit
29fccd76ea
@@ -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<typename Fn>
|
||||
requires std::regular_invocable<Fn, const binary_operator&>
|
||||
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<token>(o.lhs); });
|
||||
return find_atom(e, [] (const binary_operator& o) { return std::holds_alternative<token>(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.
|
||||
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void merge_with(::shared_ptr<restriction> restriction) override {
|
||||
if (find_if(restriction->expression, [] (const binary_operator& b) {
|
||||
if (find_atom(restriction->expression, [] (const binary_operator& b) {
|
||||
return std::holds_alternative<std::vector<column_value>>(b.lhs)
|
||||
&& std::get<std::vector<column_value>>(b.lhs).size() > 1;
|
||||
})) {
|
||||
|
||||
@@ -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<bytes_opt> 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<std::vector<column_value>>(oper.lhs);
|
||||
});
|
||||
if (found) {
|
||||
|
||||
Reference in New Issue
Block a user