What is the difference between LZ4_decompress_safe
and LZ4_decompress_safe_partial
? I understand that LZ4_decompress_safe_partial
does partial decompression, but it looks like LZ4_decompress_safe
also can do partial decompression or I am wrong. Both function signatures have input and output buffers and both have sizes of those buffers as function arguments. And that's why I am asking about it. Say I have a buffer with compressed data and want to decompress only a portion of it. What would be the difference between using LZ4_decompress_safe and LZ4_decompress_safe_partial. Would I get the same result?
Asked
Active
Viewed 1,100 times
2

flashburn
- 4,180
- 7
- 54
- 109
-
LZ4 compresses data into blocks. I believe the difference is that LZ4_decompress_safe will always decompress an entire block while LZ4_decompress_safe_partial will let you terminate early. Have you checked to see if they produce the same result? – Bimba Shrestha Apr 10 '20 at 17:41
1 Answers
1
it looks like
LZ4_decompress_safe
also can do partial decompression
That's incorrect.
LZ4_decompress_safe()
is expected to decompress full blocks, only.
It will return an error code if one tries to use it for partial decompression.
Generally speaking, LZ4_decompress_safe_partial()
is more powerful, because it can do both full and partial blocks. That being said, its strength is its weakness : if your application wants to know if the block was fully decoded or not, LZ4_decompress_safe_partial()
will not provide a useful signal for that: it will happily stop in the middle of the block if instructed to do so. It's also slightly more complex, internally, which may result in slightly slower decoding speed.

Cyan
- 13,248
- 8
- 43
- 78