diff --git ql/src/java/org/apache/hadoop/hive/ql/io/orc/RecordReaderImpl.java ql/src/java/org/apache/hadoop/hive/ql/io/orc/RecordReaderImpl.java index 0876bf7..0cbab41 100644 --- ql/src/java/org/apache/hadoop/hive/ql/io/orc/RecordReaderImpl.java +++ ql/src/java/org/apache/hadoop/hive/ql/io/orc/RecordReaderImpl.java @@ -2191,7 +2191,7 @@ static TruthValue evaluatePredicateRange(PredicateLeaf predicate, Object minValu if (sarg == null || rowIndexStride == 0) { return null; } - readRowIndex(); + readRowIndex(currentStripe); long rowsInStripe = stripes.get(currentStripe).getNumberOfRows(); int groupsInStripe = (int) ((rowsInStripe + rowIndexStride - 1) / rowIndexStride); @@ -2785,8 +2785,18 @@ private int findStripe(long rowNumber) { throw new IllegalArgumentException("Seek after the end of reader range"); } - private void readRowIndex() throws IOException { - long offset = stripes.get(currentStripe).getOffset(); + OrcProto.RowIndex[] readRowIndex(int stripeIndex) throws IOException { + long offset = stripes.get(stripeIndex).getOffset(); + StripeFooter stripeFooter; + OrcProto.RowIndex[] indexes; + // if this is the current stripe, use the cached objects. + if (stripeIndex == currentIndex) { + stripeFooter = this.stripeFooter; + indexes = this.indexes; + } else { + stripeFooter = readStripeFooter(stripes.get(stripeIndex)); + indexes = new OrcProto.RowIndex[this.indexes.length]; + } for(OrcProto.Stream stream: stripeFooter.getStreamsList()) { if (stream.getKind() == OrcProto.Stream.Kind.ROW_INDEX) { int col = stream.getColumn(); @@ -2801,6 +2811,7 @@ private void readRowIndex() throws IOException { } offset += stream.getLength(); } + return indexes; } private void seekToRowEntry(int rowEntry) throws IOException { @@ -2832,7 +2843,7 @@ public void seekToRow(long rowNumber) throws IOException { currentStripe = rightStripe; readStripe(); } - readRowIndex(); + readRowIndex(currentStripe); // if we aren't to the right row yet, advanance in the stripe. advanceToNextRow(rowNumber);