aboutsummaryrefslogtreecommitdiffstats
path: root/library/go/blockcodecs/blocksnappy/snappy.go
blob: eb9e888fcbe8b256fe357e5473ee7ef635da8b86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package blocksnappy

import (
	"github.com/golang/snappy"
	"github.com/ydb-platform/ydb/library/go/blockcodecs"
)

type snappyCodec struct{}

func (s snappyCodec) ID() blockcodecs.CodecID {
	return 50986
}

func (s snappyCodec) Name() string {
	return "snappy"
}

func (s snappyCodec) DecodedLen(in []byte) (int, error) {
	return snappy.DecodedLen(in)
}

func (s snappyCodec) Encode(dst, src []byte) ([]byte, error) {
	return snappy.Encode(dst, src), nil
}

func (s snappyCodec) Decode(dst, src []byte) ([]byte, error) {
	return snappy.Decode(dst, src)
}

func init() {
	blockcodecs.Register(snappyCodec{})
}