Skip to content

Commit 500453b

Browse files
k-rusdjatnieks
authored andcommitted
Remove unnecessary duplicated removal of ordering predicates (#1509)
buildKeysIterationPlan removes ordering predicates from an expression before planning. During planning buildPlanForExpressions is called, which repeats removing ordering predicates without consistently using the result. To reduce unnecessary duplicated removal it's removed from buildPlanForExpressions and replaced with an assertion. Also its visibility is reduced from public to default as it's called within the package only.
1 parent 4cbfa85 commit 500453b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/java/org/apache/cassandra/index/sai/plan/QueryController.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,16 +519,15 @@ private Plan.KeysIteration buildInequalityPlan(Expression predicate)
519519
* @param builder The plan node builder which receives the built index scans
520520
* @param expressions The expressions to build the plan from
521521
*/
522-
public void buildPlanForExpressions(Plan.Builder builder, Collection<Expression> expressions)
522+
void buildPlanForExpressions(Plan.Builder builder, Collection<Expression> expressions)
523523
{
524524
Operation.OperationType op = builder.type;
525525
assert !expressions.isEmpty() : "expressions should not be empty for " + op + " in " + command.rowFilter().root();
526526

527-
// VSTODO move ANN out of expressions and into its own abstraction? That will help get generic ORDER BY support
528-
Collection<Expression> exp = expressions.stream().filter(e -> e.operation != Expression.Op.ORDER_BY).collect(Collectors.toList());
527+
assert !expressions.stream().anyMatch(e -> e.operation == Expression.Op.ORDER_BY);
529528

530529
// we cannot use indexes with OR if we have a mix of indexed and non-indexed columns (see CNDB-10142)
531-
if (op == Operation.OperationType.OR && !exp.stream().allMatch(e -> e.context.isIndexed()))
530+
if (op == Operation.OperationType.OR && !expressions.stream().allMatch(e -> e.context.isIndexed()))
532531
{
533532
builder.add(planFactory.everything);
534533
return;

0 commit comments

Comments
 (0)