@API(value=EXPERIMENTAL) public class FieldElement extends Object
Note that while nested fields can be referenced from a single FieldElement
, repeated fields cannot because
they define their own stream of data values, which must be represented by a RepeatedFieldSource
.
Constructor and Description |
---|
FieldElement(Source source,
List<String> fieldNames) |
FieldElement(Source source,
String fieldName) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Object |
eval(SourceEntry sourceEntry)
Evaluate this element with respect to the given source entry, producing an object that can be interpreted
by a
Comparisons.Comparison . |
Set<Source> |
getAncestralSources()
Get the set of all sources for this element, including all ancestors of this element's sources.
|
List<String> |
getFieldNames() |
Source |
getSource() |
int |
hashCode() |
Optional<ViewExpressionComparisons> |
matchSourcesWith(ViewExpressionComparisons viewExpressionComparisons,
Element element)
Determine whether this element is the same as the given
Element when unused sources are combined with
each other. |
Optional<ComparisonRange> |
matchWith(ComparisonRange existingComparisons,
ElementPredicate predicate)
Determine whether this element can be used to satisfy the given
ElementPredicate , under the assumption
that this element is already being used to satisfy the given ComparisonRange . |
int |
planHash()
Return a hash similar to
hashCode , but with the additional guarantee that is is stable across JVMs. |
String |
toString() |
FieldElement |
withSourceMappedInto(Source originalSource,
Source duplicateSource)
Replace the given duplicate source with the given original source everywhere that it occurs in this element,
including in ancestor sources of this element's source.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
combineHashes, iterablePlanHash, objectPlanHash, objectsPlanHash, planHash, planHash, planHashUnordered, stringHashUnordered
@Nonnull public FieldElement withSourceMappedInto(@Nonnull Source originalSource, @Nonnull Source duplicateSource)
Element
originalSource
- a source to replace all occurrences of the duplicate source withduplicateSource
- a source to replace with the original source@Nonnull public Optional<ComparisonRange> matchWith(@Nonnull ComparisonRange existingComparisons, @Nonnull ElementPredicate predicate)
Element
ElementPredicate
, under the assumption
that this element is already being used to satisfy the given ComparisonRange
. Note that this method
relies on strict comparisons between elements, i.e., the sources must be reference-equal to each other.existingComparisons
- a range of existing comparisons that the planner is using this element to supportpredicate
- an element predicate to match with this element and the given comparison rangeOptional.empty()
otherwise@Nonnull public Optional<ViewExpressionComparisons> matchSourcesWith(@Nonnull ViewExpressionComparisons viewExpressionComparisons, @Nonnull Element element)
Element
Element
when unused sources are combined with
each other. Sources are determined to be used or unused based on their usage in the given
ViewExpressionComparisons
. A source is used if any element using that source has a comparison already
matched to it; otherwise, it is unused. If an available match is found, produce a version of the given
ViewExpressionComparisons
with all instances of this element's source replaced with the given element's
source.
This method makes it possible to match ElementPredicate
s generated by normalizing a
QueryComponent
with those generated by normalizing a
KeyExpression
. These normalization processes are
decoupled so the sources for each will not match in general; therefore, Element.matchWith(ComparisonRange, ElementPredicate)
will fail to notice when an index defined by a KeyExpression
can support a predicate.
viewExpressionComparisons
- view expression comparisons that determine which sources are used and unusedelement
- an element to compare with this one and look for matches made through combining sourcesOptional.empty()
otherwise@Nullable public Object eval(@Nonnull SourceEntry sourceEntry)
Element
Comparisons.Comparison
.sourceEntry
- a source entry to use when evaluating this elementpublic int planHash()
PlanHashable
hashCode
, but with the additional guarantee that is is stable across JVMs.public Set<Source> getAncestralSources()
Element
getAncestralSources
in interface Element