RocMarshal commented on a change in pull request #3813:
URL: https://github.com/apache/hudi/pull/3813#discussion_r738024300
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/compact/CompactionTriggerStrategy.java
##########
@@ -18,13 +18,87 @@
package org.apache.hudi.table.action.compact;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+@SuppressWarnings("checkstyle:LineLength")
public enum CompactionTriggerStrategy {
- // trigger compaction when reach N delta commits
- NUM_COMMITS,
- // trigger compaction when time elapsed > N seconds since last compaction
- TIME_ELAPSED,
- // trigger compaction when both NUM_COMMITS and TIME_ELAPSED are satisfied
- NUM_AND_TIME,
- // trigger compaction when NUM_COMMITS or TIME_ELAPSED is satisfied
- NUM_OR_TIME
+
+ // trigger compaction when reach N delta commits
+ NUM_COMMITS {
+ @Override
+ public boolean compactable(long compactInlineMaxDeltaCommits,
+ long deltaCommitsSinceLastCompaction,
+ long compactInlineMaxDeltaSeconds,
+ long deltaSecondsSinceLastCompaction) {
+ boolean compactable = compactInlineMaxDeltaCommits <=
deltaCommitsSinceLastCompaction;
+ if (compactable) {
+ LOG.info(String.format("The delta commits >= %s, trigger compaction
scheduler.", compactInlineMaxDeltaCommits));
+ }
+ return compactable;
+ }
+ },
+ // trigger compaction when time elapsed > N seconds since last compaction
+ TIME_ELAPSED {
+ @Override
+ public boolean compactable(long compactInlineMaxDeltaCommits,
+ long deltaCommitsSinceLastCompaction,
+ long compactInlineMaxDeltaSeconds,
+ long deltaSecondsSinceLastCompaction) {
+ boolean compactable = compactInlineMaxDeltaSeconds <=
deltaSecondsSinceLastCompaction;
+ if (compactable) {
+ LOG.info(String.format("The elapsed time >=%ss, trigger compaction
scheduler.", compactInlineMaxDeltaSeconds));
+ }
+ return compactable;
+ }
+ },
+ // trigger compaction when both NUM_COMMITS and TIME_ELAPSED are satisfied
+ NUM_AND_TIME {
+ @Override
+ public boolean compactable(long compactInlineMaxDeltaCommits,
+ long deltaCommitsSinceLastCompaction,
+ long compactInlineMaxDeltaSeconds,
+ long deltaSecondsSinceLastCompaction) {
+ boolean compactable = compactInlineMaxDeltaCommits <=
deltaCommitsSinceLastCompaction
+ && compactInlineMaxDeltaSeconds <= deltaSecondsSinceLastCompaction;
+ if (compactable) {
+ LOG.info(String.format("The delta commits >= %s or elapsed_time >=%ss,
trigger compaction scheduler.",
+ compactInlineMaxDeltaCommits, compactInlineMaxDeltaSeconds));
+ }
+ return compactable;
+ }
+ },
+ // trigger compaction when NUM_COMMITS or TIME_ELAPSED is satisfied
+ NUM_OR_TIME {
+ @Override
+ public boolean compactable(long compactInlineMaxDeltaCommits,
+ long deltaCommitsSinceLastCompaction,
+ long compactInlineMaxDeltaSeconds,
+ long deltaSecondsSinceLastCompaction) {
+ boolean compactable = compactInlineMaxDeltaCommits <=
deltaCommitsSinceLastCompaction
+ || compactInlineMaxDeltaSeconds <= deltaSecondsSinceLastCompaction;
+ if (compactable) {
+ LOG.info(String.format("The delta commits >= %s and elapsed_time
>=%ss, trigger compaction scheduler.",
+ compactInlineMaxDeltaCommits, compactInlineMaxDeltaSeconds));
+ }
+ return compactable;
+ }
+ };
+
+ /**
+ * Judge if the strategy could fire based on the condition.
+ *
+ * @param compactInlineMaxDeltaCommits {@link
org.apache.hudi.config.HoodieCompactionConfig#INLINE_COMPACT_NUM_DELTA_COMMITS}
+ * @param deltaCommitsSinceLastCompaction value in the condition.
+ * @param compactInlineMaxDeltaSeconds {@link
org.apache.hudi.config.HoodieCompactionConfig#INLINE_COMPACT_TIME_DELTA_SECONDS}
+ * @param deltaSecondsSinceLastCompaction value in the condition.
+ * @return true if it could be triggered, false else.
Review comment:
Thanks @danny0405 for the review . I updated it. Please let me know
what do you think of it .
--
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]