Documentation
¶
Index ¶
- Variables
- func DetectCompressionRatio(data []byte) float64
- type AdaptiveCompressor
- func (c *AdaptiveCompressor) Compress(w io.Writer) (io.WriteCloser, error)
- func (c *AdaptiveCompressor) Decompress(r io.Reader) (io.Reader, error)
- func (c *AdaptiveCompressor) Name() string
- func (c *AdaptiveCompressor) SetMinRatio(ratio float64)
- func (c *AdaptiveCompressor) SetThreshold(bytes int)
- func (c *AdaptiveCompressor) SetUnderlyingAlgorithm(algorithm string)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotFound = errors.New("encoding not found")
)
定义错误
Functions ¶
func DetectCompressionRatio ¶
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 ¶
Decompress 实现解压缩
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 设置底层压缩算法
Click to show internal directories.
Click to hide internal directories.