Interface QueryPredicate

  • All Superinterfaces:
    Bindable, PlanHashable
    All Known Implementing Classes:
    AndOrPredicate, AndPredicate, ElementPredicate, NotPredicate, OrPredicate

    @API(EXPERIMENTAL)
    public interface QueryPredicate
    extends Bindable, PlanHashable
    An interface describing a predicate that can be evaluated on a SourceEntry (usually derived from a record).

    QueryPredicate is generally quite similar to QueryComponent. However, there is a key difference in how each interface evaluates the predicate against a given record:

    • A QueryComponent is evaluated on a FDBRecord wrapping a Protobuf message. To evaluate predicates on nested records, a QueryComponent such as NestedField or OneOfThemWithComponent will descend into the nested record.
    • A QueryPredicate is evaluated on a SourceEntry, which maps Sources to values. The predicate can be evaluated on a nested record by specifying a complex Source, such as RepeatedFieldSource. All sources are evaluated to produce a stream of source entries before any predicates are evaluated.

    Concretely, the difference between QueryPredicates and QueryComponents is most easily seen in the way that multiple predicates on repeated fields can be expressed. Any query predicate anywhere in a tree of predicates can make use of any source. In contrast, each OneOfThemWithComponent is a single iteration through the field's repeated values so the values obtained by that iteration are usable only within that OneOfThemWithComponent.