luoluoyuyu commented on code in PR #19184:
URL: https://github.com/apache/iotdb/pull/19184#discussion_r4510828085


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/splitter/BatchedAlignedValueChunkData.java:
##########
@@ -190,4 +189,32 @@ protected void encodeAndBuildChunks() throws IOException, 
PageException {
       dataSize += valueData.remaining() + valueStat.getSerializedSize();
     }
   }
+
+  /**
+   * Whether any page of the chunk holds rows of this time partition. Only 
such a chunk mirrors the
+   * page slots of its time chunk, because only then does the time chunk have 
a page to pair with; a
+   * chunk that holds no row at all keeps the zero-page layout. This is the 
counterpart of the rule
+   * applied by the base class to the chunks it writes itself.
+   */
+  private static boolean hasPageWithRows(
+      final List<PageBuffer> chunkPages, final long startTime, final long 
endTime) {
+    for (final PageBuffer page : chunkPages) {
+      if (!page.needDecode) {
+        // A page copied as it is was read from this partition, so a page with 
a body always
+        // carries rows of the partition and only an all-null page has no body.
+        if (page.pageData.remaining() > 0) {
+          return true;
+        }
+        continue;
+      }
+      // A decoded page may be entirely outside the partition, and its 
timestamps are the only
+      // reliable record of the rows it contributes here.
+      for (final long time : page.timeBatch) {

Review Comment:
   Done in 5941397: `hasPageWithRows` now takes the answer from 
`PageBuffer.satisfiedLength` (decoded pages) and `pageData.remaining() > 0` 
(copied pages) — the same test as `AlignedChunkData#hasPageWithData` — so the 
timestamps are not visited twice. `satisfiedLength` is filled in by 
`TsFileSplitter` when it splits the page (the counter is reset at each 
partition boundary), so `> 0` is exactly "this page has rows in the partition". 
Thanks for catching it.



-- 
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]

Reply via email to