Documentation
¶
Overview ¶
Package queryexec executes immutable document-query plans.
Index ¶
- Constants
- func RationalText(value semantics.Value) string
- type Bindings
- type Cell
- type Column
- type Context
- type Error
- type ErrorKind
- type Event
- func (ev Event) Alternatives() []string
- func (ev Event) At() float64
- func (ev Event) Behavior() *symbols.Symbol
- func (ev Event) Kind() string
- func (ev Event) Label() string
- func (ev Event) Machine() string
- func (ev Event) Object() (*runtime.Instance, string)
- func (ev Event) Payload() []string
- func (ev Event) Record() runtime.TraceRecord
- func (ev Event) Summary() string
- func (ev Event) Taken() string
- func (ev Event) Target() (*runtime.Instance, string)
- func (ev Event) Text() string
- func (ev Event) Time() Value
- type Options
- type RelationshipTables
- type Root
- type Row
- type RowSet
- type State
- type Value
- func BooleanValue(value bool) Value
- func ConnectorEndValue(connector *symbols.Symbol, position int, label string) Value
- func ElementValue(sym *symbols.Symbol) Value
- func EventValue(event Event) Value
- func IntegerOf(value semantics.Value) Value
- func IntegerValue(value int64) Value
- func ObjectValue(inst *runtime.Instance, label string) Value
- func QuantityValue(quantity semantics.Quantity) Value
- func RationalOf(value semantics.Value) Value
- func RealValue(value float64) Value
- func StateValue(state State) Value
- func StringValue(value string) Value
- func VerdictValue(verdict Verdict) Value
- func (v Value) Boolean() (bool, bool)
- func (v Value) ConnectorEnd() (*symbols.Symbol, int, bool)
- func (v Value) Declaration() *symbols.Symbol
- func (v Value) Element() (*symbols.Symbol, bool)
- func (v Value) Event() (Event, bool)
- func (v Value) Integer() (int64, bool)
- func (v Value) IntegerConst() (semantics.Value, bool)
- func (v Value) Kind() ValueKind
- func (v Value) Label() string
- func (v Value) Magnitude() (Value, bool)
- func (v Value) Object() (*runtime.Instance, string, bool)
- func (v Value) Origin() symbols.Origin
- func (v Value) Quantity() (semantics.Quantity, bool)
- func (v Value) Rational() (semantics.Value, bool)
- func (v Value) Real() (float64, bool)
- func (v Value) State() (State, bool)
- func (v Value) String() (string, bool)
- func (v Value) Verdict() (Verdict, bool)
- type ValueKind
- type Verdict
- func (v Verdict) Assertion() *symbols.Symbol
- func (v Verdict) Carrier() (*runtime.Instance, bool)
- func (v Verdict) CarrierDeclaration() *symbols.Symbol
- func (v Verdict) Condition() string
- func (v Verdict) Kind() runtime.AssertionKind
- func (v Verdict) Label() string
- func (v Verdict) Path() string
- func (v Verdict) Reason() string
- func (v Verdict) Requirement() *symbols.Symbol
- func (v Verdict) Status() runtime.ValidationStatus
- func (v Verdict) Summary() string
- func (v Verdict) Text() string
- func (v Verdict) Verification() []runtime.VerdictKind
Constants ¶
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.
const PropertyValuation = "valuation"
PropertyValuation projects what a row feature's own valuation binds (KerML Feature::valuation): the value its declaration writes, or a redefinition binds, evaluated where it is an expression. A row that is not a feature, or a feature bound to nothing, reads as absent.
Variables ¶
This section is empty.
Functions ¶
func RationalText ¶ added in v0.10.0
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 Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell is one immutable projected value sequence.
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
Column describes one ordered projected property.
func (Column) Label ¶ added in v0.9.2
Label is the heading the column is presented under: the stated label, or the name when none is stated.
func (Column) Width ¶ added in v0.9.2
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.
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 ¶
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.
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 ¶
Alternatives are a choice's alternatives as offered, nil for any other record.
func (Event) Kind ¶
Kind names the record's kind as its `kind` property does: `accept`, `send`, `transition`, `entry`, `exit`, `do`, `choice`, `guard`, `terminate`.
func (Event) Label ¶
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) Object ¶
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 ¶
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 ¶
Summary is the event in one line: its instant in clock units, then its label.
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 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) Depth ¶ added in v0.9.2
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.
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.
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 ¶
Declaration is the state as declared, nil when lowering synthesized it.
func (State) Enclosing ¶
Enclosing names the composite states the leaf is nested in, outermost first; each is active with the leaf.
func (State) Label ¶
Label names the row: the state's path on its object's machine (`lamp.lp in on.dim`).
func (State) Object ¶
Object is the object whose machine is in the state, under the label the session reaches it by.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is one immutable scalar carried through query execution.
func ConnectorEndValue ¶ added in v0.10.0
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 ¶
ElementValue constructs an element value with declaration provenance.
func EventValue ¶
EventValue constructs an event value; its provenance is the object's declaration.
func IntegerOf ¶ added in v0.10.0
IntegerOf constructs the integer value of the Integer constant value, which may lie beyond int64.
func ObjectValue ¶
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 ¶
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
RationalOf constructs the value of the exact Rational constant value.
func StateValue ¶
StateValue constructs a state value; its declaration is the state.
func VerdictValue ¶
VerdictValue constructs a verdict value; its declaration is the assertion.
func (Value) ConnectorEnd ¶ added in v0.10.0
ConnectorEnd returns the connector and end position a connector-end value stands for, and whether it is one.
func (Value) Declaration ¶
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) Integer ¶
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
IntegerConst returns the value's Integer, of any size, and whether it is an integer value.
func (Value) Label ¶ added in v0.10.0
Label is the text a connector-end value is labelled by: the attachment it names, as written on the connector.
func (Value) Magnitude ¶
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 ¶
Object returns the value's runtime object, the label it is reached by, and whether it is an object value.
func (Value) Quantity ¶
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
Rational returns the value's exact Rational and whether it is a rational 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 ¶
Assertion is the asserting element: the constraint, requirement, satisfy usage or verification case.
func (Verdict) Carrier ¶
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 ¶
CarrierDeclaration is the element the carrier stands for in the model.
func (Verdict) Condition ¶
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) Path ¶
Path names the carrier from the row checked: its label, then the features walked to the carrier (`car.wheels[2]`).
func (Verdict) Requirement ¶
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) Text ¶
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.