Documentation
¶
Overview ¶
Package queryplan compiles native SysML document queries into immutable plans.
Index ¶
- Constants
- func IsQueryDefinition(index *symbols.Index, model *semantics.Model, sym *symbols.Symbol) bool
- func RelatedAggregateSupported(aggregate string) bool
- type Argument
- type Definition
- type Error
- type ErrorKind
- type Expression
- func (e Expression) Arguments() []Argument
- func (e Expression) Element() (*symbols.Symbol, bool)
- func (e Expression) Literal() (LiteralKind, string)
- func (e Expression) Multiplicity() Multiplicity
- func (e Expression) Operation() Operation
- func (e Expression) Origin() symbols.Origin
- func (e Expression) Quantity() (semantics.Quantity, bool)
- func (e Expression) Target() string
- type LiteralKind
- type Multiplicity
- type Operation
- type Parameter
- type Program
Constants ¶
const ( RelatedAggregateList = "list" RelatedAggregateCount = "count" RelatedAggregateAny = "any" )
The aggregates a related column reduces its traversal to.
Variables ¶
This section is empty.
Functions ¶
func IsQueryDefinition ¶
IsQueryDefinition reports whether sym specializes DocumentQueries::Query.
func RelatedAggregateSupported ¶
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.
type ErrorKind ¶
type ErrorKind string
ErrorKind classifies a query-planning failure.
const ( ErrorInvalidContext ErrorKind = "invalid-context" 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" )
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 ¶
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" // OperationTree arranges rows as a containment tree, each with its depth. OperationTree Operation = "tree" )
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.