package static
import "github.com/influxdata/flux/execute/table/static"
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
- func Booleans(k string, v ...interface{}) Column
- func Floats(k string, v ...interface{}) Column
- func Ints(k string, v ...interface{}) Column
- func Strings(k string, v ...interface{}) Column
- func Times(k string, v ...interface{}) Column
- func Uints(k string, v ...interface{}) Column
- type KeyColumn
- func BooleanKey(k string, v interface{}) KeyColumn
- func FloatKey(k string, v interface{}) KeyColumn
- func IntKey(k string, v interface{}) KeyColumn
- func StringKey(k string, v interface{}) KeyColumn
- func TimeKey(k string, v interface{}) KeyColumn
- func UintKey(k string, v interface{}) 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.Array
- func (s KeyColumn) Type() flux.ColType
- type Table
- func (s Table) Build(template *[]Column, mem memory.Allocator) []flux.Table
- func (s Table) Do(f func(flux.Table) error) error
- func (s Table) Table(mem memory.Allocator) flux.Table
- type TableBuilder
- type TableGroup
- func (t TableGroup) Build(template *[]Column, mem memory.Allocator) []flux.Table
- func (t TableGroup) Do(f func(flux.Table) error) error
- type TableList
- func StringKeys(k string, v ...interface{}) TableList
- func (t TableList) Build(template *[]Column, mem memory.Allocator) []flux.Table
- type TableMatrix
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.Array // 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 Booleans ¶
Booleans will construct an array of booleans. Each value can be a bool or nil.
func Floats ¶
Floats will construct an array of floats. Each value can be a float64, int, int64, or nil.
func Ints ¶
Ints will construct an array of integers. Each value can be an int, int64, or nil.
func Strings ¶
Strings will construct an array of strings. Each value can be a string or nil.
func Times ¶
Times will construct an array of times with the given time using either a string or an integer. If an integer is used, then it is in seconds.
If strings and integers are mixed, the integers will be treates as offsets from the last string time that was used.
func Uints ¶
Uints will construct an array of unsigned integers. Each value can be a uint, uint64, 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.
func (KeyColumn) Build ¶
func (KeyColumn) IsKey ¶
func (KeyColumn) KeyValue ¶
func (KeyColumn) Label ¶
func (KeyColumn) Len ¶
func (KeyColumn) Make ¶
func (KeyColumn) Type ¶
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.
func (Table) Build ¶
func (Table) Do ¶
Do will produce the Table and then invoke the function on that flux.Table.
If the produced Table is invalid, then this method will panic.
func (Table) Table ¶
Table will produce a flux.Table using the Column values that are part of this Table.
If the Table produces an invalid buffer, then this method will panic.
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.
func (TableGroup) Build ¶
Build will construct Tables using the given template.
func (TableGroup) Do ¶
func (t TableGroup) Do(f func(flux.Table) error) error
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.
func (TableList) Build ¶
type TableMatrix ¶
type TableMatrix []TableList
TableMatrix will produce a set of Tables by producing the cross product of each of the TableBuilders with each other.
func (TableMatrix) Build ¶
Source Files ¶
- Version
- v0.196.1 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 1 day ago –
Tools for package owners.