Copilot commented on code in PR #17063:
URL: https://github.com/apache/pinot/pull/17063#discussion_r2456872240
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AvgAggregationFunction.java:
##########
@@ -152,6 +188,49 @@ public void aggregateGroupByMV(int length, int[][]
groupKeysArray, GroupByResult
}
}
});
+ return;
+ }
+
+ if (blockValSet.isSingleValue()) {
+ aggregateSvGroupByMv(blockValSet, length, groupKeysArray,
groupByResultHolder);
+ } else {
+ aggregateMvGroupByMv(blockValSet, length, groupKeysArray,
groupByResultHolder);
+ }
+ }
+
+ private void aggregateSvGroupByMv(BlockValSet blockValSet, int length,
int[][] groupKeysArray,
+ GroupByResultHolder groupByResultHolder) {
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ forEachNotNull(length, blockValSet, (from, to) -> {
+ for (int i = from; i < to; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ updateGroupByResult(groupKey, groupByResultHolder, doubleValues[i],
1L);
+ }
+ }
+ });
+ }
+
+ private void aggregateMvGroupByMv(BlockValSet blockValSet, int length,
int[][] groupKeysArray,
+ GroupByResultHolder groupByResultHolder) {
+ double[][] valuesArray = blockValSet.getDoubleValuesMV();
+ forEachNotNull(length, blockValSet, (from, to) -> {
+ for (int i = from; i < to; i++) {
+ double[] values = valuesArray[i];
+ for (int groupKey : groupKeysArray[i]) {
+ aggregateOnGroupKey(groupKey, groupByResultHolder, values);
+ }
+ }
+ });
+ }
+
+ private void aggregateOnGroupKey(int groupKey, GroupByResultHolder
groupByResultHolder, double[] values) {
+ double sum = 0.0;
+ for (double value : values) {
+ sum += value;
+ }
+ long count = values.length;
+ if (count != 0) {
+ updateGroupByResult(groupKey, groupByResultHolder, sum, count);
}
Review Comment:
The check `if (count != 0)` on line 232 is unnecessary because
`values.length` can never be zero if the method was called through the
`forEachNotNull` iterator which filters null values. This check should be
removed to simplify the code.
```suggestion
updateGroupByResult(groupKey, groupByResultHolder, sum, count);
```
--
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]