module Compress::Snappy::Consts

Defined in:

snappy/snappy.cr

Constant Summary

BUF_HEADER_LEN = (MAGIC_CHUNK.size + CHECK_SUM_SIZE) + CHUNK_HEADER_SIZE
BUF_LEN = BUF_HEADER_LEN + MAX_ENCODED_LEN_OF_MAX_BLOCK_SIZE
CHECK_SUM_SIZE = 4
CHUNK_HEADER_SIZE = 4
MAGIC_BODY = "sNaPpY"
MAGIC_CHUNK = "\xFF\u0006\u0000\u0000" + MAGIC_BODY

header consists of the stream identifier flag, 3 bytes indicating a length of 6, and "sNaPpY" in ASCII

MAX_BLOCK_SIZE = 65536

MAX_BLOCK_SIZE is the maximum size that a chunk of uncompressed data must be no longer than this size. It is not part of the wire format per se, but some parts of the encoder assume that an offset fits into a UInt16.

Also, for the framing format (Writer type instead of encode function), https://github.com/google/snappy/blob/master/framing_format.txt says that "the uncompressed data in a chunk must be no longer than 65536 bytes".

MAX_ENCODED_LEN_OF_MAX_BLOCK_SIZE = 76490

MAX_ENCODED_LEN_OF_MAX_BLOCK_SIZE equals decode_length(max_block_size), but is hard coded to be a const instead of a variable, so that obufLen can also be a const.

MIN_COMPRESSION_RATIO = 0.85

Minimum Compression ratio that must be achieved to write the compressed data. This must in (0,1.0]