compression

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Overview

Package compression provides common types for other compression packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int32

Level configures the compression trade-off between speed and size.

A lower (more negative) value means better speed (faster). A higher (more positive) value means better size (smaller).

const (
	// LevelFastest means to maximize compression speed.
	LevelFastest Level = -2 << 10

	// LevelFast means to prioritize compression speed.
	//
	// It might not be as fast as LevelFastest, if doing so would require
	// substantial additional compute resources (e.g. CPU or RAM) or give up
	// substantial compression size.
	LevelFast Level = -1 << 10

	// LevelDefault means to use a reasonable default.
	LevelDefault Level = 0

	// LevelSmall means to prioritize compression size.
	//
	// It might not be as small as LevelSmallest, if doing so would require
	// substantial additional compute resources (e.g. CPU or RAM) or give up
	// substantial compression speed.
	LevelSmall Level = +1 << 10

	// LevelSmallest means to minimize compression size.
	LevelSmallest Level = +2 << 10
)

func (Level) Interpolate

func (l Level) Interpolate(fastest int32, fast int32, default_ int32, small int32, smallest int32) int32

Interpolate translates from Level (a codec-agnostic concept) to a codec-specific compression level numbering scheme. For exampe, a zlib package might translate LevelFastest to 1 and LevelSmallest to 9 by calling Interpolate(1, 2, 6, 9, 9).

The mapping is via piecewise linear interpolation, given by five points in (Level, int32) space: (LevelFastest, fastest), (LevelFast, fast), etc.

type Reader

type Reader interface {
	io.ReadCloser

	// Reset resets this Reader to switch to a new underlying io.Reader. This
	// permits re-using a Reader instead of allocating a new one.
	//
	// It is the same as the standard library's zlib.Resetter's method.
	Reset(r io.Reader, dictionary []byte) error
}

Reader is an io.ReadCloser with a Reset method.

type Writer

type Writer interface {
	io.WriteCloser

	// Reset resets this Writer to switch to a new underlying io.Writer. This
	// permits re-using a Writer instead of allocating a new one.
	Reset(w io.Writer, dictionary []byte, level Level) error
}

Writer is an io.WriteCloser with a Reset method.

Jump to

Keyboard shortcuts

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