CodecZstd.jl icon indicating copy to clipboard operation
CodecZstd.jl copied to clipboard

Only reset session on error in process, override transcode with pledge

Open mkitti opened this issue 1 year ago • 1 comments

This is another approach to making transcode save the frame content size.

Previously via #4, the compression session was reset via startproc. The only reason I can glean to reset the session would be if process errored.

Now startproc only resets the buffers, but does not reset the stream. The compression context is only reset if an error occurs during process.

After these changes we can now call ZSTD_CCtx_setPledgedSrcSize from transcode in order to encode the decompressed size in the frame header.

mkitti avatar Jun 02 '24 05:06 mkitti

Codecov Report

Attention: Patch coverage is 66.66667% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 35.56%. Comparing base (1915ffb) to head (874e49c).

Files Patch % Lines
src/compression.jl 75.00% 2 Missing :warning:
src/libzstd.jl 50.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
- Coverage   36.96%   35.56%   -1.41%     
==========================================
  Files           5        5              
  Lines         560      568       +8     
==========================================
- Hits          207      202       -5     
- Misses        353      366      +13     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 02 '24 05:06 codecov[bot]

Good, the new test_roundtrip_seekstart is catching the bug in this PR.

It is best practice for startproc to always fully reset the state of the codec.

nhz2 avatar Sep 03 '24 22:09 nhz2

We should figure out how to pledge the size from a transcode call to the normal ZstdCompressor since we know the entire buffer size. Perhaps we should add a pledged size field to ZstdCompressor to enable this so that we can pledge the size in startproc afte we reset the stream.

mkitti avatar Sep 04 '24 12:09 mkitti