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

gangwu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-java.git


The following commit(s) were added to refs/heads/master by this push:
     new 26268c941 PARQUET-2498: Vector IO to handle empty range list (#1374)
26268c941 is described below

commit 26268c941203c889ff13f701d577406b9e6b683b
Author: Steve Loughran <ste...@cloudera.com>
AuthorDate: Thu Jun 13 05:45:56 2024 +0100

    PARQUET-2498: Vector IO to handle empty range list (#1374)
    
    Empty range lists currently trigger IllegalArgumentException,
    however some (integration test) codepaths attempt to do this.
    
    Downgrading the empty list case to a no-op resolves this.
    
    Contributed by Steve Loughran
    
    Change-Id: I07ed7e8f0628e170441a2d0679e822d23cfb1440
---
 .../apache/parquet/hadoop/util/wrapped/io/VectorIoBridge.java |  7 ++++++-
 .../parquet/hadoop/util/wrapped/io/TestVectorIoBridge.java    | 11 +++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/util/wrapped/io/VectorIoBridge.java
 
b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/util/wrapped/io/VectorIoBridge.java
index 3523a12ab..7720f7fe9 100644
--- 
a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/util/wrapped/io/VectorIoBridge.java
+++ 
b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/util/wrapped/io/VectorIoBridge.java
@@ -362,7 +362,12 @@ public final class VectorIoBridge {
   private static List<ParquetFileRange> validateAndSortRanges(final 
List<ParquetFileRange> input) {
 
     requireNonNull(input, "Null input list");
-    checkArgument(!input.isEmpty(), "Empty input list");
+    if (input.isEmpty()) {
+      // this may seem a pathological case, but it
+      // has surfaced during testing.
+      LOG.debug("Empty input list");
+      return input;
+    }
     final List<ParquetFileRange> sortedRanges;
 
     if (input.size() == 1) {
diff --git 
a/parquet-hadoop/src/test/java/org/apache/parquet/hadoop/util/wrapped/io/TestVectorIoBridge.java
 
b/parquet-hadoop/src/test/java/org/apache/parquet/hadoop/util/wrapped/io/TestVectorIoBridge.java
index ad97851ba..6d7b92fc7 100644
--- 
a/parquet-hadoop/src/test/java/org/apache/parquet/hadoop/util/wrapped/io/TestVectorIoBridge.java
+++ 
b/parquet-hadoop/src/test/java/org/apache/parquet/hadoop/util/wrapped/io/TestVectorIoBridge.java
@@ -305,6 +305,17 @@ public class TestVectorIoBridge {
     verifyExceptionalVectoredRead(null, NullPointerException.class);
   }
 
+  /**
+   * An empty range list is permitted.
+   */
+  @Test
+  public void testEmptyRangeList() throws Exception {
+    List<ParquetFileRange> fileRanges = new ArrayList<>();
+    try (FSDataInputStream in = openTestFile()) {
+      readVectored(in, fileRanges);
+    }
+  }
+
   @Test
   public void testSomeRandomNonOverlappingRanges() throws Exception {
     List<ParquetFileRange> fileRanges = ranges(

Reply via email to