compression

package
v0.0.0-...-74fe3af Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const UseStandardZstdLib = true

UseStandardZstdLib indicates whether the zstd implementation is a port of the official one in the facebook/zstd repository.

This constant is only used in tests. Some tests rely on reproducibility of SST files, but a custom implementation of zstd will produce different compression result. So those tests have to be disabled in such cases.

We cannot always use the official facebook/zstd implementation since it relies on CGo.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm uint8
const (
	None Algorithm = iota
	Snappy
	Zstd
	MinLZ
)

The available compression types.

func (Algorithm) String

func (a Algorithm) String() string

String implements fmt.Stringer, returning a human-readable name for the compression algorithm.

type Compressor

type Compressor interface {
	// Compress a block, appending the compressed data to dst[:0].
	Compress(dst, src []byte) []byte

	// Close must be called when the Compressor is no longer needed.
	// After Close is called, the Compressor must not be used again.
	Close()
}

func GetCompressor

func GetCompressor(a Algorithm) Compressor

type Decompressor

type Decompressor interface {
	// DecompressInto decompresses compressed into buf. The buf slice must have the
	// exact size as the decompressed value. Callers may use DecompressedLen to
	// determine the correct size.
	DecompressInto(buf, compressed []byte) error

	// DecompressedLen returns the length of the provided block once decompressed,
	// allowing the caller to allocate a buffer exactly sized to the decompressed
	// payload.
	DecompressedLen(b []byte) (decompressedLen int, err error)

	// Close must be called when the Decompressor is no longer needed.
	// After Close is called, the Decompressor must not be used again.
	Close()
}

func GetDecompressor

func GetDecompressor(a Algorithm) Decompressor

Jump to

Keyboard shortcuts

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