typedkernel

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package typedkernel contains internal typed-column aggregate and predicate kernel substrate.

Dispatch is a prepare/block-planning boundary operation for aggregate reducers: callers provide both the #1843 semantic descriptor and the #1838 layout capabilities, and the registry only returns a concrete reducer after both gates report support. Reducers then run over a typedcolumn.RowSelection without consulting generic capability tables in per-row hot loops.

Dictionary-code equality and in-list helpers are provided as concrete predicate kernels over low-cardinality uint32 codes. They intentionally do not resolve dictionary strings per row and do not expose lexical range/prefix semantics; dictionary code order is not treated as lexical string order. Dictionary group/count/distinct reducer substrate currently lives in typedcolumn.AggregateArena selection-aware helpers; the typedkernel aggregate registry does not yet register a dictionary group-by reducer.

The package has no public API surface and no process-wide mutable caches. DefaultRegistry returns an immutable static table; tests and future planners can build caller-owned registries with additional kernels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountDictionaryCode

func CountDictionaryCode(req DictionaryPredicateRequest) (int, error)

CountDictionaryCode counts selected rows whose dictionary code equals Code.

func CountDictionaryCodesIn

func CountDictionaryCodesIn(req DictionaryPredicateRequest, scratch *Scratch) (int, error)

CountDictionaryCodesIn counts selected rows whose dictionary code is in Codes. Codes outside the granule cardinality are ignored as absent values.

func SelectDictionaryCode

func SelectDictionaryCode(req DictionaryPredicateRequest, scratch *Scratch) (typedcolumn.RowSelection, error)

SelectDictionaryCode returns selected rows whose dictionary code equals Code.

func SelectDictionaryCodesIn

func SelectDictionaryCodesIn(req DictionaryPredicateRequest, scratch *Scratch) (typedcolumn.RowSelection, error)

SelectDictionaryCodesIn returns selected rows whose dictionary code is in Codes. Codes outside the granule cardinality are ignored as absent values.

Types

type AggregateOp

type AggregateOp = columnsemantics.Operation

AggregateOp names the aggregate semantics accepted by this package. The values intentionally alias columnsemantics.Operation so callers can carry the #1843 decision through prepare without an additional translation layer.

type AggregateResult

type AggregateResult struct {
	Op         AggregateOp
	Rows       int64
	NonNulls   int64
	TrueCount  int64
	FalseCount int64
	Sum        int64
	Avg        float64
	Min        int64
	Max        int64
	HasValue   bool
}

AggregateResult keeps row-count and value-count semantics distinct. For CountRows, Rows is the row count. For CountNonNull and value aggregates, NonNulls is the number of values included in the aggregate. For OpBoolCounts, Rows and NonNulls are the selected non-null bool rows while TrueCount and FalseCount partition those rows. HasValue is false for empty min/max/avg inputs.

type DictionaryPredicateRequest

type DictionaryPredicateRequest struct {
	Rows       int
	Selection  typedcolumn.RowSelection
	Granule    typedcolumn.EncodedGranule
	HasGranule bool
	Reader     *typedcolumn.GranuleReader
	Code       uint32
	Codes      []uint32
}

DictionaryPredicateRequest is the concrete hot-loop input for one selected low-cardinality dictionary-code block. Codes are already dictionary IDs; this layer deliberately does not resolve or materialize strings per row.

type DispatchRequest

type DispatchRequest struct {
	Operation AggregateOp
	Semantic  columnsemantics.Descriptor
	Layout    columnlayout.Capabilities
}

DispatchRequest is resolved at prepare/block-planning boundaries. Semantic and layout descriptors must describe the same logical/physical column.

type KernelSpec

type KernelSpec struct {
	Name          string
	Logical       columnsemantics.LogicalType
	Physical      typedcolumn.ColumnType
	Ops           []AggregateOp
	AllowNullable bool
	Reduce        ReduceFunc
}

KernelSpec is an immutable registry entry. Empty Logical/Physical fields are wildcards, intended for generic kernels such as count rows. Value kernels should bind logical and physical types and rely on Dispatch to enforce the semantic and layout gates before matching.

type PreparedReducer

type PreparedReducer struct {
	// contains filtered or unexported fields
}

PreparedReducer is the concrete reducer selected by Dispatch. It is safe to reuse for blocks with the same prepared semantic/layout decision.

func (PreparedReducer) KernelName

func (p PreparedReducer) KernelName() string

func (PreparedReducer) LayoutCapability

func (p PreparedReducer) LayoutCapability() columnlayout.Capability

func (PreparedReducer) Operation

func (p PreparedReducer) Operation() AggregateOp

func (PreparedReducer) Reduce

func (p PreparedReducer) Reduce(req ReduceRequest, scratch *Scratch) (AggregateResult, error)

Reduce executes the selected concrete reducer. The function-table dispatch is outside row loops; reducers own their RowSelection.Kind switch.

func (PreparedReducer) SemanticCapability

func (p PreparedReducer) SemanticCapability() columnsemantics.Capability

type ReduceFunc

type ReduceFunc func(op AggregateOp, req ReduceRequest, scratch *Scratch) (AggregateResult, error)

ReduceFunc runs a concrete reducer after registry dispatch. Implementations must switch on RowSelection.Kind and must not use reflection or per-row interface/callback dispatch.

type ReduceRequest

type ReduceRequest struct {
	Rows           int
	Selection      typedcolumn.RowSelection
	Int64Values    []int64
	Int64Cursor    *typedcolumn.Int64Cursor
	BoolGranule    typedcolumn.EncodedGranule
	HasBoolGranule bool
	BoolReader     *typedcolumn.GranuleReader
}

ReduceRequest is the concrete hot-loop input for one selected block. Rows is the block-local row domain. Int64Values is used by materialized/direct-view int64 value kernels and may be nil for count-row/count-non-null reducers and empty selections. Int64Cursor is used by streaming int64 kernels; callers provide either Int64Values or Int64Cursor for value aggregates, not both.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is an immutable/caller-owned dispatch table. Methods that add a kernel return a new Registry and never mutate the receiver.

func DefaultRegistry

func DefaultRegistry() Registry

DefaultRegistry returns the package's static immutable kernel table.

func NewRegistry

func NewRegistry(entries []KernelSpec) (Registry, error)

NewRegistry returns a caller-owned registry containing the provided entries.

func (Registry) Dispatch

func (r Registry) Dispatch(req DispatchRequest) (PreparedReducer, error)

Dispatch validates #1843 semantics and #1838 layout capabilities, then picks the first matching registry entry. Unsupported/fallback capabilities fail closed before any physical kernel is selected.

func (Registry) WithKernel

func (r Registry) WithKernel(entry KernelSpec) (Registry, error)

WithKernel returns a new caller-owned registry with entry appended.

type Scratch

Scratch is caller/session-owned reusable storage for future kernels. It is deliberately explicit even though the initial int64 reducers do not need it.

Jump to

Keyboard shortcuts

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