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

rong pushed a commit to branch rc/1.3.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rc/1.3.3 by this push:
     new cb795f4e928 Pipe / Subscription : Fixed the bug that 
TsFileInsertionScanDataContainer may use wrong isMultiPage flag for aligned 
chunk when value chunk is not continuous (#13554) (#13566)
cb795f4e928 is described below

commit cb795f4e9287be9d9b56d7a56b8e31fedea1fe6d
Author: Caideyipi <[email protected]>
AuthorDate: Fri Sep 20 21:48:15 2024 +0800

    Pipe / Subscription : Fixed the bug that TsFileInsertionScanDataContainer 
may use wrong isMultiPage flag for aligned chunk when value chunk is not 
continuous (#13554) (#13566)
---
 .../scan/TsFileInsertionScanDataContainer.java        | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/container/scan/TsFileInsertionScanDataContainer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/container/scan/TsFileInsertionScanDataContainer.java
index 558a00225c9..7bbed7737e4 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/container/scan/TsFileInsertionScanDataContainer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/container/scan/TsFileInsertionScanDataContainer.java
@@ -70,13 +70,15 @@ public class TsFileInsertionScanDataContainer extends 
TsFileInsertionDataContain
   private IChunkReader chunkReader;
   private BatchData data;
 
-  private boolean isMultiPage;
+  private boolean currentIsMultiPage;
   private String currentDevice;
   private boolean currentIsAligned;
   private final List<MeasurementSchema> currentMeasurements = new 
ArrayList<>();
 
   // Cached time chunk
   private final List<Chunk> timeChunkList = new ArrayList<>();
+  private final List<Boolean> isMultiPageList = new ArrayList<>();
+
   private final Map<String, Integer> measurementIndexMap = new HashMap<>();
   private int lastIndex = -1;
   private ChunkHeader firstChunkHeader4NextSequentialValueChunks;
@@ -187,7 +189,8 @@ public class TsFileInsertionScanDataContainer extends 
TsFileInsertionDataContain
 
       boolean isFirstRow = true;
       while (data.hasCurrent()) {
-        if (isMultiPage || data.currentTime() >= startTime && 
data.currentTime() <= endTime) {
+        if (currentIsMultiPage
+            || data.currentTime() >= startTime && data.currentTime() <= 
endTime) {
           if (isFirstRow) {
             // Calculate row count and memory size of the tablet based on the 
first row
             Pair<Integer, Integer> rowCountAndMemorySize =
@@ -219,7 +222,7 @@ public class TsFileInsertionScanDataContainer extends 
TsFileInsertionDataContain
       }
 
       if (tablet == null) {
-        tablet = new Tablet(currentDevice.toString(), currentMeasurements, 1);
+        tablet = new Tablet(currentDevice, currentMeasurements, 1);
         tablet.initBitMaps();
         // Ignore the memory cost of tablet
         
PipeDataNodeResourceManager.memory().forceResize(allocatedMemoryBlockForTablet, 
0);
@@ -346,7 +349,7 @@ public class TsFileInsertionScanDataContainer extends 
TsFileInsertionDataContain
         case MetaMarker.ONLY_ONE_PAGE_TIME_CHUNK_HEADER:
           // Notice that the data in one chunk group is either aligned or 
non-aligned
           // There is no need to consider non-aligned chunks when there are 
value chunks
-          isMultiPage = marker == MetaMarker.CHUNK_HEADER || marker == 
MetaMarker.TIME_CHUNK_HEADER;
+          currentIsMultiPage = marker == MetaMarker.CHUNK_HEADER;
 
           chunkHeader = tsFileSequenceReader.readChunkHeader(marker);
 
@@ -361,6 +364,7 @@ public class TsFileInsertionScanDataContainer extends 
TsFileInsertionDataContain
             timeChunkList.add(
                 new Chunk(
                     chunkHeader, tsFileSequenceReader.readChunk(-1, 
chunkHeader.getDataSize())));
+            isMultiPageList.add(marker == MetaMarker.TIME_CHUNK_HEADER);
             break;
           }
 
@@ -371,7 +375,7 @@ public class TsFileInsertionScanDataContainer extends 
TsFileInsertionDataContain
           }
 
           chunkReader =
-              isMultiPage
+              currentIsMultiPage
                   ? new ChunkReader(
                       new Chunk(
                           chunkHeader,
@@ -433,13 +437,13 @@ public class TsFileInsertionScanDataContainer extends 
TsFileInsertionDataContain
           if (recordAlignedChunk(valueChunkList, marker)) {
             return;
           }
-          // TODO: Replace it by IDeviceID
           final String deviceID =
               ((PlainDeviceID) 
tsFileSequenceReader.readChunkGroupHeader().getDeviceID())
                   .toStringID();
           // Clear because the cached data will never be used in the next 
chunk group
           lastIndex = -1;
           timeChunkList.clear();
+          isMultiPageList.clear();
           measurementIndexMap.clear();
 
           currentDevice = pattern.mayOverlapWithDevice(deviceID) ? deviceID : 
null;
@@ -461,8 +465,9 @@ public class TsFileInsertionScanDataContainer extends 
TsFileInsertionDataContain
   private boolean recordAlignedChunk(final List<Chunk> valueChunkList, final 
byte marker)
       throws IOException {
     if (!valueChunkList.isEmpty()) {
+      currentIsMultiPage = isMultiPageList.get(lastIndex);
       chunkReader =
-          isMultiPage
+          currentIsMultiPage
               ? new AlignedChunkReader(timeChunkList.get(lastIndex), 
valueChunkList, filter)
               : new 
AlignedSinglePageWholeChunkReader(timeChunkList.get(lastIndex), valueChunkList);
       currentIsAligned = true;

Reply via email to