package snappy
Import Path
github.com/golang/snappy (on go.dev)
Dependency Relation
imports 4 packages, and imported by 2 packages
Involved Source Files
decode.go
decode_asm.go
encode.go
encode_asm.go
Package snappy implements the Snappy compression format. It aims for very
high speeds and reasonable compression.
There are actually two Snappy formats: block and stream. They are related,
but different: trying to decompress block-compressed data as a Snappy stream
will fail, and vice versa. The block format is the Decode and Encode
functions and the stream format is the Reader and Writer types.
The block format, the more common case, is used when the complete size (the
number of bytes) of the original data is known upfront, at the time
compression starts. The stream format, also known as the framing format, is
for when that isn't always true.
The canonical, C++ implementation is at https://github.com/google/snappy and
it only implements the block format.
decode_amd64.s
encode_amd64.s
Package-Level Type Names (total 2)
Reader is an io.Reader that can read Snappy-compressed bytes.
Reader handles the Snappy stream format, not the Snappy block format.
Read satisfies the io.Reader interface.
ReadByte satisfies the io.ByteReader interface.
Reset discards any buffered data, resets all state, and switches the Snappy
reader to read from r. This permits reusing a Reader rather than allocating
a new one.
*Reader : github.com/klauspost/compress/flate.Reader
*Reader : github.com/quic-go/quic-go/quicvarint.Reader
*Reader : compress/flate.Reader
*Reader : google.golang.org/protobuf/encoding/protodelim.Reader
*Reader : io.ByteReader
*Reader : io.Reader
func NewReader(r io.Reader) *Reader
Writer is an io.Writer that can write Snappy-compressed bytes.
Writer handles the Snappy stream format, not the Snappy block format.
Close calls Flush and then closes the Writer.
Flush flushes the Writer to its underlying io.Writer.
Reset discards the writer's state and switches the Snappy writer to write to
w. This permits reusing a Writer rather than allocating a new one.
Write satisfies the io.Writer interface.
*Writer : github.com/apache/thrift/lib/go/thrift.Flusher
*Writer : github.com/miekg/dns.Writer
*Writer : github.com/parquet-go/parquet-go/compress.Writer
*Writer : github.com/prometheus/common/expfmt.Closer
*Writer : internal/bisect.Writer
*Writer : io.Closer
*Writer : io.WriteCloser
*Writer : io.Writer
func NewBufferedWriter(w io.Writer) *Writer
func NewWriter(w io.Writer) *Writer
Package-Level Functions (total 7)
Decode returns the decoded form of src. The returned slice may be a sub-
slice of dst if dst was large enough to hold the entire decoded block.
Otherwise, a newly allocated slice will be returned.
The dst and src must not overlap. It is valid to pass a nil dst.
Decode handles the Snappy block format, not the Snappy stream format.
DecodedLen returns the length of the decoded block.
Encode returns the encoded form of src. The returned slice may be a sub-
slice of dst if dst was large enough to hold the entire encoded block.
Otherwise, a newly allocated slice will be returned.
The dst and src must not overlap. It is valid to pass a nil dst.
Encode handles the Snappy block format, not the Snappy stream format.
MaxEncodedLen returns the maximum length of a snappy block, given its
uncompressed length.
It will return a negative value if srcLen is too large to encode.
NewBufferedWriter returns a new Writer that compresses to w, using the
framing format described at
https://github.com/google/snappy/blob/master/framing_format.txt
The Writer returned buffers writes. Users must call Close to guarantee all
data has been forwarded to the underlying io.Writer. They may also call
Flush zero or more times before calling Close.
NewReader returns a new Reader that decompresses from r, using the framing
format described at
https://github.com/google/snappy/blob/master/framing_format.txt
NewWriter returns a new Writer that compresses to w.
The Writer returned does not buffer writes. There is no need to Flush or
Close such a Writer.
Deprecated: the Writer returned is not suitable for many small writes, only
for few large writes. Use NewBufferedWriter instead, which is efficient
regardless of the frequency and shape of the writes, and remember to Close
that Writer when done.
Package-Level Variables (total 3)
ErrCorrupt reports that the input is invalid.
ErrTooLarge reports that the uncompressed length is too large.
ErrUnsupported reports that the input isn't supported.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |