compress

package
v0.0.0-...-089e9e6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LZ4WriterPool = sync.Pool{
		New: func() any {
			return lz4.NewWriter(nil)
		},
	}
	LZ4ReaderPool = sync.Pool{
		New: func() any {
			return lz4.NewReader(nil)
		},
	}
)

Multiple instances of writers and readers can put pressure on the memory, we use a sync pool to reuse instance instead on letting the GC deal with them

Functions

This section is empty.

Types

type CompressionType

type CompressionType uint8

CompressionType represents one of the supported compression types

const (
	NONE   CompressionType = 0
	GZIP   CompressionType = 1
	SNAPPY CompressionType = 2
	LZ4    CompressionType = 3
	ZSTD   CompressionType = 4
)

Kafka compression types

type Compressor

type Compressor interface {
	Compress(data []byte) ([]byte, error)
	Decompress(data []byte) ([]byte, error)
}

Compressor represents one of the supported compressors

func GetCompressor

func GetCompressor(attribute uint16) Compressor

GetCompressor returns the Compressor based on the RecordBatch attributes

type GzipCompressor

type GzipCompressor struct{} // TODO: handle the various GZIP levels (only default now)

GzipCompressor implements Compressor interface

func (*GzipCompressor) Compress

func (c *GzipCompressor) Compress(data []byte) ([]byte, error)

Compress takes in data and applies gzip to it

func (*GzipCompressor) Decompress

func (c *GzipCompressor) Decompress(data []byte) ([]byte, error)

Decompress decompresses gzip-compressed data

type LZ4Compressor

type LZ4Compressor struct{}

LZ4Compressor implements Compressor interface

func (*LZ4Compressor) Compress

func (c *LZ4Compressor) Compress(data []byte) ([]byte, error)

Compress takes in data and applies LZ4 to it

func (*LZ4Compressor) Decompress

func (c *LZ4Compressor) Decompress(data []byte) ([]byte, error)

Decompress decompresses LZ4-compressed data

type SnappyCompressor

type SnappyCompressor struct{}

SnappyCompressor implements Compressor interface

func (*SnappyCompressor) Compress

func (c *SnappyCompressor) Compress(data []byte) ([]byte, error)

Compress takes in data and applies snappy to it

func (*SnappyCompressor) Decompress

func (c *SnappyCompressor) Decompress(data []byte) ([]byte, error)

Decompress decompresses snappy-compressed data

type ZSTDCompressor

type ZSTDCompressor struct{} // TODO: add compression levels

ZSTDCompressor implements Compressor interface

func (*ZSTDCompressor) Compress

func (c *ZSTDCompressor) Compress(data []byte) ([]byte, error)

Compress takes in data and applies ZSTD to it

func (*ZSTDCompressor) Decompress

func (c *ZSTDCompressor) Decompress(data []byte) ([]byte, error)

Decompress decompresses ZSTD-compressed data

Jump to

Keyboard shortcuts

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