encoding

package
v0.0.0-...-5d42db8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Overview

Package encoding provides the generic APIs implemented by parquet encodings in its sub-packages.

Index

Constants

View Source
const (
	MaxFixedLenByteArraySize = math.MaxInt16
)

Variables

View Source
var (
	// ErrNotSupported is an error returned when the underlying encoding does
	// not support the type of values being encoded or decoded.
	//
	// This error may be wrapped with type information, applications must use
	// errors.Is rather than equality comparisons to test the error values
	// returned by encoders and decoders.
	ErrNotSupported = errors.New("encoding not supported")

	// ErrInvalidArgument is an error returned one or more arguments passed to
	// the encoding functions are incorrect.
	//
	// As with ErrNotSupported, this error may be wrapped with specific
	// information about the problem and applications are expected to use
	// errors.Is for comparisons.
	ErrInvalidArgument = errors.New("invalid argument")
)

Functions

func CanEncodeBoolean

func CanEncodeBoolean(e Encoding) bool

CanEncodeBoolean reports whether e can encode BOOLEAN values.

func CanEncodeByteArray

func CanEncodeByteArray(e Encoding) bool

CanEncodeByteArray reports whether e can encode BYTE_ARRAY values.

func CanEncodeDouble

func CanEncodeDouble(e Encoding) bool

CanEncodeDouble reports whether e can encode DOUBLE values.

func CanEncodeFixedLenByteArray

func CanEncodeFixedLenByteArray(e Encoding) bool

CanEncodeFixedLenByteArray reports whether e can encode FIXED_LEN_BYTE_ARRAY values.

func CanEncodeFloat

func CanEncodeFloat(e Encoding) bool

CanEncodeFloat reports whether e can encode FLOAT values.

func CanEncodeInt32

func CanEncodeInt32(e Encoding) bool

CanEncodeInt32 reports whether e can encode INT32 values.

func CanEncodeInt64

func CanEncodeInt64(e Encoding) bool

CanEncodeInt64 reports whether e can encode INT64 values.

func CanEncodeInt96

func CanEncodeInt96(e Encoding) bool

CanEncodeInt96 reports whether e can encode INT96 values.

func CanEncodeLevels

func CanEncodeLevels(e Encoding) bool

CanEncodeInt8 reports whether e can encode LEVELS values.

func EncodeBoolean

func EncodeBoolean(dst []byte, src Values, enc Encoding) ([]byte, error)

func EncodeByteArray

func EncodeByteArray(dst []byte, src Values, enc Encoding) ([]byte, error)

func EncodeDouble

func EncodeDouble(dst []byte, src Values, enc Encoding) ([]byte, error)

func EncodeFixedLenByteArray

func EncodeFixedLenByteArray(dst []byte, src Values, enc Encoding) ([]byte, error)

func EncodeFloat

func EncodeFloat(dst []byte, src Values, enc Encoding) ([]byte, error)

func EncodeInt32

func EncodeInt32(dst []byte, src Values, enc Encoding) ([]byte, error)

func EncodeInt64

func EncodeInt64(dst []byte, src Values, enc Encoding) ([]byte, error)

func EncodeInt96

func EncodeInt96(dst []byte, src Values, enc Encoding) ([]byte, error)

func ErrDecodeInvalidInputSize

func ErrDecodeInvalidInputSize(e Encoding, typ string, size int) error

ErrDecodeInvalidInputSize constructs an error indicating that decoding failed due to the size of the input.

func ErrEncodeInvalidInputSize

func ErrEncodeInvalidInputSize(e Encoding, typ string, size int) error

ErrEncodeInvalidInputSize constructs an error indicating that encoding failed due to the size of the input.

func Error

func Error(e Encoding, err error) error

Error constructs an error which wraps err and indicates that it originated from the given encoding.

func Errorf

func Errorf(e Encoding, msg string, args ...interface{}) error

Errorf is like Error but constructs the error message from the given format and arguments.

Types

type Encoding

