bziobrowski commented on code in PR #15095: URL: https://github.com/apache/pinot/pull/15095#discussion_r1963046883
########## pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/AggregateOperator.java: ########## @@ -108,33 +110,28 @@ public AggregateOperator(OpChainExecutionContext context, MultiStageOperator inp List<Integer> groupKeys = node.getGroupKeys(); - //process order trimming hint - int groupTrimSize = getGroupTrimSize(node.getNodeHint(), context.getOpChainMetadata()); - - if (groupTrimSize > -1) { - // limit is set to 0 if not pushed - int nodeLimit = node.getLimit() > 0 ? node.getLimit() : Integer.MAX_VALUE; - int limit = GroupByUtils.getTableCapacity(nodeLimit, groupTrimSize); - _groupTrimSize = limit; - if (limit == Integer.MAX_VALUE) { - // disable sorting because actual result can't realistically be bigger the limit - _priorityQueue = null; + int groupTrimSize = Integer.MAX_VALUE; + Comparator<Object[]> comparator = null; + int limit = node.getLimit(); + if (limit > 0) { + List<RelFieldCollation> collations = node.getCollations(); + if (collations.isEmpty()) { + groupTrimSize = limit; } else { - List<RelFieldCollation> collations = node.getCollations(); - if (collations != null && !collations.isEmpty()) { - // order needs to be reversed so that peek() can be used to compare with each output row - _priorityQueue = - new PriorityQueue<>(groupTrimSize, new SortUtils.SortComparator(_resultSchema, collations, true)); - } else { - _priorityQueue = null; + int minGroupTrimSize = getMinGroupTrimSize(node.getNodeHint(), context.getOpChainMetadata()); + groupTrimSize = GroupByUtils.getTableCapacity(limit, minGroupTrimSize); + if (groupTrimSize <= 0) { Review Comment: Is `groupTrimSize = Integer.MAX_VALUE;` reachable ? -- 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