compression

package
v3.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExtNone   = ""
	ExtGZIP   = ".gz"
	ExtSnappy = ".sz"
	ExtLZ4    = ".lz4"
	ExtFlate  = ".zz"
	ExtZstd   = ".zst"
)

Variables

This section is empty.

Functions

func SupportedCodecs

func SupportedCodecs() string

SupportedCodecs returns the list of supported Encoding.

func ToFileExtension

func ToFileExtension(e Codec) string

Types

type Codec

type Codec byte

Codec identifies an available compression codec.

const (
	None Codec = iota
	GZIP
	Dumb // not supported
	LZ4_64k
	Snappy
	LZ4_256k
	LZ4_1M
	LZ4_4M
	Flate
	Zstd
)

The different available codecs Make sure to preserve the order, as the numeric values are serialized!

func FromFileExtension

func FromFileExtension(ext string) Codec

func ParseCodec

func ParseCodec(enc string) (Codec, error)

ParseCodec parses a chunk encoding (compression codec) by its name.

func (Codec) String

func (e Codec) String() string

type FlatePool

type FlatePool struct {
	// contains filtered or unexported fields
}

FlatePool is a flate compression pool

func (*FlatePool) GetReader

func (pool *FlatePool) GetReader(src io.Reader) (io.Reader, error)

GetReader gets or creates a new CompressionReader and reset it to read from src

func (*FlatePool) GetWriter

func (pool *FlatePool) GetWriter(dst io.Writer) io.WriteCloser

GetWriter gets or creates a new CompressionWriter and reset it to write to dst

func (*FlatePool) PutReader

func (pool *FlatePool) PutReader(reader io.Reader)

PutReader places back in the pool a CompressionReader

func (*FlatePool) PutWriter

func (pool *FlatePool) PutWriter(writer io.WriteCloser)

PutWriter places back in the pool a CompressionWriter

type GzipPool

type GzipPool struct {
	// contains filtered or unexported fields
}

GzipPool is a gnu zip compression pool

func (*GzipPool) GetReader

func (pool *GzipPool) GetReader(src io.Reader) (io.Reader, error)

GetReader gets or creates a new CompressionReader and reset it to read from src

func (*GzipPool) GetWriter

func (pool *GzipPool) GetWriter(dst io.Writer) io.WriteCloser

GetWriter gets or creates a new CompressionWriter and reset it to write to dst

func (*GzipPool) PutReader

func (pool *GzipPool) PutReader(reader io.Reader)

PutReader places back in the pool a CompressionReader

func (*GzipPool) PutWriter

func (pool *GzipPool) PutWriter(writer io.WriteCloser)

PutWriter places back in the pool a CompressionWriter

type LZ4Pool

type LZ4Pool struct {
	// contains filtered or unexported fields
}

func (*LZ4Pool) GetReader

func (pool *LZ4Pool) GetReader(src io.Reader) (io.Reader, error)

GetReader gets or creates a new CompressionReader and reset it to read from src

func (*LZ4Pool) GetWriter

func (pool *LZ4Pool) GetWriter(dst io.Writer) io.WriteCloser

GetWriter gets or creates a new CompressionWriter and reset it to write to dst

func (*LZ4Pool) PutReader

func (pool *LZ4Pool) PutReader(reader io.Reader)

PutReader places back in the pool a CompressionReader

func (*LZ4Pool) PutWriter

func (pool *LZ4Pool) PutWriter(writer io.WriteCloser)

PutWriter places back in the pool a CompressionWriter

type NoopPool

type NoopPool struct{}

func (*NoopPool) GetReader

func (pool *NoopPool) GetReader(src io.Reader) (io.Reader, error)

GetReader gets or creates a new CompressionReader and reset it to read from src

func (*NoopPool) GetWriter

func (pool *NoopPool) GetWriter(dst io.Writer) io.WriteCloser

GetWriter gets or creates a new CompressionWriter and reset it to write to dst

func (*NoopPool) PutReader

func (pool *NoopPool) PutReader(_ io.Reader)

PutReader places back in the pool a CompressionReader

func (*NoopPool) PutWriter

func (pool *NoopPool) PutWriter(_ io.WriteCloser)

PutWriter places back in the pool a CompressionWriter

type ReaderPool

type ReaderPool interface {
	GetReader(io.Reader) (io.Reader, error)
	PutReader(io.Reader)
}

ReaderPool is a pool of io.Reader ReaderPool similar to WriterPool but for reading chunks.

func GetReaderPool

func GetReaderPool(enc Codec) ReaderPool

type ReaderWriterPool

type ReaderWriterPool interface {
	ReaderPool
	WriterPool
}

ReaderPool is a pool of io.Reader and io.Writer

func GetPool

func GetPool(enc Codec) ReaderWriterPool

type SnappyPool

type SnappyPool struct {
	// contains filtered or unexported fields
}

func (*SnappyPool) GetReader

func (pool *SnappyPool) GetReader(src io.Reader) (io.Reader, error)

GetReader gets or creates a new CompressionReader and reset it to read from src

func (*SnappyPool) GetWriter

func (pool *SnappyPool) GetWriter(dst io.Writer) io.WriteCloser

GetWriter gets or creates a new CompressionWriter and reset it to write to dst

func (*SnappyPool) PutReader

func (pool *SnappyPool) PutReader(reader io.Reader)

PutReader places back in the pool a CompressionReader

func (*SnappyPool) PutWriter

func (pool *SnappyPool) PutWriter(writer io.WriteCloser)

PutWriter places back in the pool a CompressionWriter

type WriterPool

type WriterPool interface {
	GetWriter(io.Writer) io.WriteCloser
	PutWriter(io.WriteCloser)
}

WriterPool is a pool of io.Writer This is used by every chunk to avoid unnecessary allocations.

func GetWriterPool

func GetWriterPool(enc Codec) WriterPool

type ZstdPool

type ZstdPool struct {
	// contains filtered or unexported fields
}

GzipPool is a gun zip compression pool

func (*ZstdPool) GetReader

func (pool *ZstdPool) GetReader(src io.Reader) (io.Reader, error)

GetReader gets or creates a new CompressionReader and reset it to read from src

func (*ZstdPool) GetWriter

func (pool *ZstdPool) GetWriter(dst io.Writer) io.WriteCloser

GetWriter gets or creates a new CompressionWriter and reset it to write to dst

func (*ZstdPool) PutReader

func (pool *ZstdPool) PutReader(reader io.Reader)

PutReader places back in the pool a CompressionReader

func (*ZstdPool) PutWriter

func (pool *ZstdPool) PutWriter(writer io.WriteCloser)

PutWriter places back in the pool a CompressionWriter

Jump to

Keyboard shortcuts

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