Documentation
¶
Overview ¶
Package gobzip2 implements reading and writing of bzip2 format compressed data.
This is a pure Go implementation based on the bzip2 1.0.8 reference C code. It provides both compression and decompression, unlike the standard library's compress/bzip2 package which only supports decompression.
Index ¶
Constants ¶
const ( BestSpeed = 1 DefaultCompression = 9 BestCompression = 9 )
Compression levels.
const ParallelCPU = -1
ParallelCPU can be used as WriterOptions.Concurrency to use all available CPUs.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChecksumError ¶
type ChecksumError struct {
Expected, Got uint32
}
ChecksumError is returned when the CRC of the decompressed data does not match the expected value.
func (*ChecksumError) Error ¶
func (e *ChecksumError) Error() string
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader decompresses bzip2-compressed data read from the underlying reader.
type StructuralError ¶
type StructuralError string
StructuralError is returned when the bzip2 data is found to be syntactically invalid.
func (StructuralError) Error ¶
func (e StructuralError) Error() string
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer compresses data written to it in bzip2 format.
func NewWriter ¶
NewWriter returns a new Writer that compresses data at the default level (9) and writes the compressed output to w.
func NewWriterLevel ¶
NewWriterLevel returns a new Writer with the given block size level (1-9).
func NewWriterOptions ¶
func NewWriterOptions(w io.Writer, opts *WriterOptions) (*Writer, error)
NewWriterOptions returns a new Writer with the given options.
type WriterOptions ¶
type WriterOptions struct {
// Level is the block size level (1-9). Default is 9 (900KB blocks).
Level int
// Concurrency is the number of goroutines used for compression.
// 0 or 1 means single-threaded (no goroutine overhead).
// Higher values enable parallel block compression.
// Use ParallelCPU for runtime.NumCPU().
Concurrency int
// WorkFactor controls when the fallback sorting algorithm kicks in.
// 0 means use the default (30). Range: 1-250.
WorkFactor int
}
WriterOptions configures the compressor.