Documentation ¶
Overview ¶
snappystream wraps snappy-go and supplies a Reader and Writer for the snappy framed stream format:
https://snappy.googlecode.com/svn/trunk/framing_format.txt
Index ¶
Constants ¶
const MaxBlockSize = 65536
const SkipVerifyChecksum = false
const VerifyChecksum = true
Variables ¶
This section is empty.
Functions ¶
func NewReader ¶
NewReader returns an io.Reader interface to the snappy framed stream format.
It transparently handles reading the stream identifier (but does not proxy this to the caller), decompresses blocks, and (optionally) validates checksums.
Internally, three buffers are maintained. The first two are for reading off the wrapped io.Reader and for holding the decompressed block (both are grown automatically and re-used and will never exceed the largest block size, 65536). The last buffer contains the *unread* decompressed bytes (and can grow indefinitely).
The second param determines whether or not the reader will verify block checksums and can be enabled/disabled with the constants VerifyChecksum and SkipVerifyChecksum
For each Read, the returned length will be up to the lesser of len(b) or 65536 decompressed bytes, regardless of the length of *compressed* bytes read from the wrapped io.Reader.
func NewWriter ¶
NewWriter returns an io.Writer interface to the snappy framed stream format.
It transparently handles sending the stream identifier, calculating checksums, and compressing/framing blocks.
Internally, a buffer is maintained to hold a compressed block. It will automatically re-size up the the largest block size, 65536.
For each Write, the returned length will only ever be len(p) or 0, regardless of the length of *compressed* bytes written to the wrapped io.Writer.
If the returned length is 0 then error will be non-nil.
If len(p) exceeds 65536, the slice will be automatically chunked into smaller blocks.
Types ¶
This section is empty.