github.com/vc42/parquet-go@v0.0.0-20240320194221-1a9adb5f23f5/compress/snappy/snappy.go (about) 1 // Package snappy implements the SNAPPY parquet compression codec. 2 package snappy 3 4 import ( 5 "github.com/klauspost/compress/snappy" 6 "github.com/vc42/parquet-go/format" 7 ) 8 9 type Codec struct { 10 } 11 12 // The snappy.Reader and snappy.Writer implement snappy encoding/decoding with 13 // a framing protocol, but snappy requires the implementation to use the raw 14 // snappy block encoding. This is why we need to use snappy.Encode/snappy.Decode 15 // and have to ship custom implementations of the compressed reader and writer. 16 17 func (c *Codec) String() string { 18 return "SNAPPY" 19 } 20 21 func (c *Codec) CompressionCodec() format.CompressionCodec { 22 return format.Snappy 23 } 24 25 func (c *Codec) Encode(dst, src []byte) ([]byte, error) { 26 return snappy.Encode(dst, src), nil 27 } 28 29 func (c *Codec) Decode(dst, src []byte) ([]byte, error) { 30 return snappy.Decode(dst, src) 31 }