compress

package
v0.0.0-...-9f5c9a3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 16 Imported by: 0 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 DefaultBufferSize = 1024 * 1024

DefaultBufferSize is the default I/O write buffer size (1 MB) when -b is not specified.

View Source
const FormatZstdExt = ".zst"

Variables

This section is empty.

Functions

func EnsureExtension

func EnsureExtension(f Format, path string) string

EnsureExtension appends the canonical compression extension to path if missing.

func Extension

func Extension(f Format) string

Extension returns the canonical file extension for a compression Format.

func LevelRange

func LevelRange(f Format) (int, int, int)

LevelRange returns the valid (min, max, default) compression levels for a Format.

func NewStreamWriter

func NewStreamWriter(dst io.Writer, format Format, level *int, concurrency int) (io.WriteCloser, error)

NewStreamWriter wraps dst in a streaming compressor for the given Format, level, and concurrency. Uses parallel block compression (pgzip) for gzip and concurrent zstd encoding when concurrency > 1.

func OpenOutput

func OpenOutput(path string, bufferSize int, format Format, level *int, forceOverwrite bool, concurrency ...int) (io.WriteCloser, string, error)

OpenOutput opens stdout (when path == "") or a target file with buffered I/O and optional streaming compression. Optional concurrency specifies the encoder thread count for parallel codecs (gzip via pgzip, zstd).

func ValidateLevel

func ValidateLevel(f Format, level *int) (int, error)

ValidateLevel validates an optional compression level for the given Format.

Types

type EstimateResult

type EstimateResult struct {
	Bytes *big.Int // Predicted or exact compressed byte count
	Ratio float64  // Compressed / Uncompressed ratio in (0, 1+]
	Exact bool     // True when the entire dataset fit inside the in-memory probe
}

EstimateResult holds the predicted (or exact) compressed output size and empirical compression ratio.

func EstimateSize

func EstimateSize(
	ctx context.Context,
	engine *gomap.Engine,
	plan *gomap.Plan,
	stats gomap.StatsResult,
	delimiter string,
	format Format,
	level *int,
) (EstimateResult, error)

EstimateSize predicts the compressed output size of a compiled Plan before writing to disk. For small outputs (<= 512KB), it runs the real codec over the full stream in RAM for an exact byte count. For large outputs, it uses O(1) indexed seeking to sample 4 contiguous 128KB windows across the keyspace (at 0%, 33%, 66%, and 95%) through the real codec and compression level.

type Format

type Format string

Format identifies a supported streaming compression algorithm.

const (
	FormatNone  Format = ""
	FormatGzip  Format = "gzip"
	FormatBzip2 Format = "bzip2"
	FormatLZMA  Format = "lzma"
	FormatZstd  Format = "zstd"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat validates and normalizes a compression format name. Accepts "xz" as a convenient alias for "lzma".

Jump to

Keyboard shortcuts

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