Jackie-Jiang commented on code in PR #16552:
URL: https://github.com/apache/pinot/pull/16552#discussion_r2263816253


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/mutable/MutableSegmentImpl.java:
##########
@@ -1011,37 +1016,40 @@ private void recordIndexingError(String indexType) {
   private void aggregateMetrics(GenericRow row, int docId) {
     for (MetricFieldSpec metricFieldSpec : _physicalMetricFieldSpecs) {
       IndexContainer indexContainer = 
_indexContainerMap.get(metricFieldSpec.getName());
+      // NOTE: value can be null if the column is not specified in the schema.
       Object value = row.getValue(indexContainer._sourceColumn);
+      // Skip aggregation if the input value is null.
+      if (value == null) {
+        continue;
+      }
       MutableForwardIndex forwardIndex =
           (MutableForwardIndex) 
indexContainer._mutableIndexes.get(StandardIndexes.forward());
       DataType dataType = metricFieldSpec.getDataType();
 
-      Double oldDoubleValue;
-      Double newDoubleValue;
-      Long oldLongValue;
-      Long newLongValue;
       ValueAggregator valueAggregator = indexContainer._valueAggregator;
       switch (valueAggregator.getAggregatedValueType()) {
         case DOUBLE:
+          double oldDoubleValue;
+          double newDoubleValue;
           switch (dataType) {
             case INT:
               oldDoubleValue = ((Integer) 
forwardIndex.getInt(docId)).doubleValue();
-              newDoubleValue = (Double) 
valueAggregator.applyRawValue(oldDoubleValue, value);
-              forwardIndex.setInt(docId, newDoubleValue.intValue());
+              newDoubleValue = (double) 
valueAggregator.applyRawValue(oldDoubleValue, value);

Review Comment:
   Good point. Didn't realize this is extra boxing/unboxing



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