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

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

commit cae92be9f660692dfb39b65985673ad8d4a86cf2
Author: shuwenwei <[email protected]>
AuthorDate: Mon Oct 13 12:01:38 2025 +0800

    add lazy bitmap
---
 .../db/utils/datastructure/AlignedTVList.java      |  4 +-
 .../iotdb/db/utils/datastructure/LazyBitMap.java   | 82 ++++++++++++++++++++++
 2 files changed, 84 insertions(+), 2 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
index 81615904b95..15fa7696e39 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
@@ -1881,7 +1881,7 @@ public abstract class AlignedTVList extends TVList {
 
       int validRowCount = 0;
       // duplicated time or deleted time are all invalid, true if we don't 
need this row
-      BitMap timeInvalidInfo = null;
+      LazyBitMap timeInvalidInfo = null;
 
       int[] deleteCursor = {0};
       int startIndex = index;
@@ -1913,7 +1913,7 @@ public abstract class AlignedTVList extends TVList {
           validRowCount++;
         } else {
           if (Objects.isNull(timeInvalidInfo)) {
-            timeInvalidInfo = new BitMap(rows);
+            timeInvalidInfo = new LazyBitMap(index, maxNumberOfPointsInPage, 
rows - 1);
           }
           // For this timeInvalidInfo, we mark all positions that are not the 
last one in the
           // ASC traversal. It has the same behaviour for the DESC traversal, 
because our ultimate
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/LazyBitMap.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/LazyBitMap.java
new file mode 100644
index 00000000000..65c4d84d437
--- /dev/null
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/LazyBitMap.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.utils.datastructure;
+
+import org.apache.tsfile.utils.BitMap;
+
+public class LazyBitMap {
+  private final int startPosition;
+  private final int endPosition;
+  private final int blockSize;
+  private final BitMap[] blocks;
+
+  public LazyBitMap(int startIndex, int appendSize, int endIndex) {
+    if (endIndex < startIndex) {
+      throw new IllegalArgumentException("endIndex must be >= startIndex");
+    }
+    if (appendSize <= 0) {
+      throw new IllegalArgumentException("appendSize must be positive");
+    }
+    this.startPosition = startIndex;
+    this.endPosition = endIndex;
+    this.blockSize = appendSize;
+    int blockCount = (endIndex - startIndex + appendSize) / appendSize;
+    this.blocks = new BitMap[blockCount];
+  }
+
+  public void mark(int index) {
+    if (index < startPosition) {
+      throw new IndexOutOfBoundsException("Index below startPosition: " + 
index);
+    }
+    if (index > endPosition) {
+      throw new IndexOutOfBoundsException("Index exceeds endPosition: " + 
index);
+    }
+    int blockIndex = getBlockIndex(index);
+    BitMap block = blocks[blockIndex];
+    if (block == null) {
+      block = new BitMap(blockSize);
+      blocks[blockIndex] = block;
+    }
+    block.mark(getInnerIndex(index));
+  }
+
+  public boolean isMarked(int index) {
+    if (index < startPosition) {
+      return false;
+    }
+    if (index > endPosition) {
+      throw new IndexOutOfBoundsException("Index exceeds endPosition: " + 
index);
+    }
+    int blockIndex = getBlockIndex(index);
+    BitMap block = blocks[blockIndex];
+    if (block == null) {
+      return false;
+    }
+    return block.isMarked(getInnerIndex(index));
+  }
+
+  private int getBlockIndex(int index) {
+    return (index - startPosition) / blockSize;
+  }
+
+  private int getInnerIndex(int index) {
+    return (index - startPosition) % blockSize;
+  }
+}

Reply via email to