compression

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("encoding not found")
)

定义错误

Functions

func DetectCompressionRatio

func DetectCompressionRatio(data []byte) float64

DetectCompressionRatio 检测数据的可压缩性,返回预估的压缩比 使用采样方法,速度快但精度较低

Types

type AdaptiveCompressor

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

AdaptiveCompressor 是一个智能压缩器,根据消息大小自动决定是否启用压缩

func NewAdaptiveCompressor

func NewAdaptiveCompressor(algorithm string, thresholdBytes int, minRatio float64) *AdaptiveCompressor

NewAdaptiveCompressor 创建一个新的自适应压缩器

func (*AdaptiveCompressor) Compress

func (c *AdaptiveCompressor) Compress(w io.Writer) (io.WriteCloser, error)

Compress 根据消息大小自适应压缩

func (*AdaptiveCompressor) Decompress

func (c *AdaptiveCompressor) Decompress(r io.Reader) (io.Reader, error)

Decompress 实现解压缩

func (*AdaptiveCompressor) Name

func (c *AdaptiveCompressor) Name() string

Name 返回压缩器名称

func (*AdaptiveCompressor) SetMinRatio

func (c *AdaptiveCompressor) SetMinRatio(ratio float64)

SetMinRatio 设置最小压缩比

func (*AdaptiveCompressor) SetThreshold

func (c *AdaptiveCompressor) SetThreshold(bytes int)

SetThreshold 设置压缩阈值

func (*AdaptiveCompressor) SetUnderlyingAlgorithm

func (c *AdaptiveCompressor) SetUnderlyingAlgorithm(algorithm string)

SetUnderlyingAlgorithm 设置底层压缩算法

Jump to

Keyboard shortcuts

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