Documentation
¶
Overview ¶
Package collector owns reader-compiled relation graphs and typed row assembly. SQLX supplies typed rows; collector reconciles parent-child relations without introducing another scanner or row-cache model.
Index ¶
- Constants
- type Collector
- func (r *Collector) Append(value interface{})
- func (r *Collector) AppendPartition(ctx context.Context, source *Collector) error
- func (r *Collector) AppendSlice(ctx context.Context, rows any) error
- func (r *Collector) AssembleTrees() error
- func (r *Collector) BootstrapFromParentHolder() bool
- func (r *Collector) Children() []*Collector
- func (r *Collector) Clone() *Collector
- func (r *Collector) DataSync() *xhandler.DataSync
- func (r *Collector) Dest() interface{}
- func (r *Collector) DestPtr() interface{}
- func (r *Collector) EnableProvenance() error
- func (r *Collector) Fetched()
- func (r *Collector) Len() int
- func (r *Collector) Lock() *sync.Mutex
- func (r *Collector) MergeData() error
- func (r *Collector) NewItem() func() interface{}
- func (r *Collector) OnSkip(_ []interface{}) error
- func (r *Collector) OnSkipUnmapped(_ []interface{}) error
- func (r *Collector) Parent() *Collector
- func (r *Collector) ParentPlaceholders() ([]interface{}, [][]interface{}, []string)
- func (r *Collector) ParentRow() func(value interface{}) (interface{}, error)
- func (r *Collector) PartitionCopy() *Collector
- func (r *Collector) Provenance(rootHolder string, direct bool) (*readmeta.Result, error)
- func (r *Collector) ReadAll() bool
- func (r *Collector) RebindToParent() error
- func (r *Collector) RecordFields(fields *readmeta.Fields)
- func (r *Collector) Relation() *data.Relation
- func (r *Collector) Relations(selector *Statelet) []*Collector
- func (r *Collector) ReserveSQLKey(column string) *any
- func (r *Collector) Resolve(column Column) func(ptr unsafe.Pointer) interface{}
- func (r *Collector) RunOnRelation(ctx context.Context) error
- func (r *Collector) SQLKeyColumns() map[string]bool
- func (r *Collector) SetDest(dest interface{})
- func (r *Collector) Slice() (unsafe.Pointer, *xunsafe.Slice)
- func (r *Collector) Unlock()
- func (r *Collector) View() *data.View
- func (r *Collector) Visitor(ctx context.Context) VisitorFn
- func (r *Collector) WaitIfNeeded()
- type Column
- type Graph
- type KeySource
- type Link
- type Links
- type Relation
- type RelationRef
- type Relations
- type Schema
- type Statelet
- type TreePlan
- type View
- type VisitorFn
Constants ¶
const ( MatchSequential = data.MatchSequential MatchReadAll = data.MatchReadAll )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
Id string
// contains filtered or unexported fields
}
Collector collects and builds a result from one View fetched from the database. When a View or any of its With relations supports parallel fetching (ReadAll), call MergeData after all views have been fetched.
func NewCollector ¶
NewCollector creates a root Collector for view, writing into dest. dest must be a pointer to a slice (or *interface{} for dynamic dispatch).
func (*Collector) Append ¶
func (r *Collector) Append(value interface{})
Append adds a decoded typed row to the collector destination.
func (*Collector) AppendPartition ¶
AppendPartition merges one isolated partition into the canonical collector while preserving unmapped SQLx destinations used by relation keys.
func (*Collector) AppendSlice ¶
AppendSlice indexes a reducer-produced typed slice into this collector.
func (*Collector) AssembleTrees ¶
AssembleTrees materializes self-referencing views after ordinary relation merging. Children are assembled first so parent rows retain hydrated child graphs before their own flat rows become a tree.
func (*Collector) BootstrapFromParentHolder ¶
BootstrapFromParentHolder seeds this collector from already-materialised parent holder data. Useful when parent OnFetch hooks populate a virtual relation in-memory and nested collectors still need a real source.
func (*Collector) EnableProvenance ¶
EnableProvenance opts this collector tree into final-ordinal read evidence. It must be called before scanning; normal reads allocate no evidence graph.
func (*Collector) Fetched ¶
func (r *Collector) Fetched()
Fetched signals that row scanning for this collector is complete.
func (*Collector) MergeData ¶
MergeData reconciles all ReadAll child collectors into their parents. Call on the root collector after all fetches complete.
func (*Collector) NewItem ¶
func (r *Collector) NewItem() func() interface{}
NewItem returns a factory that allocates and appends a typed model row.
func (*Collector) OnSkipUnmapped ¶
OnSkipUnmapped rolls back only resolver-owned hidden columns. Codec scan rows are not appended to the typed destination until after SQLx emits them.
func (*Collector) ParentPlaceholders ¶
ParentPlaceholders returns the deduplicated parent key values needed to parameterise the child SQL query. NULL keys (or tuples with a NULL member) cannot match an equality join and are excluded. The three return values are:
- scalar values (single-column join)
- composite rows (multi-column join)
- column expressions for the SQL IN clause
func (*Collector) ParentRow ¶
ParentRow returns a function that resolves the parent struct pointer for a child row. Used by codec pipelines that need to reach back to the parent.
func (*Collector) PartitionCopy ¶
PartitionCopy creates an isolated collector for one partition. It retains relation identity for parent publication but never attaches concurrently; the canonical collector performs attachment during deterministic merge.
func (*Collector) Provenance ¶
Provenance snapshots the completed collector graph. It never walks values or re-matches relationships; edges came from actual attachment operations.
func (*Collector) RebindToParent ¶
RebindToParent refreshes a matched relation attachment after the child collector has been further hydrated (for example by nested read_all descendants). Streaming visitor attachment happens while scanning the child rows, so any later descendant merges would otherwise stay behind on the child collector copy instead of the parent-held relation values.
func (*Collector) RecordFields ¶
RecordFields records the schema for the next accepted visitor row. Allocation addresses are deliberately not retained: value slices may grow and move.
func (*Collector) Relations ¶
Relations creates child Collectors for each Relation on the view. selector may be nil (no column pruning).
func (*Collector) ReserveSQLKey ¶
ReserveSQLKey follows the unmapped allocator's row lifecycle, including rollback when a cache matcher skips a row. Fill the slot before row hooks.
func (*Collector) Resolve ¶
Resolve returns a per-row allocator for an unmapped column, buffering the scanned values so that the position-index step can use them later.
func (*Collector) RunOnRelation ¶
RunOnRelation walks the collector tree and invokes the OnRelation hook on every materialized value that implements onRelationer.
func (*Collector) SQLKeyColumns ¶
SQLKeyColumns includes keys for child reads and this view's attachment to its parent. Mapped columns need snapshots too, independent of row hooks.
func (*Collector) Unlock ¶
func (r *Collector) Unlock()
Unlock signals to dependents that this relation's data is ready.
func (*Collector) WaitIfNeeded ¶
func (r *Collector) WaitIfNeeded()
WaitIfNeeded blocks until the parent collector signals that its rows are scanned (used by child collectors that need parent positions first).
type Column ¶
Column is the minimal interface the Collector needs from a sql.ColumnType wrapper. It mirrors sqlx/io.Column but avoids a hard import of that package in callers that don't have sqlx on the class path.
type Graph ¶
type Graph struct {
Root *View
// contains filtered or unexported fields
}
Graph is the immutable reader-compiled relation graph for one root view.
func Compile ¶
Compile builds collector-only schema and field access without mutating data metadata. Row types are supplied by the reader compiler that resolved the component's output shape.
type Relation ¶
type Relation struct {
*data.Relation
On Links
Of *RelationRef
HolderField *xunsafe.Field
HolderSlice *xunsafe.Slice
}
Relation is reader-compiled state for one metadata relation.
type RelationRef ¶
type RelationRef struct {
*data.RelationRef
View *View
On Links
}
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the reader-owned compiled row and slice access for one view.
type Statelet ¶
type Statelet struct {
Columns []string
}
Statelet carries optional column-selection state used to prune relations.
type TreePlan ¶
type TreePlan struct {
// contains filtered or unexported fields
}
TreePlan is immutable registration-compiled state for one self-referencing view. Declarative Holder/Child/Parent metadata remains on the canonical spec snapshot.
func NewTreePlan ¶
Source Files
¶
- accessors.go
- attachment_targets.go
- bootstrap.go
- child_collectors.go
- collector.go
- compile.go
- doc.go
- holder_append.go
- index.go
- index_positions.go
- index_value.go
- keys.go
- lifecycle.go
- link_value.go
- merge.go
- parent_placeholders.go
- parent_row.go
- partition.go
- provenance.go
- provenance_hooks.go
- relation.go
- rowalloc.go
- schema.go
- sql_keys.go
- state.go
- tree.go
- tree_lifecycle.go
- validate.go
- visitor.go
- visitor_attach.go