jhn_snappy (jhn_stdlib v5.11.0)

View Source

A compression lib based on the snappy format using a LZ77 dictionary approach. It will compress/uncompress both the block, framed, and apple framed formats. The snappy framed can also be padded.

https://github.com/google/snappy

The options for the functions are: return_type: one of iolist or binary default iolist type: one of block/frame/iwa with the default block {search_length, Int}: setting the parameter for the encoding. The length has to be between 1 and 65536 inclusively and the default is 1095. {lookahead_length, Int}: setting the parameter for the encoding. The has to be between 4 and 64 inclusively and the default is 15.

Both the return_type and type can be provided as the tuple {Option, boolean()} where true will set it to that value.

Summary

Functions

Equivalent to compress(Data, []).

Compresses the data into a snappy block, series of frames or iwa frames depending on the options, either as a binary or iolist.

Equivalent to pad(SnappyFrames, [])

Adds pad frame of size Size at the end of the frames reurning a binary or iolist (default) depending on the Opts.

Equivalent to uncompress(Snappy, []).

Uncompress a snappy block or sequence of frames or iwa frames depending on the options and returning a binary or iolist also depending on the options.

Types

block/0

-type block() :: binary().

data/0

-type data() :: binary() | [data()].

frames/0

-type frames() :: iodata().

iwa/0

-type iwa() :: iodata().

opt/0

-type opt() ::
          return_type() |
          type() |
          {return_type, return_type()} |
          {type, type()} |
          {search_length, 1..65536} |
          {lookahead_length, 1..64} |
          {type, type()}.

return_type/0

-type return_type() :: iolist | binary.

type/0

-type type() :: block | frame | iwa.

Functions

compress(Data)

-spec compress(data()) -> block().

Equivalent to compress(Data, []).

compress(Data, Opts)

-spec compress(data(), [opt()]) -> iolist() | block() | frames().

Compresses the data into a snappy block, series of frames or iwa frames depending on the options, either as a binary or iolist.

pad(Frames, Size)

-spec pad(frames(), integer()) -> frames().

Equivalent to pad(SnappyFrames, [])

pad(Frames, Size, Opts)

-spec pad(frames(), integer(), [opt()]) -> frames().

Adds pad frame of size Size at the end of the frames reurning a binary or iolist (default) depending on the Opts.

uncompress(Frame)

-spec uncompress(block() | frames()) -> binary().

Equivalent to uncompress(Snappy, []).

uncompress(IoList, Opts)

-spec uncompress(block() | frames() | iwa(), [opt()]) -> iolist() | binary().

Uncompress a snappy block or sequence of frames or iwa frames depending on the options and returning a binary or iolist also depending on the options.