goworld: github.com/xiaonanln/goworld/engine/lib/gwsnappy Index | Files

package gwsnappy

import "github.com/xiaonanln/goworld/engine/lib/gwsnappy"

Package snappy implements the snappy block-based compression format. It aims for very high speeds and reasonable compression.

The C++ snappy implementation is at https://github.com/google/snappy

Index

Package Files

decode.go decode_amd64.go encode.go encode_amd64.go snappy.go

Variables

var (
    // ErrCorrupt reports that the input is invalid.
    ErrCorrupt = errors.New("snappy: corrupt input")
    // ErrTooLarge reports that the uncompressed length is too large.
    ErrTooLarge = errors.New("snappy: decoded block is too large")
    // ErrUnsupported reports that the input isn't supported.
    ErrUnsupported = errors.New("snappy: unsupported input")
)

func Decode Uses

func Decode(dst, src []byte) ([]byte, error)

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.

func DecodedLen Uses

func DecodedLen(src []byte) (int, error)

DecodedLen returns the length of the decoded block.

func Encode Uses

func Encode(dst, src []byte) []byte

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.

func MaxEncodedLen Uses

func MaxEncodedLen(srcLen int) int

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.

type Reader Uses

type Reader struct {
    // contains filtered or unexported fields
}

Reader is an io.Reader that can read Snappy-compressed bytes.

func NewReader Uses

func NewReader(r io.Reader) *Reader

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

func (*Reader) ClearError Uses

func (r *Reader) ClearError()

func (*Reader) Read Uses

func (r *Reader) Read(p []byte) (int, error)

Read satisfies the io.Reader interface.

func (*Reader) Reset Uses

func (r *Reader) Reset(reader io.Reader)

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.

type Writer Uses

type Writer struct {
    // contains filtered or unexported fields
}

Writer is an io.Writer that can write Snappy-compressed bytes.

func NewBufferedWriter Uses

func NewBufferedWriter(w io.Writer) *Writer

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.

func NewWriter Uses

func NewWriter(w io.Writer) *Writer

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.

func (*Writer) Close Uses

func (w *Writer) Close() error

Close calls Flush and then closes the Writer.

func (*Writer) Flush Uses

func (w *Writer) Flush() error

Flush flushes the Writer to its underlying io.Writer.

func (*Writer) Reset Uses

func (w *Writer) Reset(writer 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.

func (*Writer) Write Uses

func (w *Writer) Write(p []byte) (nRet int, errRet error)

Write satisfies the io.Writer interface.

Package gwsnappy imports 8 packages (graph) and is imported by 1 packages. Updated 2017-11-06. Refresh now. Tools for package owners.