fastnbt icon indicating copy to clipboard operation
fastnbt copied to clipboard

Implement LZ4 decompression for 1.20.5+

Open Badel2 opened this issue 10 months ago • 2 comments

Close #101

At first I tried using lz4_flex directly, but that doesn't work because java uses a different format. Then I searched "lz4 java" in crates.io and I found this nice crate that implements exactly what we need.

We need a Lz4DecoderWrapper because the API of that crate is not the same as the gzip crates. This introduces an additional copy but I believe the only way to avoid that would be to change the interface of the read_compressed_chunk function.

Tested by generating a world using a server with region-file-compression=lz4, and using the region-dump binary to test decompressing it.

Badel2 avatar Apr 05 '24 09:04 Badel2

Sorry I've not gotten around to looking at this yet.

From a brief look, my gut says I'd rather depend only on the lz4 dep directly and implement the layers on top directly. Mainly just to reduce dependencies. But that depends just how complex that would be.

owengage avatar Apr 09 '24 08:04 owengage

Well I have no interest in learning about the implementation details of lz4, and copying that dependency as a new module would be pointless, so if you or someone else wants to work on that then nice, and if not then you can always use this pull request :)

No rush on my side as most worlds will not use this compression format yet.

Badel2 avatar Apr 09 '24 19:04 Badel2

Hey, I've still not got around to looking at this more closely. I'm going to go with this as is. I can always spend the time in future if I really care about the dependencies.

Thanks again for your contributions, it's appreciated.

owengage avatar May 12 '24 19:05 owengage