From 12793e4bb7d124bbc48082d1cbabff478c9a1c73 Mon Sep 17 00:00:00 2001 From: zhoulii Date: Thu, 7 Mar 2024 22:46:46 +0800 Subject: [PATCH] [core] add commit.force-expire option --- .../shortcodes/generated/core_configuration.html | 6 ++++++ .../src/main/java/org/apache/paimon/CoreOptions.java | 10 ++++++++++ .../apache/paimon/table/AbstractFileStoreTable.java | 8 ++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/layouts/shortcodes/generated/core_configuration.html b/docs/layouts/shortcodes/generated/core_configuration.html index a1bf28c62c77..409144bd4e69 100644 --- a/docs/layouts/shortcodes/generated/core_configuration.html +++ b/docs/layouts/shortcodes/generated/core_configuration.html @@ -86,6 +86,12 @@ Boolean Whether to force create snapshot on commit. + +
commit.force-expire
+ false + Boolean + Whether to force a expiration before commit. +
compaction.max-size-amplification-percent
200 diff --git a/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java b/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java index f8eec84fbab1..d04a3ce26f8f 100644 --- a/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java +++ b/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java @@ -378,6 +378,12 @@ public class CoreOptions implements Serializable { .defaultValue(MemorySize.ofMebiBytes(128)) .withDescription("Target size of a file."); + public static final ConfigOption FORCE_EXPIRE = + key("commit.force-expire") + .booleanType() + .defaultValue(false) + .withDescription("Whether to force a expiration before commit."); + public static final ConfigOption NUM_SORTED_RUNS_COMPACTION_TRIGGER = key("num-sorted-run.compaction-trigger") .intType() @@ -1353,6 +1359,10 @@ public boolean commitForceCompact() { return options.get(COMMIT_FORCE_COMPACT); } + public boolean forceExpire() { + return options.get(FORCE_EXPIRE); + } + public int maxSizeAmplificationPercent() { return options.get(COMPACTION_MAX_SIZE_AMPLIFICATION_PERCENT); } diff --git a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java index c2756fbfc573..202ec240e70c 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java @@ -320,8 +320,12 @@ public TableCommitImpl newCommit(String commitUser, String branchName) { store().newCommit(commitUser, branchName), createCommitCallbacks(), snapshotExpire, - options.writeOnly() ? null : store().newPartitionExpire(commitUser), - options.writeOnly() ? null : store().newTagCreationManager(), + options.writeOnly() && !options.forceExpire() + ? null + : store().newPartitionExpire(commitUser), + options.writeOnly() && !options.forceExpire() + ? null + : store().newTagCreationManager(), catalogEnvironment.lockFactory().create(), CoreOptions.fromMap(options()).consumerExpireTime(), new ConsumerManager(fileIO, path),