Class SourceImpl

  • Direct Known Subclasses:
    JoinImpl, SelectorImpl

    public abstract class SourceImpl
    extends java.lang.Object
    The base class of a selector and a join.
    • Constructor Detail

      • SourceImpl

        public SourceImpl()
    • Method Detail

      • setQueryConstraint

        public abstract void setQueryConstraint​(ConstraintImpl queryConstraint)
        Set the complete constraint of the query (the WHERE ... condition).
        Parameters:
        queryConstraint - the constraint
      • addJoinCondition

        public abstract void addJoinCondition​(JoinConditionImpl joinCondition,
                                              boolean forThisSelector)
        Add the join condition (the ON ... condition).
        Parameters:
        joinCondition - the join condition
        forThisSelector - if set, the join condition can only be evaluated when all previous selectors are executed.
      • setOuterJoin

        public abstract void setOuterJoin​(boolean outerJoinLeftHandSide,
                                          boolean outerJoinRightHandSide)
        Set whether this source is the left hand side or right hand side of a left outer join.
        Parameters:
        outerJoinLeftHandSide - true if yes
        outerJoinRightHandSide - true if yes
      • getSelector

        public abstract SelectorImpl getSelector​(java.lang.String selectorName)
        Get the selector with the given name, or null if not found.
        Parameters:
        selectorName - the selector name
        Returns:
        the selector, or null
      • getExistingSelector

        public SelectorImpl getExistingSelector​(java.lang.String selectorName)
        Get the selector with the given name, or fail if not found.
        Parameters:
        selectorName - the selector name
        Returns:
        the selector (never null)
      • getPlan

        public abstract java.lang.String getPlan​(NodeState rootState)
        Get the query plan.
        Parameters:
        rootState - the root
        Returns:
        the query plan
      • getIndexCostInfo

        public abstract java.lang.String getIndexCostInfo​(NodeState rootState)
        Get the index cost as a JSON string.
        Parameters:
        rootState - the root
        Returns:
        the cost
      • prepare

        public abstract ExecutionPlan prepare()
        Prepare executing the query (recursively). This will 'wire' the selectors with the join constraints, and decide which index to use.
        Returns:
        the execution plan
      • unprepare

        public abstract void unprepare()
        Undo a prepare.
      • prepare

        public abstract void prepare​(ExecutionPlan p)
        Re-apply a previously prepared plan. This will also 're-wire' the selectors with the join constraints
        Parameters:
        p - the plan to use
      • execute

        public abstract void execute​(NodeState rootState)
        Execute the query. The current node is set to before the first row.
        Parameters:
        rootState - root state of the given revision
      • next

        public abstract boolean next()
        Go to the next node for the given source. This will also filter the result for the right node type if required.
        Returns:
        true if there is a next row
      • createFilter

        public abstract Filter createFilter​(boolean preparing)
        !Test purpose only! this creates a filter for the given query
        Parameters:
        preparing - whether this this the prepare phase
        Returns:
        a new filter
      • getInnerJoinSelectors

        public abstract java.util.List<SourceImpl> getInnerJoinSelectors()
        Get all sources that are joined via inner join. (These can be swapped.)
        Returns:
        the list of selectors (sorted from left to right)
      • getInnerJoinConditions

        public java.util.List<JoinConditionImpl> getInnerJoinConditions()
        Get the list of inner join conditions. (These match the inner join selectors.)
        Returns:
        the list of join conditions
      • isOuterJoinRightHandSide

        public abstract boolean isOuterJoinRightHandSide()
        Whether any selector is the outer-join right hand side.
        Returns:
        true if there is any
      • getSize

        public abstract long getSize​(NodeState rootState,
                                     Result.SizePrecision precision,
                                     long max)
        Get the size if known.
        Parameters:
        rootState - the root node state (to initialize the cursor, if needed)
        precision - the required precision
        max - the maximum nodes read (for an exact size)
        Returns:
        the size, or -1 if unknown
      • protect

        protected java.lang.String protect​(java.lang.Object expression)
      • quote

        protected java.lang.String quote​(java.lang.String pathOrName)
      • quoteJson

        protected java.lang.String quoteJson​(java.lang.String string)
      • setQuery

        public void setQuery​(QueryImpl query)
      • normalizePropertyName

        protected java.lang.String normalizePropertyName​(java.lang.String propertyName)
        Normalize the property name (including namespace remapping). Asterisks are kept.
        Parameters:
        propertyName - the property name to normalize
        Returns:
        the normalized (oak-) property name
      • normalizePath

        protected java.lang.String normalizePath​(java.lang.String path)
        Validate and normalize the path.
        Parameters:
        path - the path to validate
        Returns:
        the validated and normalized path
      • getLocalPath

        protected java.lang.String getLocalPath​(java.lang.String path)
        Calculate the session local path (the path excluding the workspace name) if possible.
        Parameters:
        path - the absolute path
        Returns:
        the session local path, or null if not within this workspace
      • copyOf

        @NotNull
        public @NotNull org.apache.jackrabbit.oak.query.ast.AstElement copyOf()
        Returns:
        a clone of self. Default implementation in AstElement returns same reference to this.