lz4 / lz4-java

LZ4 compression for Java
Apache License 2.0
1.1k stars 253 forks source link

how can i know destLen By compressed value? #145

Closed hisenyuan closed 4 years ago

hisenyuan commented 4 years ago

LZ4FastDecompressor decompressor = factory.fastDecompressor(); byte[] restored = new byte[decompressedLength]; int compressedLength2 = decompressor.decompress(compressed, 0, restored, 0, decompressedLength);

if i dont know dest value how i can get the length?

odaira commented 4 years ago

There is no way to get the decompressed length. You must store it at somewhere when you compress the data, or you can use LZ4SafeDecompressor, or you may want to use LZ4CompressorWithLength/LZ4DecompressorWithLength.

hisenyuan commented 4 years ago

There is no way to get the decompressed length. You must store it at somewhere when you compress the data, or you can use LZ4SafeDecompressor, or you may want to use LZ4CompressorWithLength/LZ4DecompressorWithLength.

LZ4SafeDecompressor also need decompressed length. LZ4CompressorWithLength/LZ4DecompressorWithLength need srcValue.

Zstd provider a method to get decompressedLength by compressedValue. Zstd.decompressedSize(compressedValue);

i think lz4 maybe have the same method,but ...

btw,thanks!