compression

package
v0.311.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder provides decompression functionality for supported compression types. It is agnostic to the content being decompressed, operating on byte slices of serialized data streams. The decoder maintains internal state for Zstd decompression and can handle multiple compression types including None, Snappy, and Zstd.

func NewDecoder

func NewDecoder() *Decoder

NewDecoder creates a new Decoder.

func (*Decoder) Decode

func (d *Decoder) Decode(t Type, src, buf []byte) (_ []byte, err error)

Decode returns the decoded form of src or error, given expected compression type.

The buf is used as a buffer for the returned decoded entry, and it must not overlap with src. It is valid to pass a nil buf.

type Encoder

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

Encoder provides compression encoding functionality for supported compression types. It is agnostic to the content being compressed, operating on byte slices of serialized data streams. The encoder maintains internal state for Zstd compression and can handle multiple compression types including None, Snappy, and Zstd.

func NewEncoder

func NewEncoder() (*Encoder, error)

NewEncoder creates a new Encoder. Returns an error if the zstd encoder cannot be initialized.

func (*Encoder) Encode

func (e *Encoder) Encode(t Type, src, buf []byte) (_ []byte, compressed bool, err error)

Encode returns the encoded form of src for the given compression type. It also returns the indicator if the compression was performed. Encode may skip compressing for None type, but also when src is too large e.g. for Snappy block format.

The buf is used as a buffer for returned encoding, and it must not overlap with src. It is valid to pass a nil buf.

type Type

type Type string

Type represents the compression type used for encoding and decoding data.

const (
	// None represents no compression case.
	// None it's a default when Type is empty.
	None Type = "none"
	// Snappy represents snappy block format.
	Snappy Type = "snappy"
	// Zstd represents zstd compression.
	Zstd Type = "zstd"
)

Jump to

Keyboard shortcuts

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