lzma2

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package lzma2 implements Nyarime house raw LZMA2 streams (NYA CompressionID 6). Encoder design references xz/7-Zip and klauspost/compress benchmarks; implementation is in-house.

Index

Constants

View Source
const DefaultDictSize = 4 * 1024 * 1024

DefaultDictSize matches NYA writer default (4 MiB).

Variables

This section is empty.

Functions

func Lzma2Compress

func Lzma2Compress(src []byte, dictSize int) ([]byte, error)

Lzma2Compress compresses src into a raw LZMA2 stream (no XZ container).

Large inputs are split into segments compressed in parallel. Within a segment one encoder drives every chunk and only the probability models are reset at a chunk boundary, so the match finder — and the dictionary the decoder is holding — carries across and matches reach back through the whole segment. Compressing each 64 KiB chunk in isolation, as this used to, capped the effective dictionary at the chunk size whatever dictSize said.

func Lzma2CompressOpts

func Lzma2CompressOpts(src []byte, opts Lzma2Options) ([]byte, error)

Lzma2CompressOpts compresses src with explicit encoder settings.

func Lzma2Decompress

func Lzma2Decompress(data []byte, dictSize int) ([]byte, error)

Lzma2Decompress decompresses a raw LZMA2 stream from a byte slice.

func Lzma2NewReader

func Lzma2NewReader(r io.Reader, dictSize int) io.ReadCloser

Lzma2NewReader decompresses a raw LZMA2 stream, the form Lzma2Compress produces. dictSize must be at least the value used when compressing; pass 0 for the 4 MiB default this package writes.

func LzmaCompress

func LzmaCompress(src []byte) ([]byte, error)

LzmaCompress compresses src using plain LZMA format (13-byte header + stream).

func LzmaDecompress

func LzmaDecompress(data []byte) ([]byte, error)

LzmaDecompress decompresses plain LZMA data.

func LzmaNewReader

func LzmaNewReader(r io.Reader) (io.ReadCloser, error)

LzmaNewReader creates a new plain LZMA stream decompressor.

func XzDecompress

func XzDecompress(data []byte) ([]byte, error)

XzDecompress decompresses XZ data from a byte slice.

func XzNewReader

func XzNewReader(r io.Reader) (io.ReadCloser, error)

XzNewReader creates a new XZ stream decompressor.

Types

type BenchCorpus added in v0.2.0

type BenchCorpus struct {
	Name string
	Data func() []byte
}

BenchCorpus is a named input for 7-Zip comparison benchmarks.

func BenchCorpora added in v0.2.0

func BenchCorpora() []BenchCorpus

BenchCorpora returns synthetic corpora used by TestBenchVs7zCorpora.

type Lzma2Options

type Lzma2Options struct {
	// DictSize is the match window in bytes. Zero picks the package default.
	DictSize int
	// Depth caps the hash chain walk per position. Zero picks the default.
	Depth int
	// NiceLen is the match length at which the parser stops looking for a
	// better option. Zero picks the default.
	NiceLen int
	// OptimalParse enables the DP parser (7-Zip-style). It helps on some
	// solid/repetitive corpora but is slower; off by default until tuned per level.
	OptimalParse bool
}

Lzma2Options tunes the encoder's effort.

func BenchLevel9Opts added in v0.2.0

func BenchLevel9Opts() Lzma2Options

BenchLevel9Opts returns encoder settings for ROADMAP phase-1 level-9 optimal parse.

Jump to

Keyboard shortcuts

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