jt2594838 commented on a change in pull request #2859:
URL: https://github.com/apache/iotdb/pull/2859#discussion_r595798710
##########
File path:
server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/FirstValueAggrResult.java
##########
@@ -94,11 +94,26 @@ public void updateResultUsingTimestamps(
if (hasFinalResult()) {
return;
}
+ for (int i = 0; i < length; i++) {
+ long[] oneTimestamp = new long[1];
+ oneTimestamp[0] = timestamps[i];
+ Object[] values = dataReader.getValuesInTimestamps(oneTimestamp, 1);
+ if (values[0] != null) {
+ setValue(values[0]);
+ timestamp = timestamps[i];
+ break;
+ }
+ }
Review comment:
This has a potential performance problem when there are many null values
in the front. For example, `timestamps.length == 1000` but the first 999 values
are all null, then you will have to call `dataReader.getValuesInTimestamps` for
a thousand times, which may incur some overhead.
My suggestion would be to add an interface `getFirstValueInTimestamps` in
`dataReader` which returns the first non-null value that is in the given
timestamps.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]