blob: e23bfc4772f7771c62cce2cc8b7ef4da6b1a1c07 [file] [log] [blame]
Scott Bakered4efab2020-01-13 19:12:25 -08001package sarama
2
3import (
4 "github.com/klauspost/compress/zstd"
Scott Bakered4efab2020-01-13 19:12:25 -08005)
6
7var (
David K. Bainbridgebd6b2882021-08-26 13:31:02 +00008 zstdDec, _ = zstd.NewReader(nil)
9 zstdEnc, _ = zstd.NewWriter(nil, zstd.WithZeroFrames(true))
Scott Bakered4efab2020-01-13 19:12:25 -080010)
11
12func zstdDecompress(dst, src []byte) ([]byte, error) {
Scott Bakered4efab2020-01-13 19:12:25 -080013 return zstdDec.DecodeAll(src, dst)
14}
15
16func zstdCompress(dst, src []byte) ([]byte, error) {
Scott Bakered4efab2020-01-13 19:12:25 -080017 return zstdEnc.EncodeAll(src, dst), nil
18}