compression

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package compression provides compression and decompression for RocksDB blocks.

RocksDB supports multiple compression algorithms. Each data block in an SST file is stored with a 1-byte compression type indicator followed by the compressed (or uncompressed) data.

Reference: util/compression.h, util/compression.cc

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(t Type, data []byte) ([]byte, error)

Compress compresses data using the specified compression type.

func Decompress

func Decompress(t Type, data []byte) ([]byte, error)

Decompress decompresses data using the specified compression type. For LZ4/LZ4HC, use DecompressWithSize if the uncompressed size is known.

func DecompressWithSize added in v0.2.0

func DecompressWithSize(t Type, data []byte, expectedSize int) ([]byte, error)

DecompressWithSize decompresses data with a known uncompressed size. For LZ4 raw block format, the expectedSize is required for correct decompression. If expectedSize is 0, a fallback strategy is used (may be slower or fail).

Types

type Type

type Type uint8

Type represents a compression algorithm.

const (
	// NoCompression indicates no compression.
	NoCompression Type = 0x0

	// SnappyCompression uses Google Snappy compression.
	SnappyCompression Type = 0x1

	// ZlibCompression uses zlib compression.
	ZlibCompression Type = 0x2

	// BZip2Compression uses bzip2 compression.
	// Note: Not commonly used and not implemented here.
	BZip2Compression Type = 0x3

	// LZ4Compression uses LZ4 compression.
	// Note: Requires external library.
	LZ4Compression Type = 0x4

	// LZ4HCCompression uses LZ4 High Compression mode.
	LZ4HCCompression Type = 0x5

	// XpressCompression is Windows-specific (not implemented).
	XpressCompression Type = 0x6

	// ZstdCompression uses Zstandard compression.
	// Note: Requires external library.
	ZstdCompression Type = 0x7
)

func (Type) IsSupported

func (t Type) IsSupported() bool

IsSupported returns true if the compression type is supported.

func (Type) String

func (t Type) String() string

String returns the human-readable name of the compression type.

Jump to

Keyboard shortcuts

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