Documentation
¶
Overview ¶
Package table export the table that contains the results of a BQL query.
Index ¶
- func CellString(s string) *string
- type Accumulator
- type AliasAccPair
- type Cell
- type Row
- type SortConfig
- type Table
- func (t *Table) AddBindings(bs []string)
- func (t *Table) AddRow(r Row)
- func (t *Table) AppendTable(t2 *Table) error
- func (t *Table) Bindings() []string
- func (t *Table) DeleteRow(i int) error
- func (t *Table) DotProduct(t2 *Table) error
- func (t *Table) Filter(f func(Row) bool)
- func (t *Table) HasBinding(b string) bool
- func (t *Table) Limit(i int64)
- func (t *Table) NumRows() int
- func (t *Table) ProjectBindings(bs []string) error
- func (t *Table) Reduce(cfg SortConfig, aaps []AliasAccPair) error
- func (t *Table) Row(i int) (Row, bool)
- func (t *Table) Rows() []Row
- func (t *Table) Sort(cfg SortConfig)
- func (t *Table) String() string
- func (t *Table) ToText(sep string) (*bytes.Buffer, error)
- func (t *Table) Truncate()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CellString ¶ added in v0.3.0
CellString create a pointer for the provided string.
Types ¶
type Accumulator ¶
type Accumulator interface { // Accumulate takes the given value and accumulates it to the current state. Accumulate(interface{}) (interface{}, error) // Resets the current state back to the original one. Reset() }
Accumulator type represents a generic accumulator for independent values expressed as the element of the array slice. Returns the values after being accumulated. If the wrong type is passed in, it will crash casting the interface.
func NewCountAccumulator ¶
func NewCountAccumulator() Accumulator
NewCountAccumulator accumulates the int64 types of a literal.
func NewCountDistinctAccumulator ¶
func NewCountDistinctAccumulator() Accumulator
NewCountDistinctAccumulator counts calls by incrementing the internal state only if the value has not been seen before.
func NewSumFloat64LiteralAccumulator ¶
func NewSumFloat64LiteralAccumulator(s float64) Accumulator
NewSumFloat64LiteralAccumulator accumulates the int64 types of a literal.
func NewSumInt64LiteralAccumulator ¶
func NewSumInt64LiteralAccumulator(s int64) Accumulator
NewSumInt64LiteralAccumulator accumulates the int64 types of a literal.
type AliasAccPair ¶
type AliasAccPair struct { InAlias string OutAlias string Acc Accumulator }
AliasAccPair contains the in, out alias, and the optional accumulator to use.
type Row ¶
Row represents a collection of cells.
type SortConfig ¶
SortConfig contains the sorting information. Contains the binding order to use wile sorting as well as the deriction for each of them to use.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table contains the results of a BQL query. This table implementation is not safe for concurrency. You should take appropiate precautions if you want to access it concurrently and wrap to properly control concurrent operations.
func New ¶
New returns a new table that can hold data for the the given bindings. The, table creation will fail if there are repeated bindings.
func (*Table) AddBindings ¶
AddBindings add the new binings provided to the table.
func (*Table) AddRow ¶
AddRow adds a row to the end of a table. For preformance reasons, it does not check that all bindindgs are set, nor that they are declared on table creation. BQL builds valid tables, if you plan to create tables on your own you should be carful to provide valid rows.
func (*Table) AppendTable ¶
AppendTable appends the content of the provided table. It will fail it the target table is not empty and the binidngs do not match.
func (*Table) DotProduct ¶
DotProduct does the doot product with the provided tatble
func (*Table) HasBinding ¶
HasBinding returns true if the binding currently exist on the teable.
func (*Table) ProjectBindings ¶
ProjectBindings replaces the current bidings with the projected one. The provided bindings needs to be a subsed of the original bindings. If the provided bindings are not a subset of the original ones, the projection will fail, leave the table unmodified, and return an error. The projection only modify the bindings, but does not drop non projected data.
func (*Table) Reduce ¶
func (t *Table) Reduce(cfg SortConfig, aaps []AliasAccPair) error
Reduce alters the table by sorting and then range grouping the table data. In order to group reduce the table, we sort the table and then apply the accumulator functions to each group. Finally, the table metadata gets updated to reflect the reduce operation.
func (*Table) Row ¶
Row returns the requested row. Rows start at 0. Also, if you request a row beyond it will return nil, and the ok boolean will be false.
func (*Table) Sort ¶
func (t *Table) Sort(cfg SortConfig)
Sort sorts the table given a sort configuration.