Jackie-Jiang commented on code in PR #9086:
URL: https://github.com/apache/pinot/pull/9086#discussion_r937206583
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/SumPrecisionAggregationFunction.java:
##########
@@ -126,10 +147,120 @@ public void aggregate(int length,
AggregationResultHolder aggregationResultHolde
aggregationResultHolder.setValue(sum);
}
+ private void aggregateNullHandlingEnabled(int length,
AggregationResultHolder aggregationResultHolder,
+ BlockValSet blockValSet, RoaringBitmap nullBitmap) {
+ BigDecimal sum = BigDecimal.ZERO;
+ switch (blockValSet.getValueType().getStoredType()) {
+ case INT: {
+ int[] intValues = blockValSet.getIntValuesSV();
+ if (nullBitmap.getCardinality() < length) {
+ // TODO: need to update the for-loop terminating condition to: i <
length & i < intValues.length?
+ for (int i = 0; i < length; i++) {
+ if (!nullBitmap.contains(i)) {
+ sum = sum.add(BigDecimal.valueOf(intValues[i]));
+ }
+ }
+ setAggregationResult(aggregationResultHolder, sum);
+ }
+ break;
+ }
+ case LONG: {
+ long[] longValues = blockValSet.getLongValuesSV();
+ if (nullBitmap.getCardinality() < length) {
+ for (int i = 0; i < length; i++) {
+ if (!nullBitmap.contains(i)) {
+ sum = sum.add(BigDecimal.valueOf(longValues[i]));
+ }
+ }
+ setAggregationResult(aggregationResultHolder, sum);
+ }
+ break;
+ }
+ case FLOAT: {
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ if (nullBitmap.getCardinality() < length) {
+ for (int i = 0; i < length; i++) {
+ if (!nullBitmap.contains(i)) {
+ if (Float.isFinite(floatValues[i])) {
+ sum = sum.add(BigDecimal.valueOf(floatValues[i]));
+ }
+ }
+ }
+ setAggregationResult(aggregationResultHolder, sum);
+ }
+ break;
+ }
+ case DOUBLE: {
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ if (nullBitmap.getCardinality() < length) {
+ for (int i = 0; i < length; i++) {
+ if (!nullBitmap.contains(i)) {
+ // TODO(nhejazi): throw an exception here instead of ignoring
infinite values?
+ if (Double.isFinite(doubleValues[i])) {
Review Comment:
Currently the behavior is inconsistent without null handling (throw
exception) and with null handling (values ignored). We may revisit this since
you already added a TODO here
--
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]