pgaref commented on a change in pull request #652:
URL: https://github.com/apache/orc/pull/652#discussion_r597907354
##########
File path: java/core/src/java/org/apache/orc/impl/InStream.java
##########
@@ -397,13 +397,14 @@ public String toString() {
}
}
- private static class CompressedStream extends InStream {
+ static class CompressedStream extends InStream {
Review comment:
Shall we make this public as Encrypted and Uncompressed above?
##########
File path: java/core/src/java/org/apache/orc/impl/InStream.java
##########
@@ -551,15 +556,20 @@ public void changeIv(Consumer<byte[]> modifier) {
@Override
public void seek(PositionProvider index) throws IOException {
- seek(index.getNext());
+ boolean seeked = seek(index.getNext());
long uncompressedBytes = index.getNext();
- if (uncompressedBytes != 0) {
- readHeader();
- uncompressed.position(uncompressed.position() +
- (int) uncompressedBytes);
- } else if (uncompressed != null) {
- // mark the uncompressed buffer as done
- uncompressed.position(uncompressed.limit());
+ if (!seeked && uncompressed != null) {
+ // Only reposition uncompressed
+ uncompressed.position((int) uncompressedBytes);
+ } else {
+ if (uncompressedBytes != 0) {
Review comment:
add some explanation here as well?
##########
File path: java/core/src/test/org/apache/orc/impl/TestInStream.java
##########
@@ -434,8 +437,30 @@ public void testCompressed() throws Exception {
int x = in.read();
assertEquals(i & 0xff, x);
}
+
+ // Forward seek test
+ int seeksPerformed = 0;
+ for(int i=0; i < 1024; ++i) {
+ long pos = positions[i].getNext();
+ positions[i].reset();
+ ByteBuffer c = ((InStream.CompressedStream) in).compressed;
+ if (pos == ((InStream.CompressedStream) in).currentCompressedStart) {
+ // Should have the same ByteBuffer if no seek has taken place
+ in.seek(positions[i]);
+ assertEquals(c, ((InStream.CompressedStream) in).compressed);
+ } else {
+ seeksPerformed += 1;
+ in.seek(positions[i]);
+ assertNotEquals(c, ((InStream.CompressedStream) in).compressed);
+ }
+ positions[i].reset();
+ assertEquals(i & 0xff, in.read());
+ }
+ assertEquals(1, seeksPerformed);
Review comment:
Why are we assuming 1 seek here? do we have 2 chunks total?
Shall we move this to its own test?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]