pargzip

package module
v0.0.0-...-90c7fc0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: BSD-3-Clause Imports: 7 Imported by: 2

README

GoDoc

golang.org/x/build/pargzip

Package pargzip contains a parallel gzip writer implementation.

Documentation

Overview

Package pargzip contains a parallel gzip writer implementation. By compressing each chunk of data in parallel, all the CPUs on the machine can be used, at a slight loss of compression efficiency.

Index

Constants

View Source
const (
	NoCompression      = gzip.NoCompression
	BestSpeed          = gzip.BestSpeed
	BestCompression    = gzip.BestCompression
	DefaultCompression = gzip.DefaultCompression
	HuffmanOnly        = gzip.HuffmanOnly
)

These constants are copied from the gzip package, so that code that imports pargzip does not also have to import compress/gzip.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

type Writer struct {
	// ChunkSize is the number of bytes to gzip at once.
	// The default from NewWriter is 1MB.
	ChunkSize int

	// Parallel is the number of chunks to compress in parallel.
	// The default from NewWriter is runtime.NumCPU().
	Parallel int

	// CompressionLevel is the compression level to use for gzip.
	// The default from NewWriter is DefaultCompression.
	CompressionLevel int
	// contains filtered or unexported fields
}

A Writer is an io.WriteCloser. Writes to a Writer are compressed and written to w.

Any exported fields may only be mutated before the first call to Write.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer. Writes to the returned writer are compressed and written to w.

It is the caller's responsibility to call Close on the WriteCloser when done. Writes may be buffered and not flushed until Close.

Any fields on Writer may only be modified before the first call to Write.

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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