Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

LZ4 Framing #16

Open
rektide opened this issue Dec 2, 2014 · 2 comments
Open

LZ4 Framing #16

rektide opened this issue Dec 2, 2014 · 2 comments

Comments

@rektide
Copy link

rektide commented Dec 2, 2014

I'd like to see LZ4 framing supported.

The frame-descriptor includes an optional content-length, which may help to eliminate go-lz4's unique means of storing such:

go-lz4 saves a uint32 with the original uncompressed length at the beginning of the encoded buffer

@dgryski
Copy link
Collaborator

dgryski commented Jan 20, 2015

This method is common to most of the libraries that wrap lz4 (python, ruby, etc.)

I agree proper framing would be nice to have.

@calmh
Copy link

calmh commented Jun 20, 2016

Would you accept a PR to add a function lz4.DecodeLength(dst, src []byte, length int) ([]byte, error)? This function would operate on data that doesn't have the four byte preamble.

The reasoning is that it's easy to get the desired format from Encode() when you don't want the length preamble - just chop off the first four bytes of the returned buffer. The other direction is more annoying if you happen to already have a buffer with data without length preamble - at minimum it requires constructing a new buffer with the length at front and copying the compressed data.

By extracting the decode function for a known length, the existing Decode() can trivially delegate to this new function after extracting the length from the head of the buffer.

(The existing format is also unuseful to us because the length is encoded in little endian byte order rather than network byte order...)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants