Skip to content

Commit 8817917

Browse files
xiangfu0claude
andcommitted
Fix operator priority: prefer range/inverted index over raw sorted index
When a column has both a range index and is raw-sorted, the range index should be preferred over raw sorted binary search. Moved raw sorted checks after specialized index checks to fix TextMatchTransformFunctionTest. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 62e833a commit 8817917

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

pinot-core/src/main/java/org/apache/pinot/core/operator/filter/FilterOperatorUtils.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ public BaseFilterOperator getLeafFilterOperator(QueryContext queryContext, Predi
9898
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.SORTED)) {
9999
return new SortedIndexBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
100100
}
101+
if (RangeIndexBasedFilterOperator.canEvaluate(predicateEvaluator, dataSource)
102+
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.RANGE)) {
103+
return new RangeIndexBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
104+
}
101105
if (dataSource.getDataSourceMetadata().isSorted() && dataSource.getDictionary() == null
102106
&& dataSource.getDataSourceMetadata().isSingleValue()
103107
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.SORTED)) {
104108
return new RawSortedIndexBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
105109
}
106-
if (RangeIndexBasedFilterOperator.canEvaluate(predicateEvaluator, dataSource)
107-
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.RANGE)) {
108-
return new RangeIndexBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
109-
}
110110
return new ScanBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
111111
} else if (predicateType == Predicate.Type.REGEXP_LIKE) {
112112
if (predicateEvaluator instanceof BaseDictIdBasedRegexpLikePredicateEvaluator) {
@@ -125,11 +125,6 @@ public BaseFilterOperator getLeafFilterOperator(QueryContext queryContext, Predi
125125
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.SORTED)) {
126126
return new SortedIndexBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
127127
}
128-
if (dataSource.getDataSourceMetadata().isSorted() && dataSource.getDictionary() == null
129-
&& dataSource.getDataSourceMetadata().isSingleValue()
130-
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.SORTED)) {
131-
return new RawSortedIndexBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
132-
}
133128
if (dataSource.getInvertedIndex() != null
134129
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.INVERTED)) {
135130
// Use raw value inverted index filter operator for raw encoded columns
@@ -142,6 +137,11 @@ public BaseFilterOperator getLeafFilterOperator(QueryContext queryContext, Predi
142137
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.RANGE)) {
143138
return new RangeIndexBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
144139
}
140+
if (dataSource.getDataSourceMetadata().isSorted() && dataSource.getDictionary() == null
141+
&& dataSource.getDataSourceMetadata().isSingleValue()
142+
&& queryContext.isIndexUseAllowed(dataSource, FieldConfig.IndexType.SORTED)) {
143+
return new RawSortedIndexBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
144+
}
145145
return new ScanBasedFilterOperator(queryContext, predicateEvaluator, dataSource, numDocs);
146146
}
147147
}

0 commit comments

Comments
 (0)