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 381d97d9ac..12cfe84fe6 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 @@ -119,7 +119,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; @@ -136,6 +136,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"); }