Data query operations are specified using a modular set of declarative Query objects, connected together to represent a processing tree. The Query is presented to zero or more Stores, where applicable, where it is transformed and bound into an optimal data pipeline for the specific type of Store.
All the queries below are found in the spiralcraft.data.query package.
Retrieves instances of a given type from a Store.
Most Queries in general, and all Queries that retrieve Tuple data, include a Scan as their original data source. In the unoptimized case, a Scan will "scan" all instances of a given Type.
An EquiJoin selects a subset of Tuples from its source where a set of field values in the source Tuple, aka. the "variant values", exactly matches a set of input values, aka. the "invariant values".
An EquiJoin is usually implemented using an index lookup, where applicable, and is an optimized case of a Selection. It is the optimized form of a Selection with a set of conjunctive equality constraints- ie. .f1==p1 [ && .f2==p2 ... ]
.fieldName, which represent the set of fields of the variant Tuple to search (ie. the key fields).valueExpression, which provide the values to search for. The variant Tuple will not be visible to the RHS expressions.A Selection retrieves the set of Tuples from the source Query that match the specified constraint expression. The constraint expression is evaluated in a TeleFocus where the subject, represented by "." prefixed expressions, is the variant source Tuple, and the context is invariant.
For example, the constraint expression .name=myName would compare the "name" field in the variant Tuple to the value of myName in the context (which may be some application Focus or a Tuple from an outer Query).
Stores may optimize Selections based on an analysis of the constraint expression and source pipeline.
For instance, a Selection with a constraint that contains a conjunctive equality sub-expression (ie. .f1==p1 && .f2==p2 ...)may be factored to use an EquiJoin for this purpose and would filter the result using the remainder of the constraint expression.
Combines the results of multiple sources, eliminating duplicates.
Combines the results of multiple sources, without checking for duplicates. Used when memory efficient streaming behavior is required and duplicates don't matter or are known not to be present.
Returns the set of distinct values of a projection of a source query (ie. the set of unique value combinations over a subset of the source fields).
Filters the source data by determining whether a function of the source Tuple is contained in an invariant set.
<query:SetFilter
xmlns:query="class:/spiralcraft/data/query/"
xmlns:example="class:/spiralcraft/data/test/example/"
>
<filterSetX>myListOfNames
</filterSetX>
<searchX>.name
</searchX>
<source>
<query:Scan>
<type><example:Customer.type/>
</type>
</query:Scan>
</source>
</query:SetFilter>
Sorts the data from the source according to a multi-element Order.
Randomly sorts the source data
Allows an arbitrary source of Aggregate data to source another Query pipeline. The data source is specified using an Expression, which must resolve to an Aggregate.