Documentation ¶
Overview ¶
Package static provides utilities for easily constructing static tables that are meant for tests.
The primary type is Table which will be a mapping of columns to their data. The data is defined in a columnar format instead of a row-based one.
The implementations in this package are not performant and are not meant to be used in production code. They are good enough for small datasets that are present in tests to ensure code correctness.
Index ¶
- type Column
- type KeyColumn
- func (s KeyColumn) Build(template *[]Column, mem memory.Allocator) []flux.Table
- func (s KeyColumn) IsKey() bool
- func (s KeyColumn) KeyValue() values.Value
- func (s KeyColumn) Label() string
- func (s KeyColumn) Len() int
- func (s KeyColumn) Make(n int, mem memory.Allocator) array.Interface
- func (s KeyColumn) Type() flux.ColType
- type Table
- type TableBuilder
- type TableGroup
- type TableList
- type TableMatrix
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column interface { // Label returns the label associated with this column. Label() string // Type returns the column type for this column. Type() flux.ColType // Make will construct an array with the given length // if it is possible. Make(n int, mem memory.Allocator) array.Interface // Len will return the length of this column. // If no length is known, this will return -1. Len() int // IsKey will return true if this is part of the group key. IsKey() bool // KeyValue will return the key value if this column is part // of the group key. KeyValue() values.Value // TableBuilder allows this column to add itself to a template. TableBuilder }
Column is the definition for how to construct a column for the table.
func Floats ¶
Floats will construct an array of floats. Each value can be a float64, int, int64, or nil.
type KeyColumn ¶
type KeyColumn struct {
// contains filtered or unexported fields
}
func BooleanKey ¶
BooleanKey will construct a group key with the boolean type. The value can be a bool or nil.
func FloatKey ¶
FloatKey will construct a group key with the float type. The value can be a float64, int, int64, or nil.
func IntKey ¶
IntKey will construct a group key with the integer type. The value can be an int, int64, or nil.
func StringKey ¶
StringKey will construct a group key with the string type. The value can be a string or nil.
func TimeKey ¶
TimeKey will construct a group key with the given time using either a string or an integer. If an integer is used, then it is in seconds.
func UintKey ¶
UintKey will construct a group key with the unsigned type. The value can be a uint, uint64, int, int64, or nil.
type Table ¶
type Table []Column
Table is a statically constructed table. It is a mapping between column names and the column.
This is not a performant section of code and it is primarily meant to make writing unit tests easily. Do not use in production code.
The Table struct implements the TableIterator interface and not the Table interface. To retrieve a flux.Table compatible implementation, the Table() method can be used.
type TableBuilder ¶
type TableBuilder interface { // Build will construct a set of tables using the // template as input. // // The template is a pointer as a builder is allowed // to modify the template. For implementors, the // template pointer must be non-nil. Build(template *[]Column, mem memory.Allocator) []flux.Table }
TableBuilder is used to construct a set of Tables.
type TableGroup ¶
type TableGroup []TableBuilder
TableGroup will construct a group of Tables that have common values. It includes any TableBuilder values.
type TableList ¶
type TableList []TableBuilder
TableList will produce a Table using the template and each of the table builders.
Changes to the template are not shared between each of the entries. If the TableBuilder does not produce tables, this will force a single Table to be created.
func StringKeys ¶
StringKeys creates a TableList with the given key values.