siddharthteotia commented on code in PR #15350:
URL: https://github.com/apache/pinot/pull/15350#discussion_r2059651015


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/query/SelectionOnlyOperator.java:
##########
@@ -63,24 +63,33 @@ public SelectionOnlyOperator(IndexSegment indexSegment, 
QueryContext queryContex
     _queryContext = queryContext;
     _nullHandlingEnabled = queryContext.isNullHandlingEnabled();
     _projectOperator = projectOperator;
-    _expressions = expressions;
 
-    int numExpressions = expressions.size();
-    _blockValSets = new BlockValSet[numExpressions];
-    String[] columnNames = new String[numExpressions];
-    DataSchema.ColumnDataType[] columnDataTypes = new 
DataSchema.ColumnDataType[numExpressions];
-    for (int i = 0; i < numExpressions; i++) {
-      ExpressionContext expression = expressions.get(i);
-      columnNames[i] = expression.toString();
+    // Use temp lists to gather valid expressions, names, and data types
+    List<String> columnNamesList = new ArrayList<>();
+    List<DataSchema.ColumnDataType> columnDataTypesList = new ArrayList<>();
+    List<ExpressionContext> filteredExpressions = new ArrayList<>();
+
+    for (ExpressionContext expression : expressions) {

Review Comment:
   (nit) `for-each` coding pattern has a non-zero performance penalty compared 
to vanilla `list.get(index)` since compiler resolves it to iterator which then 
leverages` iterator.hasNext()` conditional check, `.next()` dereference etc.
   
   So I suggest sticking to the for loop. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to