Skip to content

Commit

Permalink
[core] fix comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
LinMingQiang committed Jan 13, 2025
1 parent dca2077 commit 99dcebd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/layouts/shortcodes/generated/core_configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@
<td><h5>write.skip-actions</h5></td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
<td>This parameter only works when write-only is false., You can specify which actions to skip during the write process.<br />1. 'partition-expire': skipping partition expire.<br />2. 'snapshot-expire': skipping snapshot expire.<br />3. 'create-tag': skipping auto create tag.<br />Both can be configured at the same time: 'partition-expire,snapshot-expire,create-tag'.</td>
<td>This parameter only works when write-only is false., You can specify which actions to skip during the write process.<br />1. 'partition-expire': Skip the action of partition expiration.<br />2. 'snapshot-expire': Skip the action of snapshot expiration.<br />3. 'create-tag': Skip automatic tag creation.<br />Both can be configured at the same time: 'partition-expire,snapshot-expire,create-tag'.</td>
</tr>
<tr>
<td><h5>zorder.var-length-contribution</h5></td>
Expand Down
33 changes: 20 additions & 13 deletions paimon-common/src/main/java/org/apache/paimon/CoreOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,13 @@ public class CoreOptions implements Serializable {
.text(
"This parameter only works when write-only is false., You can specify which actions to skip during the write process.")
.linebreak()
.text("1. 'partition-expire': skipping partition expire.")
.text(
"1. 'partition-expire': Skip the action of partition expiration.")
.linebreak()
.text("2. 'snapshot-expire': skipping snapshot expire.")
.text(
"2. 'snapshot-expire': Skip the action of snapshot expiration.")
.linebreak()
.text("3. 'create-tag': skipping auto create tag.")
.text("3. 'create-tag': Skip automatic tag creation.")
.linebreak()
.text(
"Both can be configured at the same time: 'partition-expire,snapshot-expire,create-tag'.")
Expand Down Expand Up @@ -2260,24 +2262,29 @@ public boolean writeOnly() {
return options.get(WRITE_ONLY);
}

public HashSet<WriteAction> writeSkippingActions() {
String str = options.get(WRITE_SKIP_ACTIONS);
return StringUtils.isNullOrWhitespaceOnly(str)
? new HashSet<>(0)
: Arrays.stream(str.split(","))
.map(action -> WriteAction.valueOf(action.toUpperCase().replace('-', '_')))
.collect(Collectors.toCollection(HashSet::new));
public Set<WriteAction> writeSkippingActions() {
return options.getOptional(WRITE_SKIP_ACTIONS)
.map(
str ->
Arrays.stream(str.split(","))
.map(
action ->
WriteAction.valueOf(
action.toUpperCase()
.replace('-', '_')))
.collect(Collectors.toCollection(HashSet::new)))
.orElseGet(() -> new HashSet<>(0));
}

public boolean skippingPartitionExpire(HashSet<WriteAction> skippingActions) {
public boolean skippingPartitionExpire(Set<WriteAction> skippingActions) {
return writeOnly() || skippingActions.contains(WriteAction.PARTITION_EXPIRE);
}

public boolean skippingSnapshotExpire(HashSet<WriteAction> skippingActions) {
public boolean skippingSnapshotExpire(Set<WriteAction> skippingActions) {
return writeOnly() || skippingActions.contains(WriteAction.SNAPSHOT_EXPIRE);
}

public boolean skippingAutoCreateTag(HashSet<WriteAction> skippingActions) {
public boolean skippingAutoCreateTag(Set<WriteAction> skippingActions) {
return writeOnly() || skippingActions.contains(WriteAction.CREATE_TAG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.Set;
import java.util.SortedMap;
import java.util.function.BiConsumer;

Expand Down Expand Up @@ -434,7 +434,7 @@ public ExpireSnapshots newExpireChangelog() {
public TableCommitImpl newCommit(String commitUser) {
CoreOptions options = coreOptions();
Runnable snapshotExpire = null;
HashSet<WriteAction> skippingActions = options.writeSkippingActions();
Set<WriteAction> skippingActions = options.writeSkippingActions();
if (!options.skippingSnapshotExpire(skippingActions)) {
boolean changelogDecoupled = options.changelogLifecycleDecoupled();
ExpireConfig expireConfig = options.expireConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testSkippingAllActionsAndWriteOnly(String action) throws Exception {
HashMap<String, String> options =
createOptions(
action.equals("do-all")
? ""
? null
: "partition-expire,snapshot-expire,create-tag");

if (action.equals("write-only")) {
Expand Down Expand Up @@ -170,7 +170,9 @@ private HashMap<String, String> createOptions(String skippingActions) {
options.put(CoreOptions.FULL_COMPACTION_DELTA_COMMITS.key(), "1");

// skipping actions .
options.put(CoreOptions.WRITE_SKIP_ACTIONS.key(), skippingActions);
if (skippingActions != null) {
options.put(CoreOptions.WRITE_SKIP_ACTIONS.key(), skippingActions);
}

return options;
}
Expand Down

0 comments on commit 99dcebd

Please sign in to comment.