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


##########
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:
   **[P2] Avoid rescanning decoded timestamps to detect rows** This pre-scan 
walks every timestamp in each decoded page, and the encoding loop immediately 
traverses the same array again. `PageBuffer.satisfiedLength` already records 
the number of rows this page contributes to the current partition (the base 
class uses it for the same presence check), so using that count here would 
avoid a second O(rows) pass for each standalone value chunk. For wide or large 
TsFiles, this adds repeat work to LOAD splitting per value column.



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