github.com/vc42/parquet-go@v0.0.0-20240320194221-1a9adb5f23f5/encoding/encoding.go (about) 1 // Package encoding provides the generic APIs implemented by parquet encodings 2 // in its sub-packages. 3 package encoding 4 5 import ( 6 "math" 7 8 "github.com/vc42/parquet-go/format" 9 ) 10 11 const ( 12 MaxFixedLenByteArraySize = math.MaxInt16 13 ) 14 15 // The Encoding interface is implemented by types representing parquet column 16 // encodings. 17 // 18 // Encoding instances must be safe to use concurrently from multiple goroutines. 19 type Encoding interface { 20 // Returns a human-readable name for the encoding. 21 String() string 22 23 // Returns the parquet code representing the encoding. 24 Encoding() format.Encoding 25 26 // Encode methods serialize the source sequence of values into the 27 // destination buffer, potentially reallocating it if it was too short to 28 // contain the output. 29 // 30 // The source are expected to be encoded using the PLAIN encoding, and 31 // therefore the methods act as conversions into the target encoding. 32 EncodeLevels(dst, src []byte) ([]byte, error) 33 EncodeBoolean(dst, src []byte) ([]byte, error) 34 EncodeInt32(dst, src []byte) ([]byte, error) 35 EncodeInt64(dst, src []byte) ([]byte, error) 36 EncodeInt96(dst, src []byte) ([]byte, error) 37 EncodeFloat(dst, src []byte) ([]byte, error) 38 EncodeDouble(dst, src []byte) ([]byte, error) 39 EncodeByteArray(dst, src []byte) ([]byte, error) 40 EncodeFixedLenByteArray(dst, src []byte, size int) ([]byte, error) 41 42 // Decode methods deserialize from the source buffer into the destination 43 // slice, potentially growing it if it was too short to contain the result. 44 // 45 // Values are written in the destination buffer in the PLAIN encoding. 46 DecodeLevels(dst, src []byte) ([]byte, error) 47 DecodeBoolean(dst, src []byte) ([]byte, error) 48 DecodeInt32(dst, src []byte) ([]byte, error) 49 DecodeInt64(dst, src []byte) ([]byte, error) 50 DecodeInt96(dst, src []byte) ([]byte, error) 51 DecodeFloat(dst, src []byte) ([]byte, error) 52 DecodeDouble(dst, src []byte) ([]byte, error) 53 DecodeByteArray(dst, src []byte) ([]byte, error) 54 DecodeFixedLenByteArray(dst, src []byte, size int) ([]byte, error) 55 }