shuwenwei commented on code in PR #13380:
URL: https://github.com/apache/iotdb/pull/13380#discussion_r1746716325


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/readchunk/ReadChunkAlignedSeriesCompactionExecutor.java:
##########
@@ -515,11 +519,48 @@ private boolean canFlushPage(PageLoader timePage, 
List<PageLoader> valuePages) {
         if (valuePage.getModifiedStatus() == ModifiedStatus.PARTIAL_DELETED) {
           return false;
         }
-        if (valuePage.getHeader().getUncompressedSize() >= targetPageSize) {
+        if (Math.max(
+                valuePage.getHeader().getUncompressedSize(),
+                estimateMemorySizeAsPageWriter(valuePage))
+            >= targetPageSize) {
           largeEnough = true;
         }
       }
       return largeEnough;
     }
+
+    private long estimateMemorySizeAsPageWriter(PageLoader pageLoader) {
+      long count = pageLoader.getHeader().getStatistics().getCount();
+      long size;
+      switch (pageLoader.getDataType()) {
+        case INT32:
+        case DATE:
+          size = count * Integer.BYTES;
+          break;
+        case TIMESTAMP:
+        case INT64:
+        case VECTOR:
+          size = count * Long.BYTES;
+          break;
+        case FLOAT:
+          size = count * Float.BYTES;
+          break;
+        case DOUBLE:
+          size = count * Double.BYTES;
+          break;
+        case BOOLEAN:
+          size = count * Byte.BYTES;
+          break;
+        case TEXT:
+        case STRING:
+        case BLOB:
+          size = pageLoader.getHeader().getUncompressedSize();
+          break;
+        default:
+          throw new IllegalArgumentException(
+              "Unsupported data type: " + pageLoader.getDataType().toString());
+      }
+      return (long) (size * 1.05);

Review Comment:
   Added



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