compress

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SNAPPY = iota
	S2
	ZSTD
	MINLZ
	LZ4
)

Variables

View Source
var Algorithm = S2

Algorithm is the codec Compress and Decompress use. Segments do not record it, so it must stay the same for an index's lifetime.

View Source
var MinLZCompressionLevel = minlz.LevelBalanced

MinLZCompressionLevel is minlz.LevelSuperFast, LevelFastest, LevelBalanced or LevelSmallest.

View Source
var ZSTDCompressionLevel = 3 // 1, 3, 9

Functions

func Compress

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

func Decompress

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

func LZ4Compress added in v1.5.3

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

LZ4Compress compresses a block using lz4 algorithm. The lz4 block format does not record the decoded size, so the block is prefixed with it as a uvarint.

func LZ4Decompress added in v1.5.3

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

LZ4Decompress decompresses a block written by LZ4Compress.

func MinLZCompress added in v1.5.3

func MinLZCompress(dst, src []byte, level int) ([]byte, error)

MinLZCompress compresses a block (up to minlz.MaxBlockSize) using minlz algorithm.

func MinLZDecompress added in v1.5.3

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

MinLZDecompress decompresses a block using minlz algorithm.

func S2Compress

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

S2Compress compresses a block using s2 algorithm.

func S2Decompress

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

S2Decompress decompresses a block using s2 algorithm.

func SetAlgorithm added in v1.5.3

func SetAlgorithm(name string) error

SetAlgorithm sets Algorithm by name (snappy, s2, zstd, minlz or lz4, case insensitive), as read from user configuration.

func SnappyCompress

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

SnappyCompress compresses a block using snappy algorithm.

func SnappyDecompress

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

SnappyDecompress decompresses a block using snappy algorithm.

func ZSTDCompress

func ZSTDCompress(dst, src []byte, compressionLevel int) ([]byte, error)

ZSTDCompress compresses a block using ZSTD algorithm.

func ZSTDCompressBound

func ZSTDCompressBound(srcSize int) int

ZSTDCompressBound returns the worst case size needed for a destination buffer. Klauspost ZSTD library does not provide any API for Compression Bound. This calculation is based on the DataDog ZSTD library. See https://pkg.go.dev/github.com/DataDog/zstd#CompressBound

func ZSTDDecompress

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

ZSTDDecompress decompresses a block using ZSTD algorithm.

Types

This section is empty.

Jump to

Keyboard shortcuts

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