RocMarshal commented on a change in pull request #3813:
URL: https://github.com/apache/hudi/pull/3813#discussion_r772792723
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/compact/ScheduleCompactionActionExecutor.java
##########
@@ -141,53 +139,16 @@ private HoodieCompactionPlan scheduleCompaction() {
}
private boolean needCompact(CompactionTriggerStrategy
compactionTriggerStrategy) {
- boolean compactable;
+
+ if (compactionTriggerStrategy == null) {
+ throw new HoodieCompactionException("Unsupported compaction trigger
strategy: {}"
+ + config.getInlineCompactTriggerStrategy());
+ }
// get deltaCommitsSinceLastCompaction and lastCompactionTs
Pair<Integer, String> latestDeltaCommitInfo = getLatestDeltaCommitInfo();
int inlineCompactDeltaCommitMax = config.getInlineCompactDeltaCommitMax();
int inlineCompactDeltaSecondsMax =
config.getInlineCompactDeltaSecondsMax();
- switch (compactionTriggerStrategy) {
- case NUM_COMMITS:
- compactable = inlineCompactDeltaCommitMax <=
latestDeltaCommitInfo.getLeft();
- if (compactable) {
- LOG.info(String.format("The delta commits >= %s, trigger compaction
scheduler.", inlineCompactDeltaCommitMax));
- }
- break;
- case TIME_ELAPSED:
- compactable = inlineCompactDeltaSecondsMax <=
parsedToSeconds(instantTime) -
parsedToSeconds(latestDeltaCommitInfo.getRight());
- if (compactable) {
- LOG.info(String.format("The elapsed time >=%ss, trigger compaction
scheduler.", inlineCompactDeltaSecondsMax));
- }
- break;
- case NUM_OR_TIME:
- compactable = inlineCompactDeltaCommitMax <=
latestDeltaCommitInfo.getLeft()
- || inlineCompactDeltaSecondsMax <= parsedToSeconds(instantTime) -
parsedToSeconds(latestDeltaCommitInfo.getRight());
- if (compactable) {
- LOG.info(String.format("The delta commits >= %s or elapsed_time
>=%ss, trigger compaction scheduler.", inlineCompactDeltaCommitMax,
- inlineCompactDeltaSecondsMax));
- }
- break;
- case NUM_AND_TIME:
- compactable = inlineCompactDeltaCommitMax <=
latestDeltaCommitInfo.getLeft()
- && inlineCompactDeltaSecondsMax <= parsedToSeconds(instantTime) -
parsedToSeconds(latestDeltaCommitInfo.getRight());
- if (compactable) {
- LOG.info(String.format("The delta commits >= %s and elapsed_time
>=%ss, trigger compaction scheduler.", inlineCompactDeltaCommitMax,
- inlineCompactDeltaSecondsMax));
- }
- break;
- default:
- throw new HoodieCompactionException("Unsupported compaction trigger
strategy: " + config.getInlineCompactTriggerStrategy());
- }
- return compactable;
- }
-
- private Long parsedToSeconds(String time) {
- long timestamp;
- try {
- timestamp =
HoodieActiveTimeline.parseDateFromInstantTime(time).getTime() / 1000;
- } catch (ParseException e) {
- throw new HoodieCompactionException(e.getMessage(), e);
- }
- return timestamp;
+ return compactionTriggerStrategy
Review comment:
Good idea.
--
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]