Repository navigation
Conversation
The current implementation of ZlibDecompressionStream::seek and BlockDecompressionStream::seek resets the state of the decompressor and the underlying file reader and throws away their buffers. This commit introduces two optimizations which rely on reusing the buffers that still contain useful data, and therefore reducing the time spent reading/uncompressing the buffers again. The first case is when the seeked position is already read and decompressed into the output stream. The second case is when the seeked position is already read from the input stream, but has not been decompressed yet, ie. it's not in the output stream. Tests: - Run the ORC tests, and the Impala tests working on ORC tables. - The regression that apache#476 would cause is not present anymore.
|
FYI, I also opened since there is a lot of duplicate code: https://issues.apache.org/jira/browse/ORC-615 |
|
Sent in #500, if you could review it first, that would reduce the amount of code change (and possible mistakes) here as well. |
|
@luksan47 I am working on it. Will finish reviewing this PR by the end of this week. |
|
Thanks, @wgtmac! |
| DecompressState state; | ||
|
|
||
| // the start of the current buffer | ||
| // This pointer is not owned by us. It is either owned by zstream or |
There was a problem hiding this comment.
keep this comment to ease the understanding
There was a problem hiding this comment.
OK. Changed the comment a bit, since it is not owned by zstream.
| } | ||
| if (state == DECOMPRESS_HEADER || remainingLength == 0) { | ||
| readHeader(); | ||
| headerPosition |
There was a problem hiding this comment.
Name of headerPosition is confusing since it actually means the position of the 1st byte after the 3-byte compressed block header.
There was a problem hiding this comment.
Kept the name since we look up this position, changed the value instead.
| // seeked position. | ||
| position.next(); // Skip the input level position. | ||
| inputBuffer | ||
| = inputBufferStart + (seekedPosition - inputBufferStartPosition); |
There was a problem hiding this comment.
If seekedPosition is smaller than inputBufferStartPosition, the inputBufferStart does not contain the data we need. This can happen when users call RowReader::seekToRow() in a reverse order.
|
@luksan47 Please fix the travis build. It would be more confident if you can test cases for all 3 scenarios under seek. |
|
Hey @luksan47, are you still interested in this patch? |
|
Hey @wgtmac, sorry but I don't have the capacity at the moment to work on this PR :( |
The current implementation of ZlibDecompressionStream::seek and
BlockDecompressionStream::seek resets the state of the decompressor
and the underlying file reader and throws away their buffers.
This commit introduces two optimizations which rely on reusing
the buffers that still contain useful data, and therefore reducing
the time spent reading/uncompressing the buffers again.
The first case is when the seeked position is already read
and decompressed into the output stream.
The second case is when the seeked position is already read from
the input stream, but has not been decompressed yet, ie. it's
not in the output stream.
Tests: