Documentation
¶
Overview ¶
Package kernel provides type-specialized vectorized operations for the query engine. Generic functions are monomorphized at compile time and dispatch is resolved once at query init time (not per-row), eliminating type-switch overhead from hot loops.
Index ¶
- type Accumulator
- type BatchAggKernel
- type ColColFilterKernel
- type CompareOp
- type FilterKernel
- type Numeric
- type Ordered
- type RowAggUpdater
- func ResolveRowAvg(typ batch.TypeID) RowAggUpdater
- func ResolveRowAvgNoNulls(typ batch.TypeID) RowAggUpdater
- func ResolveRowCount(countStar bool) RowAggUpdater
- func ResolveRowMax(typ batch.TypeID) RowAggUpdater
- func ResolveRowMaxNoNulls(typ batch.TypeID) RowAggUpdater
- func ResolveRowMin(typ batch.TypeID) RowAggUpdater
- func ResolveRowMinNoNulls(typ batch.TypeID) RowAggUpdater
- func ResolveRowSum(typ batch.TypeID) RowAggUpdater
- func ResolveRowSumNoNulls(typ batch.TypeID) RowAggUpdater
- type SortCompareKernel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accumulator ¶
type Accumulator struct {
SumI64 int64
SumF64 float64
SumDec batch.Int128
Count int64
MinI64 int64
MaxI64 int64
MinF64 float64
MaxF64 float64
MinDec batch.Int128
MaxDec batch.Int128
MinStr string
MaxStr string
HasMin bool
HasMax bool
IsFloat bool // true when the source column is a float type (or AVG over int64, which accumulates in float64 to avoid int64 sum wraparound)
IsDecimal bool // true when the source column is DECIMAL
IsString bool // true when the source column is a string/bytes type (MIN/MAX)
DecScale int // scale for DECIMAL columns
}
Accumulator holds aggregate state with typed precision. Int64 sums stay int64 (no float64 precision loss); float sums use float64. Decimal sums use Int128 for exact fixed-point arithmetic.
func (*Accumulator) FinalAvg ¶
func (a *Accumulator) FinalAvg() any
FinalAvg returns the accumulated average.
func (*Accumulator) FinalMax ¶
func (a *Accumulator) FinalMax() any
FinalMax returns the accumulated maximum.
func (*Accumulator) FinalMin ¶
func (a *Accumulator) FinalMin() any
FinalMin returns the accumulated minimum.
func (*Accumulator) FinalSum ¶
func (a *Accumulator) FinalSum() any
FinalSum returns the accumulated sum as the appropriate type.
func (*Accumulator) Merge ¶
func (a *Accumulator) Merge(other *Accumulator)
Merge combines another accumulator's state into this one. Used for parallel aggregation: each worker builds partial state, then merges.
type BatchAggKernel ¶
type BatchAggKernel func(acc *Accumulator, vec *batch.Vector, sel []uint32, vecLen int)
BatchAggKernel processes an entire column (or selection) into an accumulator. Used for non-grouped aggregation or pre-aggregated groups.
func ResolveBatchAvg ¶
func ResolveBatchAvg(typ batch.TypeID) BatchAggKernel
ResolveBatchAvg returns a batch-level kernel for AVG. Differs from ResolveBatchSum only for int64-class inputs (float64 accumulation).
func ResolveBatchCount ¶
func ResolveBatchCount() BatchAggKernel
ResolveBatchCount returns a batch-level count kernel.
func ResolveBatchMax ¶
func ResolveBatchMax(typ batch.TypeID) BatchAggKernel
ResolveBatchMax returns a batch-level max kernel for the given column type.
func ResolveBatchMin ¶
func ResolveBatchMin(typ batch.TypeID) BatchAggKernel
ResolveBatchMin returns a batch-level min kernel for the given column type.
func ResolveBatchSum ¶
func ResolveBatchSum(typ batch.TypeID) BatchAggKernel
ResolveBatchSum returns a batch-level sum kernel for the given column type.
type ColColFilterKernel ¶
type ColColFilterKernel func(left, right *batch.Vector, sel []uint32, vecLen int, outSel []uint32) []uint32
ColColFilterKernel compares two columns element-wise, returning matching row indices.
func ResolveColColFilterKernel ¶
func ResolveColColFilterKernel(typ batch.TypeID, op CompareOp) ColColFilterKernel
ResolveColColFilterKernel creates a ColColFilterKernel for comparing two columns of the given type. Returns nil if the type is not supported.
type FilterKernel ¶
FilterKernel evaluates a column against a pre-resolved constant for all rows, returning the indices of matching rows.
func ResolveFilterKernel ¶
func ResolveFilterKernel(typ batch.TypeID, op CompareOp, value any) FilterKernel
ResolveFilterKernel creates a FilterKernel for comparing a column of the given type against a constant value. The type dispatch happens once here; the returned function has no type switches in its inner loop.
func ResolveInFilterKernel ¶
func ResolveInFilterKernel(typ batch.TypeID, values []any, negate bool) FilterKernel
ResolveInFilterKernel creates a FilterKernel that checks set membership. The set is built once; the inner loop does a hash lookup per element.
func ResolveLikeFilterKernel ¶
func ResolveLikeFilterKernel(pattern string, negate bool) FilterKernel
ResolveLikeFilterKernel creates a FilterKernel for SQL LIKE pattern matching. Converts SQL LIKE patterns (% and _) to optimized matching functions.
type RowAggUpdater ¶
type RowAggUpdater func(acc *Accumulator, vec *batch.Vector, row int)
RowAggUpdater updates an accumulator for a single row (used in grouped aggregation). The type dispatch is resolved once; the function body has no type switches.
func ResolveRowAvg ¶
func ResolveRowAvg(typ batch.TypeID) RowAggUpdater
ResolveRowAvg returns a row-level updater for AVG. Differs from ResolveRowSum only for int64-class inputs (float64 accumulation).
func ResolveRowAvgNoNulls ¶
func ResolveRowAvgNoNulls(typ batch.TypeID) RowAggUpdater
ResolveRowAvgNoNulls is the no-null-check variant of ResolveRowAvg.
func ResolveRowCount ¶
func ResolveRowCount(countStar bool) RowAggUpdater
ResolveRowCount returns a row-level count updater. If countStar is true, counts all rows (including nulls).
func ResolveRowMax ¶
func ResolveRowMax(typ batch.TypeID) RowAggUpdater
ResolveRowMax returns a row-level max updater for the given column type.
func ResolveRowMaxNoNulls ¶
func ResolveRowMaxNoNulls(typ batch.TypeID) RowAggUpdater
ResolveRowMaxNoNulls returns a no-null-check max updater.
func ResolveRowMin ¶
func ResolveRowMin(typ batch.TypeID) RowAggUpdater
ResolveRowMin returns a row-level min updater for the given column type.
func ResolveRowMinNoNulls ¶
func ResolveRowMinNoNulls(typ batch.TypeID) RowAggUpdater
ResolveRowMinNoNulls returns a no-null-check min updater.
func ResolveRowSum ¶
func ResolveRowSum(typ batch.TypeID) RowAggUpdater
ResolveRowSum returns a row-level sum updater for the given column type.
func ResolveRowSumNoNulls ¶
func ResolveRowSumNoNulls(typ batch.TypeID) RowAggUpdater
ResolveRowSumNoNulls returns a no-null-check sum updater.
type SortCompareKernel ¶
SortCompareKernel compares one row from vector a against one row from vector b. Returns -1, 0, or 1. Null handling is included.
func ResolveSortCompare ¶
func ResolveSortCompare(typ batch.TypeID) SortCompareKernel
ResolveSortCompare returns a comparison function for the given column type. The returned function has no type switch — the type is baked into the closure.
func ResolveSortCompareNoNulls ¶
func ResolveSortCompareNoNulls(typ batch.TypeID) SortCompareKernel
ResolveSortCompareNoNulls returns a sort compare function that skips null checks.
func ResolveSortCompareNullsLast ¶
func ResolveSortCompareNullsLast(typ batch.TypeID) SortCompareKernel
ResolveSortCompareNullsLast returns a sort compare function with NULLS LAST ordering.