Documentation ¶
Overview ¶
Package frame implements a typed, columnar data structure that represents data vectors throughout Bigslice.
The package contains the definition of Frame as well as a set of index-based operators that amortize runtime safety overhead.
Index ¶
- Variables
- func CanCompare(typ reflect.Type) bool
- func CanHash(typ reflect.Type) bool
- func Compatible(f, g Frame) bool
- func Copy(dst, src Frame) (n int)
- func RegisterOps(make interface{})
- type Decoder
- type Encoder
- type Frame
- func (f Frame) Cap() int
- func (f Frame) Decode(col int, d Decoder) error
- func (f Frame) Encode(col int, e Encoder) error
- func (f Frame) Ensure(n int) Frame
- func (f Frame) Grow(n int) Frame
- func (f Frame) HasCodec(col int) bool
- func (f Frame) Hash(i int) uint32
- func (f Frame) HashWithSeed(i int, seed uint32) uint32
- func (f Frame) Index(col, i int) reflect.Value
- func (f Frame) Interface(i int) interface{}
- func (f Frame) Interfaces() []interface{}
- func (f Frame) IsZero() bool
- func (f Frame) Len() int
- func (f Frame) Less(i, j int) bool
- func (f Frame) NumOut() int
- func (f Frame) Out(i int) reflect.Type
- func (f Frame) Prefix() int
- func (f Frame) Prefixed(prefix int) Frame
- func (f Frame) Slice(i, j int) Frame
- func (f Frame) SliceHeader(i int) reflect.SliceHeader
- func (f Frame) String() string
- func (f Frame) Swap(i, j int)
- func (f Frame) TabString() string
- func (f Frame) UnsafeIndexPointer(col, i int) unsafe.Pointer
- func (f Frame) Value(i int) reflect.Value
- func (f Frame) Values() []reflect.Value
- func (f Frame) WriteTab(w io.Writer)
- func (f Frame) Zero()
- type Key
- type Ops
- type Session
Constants ¶
This section is empty.
Variables ¶
var Empty = Frame{/* contains filtered or unexported fields */}
Empty is the empty frame.
Functions ¶
func CanCompare ¶
CanCompare returns whether values of the provided type are comparable.
func Compatible ¶
Compatible reports whether frames f and g are assignment compatible: that is, they have the same number of columns and the same column types.
func Copy ¶
Copy copies the contents of src until either dst has been filled or src exhausted. It returns the number of elements copied.
func RegisterOps ¶
func RegisterOps(make interface{})
RegisterOps registers an ops implementation. The provided argument make should be a function of the form
func(slice []t) Ops
returning operations for a t-typed slice. RegisterOps panics if the argument does not have the required shape or if operations have already been registered for type t.
Types ¶
type Encoder ¶
type Encoder interface { Session // Encode encodes the provided value into the // encoder's stream using Gob. Encode(v interface{}) error }
An Encoder manages transmission of data over a connection or file.
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
A Frame is a collection of 0 or more typed, equal-length columns that form a logical table. Each column is represented by a Go slice. Frames can be sliced efficiently, and the package provides computed operators that can perform efficient index-based operations on the Frame.
func AppendFrame ¶
AppendFrame appends src to dst, growing dst if needed.
func Slices ¶
func Slices(cols ...interface{}) Frame
Slices returns a new Frame constructed from a set of Go slices, each representing a column. The slices must have the same length, or Slices panics.
func Values ¶
Values returns a new Frame constructed from a set of reflect.Values, each representing a column. The slices must have the same length, or Values panics.
func (Frame) Decode ¶
Decode decodes a column col as encoded by Frame.Encode. may only Decode be invoked for columns where HasCodec is true.
func (Frame) Encode ¶
Encode encodes column col of this frame. The given scratch buffer may be used by the encode function to avoid extra allocation. Encode may only be invoked for columns where HasCodec is true.
func (Frame) Grow ¶
Grow returns a Frame with at least n extra capacity. The returned frame will have length f.Len()+n.
func (Frame) HashWithSeed ¶
HashWithSeed returns a 32-bit seeded hash of the prefix columns of frame f.
func (Frame) Interfaces ¶
func (f Frame) Interfaces() []interface{}
Interfaces returns the frame's columns as empty interfaces.
func (Frame) Less ¶
Less reports whether the row with index i should sort before the element with index j. Less operates on the frame's prefix columns, and is available only if the operation is defined for those column types. See RegisterOps for more details.
TODO(marius): this method presents an unnecessary indirection; provide a way to get at a sort.Interface directly.
func (Frame) SliceHeader ¶
func (f Frame) SliceHeader(i int) reflect.SliceHeader
SliceHeader returns the slice header for column i. As with other uses of SliceHeader, the user must ensure that a reference to the frame is maintained so that the underlying slice is not garbage collected while (unsafely) using the slice header.
func (Frame) UnsafeIndexPointer ¶
UnsafeIndexPointer returns a pointer to the i'th row of the col'th column. This can be used by advanced clients that import the unsafe package. Clients are responsible for managing reference lifetimes so that the underlying objects will not be garbage collected while an address returned from this method may still be used. (This function previously returned a uintptr address to force import of the unsafe package, but unfortunately that didn't play well with go vet.)
type Ops ¶
type Ops struct { // Less compares two indices of a slice. Less func(i, j int) bool // HashWithSeed computes a 32-bit hash, given a seed, of an index // of a slice. HashWithSeed func(i int, seed uint32) uint32 // Encode encodes a slice of the underlying vector. Encode is // optional, and overrides the default encoding (gob) used when // serializing and deserializing frames. Encode and decode must // always be specified together. Encode func(enc Encoder, i, j int) error // Decode decodes a slice encoded by Encode(i, j). Decode func(dec Decoder, i, j int) error // contains filtered or unexported fields }
Ops represents a set of operations on a single frame instance. Ops are instantiated from implementations registered with RegisterOps and are managed by the frame instance.
Note that not all types may support all operations.
type Session ¶
type Session interface { // State retrieves the session state for the provided key // into the pointer state. If state is not a pointer, then // State will panic. State returns true the first time the key // is encountered in the session. This is typically used by // user code to initialize the state. // // If the state value is a pointer, then the first call to State // sets the state pointer (a pointer to a pointer) to a newly // allocated value. Otherwise it is set to a zero value of the // value type. State(key Key, state interface{}) bool }
Session is a key-value store that is used by frame codecs to store session-specific state.