新增压缩功能-LZS算法

This commit is contained in:
lanrenwo
2023-01-17 12:09:04 +08:00
parent 70c82b8baa
commit 768e137ff9
12 changed files with 212 additions and 23 deletions

View File

@@ -0,0 +1,35 @@
package sessdata
import (
"github.com/lanrenwo/lzsgo"
)
type CmpEncoding interface {
Compress(src []byte, dst []byte) (int, error)
Uncompress(src []byte, dst []byte) (int, error)
}
type LzsgoCmp struct {
}
func (l LzsgoCmp) Compress(src []byte, dst []byte) (int, error) {
n, err := lzsgo.Compress(src, dst)
return n, err
}
func (l LzsgoCmp) Uncompress(src []byte, dst []byte) (int, error) {
n, err := lzsgo.Uncompress(src, dst)
return n, err
}
// type Lz4Cmp struct {
// c lz4.Compressor
// }
// func (l Lz4Cmp) Compress(src []byte, dst []byte) (int, error) {
// return l.c.CompressBlock(src, dst)
// }
// func (l Lz4Cmp) Uncompress(src []byte, dst []byte) (int, error) {
// return lz4.UncompressBlock(src, dst)
// }