songwdfu commented on code in PR #16308:
URL: https://github.com/apache/pinot/pull/16308#discussion_r2275213731


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/query/GroupByOperator.java:
##########
@@ -139,24 +138,47 @@ protected GroupByResultsBlock getNextBlock() {
     // TODO: Currently the groups are not trimmed if there is no ordering 
specified. Consider ordering on group-by
     //       columns if no ordering is specified.
     int trimSize = _queryContext.getEffectiveSegmentGroupTrimSize();
-    if (trimSize > 0) {
-      if (groupByExecutor.getNumGroups() > trimSize) {
-        TableResizer tableResizer = new TableResizer(_dataSchema, 
_queryContext);
-        Collection<IntermediateRecord> intermediateRecords = 
groupByExecutor.trimGroupByResult(trimSize, tableResizer);
-        // trim groupKeyGenerator after getting intermediateRecords
-        groupByExecutor.getGroupKeyGenerator().close();
-
-        
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;
-      }
+    boolean unsafeTrim = _queryContext.isUnsafeTrim();
+
+    if (trimSize == 0) {

Review Comment:
   Same as the above



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