Documentation
¶
Overview ¶
Package codec wraps a stream in the compression the source uses.
It is the one place a codec is chosen. The package had two switches over the same nine codecs, one reached through filesql.CompressionType and one through the parser package's fused file types, and a codec added to either was missing from the other.
Index ¶
Constants ¶
const ( ExtGZ = ".gz" ExtBZ2 = ".bz2" ExtXZ = ".xz" ExtZSTD = ".zst" ExtZLIB = ".z" ExtSNAPPY = ".snappy" ExtS2 = ".s2" ExtLZ4 = ".lz4" )
File extensions, one per codec.
Variables ¶
var ErrNoBZ2Writer = errors.New("bzip2 compression is not supported for writing")
ErrNoBZ2Writer reports a request to write bzip2, which the standard library can read but not write. It is a sentinel so a caller can report it as an unsupported format rather than as a failed compressor.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec int
Codec is a compression format.
const ( // None is an uncompressed stream, which passes through unchanged. None Codec = iota // GZ is gzip. GZ // BZ2 is bzip2, which can be read but not written: the standard library // has no bzip2 writer. BZ2 // XZ is xz. XZ // ZSTD is Zstandard. ZSTD // ZLIB is zlib. ZLIB // SNAPPY is the Snappy framing format. SNAPPY // S2 is S2, Snappy's extension. S2 // LZ4 is LZ4. LZ4 )
func (Codec) NewReader ¶
NewReader wraps reader so it reads the decompressed bytes, and returns the function that releases the decompressor.
The close function is never nil, so a caller can defer it without asking whether this codec has anything to release.