siddharthteotia commented on a change in pull request #8139: URL: https://github.com/apache/pinot/pull/8139#discussion_r800104010
########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/MaxAggregationFunction.java ########## @@ -54,13 +54,39 @@ public GroupByResultHolder createGroupByResultHolder(int initialCapacity, int ma @Override public void aggregate(int length, AggregationResultHolder aggregationResultHolder, Map<ExpressionContext, BlockValSet> blockValSetMap) { - double[] valueArray = blockValSetMap.get(_expression).getDoubleValuesSV(); double max = aggregationResultHolder.getDoubleResult(); - for (int i = 0; i < length; i++) { - double value = valueArray[i]; - if (value > max) { - max = value; + BlockValSet blockValSet = blockValSetMap.get(_expression); + switch (blockValSet.getValueType().getStoredType()) { + case INT: { + int[] values = blockValSet.getIntValuesSV(); + for (int i = 0; i < length & i < values.length; i++) { + max = Math.max(values[i], max); + } + break; + } + case LONG: { + long[] values = blockValSet.getLongValuesSV(); + for (int i = 0; i < length & i < values.length; i++) { + max = Math.max(values[i], max); + } + break; + } + case FLOAT: { + float[] values = blockValSet.getFloatValuesSV(); + for (int i = 0; i < length & i < values.length; i++) { + max = Math.max(values[i], max); + } + break; + } + case DOUBLE: { + double[] values = blockValSet.getDoubleValuesSV(); + for (int i = 0; i < length & i < values.length; i++) { + max = Math.max(values[i], max); + } + break; } + default: + throw new IllegalStateException(); Review comment: Let's include a message in exception ? -- 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