You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by sh...@apache.org on 2025/09/03 10:57:54 UTC

(iotdb) branch fixBug0903-1.3 created (now 188e21859d7)

This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a change to branch fixBug0903-1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 188e21859d7 Page time range set in TVListIterator is not processed

This branch includes the following new commits:

     new 188e21859d7 Page time range set in TVListIterator is not processed

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(iotdb) 01/01: Page time range set in TVListIterator is not processed

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch fixBug0903-1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 188e21859d7502211cdbfda008037be8687fd5c1
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Wed Sep 3 18:54:58 2025 +0800

    Page time range set in TVListIterator is not processed
---
 .../apache/iotdb/db/utils/datastructure/TVList.java    | 18 ++++++++++++++++++
 .../dataregion/memtable/AlignedTVListIteratorTest.java | 14 ++++++++++----
 .../memtable/NonAlignedTVListIteratorTest.java         | 11 +++++++++--
 3 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/TVList.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/TVList.java
index c88968d6ffa..e37fdec551e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/TVList.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/TVList.java
@@ -813,6 +813,9 @@ public abstract class TVList implements WALEntryValue {
         case BOOLEAN:
           while (index < rows && builder.getPositionCount() < maxNumberOfPointsInPage) {
             long time = getTime(getScanOrderIndex(index));
+            if (isCurrentTimeExceedTimeRange(time)) {
+              break;
+            }
             if (!isNullValue(getValueIndex(getScanOrderIndex(index)))
                 && !isPointDeleted(time, deletionList, deleteCursor, scanOrder)
                 && isLatestPoint(index, time)
@@ -831,6 +834,9 @@ public abstract class TVList implements WALEntryValue {
         case DATE:
           while (index < rows && builder.getPositionCount() < maxNumberOfPointsInPage) {
             long time = getTime(getScanOrderIndex(index));
+            if (isCurrentTimeExceedTimeRange(time)) {
+              break;
+            }
             if (!isNullValue(getValueIndex(getScanOrderIndex(index)))
                 && !isPointDeleted(time, deletionList, deleteCursor, scanOrder)
                 && isLatestPoint(index, time)
@@ -849,6 +855,9 @@ public abstract class TVList implements WALEntryValue {
         case TIMESTAMP:
           while (index < rows && builder.getPositionCount() < maxNumberOfPointsInPage) {
             long time = getTime(getScanOrderIndex(index));
+            if (isCurrentTimeExceedTimeRange(time)) {
+              break;
+            }
             if (!isNullValue(getValueIndex(getScanOrderIndex(index)))
                 && !isPointDeleted(time, deletionList, deleteCursor, scanOrder)
                 && isLatestPoint(index, time)
@@ -866,6 +875,9 @@ public abstract class TVList implements WALEntryValue {
         case FLOAT:
           while (index < rows && builder.getPositionCount() < maxNumberOfPointsInPage) {
             long time = getTime(getScanOrderIndex(index));
+            if (isCurrentTimeExceedTimeRange(time)) {
+              break;
+            }
             if (!isNullValue(getValueIndex(getScanOrderIndex(index)))
                 && !isPointDeleted(time, deletionList, deleteCursor, scanOrder)
                 && isLatestPoint(index, time)
@@ -885,6 +897,9 @@ public abstract class TVList implements WALEntryValue {
         case DOUBLE:
           while (index < rows && builder.getPositionCount() < maxNumberOfPointsInPage) {
             long time = getTime(getScanOrderIndex(index));
+            if (isCurrentTimeExceedTimeRange(time)) {
+              break;
+            }
             if (!isNullValue(getValueIndex(getScanOrderIndex(index)))
                 && !isPointDeleted(time, deletionList, deleteCursor, scanOrder)
                 && isLatestPoint(index, time)
@@ -906,6 +921,9 @@ public abstract class TVList implements WALEntryValue {
         case STRING:
           while (index < rows && builder.getPositionCount() < maxNumberOfPointsInPage) {
             long time = getTime(getScanOrderIndex(index));
+            if (isCurrentTimeExceedTimeRange(time)) {
+              break;
+            }
             if (!isNullValue(getValueIndex(getScanOrderIndex(index)))
                 && !isPointDeleted(time, deletionList, deleteCursor, scanOrder)
                 && isLatestPoint(index, time)
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedTVListIteratorTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedTVListIteratorTest.java
index 59e58182f6f..758e0869f2c 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedTVListIteratorTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedTVListIteratorTest.java
@@ -618,11 +618,15 @@ public class AlignedTVListIteratorTest {
     List<Statistics<? extends Serializable>> pageStatisticsList = chunk.getTimeStatisticsList();
     int count = 0;
     long offset = paginationController.getCurOffset();
+    if (!scanOrder.isAscending()) {
+      Collections.reverse(pageStatisticsList);
+    }
     for (Statistics<? extends Serializable> statistics : pageStatisticsList) {
-      if (statistics.getStartTime() <= statistics.getEndTime()) {
-        memPointIterator.setCurrentPageTimeRange(
-            new TimeRange(statistics.getStartTime(), statistics.getEndTime()));
-      }
+      TimeRange currentTimeRange =
+          (statistics.getStartTime() <= statistics.getEndTime())
+              ? new TimeRange(statistics.getStartTime(), statistics.getEndTime())
+              : null;
+      memPointIterator.setCurrentPageTimeRange(currentTimeRange);
       while (memPointIterator.hasNextBatch()) {
         TsBlock tsBlock = memPointIterator.nextBatch();
         for (int i = 0; i < tsBlock.getPositionCount(); i++) {
@@ -635,6 +639,8 @@ public class AlignedTVListIteratorTest {
             count++;
           }
           long currentTimestamp = tsBlock.getTimeByIndex(i);
+          Assert.assertTrue(
+              currentTimeRange == null || currentTimeRange.contains(currentTimestamp));
           Long int64Value = tsBlock.getColumn(0).isNull(i) ? null : tsBlock.getColumn(0).getLong(i);
           Boolean boolValue =
               tsBlock.getColumn(1).isNull(i) ? null : tsBlock.getColumn(1).getBoolean(i);
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/NonAlignedTVListIteratorTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/NonAlignedTVListIteratorTest.java
index a984eaada1f..c22dcbb6b0f 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/NonAlignedTVListIteratorTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/memtable/NonAlignedTVListIteratorTest.java
@@ -497,9 +497,15 @@ public class NonAlignedTVListIteratorTest {
     List<Statistics<? extends Serializable>> pageStatisticsList = chunk.getPageStatisticsList();
     int count = 0;
     long offset = paginationController.getCurOffset();
+    if (!scanOrder.isAscending()) {
+      Collections.reverse(pageStatisticsList);
+    }
     for (Statistics<? extends Serializable> statistics : pageStatisticsList) {
-      memPointIterator.setCurrentPageTimeRange(
-          new TimeRange(statistics.getStartTime(), statistics.getEndTime()));
+      TimeRange currentTimeRange =
+          (statistics.getStartTime() <= statistics.getEndTime())
+              ? new TimeRange(statistics.getStartTime(), statistics.getEndTime())
+              : null;
+      memPointIterator.setCurrentPageTimeRange(currentTimeRange);
       while (memPointIterator.hasNextBatch()) {
         TsBlock tsBlock = memPointIterator.nextBatch();
         for (int i = 0; i < tsBlock.getPositionCount(); i++) {
@@ -512,6 +518,7 @@ public class NonAlignedTVListIteratorTest {
             count++;
           }
           long currentTimestamp = tsBlock.getTimeByIndex(i);
+          Assert.assertTrue(currentTimeRange.contains(currentTimestamp));
           long value = tsBlock.getColumn(0).getLong(i);
           Assert.assertEquals(currentTimestamp, value);
           if (globalTimeFilter != null) {