commit cc1c71be350945bd84e56ae879cbc673f985c1cd Author: Mithun RK Date: Mon Oct 30 14:23:22 2017 -0700 HIVE-17940: IllegalArgumentException when reading last row-group in an ORC stripe (Chris Drome, reviewed by Mithun Radhakrishnan) diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/InStream.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/InStream.java index 6fec8b76d7..4d5a9ef274 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/InStream.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/InStream.java @@ -121,7 +121,7 @@ public void seek(long desired) { return; } int i = 0; - for(DiskRange curRange : bytes) { + for (DiskRange curRange : bytes) { if (desired == 0 && curRange.getData().remaining() == 0) { logEmptySeek(name); return; @@ -138,6 +138,18 @@ public void seek(long desired) { } ++i; } + // if they are seeking to the precise end, go ahead and let them go there + int segments = bytes.size(); + if (segments != 0 && desired == bytes.get(segments - 1).getEnd()) { + currentOffset = desired; + currentRange = segments - 1; + DiskRange curRange = bytes.get(currentRange); + this.range = curRange.getData().duplicate(); + int pos = range.position(); + pos += (int)(desired - curRange.getOffset()); // this is why we duplicate + this.range.position(pos); + return; + } throw new IllegalArgumentException("Seek in " + name + " to " + desired + " is outside of the data"); }