On Sun, May 12, 2013 at 4:27 PM, Damjan Jovanovic <damjan....@gmail.com> wrote:
> On Sun, May 12, 2013 at 12:34 PM, Stefan Bodewig <bode...@apache.org> wrote:
>> As for LZMA compression, the required code in XZ for Java's lzma
>> subpackage doesn't lend itself to streaming support but it may be
>> possible to leverage it anyway.
>
> I am looking into that now.

With some hacks to its constructor and read() method, I've just gotten
XZ's LZMA2InputStream to decompress an LZMA file. The remaining
problems and requirements for streaming support are:
* RangeDecoder reads the entire file into byte[]. But it's beyond
trivial to patch normalize(), its only method that uses the file
contents, to use inputStream.read() instead of buf[pos++].
* RangeDecoder wants an exact size, but the lzma CLI tool writes a
size of -1 = unknown size. It looks tricky to handle end-of-file
without this.
* RangeDecoder is final and require package-private static fields from
its parent class. Copying it into commons-compress, copying those
fields into it, and changing our LZMAInputStream to use it then causes
LZMADecoder to also need importing and changing, since it uses the old
RangeDecoder and can neither be constructed with the new one, nor can
the new one override the final old one. But it inherits from LZMACoder
which is package-private. So it looks like we need to either fork all
the XZ code, fork a lot of the XZ code which introduces fragility
against future XZ changes, or add support for LZMA upstream and use
the new XZ version.
* For 7z we either need a way to specify all the LZMA properties
manually instead of by parsing them from the file header, or a
ConcatenatedInputStream class, because in 7z files the LZMA header
(see lzma.txt) is not stored with the compressed stream and has to be
reconstructed from the file's size and the coder's properties.

Anyone want to help?

Damjan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to