Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public void testCreateNewInstantTime() throws Exception {
}

executorService.shutdown();
assertTrue(executorService.awaitTermination(10, TimeUnit.SECONDS));
assertTrue(executorService.awaitTermination(60, TimeUnit.SECONDS));
// required to catch exceptions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modify it because the test is flaky.

for (Future f : futures) {
f.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,31 @@ protected void setUp(Configuration conf) {
conf.setBoolean(FlinkOptions.COMPACTION_ASYNC_ENABLED, false);
}

@Test
public void testIndexStateBootstrapWithMultiFilesInOneSlice() throws Exception {
// open the function and ingest data
preparePipeline(conf)
.consume(TestData.filterOddRows(TestData.DATA_SET_INSERT))
.assertEmptyDataFiles()
.checkpoint(1)
.assertNextEvent()
.checkpointComplete(1)
.consume(TestData.filterEvenRows(TestData.DATA_SET_INSERT))
.checkpoint(2)
.assertNextEvent()
.checkpointComplete(2)
.checkWrittenData(EXPECTED1, 4)
// write another commit but does not complete it
.consume(TestData.filterEvenRows(TestData.DATA_SET_INSERT))
.checkpoint(3)
.assertNextEvent()
.end();

// reset the config option
conf.setBoolean(FlinkOptions.INDEX_BOOTSTRAP_ENABLED, true);
validateIndexLoaded();
}

@Test
public void testIndexStateBootstrapWithCompactionScheduled() throws Exception {
// sets up the delta commits as 1 to generate a new compaction plan.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -304,6 +305,24 @@ public static List<RowData> dataSetInsert(int... ids) {
return inserts;
}

public static List<RowData> filterOddRows(List<RowData> rows) {
return filterRowsByIndexPredicate(rows, i -> i % 2 != 0);
}

public static List<RowData> filterEvenRows(List<RowData> rows) {
return filterRowsByIndexPredicate(rows, i -> i % 2 == 0);
}

private static List<RowData> filterRowsByIndexPredicate(List<RowData> rows, Predicate<Integer> predicate) {
List<RowData> filtered = new ArrayList<>();
for (int i = 0; i < rows.size(); i++) {
if (predicate.test(i)) {
filtered.add(rows.get(i));
}
}
return filtered;
}

private static Integer toIdSafely(Object id) {
if (id == null) {
return -1;
Expand Down