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

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 00d46e689f [core] Fix disk usage calculation in ExternalBuffer. (#6680)
00d46e689f is described below

commit 00d46e689f3b41b937626eeb143f3c0fd10575b4
Author: zhoulii <[email protected]>
AuthorDate: Wed Nov 26 21:36:24 2025 +0800

    [core] Fix disk usage calculation in ExternalBuffer. (#6680)
---
 .../main/java/org/apache/paimon/disk/ExternalBuffer.java |  7 ++++---
 .../java/org/apache/paimon/disk/ExternalBufferTest.java  | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/disk/ExternalBuffer.java 
b/paimon-core/src/main/java/org/apache/paimon/disk/ExternalBuffer.java
index 138061cc6c..60cb36bd2f 100644
--- a/paimon-core/src/main/java/org/apache/paimon/disk/ExternalBuffer.java
+++ b/paimon-core/src/main/java/org/apache/paimon/disk/ExternalBuffer.java
@@ -102,7 +102,8 @@ public class ExternalBuffer implements RowBuffer {
         }
     }
 
-    private long getDiskUsage() {
+    @VisibleForTesting
+    public long getDiskUsage() {
         long bytes = 0;
 
         for (ChannelWithMeta spillChannelID : spilledChannelIDs) {
@@ -164,7 +165,7 @@ public class ExternalBuffer implements RowBuffer {
             LOG.info(
                     "here spill the reset buffer data with {} records {} 
bytes",
                     inMemoryBuffer.size(),
-                    channelWriterOutputView.getNumBytes());
+                    channelWriterOutputView.getWriteBytes());
             channelWriterOutputView.close();
         } catch (IOException e) {
             channelWriterOutputView.closeAndDelete();
@@ -175,7 +176,7 @@ public class ExternalBuffer implements RowBuffer {
                 new ChannelWithMeta(
                         channel,
                         inMemoryBuffer.getNumRecordBuffers(),
-                        channelWriterOutputView.getNumBytes()));
+                        channelWriterOutputView.getWriteBytes()));
 
         inMemoryBuffer.reset();
     }
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/disk/ExternalBufferTest.java 
b/paimon-core/src/test/java/org/apache/paimon/disk/ExternalBufferTest.java
index 6265258d10..19922709df 100644
--- a/paimon-core/src/test/java/org/apache/paimon/disk/ExternalBufferTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/disk/ExternalBufferTest.java
@@ -32,7 +32,9 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
 import java.io.IOException;
+import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
@@ -115,6 +117,20 @@ public class ExternalBufferTest {
         assertThat(buffer.getSpillChannels().size()).isGreaterThan(0);
         assertThat(buffer.flushMemory()).isFalse();
 
+        assertThat(buffer.getDiskUsage())
+                .isEqualTo(
+                        buffer.getSpillChannels().stream()
+                                .map(
+                                        c -> {
+                                            try {
+                                                return Files.size(
+                                                        
Paths.get(c.getChannel().getPath()));
+                                            } catch (IOException e) {
+                                                throw new RuntimeException(e);
+                                            }
+                                        })
+                                .reduce(0L, Long::sum));
+
         // repeat read
         assertBuffer(expected, buffer);
         buffer.newIterator();

Reply via email to