queryexec

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 17 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 queryexec executes immutable document-query plans.

Index

Constants

View Source
const AssertionVerification runtime.AssertionKind = "verification"

AssertionVerification is the kind of a verdict row reporting a verification case's run, following the requirement verdict it verifies.

Variables

This section is empty.

Functions

func RationalText added in v0.10.0

func RationalText(value semantics.Value) string

RationalText spells an exact Rational as a document spells a number: a terminating one in decimal, as strconv's shortest 'g' form spells a Real, else `numer/denom`.

Types

type Bindings

type Bindings map[string][]Value

Bindings supplies named values to an entry query.

type Cell

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

Cell is one immutable projected value sequence.

func (Cell) Origin

func (c Cell) Origin() symbols.Origin

Origin returns the selected model element behind the cell.

func (Cell) Values

func (c Cell) Values() []Value

Values returns an independent copy of the cell values.

type Column

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

Column describes one ordered projected property.

func (Column) Label added in v0.9.2

func (c Column) Label() string

Label is the heading the column is presented under: the stated label, or the name when none is stated.

func (Column) Name

func (c Column) Name() string

Name returns the projected property name.

func (Column) Origin

func (c Column) Origin() symbols.Origin

Origin returns the query expression that projected the column.

func (Column) Width added in v0.9.2

func (c Column) Width() int

Width is the column's stated width in source units relative to the other columns of its table, 0 when the column is sized automatically.

func (Column) WithLabel added in v0.9.2

func (c Column) WithLabel(label string) Column

WithLabel returns the column headed label; "" heads it by its name.

func (Column) WithWidth added in v0.9.2

func (c Column) WithWidth(width int) Column

WithWidth returns the column with a stated width; a width of 0 sizes it automatically.

type Context

type Context struct {
	Index     *symbols.Index
	Resolver  *resolve.Resolver
	Model     *semantics.Model
	LineIndex func(doc string) *source.LineIndex
	// Runtime holds the objects the query may read; nil makes object bindings
	// and Objects typed errors.
	Runtime *runtime.Context
	// Roots are the objects the session holds directly, each under its label,
	// in the order Objects enumerates them.
	Roots []Root
	// Related memoizes relationship edge tables across the executions sharing
	// this context; nil builds them once per execution.
	Related *RelationshipTables
}

Context provides the semantic workspace used by one execution; Index, Resolver and Model are required, Runtime and Roots absent over the model alone.

func (Context) HeldRoot

func (c Context) HeldRoot(sym *symbols.Symbol) (Value, bool)

HeldRoot returns the first root materialized from a declaration, so a binding naming the declaration binds its object while the session holds one.

func (Context) Verifier added in v0.10.0

func (c Context) Verifier() runtime.RequirementVerifier

Verifier runs verification cases over the context: in its runtime when it holds one, or a behavior-free reader over its model.

type Error

type Error struct {
	Kind      ErrorKind
	Query     string
	Operation queryplan.Operation
	Parameter string
	Property  string
	Target    string
	Path      []string
	Expected  string
	Actual    string
	Origin    symbols.Origin
	// Cause is the evaluator's reason an unevaluable feature could not be read.
	Cause error
}

Error is a typed query-execution failure with plan provenance.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind string

ErrorKind classifies a document-query execution failure.

