snappystream

package
v0.0.0-...-65af2ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2014 License: AGPL-3.0 Imports: 6 Imported by: 0

README

go-snappystream

a Go package for framed snappy streams. See godoc.

This package wraps snappy-go and supplies a Reader and Writer for the snappy framed stream format.

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

View Source
const MaxBlockSize = 65536
View Source
const SkipVerifyChecksum = false
View Source
const VerifyChecksum = true

Variables

This section is empty.

Functions

func NewReader

func NewReader(r io.Reader, verifyChecksum bool) io.Reader

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

func NewWriter(w io.Writer) io.Writer

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL