shuwenwei opened a new pull request, #17283:
URL: https://github.com/apache/iotdb/pull/17283
## Description
### Problem
In the streaming query path of MemChunkLoader, unpackOneFakeMemChunkMetaData
iterates through statisticsList to construct LazyMemVersionPageReader instances.
However, the original implementation always iterated statisticsList in
ascending order while using the following early termination logic:
```
(orderUtils.getAscending() && orderTime > satisfiedTimeRange.getMax())
|| (!orderUtils.getAscending() && orderTime < satisfiedTimeRange.getMin())
```
When executing a descending scan, statisticsList is still ordered from small
to large timestamps. This may cause the loop to break prematurely because the
first element already satisfies orderTime < satisfiedTimeRange.getMin(), even
though later elements could still fall within the query time range.
As a result, some valid pages may not be added to the page reader list,
leading to missing data during descending scans.
### Solution
This PR fixes the issue by iterating statisticsList according to the scan
order:
• Ascending scan: iterate statisticsList in its natural order.
• Descending scan: iterate statisticsList in reverse order.
With this change, the early termination condition (break) becomes correct
for both scan directions because the iteration order now matches the scan order.
The behavior is now consistent with the logic used in
unpackOneChunkMetaData, where pageReaderList is also traversed differently
depending on the scan order.
--
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]