Documentation
¶
Overview ¶
Package resultops applies deterministic local operations to captured result snapshots. It has no executor or network dependency; indexes in its output always refer to the original captured row order.
Index ¶
- Constants
- Variables
- type AggregateTerm
- type Cell
- type Column
- type Group
- type Row
- type Snapshot
- func (s Snapshot) Columns() []Column
- func (s Snapshot) GroupBy(columnNames []string) ([]Group, error)
- func (s Snapshot) GroupByAggregates(columnNames []string, count bool, terms []AggregateTerm) ([]Group, error)
- func (s Snapshot) OriginalOrder() []int
- func (s Snapshot) RowCount() int
- func (s Snapshot) Sort(keys []SortKey) ([]int, error)
- type SortKey
Constants ¶
const ( AggregateSum = "SUM" AggregateCount = "COUNT" AggregateMin = "MIN" AggregateMax = "MAX" AggregateAvg = "AVG" )
Variables ¶
var ErrNoGroupColumns = errors.New("grouping requires at least one column")
Functions ¶
This section is empty.
Types ¶
type AggregateTerm ¶
AggregateTerm requests one explicitly named aggregate over a captured column. Function is one of AggregateSum, AggregateCount, AggregateMin, or AggregateMax. AVG is intentionally unsupported because this package does not infer an output precision or rounding policy.
type Cell ¶
Cell distinguishes a missing value from SQL/JSON null. A present cell with Value == nil is null; Present == false is unavailable/missing.
type Group ¶
Group is one first-occurrence ordered group. Keys retain missing/null/value distinctions and RowIndices map to the source snapshot, in original order. Count is the number of source rows in the group, independent of whether the caller requests COUNT(*) as an output column.
type Row ¶
type Row struct {
Cells []Cell
}
Row is input data for Capture. Its captured identity is its original zero- based row index, which remains stable through grouping and sorting.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot owns deep copies of its columns and cells. Its fields are private, and every result mapping points into this immutable captured row order.
func Capture ¶
Capture validates the row shape and deep-copies all data so later page loads or caller mutation cannot change the local operation's scope.
func (Snapshot) GroupBy ¶
GroupBy groups selected columns by typed ordered tuples. Group order follows first occurrence, and rows within each group preserve their original order.
func (Snapshot) GroupByAggregates ¶
func (s Snapshot) GroupByAggregates(columnNames []string, count bool, terms []AggregateTerm) ([]Group, error)
GroupByAggregates groups captured rows and computes only the explicitly requested aggregates. count marks whether the caller will emit the reserved COUNT(*) output; Group.Count always retains the actual row count. COUNT(column) ignores null values. Missing cells are refused because they do not have SQL aggregate semantics. Integer and decimal sums remain exact; floating sums use sequential IEEE-754 addition and reject non-finite results. Group order and RowIndices retain GroupBy's first-occurrence and source-order behavior.
func (Snapshot) OriginalOrder ¶
OriginalOrder returns the mapping that restores the captured row order.