queryplan

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package queryplan compiles native SysML document queries into immutable plans.

Index

Constants

View Source
const (
	RelatedAggregateList  = "list"
	RelatedAggregateCount = "count"
	RelatedAggregateAny   = "any"
)

The aggregates a related column reduces its traversal to.

Variables

This section is empty.

Functions

func IsQueryDefinition

func IsQueryDefinition(index *symbols.Index, model *semantics.Model, sym *symbols.Symbol) bool

IsQueryDefinition reports whether sym specializes DocumentQueries::Query.

func RelatedAggregateSupported

func RelatedAggregateSupported(aggregate string) bool

RelatedAggregateSupported reports whether aggregate names a related-column aggregate.

Types

type Argument

type Argument struct {
	Name  string
	Named bool
	Value Expression
}

Argument is one normalized invocation argument.

type Definition

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

Definition is one reusable query definition in a compiled program.

func (Definition) Dependencies

func (d Definition) Dependencies() []string

Dependencies returns the invoked query definitions in encounter order.

func (Definition) Expression

func (d Definition) Expression() Expression

Expression returns an independent copy of the compiled result expression.

func (Definition) Name

func (d Definition) Name() string

Name returns the definition's fully qualified name.

func (Definition) Origin

func (d Definition) Origin() symbols.Origin

Origin returns the definition's declaration location.

func (Definition) Parameters

func (d Definition) Parameters() []Parameter

Parameters returns the definition's ordered effective inputs.

func (Definition) Result

func (d Definition) Result() Parameter

Result returns the definition's typed result parameter.

type Error

type Error struct {
	Kind      ErrorKind
	Query     string
	Target    string
	Parameter string
	Path      []string
	Expected  string
	Actual    string
	Origin    symbols.Origin
}

Error is a typed query-planning failure with its source location.

func (*Error) Error

func (e *Error) Error() string

type ErrorKind

type ErrorKind string

ErrorKind classifies a query-planning failure.

const (
	ErrorInvalidContext         ErrorKind = "invalid-context"
	ErrorLibraryUnavailable     ErrorKind = "library-unavailable"
	ErrorNotQueryDefinition     ErrorKind = "not-query-definition"
	ErrorMissingResultParameter ErrorKind = "missing-result-parameter"
	ErrorInvalidParameter       ErrorKind = "invalid-parameter"
	ErrorMissingResult          ErrorKind = "missing-result"
	ErrorConflictingResult      ErrorKind = "conflicting-result"
	ErrorUnsupportedResult      ErrorKind = "unsupported-result"
	ErrorUnknownInvocation      ErrorKind = "unknown-invocation"
	ErrorAmbiguousInvocation    ErrorKind = "ambiguous-invocation"
	ErrorPositionalQueryArgs    ErrorKind = "positional-query-arguments"
	ErrorDuplicateArgument      ErrorKind = "duplicate-argument"
	ErrorUnknownArgument        ErrorKind = "unknown-argument"
	ErrorMissingArgument        ErrorKind = "missing-argument"
	ErrorArgumentCount          ErrorKind = "argument-count"
	ErrorArgumentType           ErrorKind = "argument-type"
	ErrorArgumentMultiplicity   ErrorKind = "argument-multiplicity"
	ErrorCompositionCycle       ErrorKind = "composition-cycle"
	ErrorUnknownParameter       ErrorKind = "unknown-parameter"
	ErrorUnsupportedExpression  ErrorKind = "unsupported-expression"
	ErrorUnsupportedDefault     ErrorKind = "unsupported-default"
	ErrorDefaultType            ErrorKind = "default-type"
	ErrorDefaultMultiplicity    ErrorKind = "default-multiplicity"
	ErrorInvalidColumn          ErrorKind = "invalid-column"
	ErrorColumnSource           ErrorKind = "column-source"
	ErrorColumnName             ErrorKind = "column-name"
	ErrorUnknownColumnProperty  ErrorKind = "unknown-column-property"
	ErrorColumnOperator         ErrorKind = "column-operator"
	ErrorColumnType             ErrorKind = "column-type"
	ErrorDuplicateColumn        ErrorKind = "duplicate-column"
	ErrorEmptyProjection        ErrorKind = "empty-projection"
	ErrorColumnAggregate        ErrorKind = "column-aggregate"
	// ErrorCollectionFunction is a `->` function a cell cannot apply: unknown,
	// or given the wrong arguments.
	ErrorCollectionFunction ErrorKind = "collection-function"
)

func ErrorKinds added in v0.11.0

func ErrorKinds() []ErrorKind

ErrorKinds lists every error kind, in declaration order.

type Expression

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

Expression is one immutable node of a compiled query plan.

func (Expression) Arguments

func (e Expression) Arguments() []Argument

Arguments returns an independent copy of the expression's arguments.

func (Expression) Element

func (e Expression) Element() (*symbols.Symbol, bool)

Element returns the model element an element expression binds.

func (Expression) Literal

func (e Expression) Literal() (LiteralKind, string)

Literal returns the kind and source value of a literal expression.

func (Expression) Multiplicity added in v0.9.2

func (e Expression) Multiplicity() Multiplicity

Multiplicity returns the declared multiplicity of the feature or parameter a column expression reads, which bounds how many values a cell may hold.

func (Expression) Operation

