Skip to content

Commit

Permalink
[Bug] Fix the IndexOutOfBoundsException when lookup empty sortedRun (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitozi authored Dec 20, 2023
1 parent 1308150 commit 998e5b1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public static <T> T lookup(
SortedRun level,
BiFunctionWithIOE<InternalRow, DataFileMeta, T> lookup)
throws IOException {
if (!level.nonEmpty()) {
return null;
}
List<DataFileMeta> files = level.files();
int left = 0;
int right = files.size() - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,22 @@ public void testMaxDiskSize() throws IOException {
assertThat(lookupLevels.lookupFiles().estimatedSize()).isEqualTo(0);
}

@Test
public void testLookupEmptyLevel() throws IOException {
Levels levels =
new Levels(
comparator,
Arrays.asList(
newFile(1, kv(1, 11), kv(3, 33), kv(5, 5)),
// empty level 2
newFile(3, kv(2, 22), kv(5, 55))),
3);
LookupLevels lookupLevels = createLookupLevels(levels, MemorySize.ofMebiBytes(10));

KeyValue kv = lookupLevels.lookup(row(2), 1);
assertThat(kv).isNotNull();
}

private LookupLevels createLookupLevels(Levels levels, MemorySize maxDiskSize) {
return new LookupLevels(
levels,
Expand Down

0 comments on commit 998e5b1

Please sign in to comment.