stream

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package stream implements execution operations for querying stream data.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ENode is an empty node.
	ENode = new(emptyNode)
)

Functions

func Analyze added in v0.3.0

func Analyze(criteria *streamv1.QueryRequest, metadata []*commonv1.Metadata, ss []logical.Schema, ecc []executor.StreamExecutionContext) (logical.Plan, error)

Analyze converts logical expressions to executable operation tree represented by Plan.

func BuildElementsFromStreamResult added in v0.6.1

func BuildElementsFromStreamResult(ctx context.Context, result model.StreamQueryResult, projectionTags []model.TagProjection) (elements []*streamv1.Element, err error)

BuildElementsFromStreamResult builds a slice of elements from the given stream query result.

func BuildSchema added in v0.3.0

func BuildSchema(sm *databasev1.Stream, indexRules []*databasev1.IndexRule) (logical.Schema, error)

BuildSchema returns Schema loaded from the metadata repository.

func DistributedAnalyze added in v0.5.0

func DistributedAnalyze(criteria *streamv1.QueryRequest, ss []logical.Schema) (logical.Plan, error)

DistributedAnalyze converts logical expressions to executable operation tree represented by Plan.

func MergeGroupElements added in v0.11.0

func MergeGroupElements(perGroup [][]*streamv1.Element, sortByTime bool, sortTagSpec logical.TagSpec, desc bool) []*streamv1.Element

MergeGroupElements k-way merges the per-group ordered element slices into a single ordered slice, using the SAME comparableElement/sortableElements + sort.NewItemIter primitives the row mergePlan.Execute uses. Both the row path and the vec multi-group dispatch call this so cross-group ordering is byte-identical (DRY). The merge is UNCAPPED — the caller applies the outer offset:offset+limit slice.

func VecExecutable added in v0.11.0

func VecExecutable(plan logical.Plan) executor.StreamVecExecutable

VecExecutable returns the vec-eligible StreamVecExecutable at the scan position of the analyzed plan, or nil when the plan cannot be vectorized.

Eligibility: the plan top is the *limit node (stream_analyzer.go:86); its Input must resolve to a *localIndexScan — either directly (no criteria) or wrapped in a *tagFilterPlan (criteria query, stream_plan_tag_filter.go). For the tag-filter case the inner scan already projects the criteria + hidden tags and pushes the INDEXED criteria into its sqo (invertedFilter/skippingFilter); the caller then applies the SAME per-element tagFilter.Match + hidden-tag strip that tagFilterPlan.Execute does (via VecTagFilter) so the result is byte-identical to the row path. A multi-group merger or any other shape does not resolve to a *localIndexScan, so we decline and the caller runs the row path.

func VecOffsetLimit added in v0.11.0

func VecOffsetLimit(plan logical.Plan) (offsetNum, limitNum uint32, ok bool)

VecOffsetLimit returns the client offset/limit the *limit plan node carries, so the standalone vec egress can apply the same offset:offset+limit slice the row *limit.Execute would apply. Returns ok=false when plan is not the *limit shape.

func VecTagFilter added in v0.11.0

func VecTagFilter(plan logical.Plan) (tagFilter logical.TagFilter, hiddenTags logical.HiddenTagSet, schema logical.Schema, ok bool)

VecTagFilter returns the criteria tag filter, the hidden-tag set, and the schema carried by the *limit plan's *tagFilterPlan input, so the standalone vec egress can apply the SAME per-element tagFilter.Match + hidden-tag strip that the row path's tagFilterPlan.Execute applies. Returns ok=false when the plan is not the *limit → *tagFilterPlan shape (a criteria-less query needs no post-filter).

Types

type Parent added in v0.3.0

type Parent struct {
	UnresolvedInput logical.UnresolvedPlan
	Input           logical.Plan
}

Parent refers to a parent node in the execution tree(plan).

type VecMerge added in v0.11.0

type VecMerge struct {
	SortTagSpec logical.TagSpec
	Groups      []VecMergeGroup
	Offset      uint32
	Limit       uint32
	SortByTime  bool
	Desc        bool
}

VecMerge is the vec-eligible form of a multi-group query (*limit → *mergePlan). It carries each group's resolved vec node plus the EXACT merge params the row mergePlan.Execute uses (SortByTime, SortTagSpec, Desc), so the dispatch merges across groups via the shared MergeGroupElements and slices with Offset/Limit.

func VecMergeExecutable added in v0.11.0

func VecMergeExecutable(plan logical.Plan) (*VecMerge, bool)

VecMergeExecutable returns the vec-eligible multi-group form when the plan is *limit → *mergePlan and EVERY subPlan resolves to a vec-eligible *localIndexScan (via scanFromInput, incl. orderTagProjected). If ANY subPlan is not vec-eligible, it returns ok=false so the whole query runs the row path — vec and row are never mixed across groups. The merge params (sortByTime/sortTagSpec/desc) are taken verbatim from the mergePlan so the cross-group order matches the row path exactly.

type VecMergeGroup added in v0.11.0

type VecMergeGroup struct {
	Scan         executor.StreamVecExecutable
	TagFilter    logical.TagFilter
	HiddenTags   logical.HiddenTagSet
	FilterSchema logical.Schema
	HasFilter    bool
}

VecMergeGroup is one group's resolved vec scan plus its optional per-element tag filter, for the multi-group dispatch. The processor runs Scan.ExecuteVectorized → BuildElementsFromBatches → (if HasFilter) applyStreamTagFilter, yielding that group's ordered []Element; the caller then cross-group merges via MergeGroupElements.

Jump to

Keyboard shortcuts

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