Class ValueElement

  • All Implemented Interfaces:
    PlanHashable, Element

    @API(EXPERIMENTAL)
    public class ValueElement
    extends Object
    An Element representing an entire value, such as a scalar or message, obtained from a source.

    For example, the integer values from a RepeatedFieldSource on a record's repeated integer field would be represented by a ValueElement.

    • Constructor Detail

    • Method Detail

      • matchWith

        @Nonnull
        public Optional<ComparisonRange> matchWith​(@Nonnull
                                                   ComparisonRange existingComparisons,
                                                   @Nonnull
                                                   ElementPredicate predicate)
        Description copied from interface: Element
        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. Note that this method relies on strict comparisons between elements, i.e., the sources must be reference-equal to each other.
        Parameters:
        existingComparisons - a range of existing comparisons that the planner is using this element to support
        predicate - an element predicate to match with this element and the given comparison range
        Returns:
        a new comparison range incorporating the predicate's comparison if the match was successful, Optional.empty() otherwise
      • matchSourcesWith

        @Nonnull
        public Optional<ViewExpressionComparisons> matchSourcesWith​(@Nonnull
                                                                    ViewExpressionComparisons viewExpressionComparisons,
                                                                    @Nonnull
                                                                    Element element)
        Description copied from interface: Element
        Determine whether this element is the same as the given 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 ElementPredicates 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.

        Parameters:
        viewExpressionComparisons - view expression comparisons that determine which sources are used and unused
        element - an element to compare with this one and look for matches made through combining sources
        Returns:
        a new view expression comparisons with instances of this element's source replaced with the given element's if a match is found, Optional.empty() otherwise
      • withSourceMappedInto

        @Nonnull
        public Element withSourceMappedInto​(@Nonnull
                                            Source originalSource,
                                            @Nonnull
                                            Source duplicateSource)
        Description copied from interface: Element
        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.
        Parameters:
        originalSource - a source to replace all occurrences of the duplicate source with
        duplicateSource - a source to replace with the original source
        Returns:
        a copy of this element with all occurrences of the duplicate source replaced with the original source
      • eval

        @Nullable
        public Object eval​(@Nonnull
                           SourceEntry sourceEntry)
        Description copied from interface: Element
        Evaluate this element with respect to the given source entry, producing an object that can be interpreted by a Comparisons.Comparison.
        Parameters:
        sourceEntry - a source entry to use when evaluating this element
        Returns:
        the value of this element on the given source entry
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • planHash

        public int planHash()
        Description copied from interface: PlanHashable
        Return a hash similar to hashCode, but with the additional guarantee that is is stable across JVMs.
        Returns:
        a stable hash code
      • getAncestralSources

        public Set<Source> getAncestralSources()
        Description copied from interface: Element
        Get the set of all sources for this element, including all ancestors of this element's sources.
        Specified by:
        getAncestralSources in interface Element
        Returns:
        a set of the sources of all (inclusive) ancestors of this element's sources