const (
	ErrorInvalidContext        ErrorKind = "invalid-context"
	ErrorUnknownBinding        ErrorKind = "unknown-binding"
	ErrorMissingBinding        ErrorKind = "missing-binding"
	ErrorBindingType           ErrorKind = "binding-type"
	ErrorBindingMultiplicity   ErrorKind = "binding-multiplicity"
	ErrorMissingElement        ErrorKind = "missing-element"
	ErrorUnsupportedOperation  ErrorKind = "unsupported-operation"
	ErrorInvalidArgument       ErrorKind = "invalid-argument"
	ErrorInvalidOperator       ErrorKind = "invalid-operator"
	ErrorInvalidOrder          ErrorKind = "invalid-order"
	ErrorUnknownProperty       ErrorKind = "unknown-property"
	ErrorUnknownClassification ErrorKind = "unknown-classification"
	ErrorUnknownElement        ErrorKind = "unknown-element"
	ErrorUnknownRelationship   ErrorKind = "unknown-relationship"
	ErrorUnevaluableFeature    ErrorKind = "unevaluable-feature"
	ErrorUnknownInvocation     ErrorKind = "unknown-invocation"
	ErrorInvocationCycle       ErrorKind = "invocation-cycle"
	ErrorInvocationDepth       ErrorKind = "invocation-depth"
	ErrorInvocationBudget      ErrorKind = "invocation-budget"
	ErrorVisitBudget           ErrorKind = "visit-budget"
	ErrorResultType            ErrorKind = "result-type"
	ErrorResultMultiplicity    ErrorKind = "result-multiplicity"
	ErrorColumnOperand         ErrorKind = "column-operand"
	ErrorColumnOperandType     ErrorKind = "column-operand-type"
	ErrorColumnDivisionByZero  ErrorKind = "column-division-by-zero"
	ErrorColumnIncommensurable ErrorKind = "column-incommensurable"
	ErrorColumnArithmetic      ErrorKind = "column-arithmetic"
	ErrorColumnAbsent          ErrorKind = "column-absent"
	ErrorColumnCardinality     ErrorKind = "column-cardinality"
	// ErrorNoRuntime: an operation over a session's objects ran with no session.
	ErrorNoRuntime ErrorKind = "no-runtime"
	// ErrorObjectRow: a model-only operation was given a runtime object row.
	ErrorObjectRow ErrorKind = "object-row"
	// ErrorVerdictRow: a model-only operation was given a verdict row.
	ErrorVerdictRow ErrorKind = "verdict-row"
	// ErrorNotAnObject: Verdicts was asked about an element that declares no object.
	ErrorNotAnObject ErrorKind = "not-an-object"
	// ErrorIncompleteValidation: Verdicts could not check every assertion about a row.
	ErrorIncompleteValidation ErrorKind = "incomplete-validation"
	// ErrorStateRow: a model-only operation was given a state row.
	ErrorStateRow ErrorKind = "state-row"
	// ErrorEventRow: a model-only operation was given an event row.
	ErrorEventRow ErrorKind = "event-row"
	// ErrorNotHeld: a runtime operation was given an element the session holds no object of.
	ErrorNotHeld ErrorKind = "not-held"
	// ErrorNoStateMachine: States was asked about an object exhibiting no state machine.
	ErrorNoStateMachine ErrorKind = "no-state-machine"
	// ErrorUnknownState: InState named a state no session object's machine declares.
	ErrorUnknownState ErrorKind = "unknown-state"
	// ErrorObjectDestroyed: States or Events was given an object the run destroyed.
	ErrorObjectDestroyed ErrorKind = "object-destroyed"
	// ErrorNoTrace: Events ran in a session that records no trace.
	ErrorNoTrace ErrorKind = "no-trace"
	// ErrorInvalidInterval: an Events bound is not an instant on the clock, or the interval is empty.
	ErrorInvalidInterval ErrorKind = "invalid-interval"
	// ErrorTraceTruncated: Events reaches back to records the session's bounded trace has dropped.
	ErrorTraceTruncated ErrorKind = "trace-truncated"
	// ErrorUndeclaredRow: a RelatedColumn was to traverse from a row no element declares.
	ErrorUndeclaredRow ErrorKind = "undeclared-row"
	// ErrorProjectedAncestors: Tree was given ancestors for rows already projected.
	ErrorProjectedAncestors ErrorKind = "projected-ancestors"
)

type Event

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

Event is one row of Events: a typed record of the session's trace, at the instant it was made. Immutable once built.

func EventsFromTrace added in v0.10.0

func EventsFromTrace(ctx *runtime.Context, records []runtime.TraceRecord) []Event

EventsFromTrace converts documented trace records into rows in run order.

func (Event) Alternatives

func (ev Event) Alternatives() []string

Alternatives are a choice's alternatives as offered, nil for any other record.

func (Event) At

func (ev Event) At() float64

At is the clock instant the record was made at, in clock units.

func (Event) Behavior

func (ev Event) Behavior() *symbols.Symbol

Behavior is the state machine or action the record was made under.

func (Event) Kind

