diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanSelectiveStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanSelectiveStreamReader.java index 4ff2f33524f8..ce5574e8f216 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanSelectiveStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanSelectiveStreamReader.java @@ -150,6 +150,7 @@ private void openRowGroup() public int read(int offset, int[] positions, int positionCount) throws IOException { + checkArgument(positionCount > 0, "positionCount must be greater than zero"); checkState(!valuesInUse, "BlockLease hasn't been closed yet"); if (!rowGroupOpen) { diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/ListSelectiveStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/ListSelectiveStreamReader.java index a391aff933f6..930ba730017f 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/ListSelectiveStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/ListSelectiveStreamReader.java @@ -189,6 +189,7 @@ private static Optional getTopLevelFilter(Map 0, "positionCount must be greater than zero"); checkState(!valuesInUse, "BlockLease hasn't been closed yet"); if (!rowGroupOpen) { @@ -369,7 +370,7 @@ private int readNotAllNulls(int[] positions, int positionCount) listFilter.populateElementFilters(outputPositionCount, nulls, elementLengths, elementPositionCount); } - if (elementStreamReader != null) { + if (elementStreamReader != null && elementPositionCount > 0) { elementStreamReader.read(elementReadOffset, elementPositions, elementPositionCount); } elementReadOffset += elementPositionCount + skippedElements; diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDictionarySelectiveStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDictionarySelectiveStreamReader.java index aedcb432e80a..0fe655e393a6 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDictionarySelectiveStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDictionarySelectiveStreamReader.java @@ -97,6 +97,8 @@ public LongDictionarySelectiveStreamReader( public int read(int offset, int[] positions, int positionCount) throws IOException { + checkArgument(positionCount > 0, "positionCount must be greater than zero"); + if (!rowGroupOpen) { openRowGroup(); } diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectSelectiveStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectSelectiveStreamReader.java index 43c12912934c..049f55e3c5fe 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectSelectiveStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectSelectiveStreamReader.java @@ -88,6 +88,8 @@ public LongDirectSelectiveStreamReader( public int read(int offset, int[] positions, int positionCount) throws IOException { + checkArgument(positionCount > 0, "positionCount must be greater than zero"); + if (!rowGroupOpen) { openRowGroup(); } diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/TimestampSelectiveStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/TimestampSelectiveStreamReader.java index f8e22383b39e..57ff310f3836 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/TimestampSelectiveStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/TimestampSelectiveStreamReader.java @@ -144,6 +144,7 @@ private void openRowGroup() public int read(int offset, int[] positions, int positionCount) throws IOException { + checkArgument(positionCount > 0, "positionCount must be greater than zero"); checkState(!valuesInUse, "BlockLease hasn't been closed yet"); if (!rowGroupOpen) {