yanghua commented on code in PR #6144:
URL: https://github.com/apache/hudi/pull/6144#discussion_r937298503
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/action/compact/TestInlineCompaction.java:
##########
@@ -93,6 +96,50 @@ public void testSuccessfulCompactionBasedOnNumCommits()
throws Exception {
}
}
+ @Test
+ public void testSuccessfulCompactionBasedOnNumAfterCompactionRequest()
throws Exception {
+ // Given: make 4 commits
+ HoodieWriteConfig cfg = getConfigForInlineCompaction(4, 60,
CompactionTriggerStrategy.NUM_COMMITS_AFTER_LAST_REQUEST);
+
+ List<String> instants = IntStream.range(0, 3).mapToObj(i ->
HoodieActiveTimeline.createNewInstantTime()).collect(Collectors.toList());
+
+ try (SparkRDDWriteClient<?> writeClient = getHoodieWriteClient(cfg)) {
+ List<HoodieRecord> records = dataGen.generateInserts(instants.get(0),
100);
+ HoodieReadClient readClient = getHoodieReadClient(cfg.getBasePath());
+ runNextDeltaCommits(writeClient, readClient, instants, records, cfg,
true, new ArrayList<>());
+
+ metaClient =
HoodieTableMetaClient.builder().setConf(hadoopConf).setBasePath(cfg.getBasePath()).build();
+
+ cfg.setValue(INLINE_COMPACT_NUM_DELTA_COMMITS,"1");
+ String requestInstant = HoodieActiveTimeline.createNewInstantTime();
+ // add one compaction request
+ scheduleCompaction(requestInstant, writeClient, cfg);
+ metaClient.getActiveTimeline().reload();
+
assertEquals(metaClient.getActiveTimeline().getInstants().filter(hoodieInstant
-> hoodieInstant.getAction().equals(HoodieTimeline.COMPACTION_ACTION)
Review Comment:
too long
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/action/compact/TestInlineCompaction.java:
##########
@@ -93,6 +96,50 @@ public void testSuccessfulCompactionBasedOnNumCommits()
throws Exception {
}
}
+ @Test
+ public void testSuccessfulCompactionBasedOnNumAfterCompactionRequest()
throws Exception {
+ // Given: make 4 commits
+ HoodieWriteConfig cfg = getConfigForInlineCompaction(4, 60,
CompactionTriggerStrategy.NUM_COMMITS_AFTER_LAST_REQUEST);
+
+ List<String> instants = IntStream.range(0, 3).mapToObj(i ->
HoodieActiveTimeline.createNewInstantTime()).collect(Collectors.toList());
+
+ try (SparkRDDWriteClient<?> writeClient = getHoodieWriteClient(cfg)) {
+ List<HoodieRecord> records = dataGen.generateInserts(instants.get(0),
100);
+ HoodieReadClient readClient = getHoodieReadClient(cfg.getBasePath());
+ runNextDeltaCommits(writeClient, readClient, instants, records, cfg,
true, new ArrayList<>());
+
+ metaClient =
HoodieTableMetaClient.builder().setConf(hadoopConf).setBasePath(cfg.getBasePath()).build();
+
+ cfg.setValue(INLINE_COMPACT_NUM_DELTA_COMMITS,"1");
Review Comment:
blank before "1"
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/action/compact/TestInlineCompaction.java:
##########
@@ -93,6 +96,50 @@ public void testSuccessfulCompactionBasedOnNumCommits()
throws Exception {
}
}
+ @Test
+ public void testSuccessfulCompactionBasedOnNumAfterCompactionRequest()
throws Exception {
+ // Given: make 4 commits
Review Comment:
it would be more readable, if you use `step 1, step 2` to describe your
intention. WDYT?
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/action/compact/TestInlineCompaction.java:
##########
@@ -93,6 +96,50 @@ public void testSuccessfulCompactionBasedOnNumCommits()
throws Exception {
}
}
+ @Test
+ public void testSuccessfulCompactionBasedOnNumAfterCompactionRequest()
throws Exception {
+ // Given: make 4 commits
+ HoodieWriteConfig cfg = getConfigForInlineCompaction(4, 60,
CompactionTriggerStrategy.NUM_COMMITS_AFTER_LAST_REQUEST);
+
+ List<String> instants = IntStream.range(0, 3).mapToObj(i ->
HoodieActiveTimeline.createNewInstantTime()).collect(Collectors.toList());
+
+ try (SparkRDDWriteClient<?> writeClient = getHoodieWriteClient(cfg)) {
+ List<HoodieRecord> records = dataGen.generateInserts(instants.get(0),
100);
+ HoodieReadClient readClient = getHoodieReadClient(cfg.getBasePath());
+ runNextDeltaCommits(writeClient, readClient, instants, records, cfg,
true, new ArrayList<>());
+
+ metaClient =
HoodieTableMetaClient.builder().setConf(hadoopConf).setBasePath(cfg.getBasePath()).build();
+
+ cfg.setValue(INLINE_COMPACT_NUM_DELTA_COMMITS,"1");
+ String requestInstant = HoodieActiveTimeline.createNewInstantTime();
+ // add one compaction request
+ scheduleCompaction(requestInstant, writeClient, cfg);
+ metaClient.getActiveTimeline().reload();
+
assertEquals(metaClient.getActiveTimeline().getInstants().filter(hoodieInstant
-> hoodieInstant.getAction().equals(HoodieTimeline.COMPACTION_ACTION)
+ && hoodieInstant.getState() ==
HoodieInstant.State.REQUESTED).count(), 1);
+ // can not add request second time
+ requestInstant = HoodieActiveTimeline.createNewInstantTime();
+ try {
+ scheduleCompaction(requestInstant, writeClient, cfg);
+ Assertions.fail();
+ } catch (AssertionError error) {
+ //should be here
+ }
+ cfg.setValue(INLINE_COMPACT_NUM_DELTA_COMMITS,"4");
Review Comment:
blank
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/compact/ScheduleCompactionActionExecutor.java:
##########
@@ -140,6 +140,17 @@ private Option<Pair<Integer, String>>
getLatestDeltaCommitInfo() {
return Option.empty();
}
+ private Option<Pair<Integer, String>>
getLatestDeltaCommitInfoSinceCompactionRequest() {
+ Option<Pair<HoodieTimeline, HoodieInstant>> deltaCommitsInfo =
Review Comment:
If you think hoodie timeline hosted commits, yes, reasonable.
--
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]