richardstartin commented on a change in pull request #8138:
URL: https://github.com/apache/pinot/pull/8138#discussion_r800106224



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CaseTransformFunction.java
##########
@@ -209,17 +220,23 @@ public TransformResultMetadata getResultMetadata() {
       return super.transformToIntValuesSV(projectionBlock);
     }
     int[] selected = getSelectedArray(projectionBlock);
-    if (_intResults == null) {
-      _intResults = new int[DocIdSetPlanNode.MAX_DOC_PER_CALL];
+    int numDocs = projectionBlock.getNumDocs();
+    if (_intResults == null || _intResults.length < numDocs) {
+      _intResults = new int[numDocs];
     }
     int numElseThenStatements = _elseThenStatements.size();
     for (int i = 0; i < numElseThenStatements; i++) {
-      TransformFunction transformFunction = _elseThenStatements.get(i);
-      int[] intValues = 
transformFunction.transformToIntValuesSV(projectionBlock);
-      int numDocs = projectionBlock.getNumDocs();
-      for (int j = 0; j < numDocs; j++) {
-        if (selected[j] == i) {
-          _intResults[j] = intValues[j];
+      if (_selections[i]) {
+        TransformFunction transformFunction = _elseThenStatements.get(i);
+        int[] intValues = 
transformFunction.transformToIntValuesSV(projectionBlock);
+        if (_numSelections == 1) {
+          System.arraycopy(intValues, 0, _intResults, 0, numDocs);
+        } else {

Review comment:
       the alternative is the loop below which handles the generic case, which 
is a lot slower.




-- 
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