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 @@ -294,7 +294,14 @@ public static List<? extends FileRange> validateAndSortRanges(
final Optional<Long> fileLength) throws EOFException {

requireNonNull(input, "Null input list");
checkArgument(!input.isEmpty(), "Empty input list");

if (input.isEmpty()) {
// this may seem a pathological case, but it was valid
// before and somehow Spark can call it through parquet.
LOG.debug("Empty input list");
return input;
}

final List<? extends FileRange> sortedRanges;

if (input.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ No empty lists.

```python
if ranges = null raise NullPointerException
if ranges.len() = 0 raise IllegalArgumentException
if allocate = null raise NullPointerException
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,17 @@ public void testConsecutiveRanges() throws Exception {
}
}

@Test
public void testEmptyRanges() throws Exception {
List<FileRange> fileRanges = new ArrayList<>();
try (FSDataInputStream in = openVectorFile()) {
in.readVectored(fileRanges, allocate);
Assertions.assertThat(fileRanges)
.describedAs("Empty ranges must stay empty")
.isEmpty();
}
}

/**
* Test to validate EOF ranges.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,12 +702,11 @@ private static Stream mockStreamWithReadFully() throws IOException {
}

/**
* Empty ranges cannot be sorted.
* Empty ranges are allowed.
*/
@Test
public void testEmptyRangesRaisesIllegalArgument() throws Throwable {
intercept(IllegalArgumentException.class,
() -> validateAndSortRanges(Collections.emptyList(), Optional.empty()));
public void testEmptyRangesAllowed() throws Throwable {
validateAndSortRanges(Collections.emptyList(), Optional.empty());
}

/**
Expand Down