Repository navigation
ORC-614: [C++] Implement efficient seek() in decompression streams - #695
Conversation
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Thank you for the fix. BTW, is this applicable to branch-1.6 too, @wgtmac ?
@dongjoon-hyun No, the |
|
Got it. Thank you for the explanation. |
| void DecompressionStream::seek(PositionProvider& position) { | ||
| // clear state to force seek to read from the right position | ||
| size_t seekedPosition = position.current(); | ||
| // Case 3.: the seeked position is the one that is currently buffered and |
There was a problem hiding this comment.
It seems that this is 1 at line 536. Shall we match the number by changing this Case 3.: -> Case 1:?
| inputBuffer | ||
| = inputBufferStart + (seekedPosition - inputBufferStartPosition); | ||
| } else { | ||
| // Case 1.: The seeked position is not in the input buffer, here we are |
There was a problem hiding this comment.
Ditto. This looks like 3. It is not read yet from the inputstream..
Switching from Case 1.: to Case 3: will be better. WDYT?
| size_t remainingLength; | ||
|
|
||
| // the last buffer returned from the input | ||
| const char* inputBufferStart; |
There was a problem hiding this comment.
nit. Shall we match with the coding style with the existing line 371 and 372?
- const char* inputBufferStart;
+ const char *inputBufferStart;
dongjoon-hyun
left a comment
There was a problem hiding this comment.
I left a few comments. BTW, do you think it's possible to have a simple test case for this?
Also, cc @pgaref
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Thank you for updating, @wgtmac . +1, LGTM.
|
Merged to main for Apache ORC 1.7.0. |
What changes were proposed in this pull request?
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.
Why are the changes needed?
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.
How was this patch tested?
Tests: