compress

package
v0.3.75-rc-71dbe31 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressStringArray

func CompressStringArray(input []string, compressor Compressor) ([]byte, error)

func DecompressStringArray

func DecompressStringArray(input []byte, decompressor Decompressor) ([]string, error)

func MustCompressStringArray added in v0.3.47

func MustCompressStringArray(input []string, compressor Compressor) []byte

func MustDecompressStringArray added in v0.3.47

func MustDecompressStringArray(input []byte, compressor Decompressor) []string

Types

type Compressor

type Compressor interface {
	// Compress compresses the byte array
	Compress(b []byte) ([]byte, error)
}

Compressor is a fast, single threaded compressor. This type allows us to reuse buffers etc for performance

type Decompressor

type Decompressor interface {
	// Decompress decompresses the byte array
	Decompress(b []byte) ([]byte, error)
}

Decompressor is a fast, single threaded compressor. This type allows us to reuse buffers etc for performance

type NoOpCompressor

type NoOpCompressor struct{}

NoOpCompressor is a Compressor that does nothing. Useful for tests.

func (*NoOpCompressor) Compress

func (c *NoOpCompressor) Compress(b []byte) ([]byte, error)

type NoOpDecompressor

type NoOpDecompressor struct{}

NoOpDecompressor is a DeCompressor that does nothing. Useful for tests.

func (*NoOpDecompressor) Decompress

func (c *NoOpDecompressor) Decompress(b []byte) ([]byte, error)

type ThreadSafeZlibCompressor

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

ThreadSafeZlibCompressor provides a thread safe compressor, at the cost of instantiating a new ZlibCompressor for each Compress call

func NewThreadSafeZlibCompressor

func NewThreadSafeZlibCompressor(minCompressSize int) *ThreadSafeZlibCompressor

func (*ThreadSafeZlibCompressor) Compress

func (c *ThreadSafeZlibCompressor) Compress(b []byte) ([]byte, error)

type ThreadSafeZlibDecompressor

type ThreadSafeZlibDecompressor struct{}

ThreadSafeZlibDecompressor provides a thread safe decompressor, at the cost of instantiating a new ZlibDecompressor for each Decompress call

func NewThreadSafeZlibDecompressor

func NewThreadSafeZlibDecompressor() *ThreadSafeZlibDecompressor

func (*ThreadSafeZlibDecompressor) Decompress

func (d *ThreadSafeZlibDecompressor) Decompress(b []byte) ([]byte, error)

type ZlibCompressor

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

ZlibCompressor compresses to Zlib, which for KB size payloads seems more (cpu) efficient than the newer formats such as zstd. The compressor will only compress if the msg is greater than minCompressSize

func NewZlibCompressor

func NewZlibCompressor(minCompressSize int) (*ZlibCompressor, error)

func (*ZlibCompressor) Compress

func (c *ZlibCompressor) Compress(b []byte) ([]byte, error)

type ZlibDecompressor

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

ZlibDecompressor decompresses Zlib

func NewZlibDecompressor

func NewZlibDecompressor() *ZlibDecompressor

func (*ZlibDecompressor) Decompress

func (d *ZlibDecompressor) Decompress(b []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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