Documentation
¶
Overview ¶
Package array decodes the serialized arrays of a flat segment into in-memory arrays. One file per encoding, found by its identifier through the footer's array specs.
Index ¶
- func Encodings() []string
- type Arena
- type Array
- func Concat(t DType, parts []*Array) *Array
- func Decode(seg []byte, specs []string, t DType, rows int, opt Options) (*Array, error)
- func TakeDict(ar *Arena, values, codes *Array, p PType, t DType) (*Array, error)
- func TakeDictInto(out *Array, ar *Arena, values, codes *Array, p PType, t DType) (*Array, error)
- type Bitmap
- type DType
- type Decoder
- type Field
- type Kind
- type Node
- func (n *Node) Buffer(i int) ([]byte, error)
- func (n *Node) Child(i int, t DType, rows int) (*Array, error)
- func (n *Node) ChildEncoding(i int) string
- func (n *Node) Field(i int, name string, t DType, rows int) (*Array, error)
- func (n *Node) Metadata() []byte
- func (n *Node) NumBuffers() int
- func (n *Node) NumChildren() int
- func (n *Node) Validity(i, rows int) (*Bitmap, error)
- type Options
- type PType
- type Pool
- type Rows
- type VariantData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Arena ¶
type Arena struct {
// contains filtered or unexported fields
}
Arena is the buffers of the arrays of one decode, taken from a pool and given back together by Release. The nil arena allocates, and gives nothing back. An arena is used by one goroutine at a time.
type Array ¶
type Array struct {
// Skipped is set when the array was not decoded because of an unsupported encoding,
// and the caller accepted it (Options.Tolerate). The other fields are empty then.
Skipped error
// Validity is nil when every value is valid. It is ignored for the Null type.
Validity *Bitmap
// Elems is the elements of a List, a FixedSizeList and a Map (a struct of key and value).
Elems *Array
// Var is the content of a Variant array.
Var *VariantData
// Data is, for Prim, the values, little-endian; for Decimal, the values at Width bytes
// each, little-endian two's complement; for Utf8 and Binary, the bytes Starts and Ends
// point into.
Data []byte
// Starts and Ends are, per row, the range of Data (Utf8, Binary) or of Elems (List, Map)
// of the row. Ranges may overlap and come in any order, but stay inside their target.
Starts, Ends []int
Fields []*Array
Bits Bitmap // Bool: the values
Type DType
Width int // Decimal: the bytes of a stored value
Len int
// VOff is, for a Variant array, the row of Var that row 0 is.
VOff int
// contains filtered or unexported fields
}
Array is a decoded array. Only the fields of its Type are set.
func Decode ¶
Decode decodes the serialized array of seg: its buffers, the flatbuffer of the tree, then the length of the flatbuffer. specs are the array specs of the footer, rows the number of rows and t the type the array must have.
func TakeDict ¶
TakeDict makes the array of type t, in the arena ar, whose row i is the value of values at the code of row i of codes, an array of integers of type p. A null code is a null row. A code past the values is an error. When values or codes were skipped, the result is skipped too.
func TakeDictInto ¶
TakeDictInto is TakeDict into out, which it overwrites and returns when the values are numbers, bytes or lists: it then allocates nothing but the buffers of the rows.
func (*Array) SliceInto ¶
SliceInto is Slice into out, which it overwrites and returns. It allocates nothing when out was filled by an earlier SliceInto of an array of the same shape: the children of a struct or of a fixed-size list are sliced into the ones out already has. out must not share any node with a.
func (*Array) VariantValue ¶
VariantValue returns row i of a Variant array as a Go value: nil, bool, int64, float64, string, []byte, time.Time, []any, map[string]any, or what dec returns for a decimal given its unscaled little-endian bytes and its scale. It allocates.
type Bitmap ¶
Bitmap is a sequence of bits, the first one being bit Off of Bytes (least significant bit first).
type DType ¶
type DType struct {
Storage *DType // Ext
// Elem is the element type of a List or a FixedSizeList, and the entry type (a struct of
// key and value) of a Map.
Elem *DType
Label string // Ext: the identifier of the extension type, when it comes from a protobuf DType
Fields []Field // Struct
Size int // FixedSizeList: the number of elements of every value
Kind Kind
PType PType
Scale int8 // Decimal, when the type comes from a protobuf DType
// Nullable is whether the array may hold nulls.
Nullable bool
// Ticks is, on the storage of a timestamp, the number of ticks of its unit in a second.
Ticks int32
}
DType is the type an array must decode to. It is not stored in the array: the parent gives it.
func ParseDType ¶
ParseDType decodes a DType in protobuf, as an array stores it in its metadata. A date, a time and a timestamp are an Ext of their storage, with the identifier in Label.
func (DType) NonNullable ¶
NonNullable returns t, but not nullable.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a node of the tree of a serialized array, as a decoder sees it.
func (*Node) ChildEncoding ¶
ChildEncoding is the identifier of the encoding that Child decodes child i with, "" when the footer has none for it.
type Options ¶
type Options struct {
// Tolerate is asked, for a struct field whose decoding failed with an unsupported
// encoding, whether to carry on: the field then is an Array with Skipped set. The path
// is the dotted names of the fields from the root. Tests use it, a scan never does.
Tolerate func(path string, err error) bool
// Pool, when not nil, is where a scan takes the buffers of its arrays from.
Pool *Pool
// Arena, when not nil, is where the buffers of the decoded array come from: the array
// must not be read once the arena is released.
Arena *Arena
// MaxRows, when not 0, is the most rows of any node: the rows of a child come from the
// file (the elements of a list, the codes of a dictionary), and a node that expands
// without a buffer to bound it (a constant, a sequence) allocates as many.
MaxRows int
}
Options changes how an array is decoded.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool keeps the buffers of the arrays a scan is done with, for the arrays it decodes next: a scan then works in the same memory from one batch to the next. It is safe for concurrent use.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows is a serialized array whose rows are decoded some at a time. Its nodes are opened once, on the first Decode, and its arrays come from a slab it keeps: a segment decoded batch after batch allocates nothing once it is running.
func OpenRows ¶
OpenRows reads the tree of the serialized array of seg, like Decode does, and decodes nothing: Decode does, for the rows it is given.
func (*Rows) Can ¶
Can reports whether every encoding on the way to the rows of the array decodes some rows only: Decode is then ok, unless the array is not what its tree says.
func (*Rows) Decode ¶
Decode decodes the rows idx, in increasing order, of the array, of type t and of that many rows, into buffers of the arena ar: row k of the result is row idx[k] of the array. It is not ok when an encoding of the array has no way to decode some rows only: the caller then decodes all of them.
type VariantData ¶
type VariantData struct {
Metadata, Value, Typed *Array
Core, Shredded *Array
Parts []*Array
// TypedType is the type of Typed or of Shredded, which the arrays alone cannot tell: an
// extension type decodes as its storage.
TypedType DType
}
VariantData is what a Variant array holds. There are three shapes.
A Parquet one (vortex.parquet.variant) has Metadata, the key dictionary of each row, Value, the encoded value of each row (nil when the array has none), and Typed, the shredded typed_value (nil when it has none), in the layout of Parquet: the fields of a shredded object are structs of a "value" and a "typed_value".
A logical one (vortex.variant with a shredded child) has Core, a Variant array of the first shape without typed_value, and Shredded, the typed values with no wrapper: a shredded object is a struct of its fields, a field that is itself partly shredded being a Variant array.
A chunked one has the Parts it was joined from.
Source Files
¶
- alp.go
- arena.go
- array.go
- bitpacked.go
- bool.go
- bytebool.go
- chunked.go
- constant.go
- datetimeparts.go
- decimal.go
- decimalparts.go
- decode.go
- delta.go
- dict.go
- doc.go
- dtype.go
- dtypeproto.go
- ext.go
- fastlanes.go
- for.go
- fsst.go
- ints.go
- list.go
- masked.go
- null.go
- onpair.go
- patches.go
- pco.go
- primitive.go
- rle.go
- rows.go
- runend.go
- sequence.go
- sparse.go
- struct.go
- take.go
- varbin.go
- variant.go
- words.go
- zstd.go