cql3: statement_restrictions: push down clustering prefix wrapper one level

This allows us to tackle each case separately.
This commit is contained in:
Avi Kivity
2024-10-23 12:58:12 +03:00
parent 1039ed9ed2
commit dcdd2f7e72

View File

@@ -2642,11 +2642,13 @@ query::clustering_range range_from_raw_bounds(
get_clustering_bounds_fn_t
statement_restrictions::build_get_clustering_bounds_fn() const {
return [&] (const query_options& options) -> std::vector<query::clustering_range> {
if (_clustering_prefix_restrictions.empty()) {
return [&] (const query_options& options) -> std::vector<query::clustering_range> {
return {query::clustering_range::make_open_ended_both_sides()};
};
}
if (find_binop(_clustering_prefix_restrictions[0], is_multi_column)) {
return [&] (const query_options& options) -> std::vector<query::clustering_range> {
bool all_natural = true, all_reverse = true; ///< Whether column types are reversed or natural.
for (auto& r : _clustering_prefix_restrictions) { // TODO: move to constructor, do only once.
using namespace expr;
@@ -2678,10 +2680,12 @@ statement_restrictions::build_get_clustering_bounds_fn() const {
}
}
return bounds;
};
} else {
return [&] (const query_options& options) -> std::vector<query::clustering_range> {
return get_single_column_clustering_bounds(options, *_schema, _clustering_prefix_restrictions);
};
}
};
}
std::vector<query::clustering_range> statement_restrictions::get_clustering_bounds(const query_options& options) const {