type Encoding interface {
	// Returns a human-readable name for the encoding.
	String() string

	// Returns the parquet code representing the encoding.
	Encoding() format.Encoding

	// Encode methods serialize the source sequence of values into the
	// destination buffer, potentially reallocating it if it was too short to
	// contain the output.
	//
	// The methods panic if the type of src values differ from the type of
	// values being encoded.
	EncodeLevels(dst []byte, src []uint8) ([]byte, error)
	EncodeBoolean(dst []byte, src []byte) ([]byte, error)
	EncodeInt32(dst []byte, src []int32) ([]byte, error)
	EncodeInt64(dst []byte, src []int64) ([]byte, error)
	EncodeInt96(dst []byte, src []deprecated.Int96) ([]byte, error)
	EncodeFloat(dst []byte, src []float32) ([]byte, error)
	EncodeDouble(dst []byte, src []float64) ([]byte, error)
	EncodeByteArray(dst []byte, src []byte, offsets []uint32) ([]byte, error)
	EncodeFixedLenByteArray(dst []byte, src []byte, size int) ([]byte, error)

	// Decode methods deserialize from the source buffer into the destination
	// slice, potentially growing it if it was too short to contain the result.
	//
	// The methods panic if the type of dst values differ from the type of
	// values being decoded.
	DecodeLevels(dst []uint8, src []byte) ([]uint8, error)
	DecodeBoolean(dst []byte, src []byte) ([]byte, error)
	DecodeInt32(dst []int32, src []byte) ([]int32, error)
	DecodeInt64(dst []int64, src []byte) ([]int64, error)
	DecodeInt96(dst []deprecated.Int96, src []byte) ([]deprecated.Int96, error)
	DecodeFloat(dst []float32, src []byte) ([]float32, error)
	DecodeDouble(dst []float64, src []byte) ([]float64, error)
	DecodeByteArray(dst []byte, src []byte, offsets []uint32) ([]byte, []uint32, error)
	DecodeFixedLenByteArray(dst []byte, src []byte, size int) ([]byte, error)

	// Computes an estimation of the output size of decoding the encoded page
	// of values passed as argument.
	//
	// Note that this is an estimate, it is useful to preallocate the output
	// buffer that will be passed to the decode method, but the actual output
	// size may be different.
	//
	// The estimate never errors since it is not intended to be used as an
	// input validation method.
	EstimateDecodeByteArraySize(src []byte) int

	// When this method returns true, the encoding supports receiving the same
	// buffer as source and destination.
	CanDecodeInPlace() bool
}

The Encoding interface is implemented by types representing parquet column encodings.

Encoding instances must be safe to use concurrently from multiple goroutines.

type Kind

type Kind int32
const (
	Undefined Kind = iota
	Boolean
	Int32
	Int64
	Int96
	Float
	Double
	ByteArray
	FixedLenByteArray
)

func (Kind) String

func (kind Kind) String() string

type NotSupported

type NotSupported struct {
}

NotSupported is a type satisfying the Encoding interface which does not support encoding nor decoding any value types.

func (NotSupported) CanDecodeInPlace

func (NotSupported) CanDecodeInPlace() bool

func (NotSupported) DecodeBoolean

func (NotSupported) DecodeBoolean(dst []byte, src []byte) ([]byte, error)

func (NotSupported) DecodeByteArray

func (NotSupported) DecodeByteArray(dst []byte, src []byte, offsets []uint32) ([]byte, []uint32, error)

func (NotSupported) DecodeDouble

func (NotSupported) DecodeDouble(dst []float64, src []byte) ([]float64, error)

func (NotSupported) DecodeFixedLenByteArray

func (NotSupported) DecodeFixedLenByteArray(dst []byte, src []byte, size int) ([]byte, error)

func (NotSupported) DecodeFloat

func (NotSupported) DecodeFloat(dst []float32, src []byte) ([]float32, error)

func (NotSupported) DecodeInt32

func (NotSupported) DecodeInt32(dst []int32, src []byte) ([]int32, error)

func (NotSupported) DecodeInt64

func (NotSupported) DecodeInt64(dst []int64, src []byte) ([]int64, error)

func (NotSupported) DecodeInt96

func (NotSupported) DecodeInt96(dst []deprecated.Int96, src []byte) ([]deprecated.Int96, error)

func (NotSupported) DecodeLevels

func (NotSupported) DecodeLevels(dst []uint8, src []byte) ([]uint8, error)

func (NotSupported) EncodeBoolean

func (NotSupported) EncodeBoolean(dst []byte, src []byte) ([]byte, error)

func (NotSupported) EncodeByteArray

func (NotSupported) EncodeByteArray(dst []byte, src []byte, offsets []uint32) ([]byte, error)

func (NotSupported) EncodeDouble

func (NotSupported) EncodeDouble(dst []byte, src []float64) ([]byte, error)

func (NotSupported) EncodeFixedLenByteArray

func (NotSupported) EncodeFixedLenByteArray(dst []byte, src []byte, size int) ([]byte, error)

func (NotSupported) EncodeFloat

func (NotSupported) EncodeFloat(dst []byte, src []float32) ([]byte, error)

