static

package
v0.72.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: MIT Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column interface {
	// 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) 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
}

Column is the definition for how to construct a column for the table.

func BooleanKey

func BooleanKey(v interface{}) Column

BooleanKey will construct a group key with the boolean type. The value can be a bool or nil.

func Booleans

func Booleans(v ...interface{}) Column

Booleans will construct an array of booleans. Each value can be a bool or nil.

func FloatKey

func FloatKey(v interface{}) Column

FloatKey will construct a group key with the float type. The value can be a float64, int, int64, or nil.

func Floats

func Floats(v ...interface{}) Column

Floats will construct an array of floats. Each value can be a float64, int, int64, or nil.

func IntKey

func IntKey(v interface{}) Column

IntKey will construct a group key with the integer type. The value can be an int, int64, or nil.

func Ints

func Ints(v ...interface{}) Column

Ints will construct an array of integers. Each value can be an int, int64, or nil.

func StringKey

func StringKey(v interface{}) Column

StringKey will construct a group key with the string type. The value can be a string or nil.

func Strings

func Strings(v ...interface{}) Column

Strings will construct an array of strings. Each value can be a string or nil.

func TimeKey

func TimeKey(v interface{}) Column

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 Times

func Times(v ...interface{}) Column

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 UintKey

func UintKey(v interface{}) Column

UintKey will construct a group key with the unsigned type. The value can be a uint, uint64, int, int64, or nil.

func Uints

func Uints(v ...interface{}) Column

Uints will construct an array of unsigned integers. Each value can be a uint, uint64, int, int64, or nil.

type Table

type Table map[string]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 easy. Do not use in production code.

func (Table) Cols

func (s Table) Cols() []flux.ColMeta

func (Table) Do

func (s Table) Do(f func(flux.ColReader) error) error

func (Table) Done

func (s Table) Done()

func (Table) Empty

func (s Table) Empty() bool

func (Table) Key

func (s Table) Key() flux.GroupKey

Jump to

Keyboard shortcuts

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