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) ToJSON(w io.Writer)
- 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 Cell ¶
type Cell struct { S *string `json:"s,omitempty"` N *node.Node `json:"node,omitempty"` P *predicate.Predicate `json:"pred,omitempty"` L *literal.Literal `json:"lit,omitempty"` T *time.Time `json:"time,omitempty"` }
Cell contains one of the possible values that form rows.
type Row ¶
Row represents a collection of cells.
type SortConfig ¶
SortConfig contains the sorting information. Contains the binding order to use while sorting as well as the direction for each of them to use.
func (SortConfig) String ¶ added in v0.7.0
func (s SortConfig) String() string
type Table ¶
type Table struct { // AvailableBindings in order contained on the table AvailableBindings []string `json:"bindings,omitempty"` // Data that form the table. Data []Row `json:"rows,omitempty"` // contains filtered or unexported fields }
Table contains the results of a BQL query. This table implementation is not safe for concurrency. You should take appropriate 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 bindings provided to the table.
func (*Table) AddRow ¶
AddRow adds a row to the end of a table. For performance reasons, it does not check that all bindings 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 careful 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 bindings do not match.
func (*Table) DeleteRow ¶
DeleteRow removes the row at position i from the table. This should be used carefully. If you are planning to delete a large volume of rows consider creating a new table and just copy the rows you need. This operation relies on slices and it *will* *not* release the underlying deleted row. Please, see https://blog.golang.org/go-slices-usage-and-internals for a detailed explanation.
func (*Table) DotProduct ¶
DotProduct does the dot product with the provided table
func (*Table) HasBinding ¶
HasBinding returns true if the binding currently exist on the table.
func (*Table) ProjectBindings ¶
ProjectBindings replaces the current bindings with the projected one. The provided bindings needs to be a subset 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.
func (*Table) ToJSON ¶ added in v0.8.0
ToJSON convert the table intotext versions. It requires the separator to be used between cells JSON.