-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HUDI-5007] Prevent Hudi from reading the entire timeline's when perf…
…orming a LATEST streaming read
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...atasource/hudi-flink/src/test/java/org/apache/hudi/source/TestIncrementalInputSplits.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.apache.hudi.source; | ||
|
||
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline; | ||
import org.apache.hudi.common.table.timeline.HoodieInstant; | ||
import org.apache.hudi.common.table.timeline.HoodieTimeline; | ||
import org.apache.hudi.common.testutils.HoodieCommonTestHarness; | ||
import org.apache.hudi.configuration.FlinkOptions; | ||
import org.apache.hudi.utils.TestConfigurations; | ||
|
||
import org.apache.flink.configuration.Configuration; | ||
import org.apache.flink.core.fs.Path; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertIterableEquals; | ||
|
||
public class TestIncrementalInputSplits extends HoodieCommonTestHarness { | ||
|
||
@BeforeEach | ||
private void init() throws IOException { | ||
initPath(); | ||
initMetaClient(); | ||
} | ||
|
||
@Test | ||
void testFilterInstantsWithRange() { | ||
HoodieActiveTimeline timeline = new HoodieActiveTimeline(metaClient, true); | ||
Configuration conf = TestConfigurations.getDefaultConf(basePath); | ||
IncrementalInputSplits iis = IncrementalInputSplits.builder() | ||
.conf(conf) | ||
.path(new Path(basePath)) | ||
.rowType(TestConfigurations.ROW_TYPE) | ||
.build(); | ||
|
||
HoodieInstant commit1 = new HoodieInstant(HoodieInstant.State.COMPLETED, HoodieTimeline.DELTA_COMMIT_ACTION, "1"); | ||
HoodieInstant commit2 = new HoodieInstant(HoodieInstant.State.COMPLETED, HoodieTimeline.DELTA_COMMIT_ACTION, "2"); | ||
HoodieInstant commit3 = new HoodieInstant(HoodieInstant.State.COMPLETED, HoodieTimeline.DELTA_COMMIT_ACTION, "3"); | ||
timeline.createNewInstant(commit1); | ||
timeline.createNewInstant(commit2); | ||
timeline.createNewInstant(commit3); | ||
timeline = timeline.reload(); | ||
|
||
// previous read iteration read till instant time "1", next read iteration should return ["2", "3"] | ||
List<HoodieInstant> instantRange2 = iis.filterInstantsWithRange(timeline, "1"); | ||
assertEquals(2, instantRange2.size()); | ||
assertIterableEquals(Arrays.asList(commit2, commit3), instantRange2); | ||
|
||
// simulate first iteration cycle with read from LATEST commit | ||
List<HoodieInstant> instantRange1 = iis.filterInstantsWithRange(timeline, null); | ||
assertEquals(1, instantRange1.size()); | ||
assertIterableEquals(Collections.singletonList(commit3), instantRange1); | ||
|
||
// specifying a start and end commit | ||
conf.set(FlinkOptions.READ_START_COMMIT, "1"); | ||
conf.set(FlinkOptions.READ_END_COMMIT, "3"); | ||
List<HoodieInstant> instantRange3 = iis.filterInstantsWithRange(timeline, null); | ||
assertEquals(3, instantRange3.size()); | ||
assertIterableEquals(Arrays.asList(commit1, commit2, commit3), instantRange3); | ||
} | ||
|
||
} |