func (ev Event) Kind() string

Kind names the record's kind as its `kind` property does: `accept`, `send`, `transition`, `entry`, `exit`, `do`, `choice`, `guard`, `terminate`.

func (Event) Label

func (ev Event) Label() string

Label names the row: the machine it came from and its text (`lamp.lp: enter: on`); a record with no object reads as its text alone.

func (Event) Machine

func (ev Event) Machine() string

Machine names the behavior as its `machine` property does, "" for none.

func (Event) Object

func (ev Event) Object() (*runtime.Instance, string)

Object is the object whose behavior made the record, nil for one made from outside the run, with the label a session reaches it by.

func (Event) Payload

func (ev Event) Payload() []string

Payload is an accept's or send's payload, `name = value` per parameter in name order, in the runtime's notation.

func (Event) Record

func (ev Event) Record() runtime.TraceRecord

Record is the trace record the row reads.

func (Event) Summary

func (ev Event) Summary() string

Summary is the event in one line: its instant in clock units, then its label.

func (Event) Taken

func (ev Event) Taken() string

Taken is the alternative a choice took, "" for any other record.

func (Event) Target

func (ev Event) Target() (*runtime.Instance, string)

Target is the object a send was addressed to, nil for any other record, with the label a session reaches it by.

func (Event) Text

func (ev Event) Text() string

Text is the record's trace text.

func (Event) Time

func (ev Event) Time() Value

Time is the instant as its `time` property answers it.

type Options

type Options struct {
	VisitBudget      int
	InvocationDepth  int
	InvocationBudget int
}

Options controls bounded query execution.

type RelationshipTables

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

RelationshipTables memoizes one model's per-kind edge tables across the executions whose Context shares them. Not safe for concurrent use.

func NewRelationshipTables

func NewRelationshipTables() *RelationshipTables

NewRelationshipTables returns empty tables for a Context to carry.

type Root

type Root struct {
	Label  string
	Object *runtime.Instance
}

Root is one object a session holds directly, under its label (`Demo::car`, `#7`).

type Row

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

Row retains the selected element, object, verdict, state or event and its ordered projected cells.

func (Row) Cells

func (r Row) Cells() []Cell

Cells returns an independent copy of the row's projected cells.

func (Row) Depth added in v0.9.2

func (r Row) Depth() int64

Depth is the row's nesting under the rows above it: 0 for a top-level row, one more for each row it nests under when the query arranged its rows as a tree (`Tree`); otherwise every row is at depth 0.

func (Row) Element

func (r Row) Element() Value

Element returns the selected value: a model element, a runtime object when the query ran over a session's objects, a verdict about one, a state one is in, or an event of the session's trace.

func (Row) Origin

func (r Row) Origin() symbols.Origin

Origin returns the selected element's declaration provenance.

type RowSet

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

RowSet is an immutable ordered query result.

func Execute

func Execute(program *queryplan.Program, context Context, bindings Bindings, options Options) (*RowSet, error)

Execute evaluates a compiled entry query into an immutable ordered row set.

func (*RowSet) Columns

func (r *RowSet) Columns() []Column

Columns returns an independent copy of the projected columns.

func (*RowSet) Origin

func (r *RowSet) Origin() symbols.Origin

Origin returns the entry query declaration.

func (*RowSet) Rows

func (r *RowSet) Rows() []Row

Rows returns an independent copy of the result rows.

type State

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

State is one row of States or InState: an active leaf state of one object's state machine, as the session stands. Immutable once built.

func (State) Declaration

func (s State) Declaration() *symbols.Symbol

Declaration is the state as declared, nil when lowering synthesized it.

func (State) Enclosing

func (s State) Enclosing() []string

Enclosing names the composite states the leaf is nested in, outermost first; each is active with the leaf.

func (State) Label

func (s State) Label() string

Label names the row: the state's path on its object's machine (`lamp.lp in on.dim`).

func (State) Machine

func (s State) Machine() string

Machine names the state machine the object exhibits that is in the state.

func (State) Name

func (s State) Name() string

Name is the active leaf state's own name.

func (State) Object

func (s State) Object() (*runtime.Instance, string)

Object is the object whose machine is in the state, under the label the session reaches it by.