func (e Expression) Operation() Operation

Operation returns the operation this expression performs.

func (Expression) Origin

func (e Expression) Origin() symbols.Origin

Origin returns the source expression that produced this plan node.

func (Expression) Quantity

func (e Expression) Quantity() (semantics.Quantity, bool)

Quantity returns an independent copy of a quantity literal's folded value and whether the expression is one.

func (Expression) Target

func (e Expression) Target() string

Target returns the parameter or query definition named by the expression.

type LiteralKind

type LiteralKind string

LiteralKind classifies a literal retained in a query plan.

const (
	LiteralString   LiteralKind = "string"
	LiteralInteger  LiteralKind = "integer"
	LiteralReal     LiteralKind = "real"
	LiteralBoolean  LiteralKind = "boolean"
	LiteralInfinity LiteralKind = "infinity"
	LiteralNull     LiteralKind = "null"
	// LiteralQuantity is a magnitude in a unit, `2.5 [s]`, folded at planning.
	LiteralQuantity LiteralKind = "quantity"
)

type Multiplicity

type Multiplicity struct {
	Lower         int64
	Upper         int64
	UpperInfinite bool
	Known         bool
}

Multiplicity is the effective cardinality of a query parameter or of the feature a column reads.

func (Multiplicity) Admits added in v0.9.2

func (m Multiplicity) Admits(count int) bool

Admits reports whether a value count lies within a known multiplicity; an unknown multiplicity admits every count.

func (Multiplicity) String added in v0.9.2

func (m Multiplicity) String() string

String writes the multiplicity in notation form, `[lower..upper]`.

type Operation

type Operation string

Operation is one closed document-query planning operation.

const (
	OperationParameter     Operation = "parameter"
	OperationElement       Operation = "element"
	OperationLiteral       Operation = "literal"
	OperationSequence      Operation = "sequence"
	OperationInvoke        Operation = "invoke"
	OperationOwnedElements Operation = "owned-elements"
	OperationDescendants   Operation = "descendants"
	OperationAncestors     Operation = "ancestors"
	// OperationNamed resolves qualified names to the model elements they denote.
	OperationNamed Operation = "named"
	// OperationObjects enumerates the objects a session holds, by type.
	OperationObjects Operation = "objects"
	// OperationVerdicts checks the assertions about each source row's object.
	OperationVerdicts Operation = "verdicts"
	// OperationStates lists the active states of each source row's object.
	OperationStates Operation = "states"
	// OperationInState lists the session's objects whose machine is in a state.
	OperationInState Operation = "in-state"
	// OperationEvents reads the session's trace as time-ordered rows.
	OperationEvents          Operation = "events"
	OperationRelatedElements Operation = "related-elements"
	OperationWhereType       Operation = "where-type"
	OperationWhereMetadata   Operation = "where-metadata"
	OperationWhereName       Operation = "where-name"
	OperationWhereText       Operation = "where-text"
	OperationWhereFeature    Operation = "where-feature"
	OperationOrderBy         Operation = "order-by"
	OperationProject         Operation = "project"
	OperationColumn          Operation = "column"
	OperationRowProperty     Operation = "row-property"
	// OperationRowMember reads a feature reached through a member path nested
	// in the row element — a feature chain like `stat.runs`.
	OperationRowMember      Operation = "row-member"
	OperationColumnOperator Operation = "column-operator"
	// OperationRelatedColumn projects the elements a relationship reaches from each row.
	OperationRelatedColumn Operation = "related-column"
	// OperationWhereRelated keeps the source rows by whether a related element exists.
	OperationWhereRelated Operation = "where-related"
	// OperationExcept and OperationUnion are the ordered set operations over rows.
	OperationExcept Operation = "except"
	OperationUnion  Operation = "union"
	// OperationDiffer is the keyed value comparison of two projected row sets.
	OperationDiffer Operation = "differ"
	// OperationTree arranges rows as a containment tree, each with its depth.
	OperationTree Operation = "tree"
	// OperationVariable reads a cell's row parameter or the element a
	// collection body is bound to.
	OperationVariable Operation = "variable"
	// OperationNavigate reads one feature of each element its source yields.
	OperationNavigate Operation = "navigate"
	// OperationCollection applies a sequence function — `->size()`,
	// `->select {in e; …}` — to its source.
	OperationCollection Operation = "collection"
	// OperationLambda is the body a collection function evaluates once per
	// element, bound to the variable it names.
	OperationLambda Operation = "lambda"
)

type Parameter

type Parameter struct {
	Name         string
	Type         string
	Multiplicity Multiplicity
	HasDefault   bool
	Default      Expression
	DefaultQuery string
	Origin       symbols.Origin
}

Parameter is one typed query input or result. A defaulted input carries its compiled default and the query whose declaration supplied it.

type Program

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

Program is an immutable dependency-ordered query plan.

func Compile

func Compile(index *symbols.Index, model *semantics.Model, resolver *resolve.Resolver, entry *symbols.Symbol) (*Program, error)

Compile compiles entry and every query it invokes into dependency order.

func (*Program) Definitions

func (p *Program) Definitions() []Definition

Definitions returns dependencies before their consumers, each exactly once.

func (*Program) Entry

func (p *Program) Entry() string

Entry returns the fully qualified entry query name.

Jump to

Keyboard shortcuts

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