func (NotSupported) EncodeInt32

func (NotSupported) EncodeInt32(dst []byte, src []int32) ([]byte, error)

func (NotSupported) EncodeInt64

func (NotSupported) EncodeInt64(dst []byte, src []int64) ([]byte, error)

func (NotSupported) EncodeInt96

func (NotSupported) EncodeInt96(dst []byte, src []deprecated.Int96) ([]byte, error)

func (NotSupported) EncodeLevels

func (NotSupported) EncodeLevels(dst []byte, src []uint8) ([]byte, error)

func (NotSupported) Encoding

func (NotSupported) Encoding() format.Encoding

func (NotSupported) EstimateDecodeByteArraySize

func (NotSupported) EstimateDecodeByteArraySize(src []byte) int

func (NotSupported) String

func (NotSupported) String() string

type Values

type Values struct {
	// contains filtered or unexported fields
}

func BooleanValues

func BooleanValues(values []byte) Values

func ByteArrayValues

func ByteArrayValues(values []byte, offsets []uint32) Values

func DecodeBoolean

func DecodeBoolean(dst Values, src []byte, enc Encoding) (Values, error)

func DecodeByteArray

func DecodeByteArray(dst Values, src []byte, enc Encoding) (Values, error)

func DecodeDouble

func DecodeDouble(dst Values, src []byte, enc Encoding) (Values, error)

func DecodeFixedLenByteArray

func DecodeFixedLenByteArray(dst Values, src []byte, enc Encoding) (Values, error)

func DecodeFloat

func DecodeFloat(dst Values, src []byte, enc Encoding) (Values, error)

func DecodeInt32

func DecodeInt32(dst Values, src []byte, enc Encoding) (Values, error)

func DecodeInt64

func DecodeInt64(dst Values, src []byte, enc Encoding) (Values, error)

func DecodeInt96

func DecodeInt96(dst Values, src []byte, enc Encoding) (Values, error)

func DoubleValues

func DoubleValues(values []float64) Values

func DoubleValuesFromBytes

func DoubleValuesFromBytes(values []byte) Values

func FixedLenByteArrayValues

func FixedLenByteArrayValues(values []byte, size int) Values

func FloatValues

func FloatValues(values []float32) Values

func FloatValuesFromBytes

func FloatValuesFromBytes(values []byte) Values

func Int32Values

func Int32Values(values []int32) Values

func Int32ValuesFromBytes

func Int32ValuesFromBytes(values []byte) Values

func Int64Values

func Int64Values(values []int64) Values

func Int64ValuesFromBytes

func Int64ValuesFromBytes(values []byte) Values

func Int96Values

func Int96Values(values []deprecated.Int96) Values

func Int96ValuesFromBytes

func Int96ValuesFromBytes(values []byte) Values

func Uint128Values

func Uint128Values(values [][16]byte) Values

func Uint32Values

func Uint32Values(values []uint32) Values

func Uint64Values

func Uint64Values(values []uint64) Values

func (*Values) Boolean

func (v *Values) Boolean() []byte

func (*Values) ByteArray

func (v *Values) ByteArray() (data []byte, offsets []uint32)

func (*Values) Data

func (v *Values) Data() (data []byte, offsets []uint32)

func (*Values) Double

func (v *Values) Double() []float64

func (*Values) FixedLenByteArray

func (v *Values) FixedLenByteArray() (data []byte, size int)

func (*Values) Float

func (v *Values) Float() []float32

func (*Values) Int32

func (v *Values) Int32() []int32

func (*Values) Int64

func (v *Values) Int64() []int64

func (*Values) Int96

func (v *Values) Int96() []deprecated.Int96

func (*Values) Kind

func (v *Values) Kind() Kind

func (*Values) Size

func (v *Values) Size() int64

func (*Values) Uint128

func (v *Values) Uint128() [][16]byte

func (*Values) Uint32

func (v *Values) Uint32() []uint32

func (*Values) Uint64

func (v *Values) Uint64() []uint64

Directories

Path Synopsis
Package fuzz contains functions to help fuzz test parquet encodings.
Package fuzz contains functions to help fuzz test parquet encodings.
Package plain implements the PLAIN parquet encoding.
Package plain implements the PLAIN parquet encoding.
Package rle implements the hybrid RLE/Bit-Packed encoding employed in repetition and definition levels, dictionary indexed data pages, and boolean values in the PLAIN encoding.
Package rle implements the hybrid RLE/Bit-Packed encoding employed in repetition and definition levels, dictionary indexed data pages, and boolean values in the PLAIN encoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL