Documentation
¶
Overview ¶
Package decompress turns a compressed source (gzip, zstd, bzip2, xz, LZ4, Snappy, or Brotli) into the sized, randomly-addressable options.Source every format's decoder needs.
Index ¶
Constants ¶
const DefaultMemoryLimit = 64 << 20
DefaultMemoryLimit is how many decompressed bytes Open keeps in memory before spooling to disk.
Variables ¶
var ErrNotCompressed = errors.New("streamio: no decompression codec selected")
ErrNotCompressed is returned when asked to decompress with CompressionNone or CompressionAuto.
var ErrTooLarge = errors.New("streamio: decompressed input exceeds the configured size limit")
ErrTooLarge is returned when a compressed input expands past the configured size cap.
Functions ¶
func NewReader ¶
func NewReader(r io.Reader, c options.Compression) (io.ReadCloser, error)
NewReader wraps r in a streaming decoder for c. The caller closes the returned reader.
func Open ¶
func Open( ctx context.Context, src options.Source, c options.Compression, lim Limits, ) (options.Source, func() error, error)
Open fully decompresses src and returns a Source over the result, plus a function releasing it.
Small results stay in memory; larger ones spool to a temp file, which the returned function removes. Either way every decoder keeps its random access, so chunked parallel decoding is unaffected by the input having been compressed.
Types ¶
type Limits ¶
type Limits struct {
// MemoryLimit is the decompressed size above which Open spools to a temp file.
MemoryLimit int64
// MaxSize is the decompressed size above which Open fails with ErrTooLarge.
MaxSize int64
}
Limits bounds what Open may hold. A zero field means the default (MemoryLimit) or no cap (MaxSize).