func (State) Path

func (s State) Path() string

Path is the leaf's name qualified by the states enclosing it (`on.run`).

func (State) Region

func (s State) Region() string

Region names the orthogonal region the leaf runs in, "" outside any region.

type Value

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

Value is one immutable scalar carried through query execution.

func BooleanValue

func BooleanValue(value bool) Value

BooleanValue constructs a Boolean value.

func ConnectorEndValue added in v0.10.0

func ConnectorEndValue(connector *symbols.Symbol, position int, label string) Value

ConnectorEndValue constructs the value of end position of connector, labelled by the attachment it names (`bench.ccd.usb`), with the connector as provenance.

func ElementValue

func ElementValue(sym *symbols.Symbol) Value

ElementValue constructs an element value with declaration provenance.

func EventValue

func EventValue(event Event) Value

EventValue constructs an event value; its provenance is the object's declaration.

func IntegerOf added in v0.10.0

func IntegerOf(value semantics.Value) Value

IntegerOf constructs the integer value of the Integer constant value, which may lie beyond int64.

func IntegerValue

func IntegerValue(value int64) Value

IntegerValue constructs an integer value.

func ObjectValue

func ObjectValue(inst *runtime.Instance, label string) Value

ObjectValue constructs a runtime object value under the label a session reaches it by (`car.wheels[2]`, `#7`), with its declaration as provenance.

func QuantityValue

func QuantityValue(quantity semantics.Quantity) Value

QuantityValue constructs a quantity value from a magnitude in a unit; the quantity is deep-copied, so the value stays immutable.

func RationalOf added in v0.10.0

func RationalOf(value semantics.Value) Value

RationalOf constructs the value of the exact Rational constant value.

func RealValue

func RealValue(value float64) Value

RealValue constructs a real value.

func StateValue

func StateValue(state State) Value

StateValue constructs a state value; its declaration is the state.

func StringValue

func StringValue(value string) Value

StringValue constructs a string value.

func VerdictValue

func VerdictValue(verdict Verdict) Value

VerdictValue constructs a verdict value; its declaration is the assertion.

func (Value) Boolean

func (v Value) Boolean() (bool, bool)

Boolean returns the value's Boolean and whether it is a Boolean value.

func (Value) ConnectorEnd added in v0.10.0

func (v Value) ConnectorEnd() (*symbols.Symbol, int, bool)

ConnectorEnd returns the connector and end position a connector-end value stands for, and whether it is one.

func (Value) Declaration

func (v Value) Declaration() *symbols.Symbol

