Package com.apple.foundationdb.record.query.plan.temp.view

Classes related to the ViewExpression abstraction.

A view expression is an abstraction that represents a stream of values that can be represented as tuple-encoded keys and binary values in FoundationDB. View expressions are quite general and can represent a large variety of index structures and even queries. However, because they are defined by their close relationship to the FDB tuple layer encoding, they are extremely useful for many query planning operations, such as incremental index selection (for example, see PushElementWithComparisonIntoExistingScanRule).

Semantically, a view expression can be read much like a query in a declarative query language like SQL. For example, it can specify a projection, sort order, and filter predicate. When used to represent the structure of an index, a view expression can be interpreted as a query for which the index acts as a materialized view. ViewExpression describes the specific semantics in further detail.

The two key abstractions that are used for defining view expressions are Sources and Elements. A source represents a stream of entities that can be manipulated to form a view expression, while an element defines the mapping from one entry in a source's stream to a value that can be represented as part of a tuple. For example, the RecordTypeSource represents a stream of records with types from a specified set of record types. A FieldElement produces values from a field of each entry in a stream of records.

During query planning with the Cascades-style planner, Comparisons.Comparisons are matched to elements of a view expression. The state and logic for determining which comparisons can be matched to a (partially matched) view expression is encapsulated in the ViewExpressionComparisons class.