diff --git a/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java b/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java index 0074f5ebd183..51ee83d0cbf6 100644 --- a/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java +++ b/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java @@ -77,6 +77,9 @@ public class AppendOnlyWriter implements RecordWriter, MemoryOwner private WriterMetrics writerMetrics; + /** The amount of time once compact takes*/ + private long compactTime; + public AppendOnlyWriter( FileIO fileIO, IOManager ioManager, @@ -210,6 +213,12 @@ public void close() throws Exception { sinkWriter.close(); } + @Override + public long getCompactTime() { + + return compactTime; + } + private RowDataRollingFileWriter createRollingRowWriter() { return new RowDataRollingFileWriter( fileIO, @@ -231,6 +240,7 @@ private void trySyncLatestCompaction(boolean blocking) result -> { compactBefore.addAll(result.before()); compactAfter.addAll(result.after()); + compactTime = result.compactTime(); }); } diff --git a/paimon-core/src/main/java/org/apache/paimon/compact/CompactResult.java b/paimon-core/src/main/java/org/apache/paimon/compact/CompactResult.java index 6a004d305202..18f8ac423d9e 100644 --- a/paimon-core/src/main/java/org/apache/paimon/compact/CompactResult.java +++ b/paimon-core/src/main/java/org/apache/paimon/compact/CompactResult.java @@ -31,6 +31,9 @@ public class CompactResult { private final List after; private final List changelog; + /** The amount of time once compact takes*/ + private long compactTime; + public CompactResult() { this(Collections.emptyList(), Collections.emptyList()); } @@ -62,6 +65,14 @@ public List changelog() { return changelog; } + public long compactTime() { + return compactTime; + } + + public void setCompactTime(long compactTime) { + this.compactTime = compactTime; + } + public void merge(CompactResult that) { before.addAll(that.before); after.addAll(that.after); diff --git a/paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreWrite.java b/paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreWrite.java index 083f23d53679..6391630568e2 100644 --- a/paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreWrite.java +++ b/paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreWrite.java @@ -420,6 +420,10 @@ public ExecutorService getCompactExecutor() { protected void notifyNewWriter(RecordWriter writer) {} + public Map>> getWriters() { + return writers; + } + protected abstract RecordWriter createWriter( BinaryRow partition, int bucket, diff --git a/paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java b/paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java index 6f46bc58ec3d..a7152df45221 100644 --- a/paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java +++ b/paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java @@ -69,4 +69,7 @@ public interface RecordWriter { /** Close this writer, the call will delete newly generated but not committed files. */ void close() throws Exception; + + /** get the time of once compact takes by compactManager*/ + long getCompactTime(); }