Declaration returns the element a value is declared by: an element itself, the usage or definition an object stands for, the assertion a verdict is about, the state a state row is of, the behavior an event row came from (its object's declaration when the record names none), and nil for a scalar.

func (Value) Element

func (v Value) Element() (*symbols.Symbol, bool)

Element returns the value's element and whether it is an element value.

func (Value) Event

func (v Value) Event() (Event, bool)

Event returns the value's event and whether it is an event value.

func (Value) Integer

func (v Value) Integer() (int64, bool)

Integer returns the value's integer and whether it is an integer value within int64; IntegerConst reads any integer value.

func (Value) IntegerConst added in v0.10.0

func (v Value) IntegerConst() (semantics.Value, bool)

IntegerConst returns the value's Integer, of any size, and whether it is an integer value.

func (Value) Kind

func (v Value) Kind() ValueKind

Kind returns the value's scalar kind.

func (Value) Label added in v0.10.0

func (v Value) Label() string

Label is the text a connector-end value is labelled by: the attachment it names, as written on the connector.

func (Value) Magnitude

func (v Value) Magnitude() (Value, bool)

Magnitude returns a quantity value's magnitude as the bare integer or real value it is, and whether the value is a quantity.

func (Value) Object

func (v Value) Object() (*runtime.Instance, string, bool)

Object returns the value's runtime object, the label it is reached by, and whether it is an object value.

func (Value) Origin

func (v Value) Origin() symbols.Origin

Origin returns the source declaration behind the value.

func (Value) Quantity

func (v Value) Quantity() (semantics.Quantity, bool)

Quantity returns an independent copy of the value's quantity and whether it is a quantity value.

func (Value) Rational added in v0.10.0

func (v Value) Rational() (semantics.Value, bool)

Rational returns the value's exact Rational and whether it is a rational value.

func (Value) Real

func (v Value) Real() (float64, bool)

Real returns the value's real and whether it is a real value.

func (Value) State

func (v Value) State() (State, bool)

State returns the value's state and whether it is a state value.

func (Value) String

func (v Value) String() (string, bool)

String returns the value's string and whether it is a string value.

func (Value) Verdict

func (v Value) Verdict() (Verdict, bool)

Verdict returns the value's verdict and whether it is a verdict value.

type ValueKind

type ValueKind string

ValueKind classifies one scalar query value.

const (
	ValueElement ValueKind = "element"
	// ValueObject is a runtime object a session holds, `car.wheels[2]`, as opposed
	// to the model element declaring it.
	ValueObject ValueKind = "object"
	// ValueVerdict is an assertion checked about an object, carried as a row whose
	// declaration is the asserting element.
	ValueVerdict ValueKind = "verdict"
	// ValueState is one active state of an object's state machine, carried as a
	// row whose declaration is the state.
	ValueState ValueKind = "state"
	// ValueEvent is one record of a session's trace, carried as a row whose
	// declaration is the behavior that made it.
	ValueEvent   ValueKind = "event"
	ValueString  ValueKind = "string"
	ValueInteger ValueKind = "integer"
	ValueReal    ValueKind = "real"
	// ValueRational is an exact non-integer Rational, `1/3` or `0.1`.
	ValueRational ValueKind = "rational"
	ValueBoolean  ValueKind = "boolean"
	ValueInfinity ValueKind = "infinity"
	// ValueQuantity is a magnitude in a measurement unit, `2290000 [kg]`.
	ValueQuantity ValueKind = "quantity"
	// ValueConnectorEnd is one end of a connector usage, reached by navigating
	// its Connector::connectorEnd: it names the features its attachment walks.
	ValueConnectorEnd ValueKind = "connectorEnd"
)

type Verdict

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

Verdict is one row of Verdicts: an assertion checked about one object, and how it came out. Immutable once built.

func (Verdict) Assertion

func (v Verdict) Assertion() *symbols.Symbol

Assertion is the asserting element: the constraint, requirement, satisfy usage or verification case.

func (Verdict) Carrier

func (v Verdict) Carrier() (*runtime.Instance, bool)

Carrier is the object the assertion was checked on, and whether the query's session holds it rather than the check having materialized it as declared.

func (Verdict) CarrierDeclaration

func (v Verdict) CarrierDeclaration() *symbols.Symbol

CarrierDeclaration is the element the carrier stands for in the model.

func (Verdict) Condition

func (v Verdict) Condition() string

Condition is the condition that evaluated to false on a violated verdict.

func (Verdict) Kind

func (v Verdict) Kind() runtime.AssertionKind

Kind is the kind of assertion checked: constraint, requirement, satisfaction or verification.

func (Verdict) Label

func (v Verdict) Label() string

Label names the verdict: the assertion as written on its carrier's path.

func (Verdict) Path

func (v Verdict) Path() string

Path names the carrier from the row checked: its label, then the features walked to the carrier (`car.wheels[2]`).

func (Verdict) Reason

func (v Verdict) Reason() string

Reason is why the assertion is violated or undecided; empty when it holds.

func (Verdict) Requirement

func (v Verdict) Requirement() *symbols.Symbol

Requirement is the requirement a requirement, satisfaction or verification verdict is about; nil for a constraint.

func (Verdict) Status

func (v Verdict) Status() runtime.ValidationStatus

Status is how the assertion came out.

func (Verdict) Summary

func (v Verdict) Summary() string

Summary is the verdict in one line: its label and status.

func (Verdict) Text

func (v Verdict) Text() string

Text is the assertion as written (`constraint massLimit`), naming an anonymous one.

func (Verdict) Verification

func (v Verdict) Verification() []runtime.VerdictKind

Verification is the verdict kinds of the verification cases the row reports: its own case on a verification row, those verifying its requirement otherwise.

Jump to

Keyboard shortcuts

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