Jackie-Jiang commented on code in PR #16308:
URL: https://github.com/apache/pinot/pull/16308#discussion_r2277355304


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/query/FilteredGroupByOperator.java:
##########
@@ -187,28 +187,48 @@ protected GroupByResultsBlock getNextBlock() {
     // - There are more groups than the trim size
     // TODO: Currently the groups are not trimmed if there is no ordering 
specified. Consider ordering on group-by
     //       columns if no ordering is specified.
+    // TODO: extract common logic with GroupByOperator
     int trimSize = _queryContext.getEffectiveSegmentGroupTrimSize();
-    if (trimSize > 0) {
-      if (groupKeyGenerator.getNumKeys() > trimSize) {
-        TableResizer tableResizer = new TableResizer(_dataSchema, 
_queryContext);
-        Collection<IntermediateRecord> intermediateRecords =
-            tableResizer.trimInSegmentResults(groupKeyGenerator, 
groupByResultHolders, trimSize);
-        // Release the resources used by the group key generator
-        groupKeyGenerator.close();
+    boolean unsafeTrim = _queryContext.isUnsafeTrim();
 
-        
ServerMetrics.get().addMeteredGlobalValue(ServerMeter.AGGREGATE_TIMES_GROUPS_TRIMMED,
 1);
-        boolean unsafeTrim = _queryContext.isUnsafeTrim(); // set trim flag 
only if it's not safe
-        GroupByResultsBlock resultsBlock = new 
GroupByResultsBlock(_dataSchema, intermediateRecords, _queryContext);
-        resultsBlock.setGroupsTrimmed(unsafeTrim);
-        resultsBlock.setNumGroupsLimitReached(numGroupsLimitReached);
-        
resultsBlock.setNumGroupsWarningLimitReached(numGroupsWarningLimitReached);
-        return resultsBlock;
-      }
+    if (trimSize == 0) {

Review Comment:
   In that case, let's short circuit it at the beginning of `getNextBlock()` 
because we don't need any extra info to create the results block.
   (nit) We usually use `List.of()` to replace `Collections.emptyList()` for 
conciseness



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to