variant

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package variant decodes the values of the Parquet Variant encoding (apache/parquet-format, VariantEncoding.md): a metadata dictionary of the object keys and a value, both byte strings. It knows nothing of Vortex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(meta, value []byte, v any) (outMeta, outValue []byte, err error)

Append is Encoder.Encode, the metadata and the value appended to meta and value. It takes no decimal. On an error it returns meta and value as they were.

func Decode

func Decode(metadata, value []byte, dec DecimalFunc) (any, error)

Decode decodes one value, whose keys are in metadata. It returns nil, bool, int64, float64, string, []byte, time.Time, []any, map[string]any, or what dec returns for a decimal. A time of day is a time.Time on 1970-01-01, a UUID its 16 bytes.

func DecodeWith

func DecodeWith(keys Keys, value []byte, dec DecimalFunc) (any, error)

DecodeWith is Decode with metadata already parsed.

Types

type DecimalFunc

type DecimalFunc func(unscaled []byte, scale int) any

DecimalFunc builds the Go value of a decimal: its unscaled value as little-endian two's complement bytes (4, 8 or 16 of them), and its scale.

type DecimalOf

type DecimalOf func(v any) (unscaled []byte, scale int, ok bool)

DecimalOf recognizes the decimal values of the caller: it returns the unscaled value as little-endian two's complement bytes (at most 32 of them) and the scale of v, and false for a value that is not a decimal.

type Encoder

type Encoder struct {
	// Decimal recognizes the decimals; nil for none.
	Decimal DecimalOf
	// contains filtered or unexported fields
}

Encoder turns Go values into the metadata and the value of a Variant row, the inverse of Decode. The zero Encoder takes no decimal. It reuses its buffers: after the first rows it allocates only for what a row holds besides its scalars. It is not safe for concurrent use, except for Check.

func (*Encoder) Check

func (e *Encoder) Check(v any) error

Check returns the error that Encode would, without building anything. It may be called concurrently.

func (*Encoder) Encode

func (e *Encoder) Encode(v any) (meta, value []byte, err error)

Encode returns the metadata and the value of v, which is nil, a bool, a Go integer or float of any width, a string, a []byte, a time.Time, a decimal the Encoder knows, a []any or a map[string]any of these. Integers take the narrowest width, the keys of the objects go in a sorted dictionary, and the fields of an object are in the order of their keys. The slices are valid until the next call.

type Keys

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

Keys is the dictionary of the keys of the objects of a value: the metadata.

func ParseMetadata

func ParseMetadata(b []byte) (Keys, error)

ParseMetadata reads the header, the offsets and the strings of a metadata. The version must be 1.

func (Keys) Key

func (k Keys) Key(i int) (string, error)

Key returns key i. It is an error for i to be out of the dictionary.

func (Keys) Len

func (k Keys) Len() int

Len is the number of keys.

Jump to

Keyboard shortcuts

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