Class Source
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.view.Source
-
- Direct Known Subclasses:
RecordTypeSource
,RepeatedFieldSource
@API(EXPERIMENTAL) public abstract class Source extends Object
A source represents a stream of entities that can be used to generateElement
s, such as records or field values.Sources can stand alone or be derived from other sources. By combining sources, complex streams of values derived from stored information can be described and manipulated. For example:
- A
RecordTypeSource
represents the stream of all records of a particular record type. - A
RepeatedFieldSource
represents the stream of all (nested) values in a repeated field of a record.
Generally, a query or
ViewExpression
has a "root" source. This root source is not derived from another source and defines a stream of entries from which all other sources are derived.A source encapsulates the logic for generating and combining streams of data. For example, if there are two
RepeatedFieldSource
s derived from the sameRecordTypeSource
, the source encapsulates the implicit Cartesian product between the two. Similarly, it encapsulates the logic for checking whether or not a particular source has already been "used up" by the query planner.- See Also:
Element
,ViewExpression
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addDependentSource(Source source)
boolean
equals(Object other)
Override of equality to ensure that sources are compared using reference equality.protected abstract Stream<SourceEntry>
evalSourceEntriesFor(SourceEntry entry)
Produce the stream of source entries that this source represents, drawing the values for dependent sources from the given source entry if needed.Stream<SourceEntry>
evalSourceEntriesFor(MessageOrBuilder message)
Produce the stream of source entries that this source represents, drawing the value for the input of this source from the givenMessageOrBuilder
.abstract Set<Source>
getSources()
Get the set of all sources of ancestor's of this source, include this source itself.int
hashCode()
abstract boolean
supportsSourceIn(ViewExpressionComparisons comparisons, Source other)
Check whether this source can be replaced by the given source in the givenViewExpressionComparisons
.abstract Source
withSourceMappedInto(Source originalSource, Source duplicateSource)
Replace the given duplicate source with the given original source everywhere that it occurs in this source, including in ancestor sources.
-
-
-
Method Detail
-
getSources
public abstract Set<Source> getSources()
Get the set of all sources of ancestor's of this source, include this source itself.- Returns:
- a set of the sources of all (inclusive) ancestors of this source
-
supportsSourceIn
public abstract boolean supportsSourceIn(@Nonnull ViewExpressionComparisons comparisons, @Nonnull Source other)
Check whether this source can be replaced by the given source in the givenViewExpressionComparisons
. In general, this source can be replaced by the given source if and only if:- The sources match each other "structurally" (i.e., differ only in a pointer-equality sense).
- The elements with comparisons in the
ViewExpressionComparisons
do not use this source.
- Parameters:
comparisons
- a view expression comparisons that specifies which sources are used and unusedother
- a candidate replacement for this source- Returns:
- whether this source can be replaced by
other
- See Also:
withSourceMappedInto(Source, Source)
,Element.matchSourcesWith(ViewExpressionComparisons, Element)
-
withSourceMappedInto
@Nonnull public abstract Source withSourceMappedInto(@Nonnull Source originalSource, @Nonnull Source duplicateSource)
Replace the given duplicate source with the given original source everywhere that it occurs in this source, including in ancestor sources.- Parameters:
originalSource
- a source to replace all occurrences of the duplicate source withduplicateSource
- a source to replace with the original source- Returns:
- a copy of this source with all occurrences of the duplicate source replaced with the original source
-
evalSourceEntriesFor
@Nonnull protected abstract Stream<SourceEntry> evalSourceEntriesFor(@Nonnull SourceEntry entry)
Produce the stream of source entries that this source represents, drawing the values for dependent sources from the given source entry if needed.- Parameters:
entry
- a source entry to draw the input for this source from- Returns:
- a stream of source entries, each of which has a value associated with this source
-
evalSourceEntriesFor
public final Stream<SourceEntry> evalSourceEntriesFor(@Nonnull MessageOrBuilder message)
Produce the stream of source entries that this source represents, drawing the value for the input of this source from the givenMessageOrBuilder
.- Parameters:
message
- a message to use when evaluating this source- Returns:
- a stream of source entries, each of which has a value associated with this source
-
equals
public final boolean equals(Object other)
Override of equality to ensure that sources are compared using reference equality.
-
-