This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 998e5b1c2 [Bug] Fix the IndexOutOfBoundsException when  lookup empty 
sortedRun (#2530)
998e5b1c2 is described below

commit 998e5b1c2d2fbc9cb31888db2764dc8f63fbe3e6
Author: Aitozi <[email protected]>
AuthorDate: Wed Dec 20 09:43:00 2023 +0800

    [Bug] Fix the IndexOutOfBoundsException when  lookup empty sortedRun (#2530)
---
 .../java/org/apache/paimon/mergetree/LookupUtils.java    |  3 +++
 .../org/apache/paimon/mergetree/LookupLevelsTest.java    | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/mergetree/LookupUtils.java 
b/paimon-core/src/main/java/org/apache/paimon/mergetree/LookupUtils.java
index 977d7ab9f..7d847227a 100644
--- a/paimon-core/src/main/java/org/apache/paimon/mergetree/LookupUtils.java
+++ b/paimon-core/src/main/java/org/apache/paimon/mergetree/LookupUtils.java
@@ -59,6 +59,9 @@ public class LookupUtils {
             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;
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/mergetree/LookupLevelsTest.java 
b/paimon-core/src/test/java/org/apache/paimon/mergetree/LookupLevelsTest.java
index 35b847bcf..d13fb5650 100644
--- 
a/paimon-core/src/test/java/org/apache/paimon/mergetree/LookupLevelsTest.java
+++ 
b/paimon-core/src/test/java/org/apache/paimon/mergetree/LookupLevelsTest.java
@@ -198,6 +198,22 @@ public class LookupLevelsTest {
         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,

Reply via email to