diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index f3364ab0cb..6e2eff0eb8 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -221,20 +221,9 @@ static std::vector extract_partition_range( return {}; } -/// Extracts where_clause atoms with clustering-column LHS and copies them to a vector such that: -/// 1. all elements must be simultaneously satisfied (as restrictions) for where_clause to be satisfied -/// 2. each element is an atom or a conjunction of atoms -/// 3. either all atoms (across all elements) are multi-column or they are all single-column -/// 4. if single-column, then: -/// 4.1 all atoms from an element have the same LHS, which we call the element's LHS -/// 4.2 each element's LHS is different from any other element's LHS -/// 4.3 the list of each element's LHS, in order, forms a clustering-key prefix -/// 4.4 elements other than the last have only EQ or IN atoms -/// 4.5 the last element has only EQ, IN, or is_slice() atoms -/// -/// These elements define the boundaries of any clustering slice that can possibly meet where_clause. -/// -/// This vector can be calculated before binding expression markers, since LHS and operator are always known. +/// Extracts where_clause atoms with clustering-column LHS and copies them to a vector. These elements define the +/// boundaries of any clustering slice that can possibly meet where_clause. This vector can be calculated before +/// binding expression markers, since LHS and operator are always known. static std::vector extract_clustering_prefix_restrictions( const expr::expression& where_clause, schema_ptr schema) { using namespace expr; diff --git a/cql3/restrictions/statement_restrictions.hh b/cql3/restrictions/statement_restrictions.hh index 33b70fa798..de36039336 100644 --- a/cql3/restrictions/statement_restrictions.hh +++ b/cql3/restrictions/statement_restrictions.hh @@ -105,8 +105,30 @@ private: bool _has_queriable_regular_index = false, _has_queriable_pk_index = false, _has_queriable_ck_index = false; std::optional _where; ///< The entire WHERE clause. - std::vector _clustering_prefix_restrictions; ///< Parts of _where defining the clustering slice. - std::vector _partition_range_restrictions; ///< Parts of _where defining the partition range. + + /// Parts of _where defining the clustering slice. + /// + /// Meets all of the following conditions: + /// 1. all elements must be simultaneously satisfied (as restrictions) for _where to be satisfied + /// 2. each element is an atom or a conjunction of atoms + /// 3. either all atoms (across all elements) are multi-column or they are all single-column + /// 4. if single-column, then: + /// 4.1 all atoms from an element have the same LHS, which we call the element's LHS + /// 4.2 each element's LHS is different from any other element's LHS + /// 4.3 the list of each element's LHS, in order, forms a clustering-key prefix + /// 4.4 elements other than the last have only EQ or IN atoms + /// 4.5 the last element has only EQ, IN, or is_slice() atoms + /// 5. if multi-column, then each element is a binary_operator + std::vector _clustering_prefix_restrictions; + + /// Parts of _where defining the partition range. + /// + /// If the partition range is dictated by token restrictions, this is a single element that holds all the + /// binary_operators on token. If single-column restrictions define the partition range, each element holds + /// restrictions for one partition column. Each partition column has a corresponding element, but the elements + /// are in arbitrary order. + std::vector _partition_range_restrictions; + bool _partition_range_is_simple; ///< False iff _partition_range_restrictions imply a Cartesian product. public: