Class SourceImpl
- java.lang.Object
-
- org.apache.jackrabbit.oak.query.ast.SourceImpl
-
- Direct Known Subclasses:
JoinImpl
,SelectorImpl
public abstract class SourceImpl extends Object
The base class of a selector and a join.
-
-
Constructor Summary
Constructors Constructor Description SourceImpl()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addJoinCondition(JoinConditionImpl joinCondition, boolean forThisSelector)
Add the join condition (the ON ...protected PropertyValue
convertValueToType(PropertyValue v, PropertyValue targetType)
@NotNull org.apache.jackrabbit.oak.query.ast.AstElement
copyOf()
abstract Filter
createFilter(boolean preparing)
!Test purpose only! this creates a filter for the given queryabstract void
execute(NodeState rootState)
Execute the query.SelectorImpl
getExistingSelector(String selectorName)
Get the selector with the given name, or fail if not found.abstract String
getIndexCostInfo(NodeState rootState)
Get the index cost as a JSON string.List<JoinConditionImpl>
getInnerJoinConditions()
Get the list of inner join conditions.abstract List<SourceImpl>
getInnerJoinSelectors()
Get all sources that are joined via inner join.protected String
getLocalPath(String path)
Calculate the session local path (the path excluding the workspace name) if possible.abstract String
getPlan(NodeState rootState)
Get the query plan.abstract SelectorImpl
getSelector(String selectorName)
Get the selector with the given name, or null if not found.abstract long
getSize(NodeState rootState, Result.SizePrecision precision, long max)
Get the size if known.abstract boolean
isOuterJoinRightHandSide()
Whether any selector is the outer-join right hand side.abstract boolean
next()
Go to the next node for the given source.protected String
normalizePath(String path)
Validate and normalize the path.protected String
normalizePropertyName(String propertyName)
Normalize the property name (including namespace remapping).abstract ExecutionPlan
prepare()
Prepare executing the query (recursively).abstract void
prepare(ExecutionPlan p)
Re-apply a previously prepared plan.protected String
protect(Object expression)
protected static String
quote(String pathOrName)
protected static String
quoteJson(String string)
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.void
setQuery(QueryImpl query)
abstract void
setQueryConstraint(ConstraintImpl queryConstraint)
Set the complete constraint of the query (the WHERE ...abstract void
unprepare()
Undo a prepare.
-
-
-
Field Detail
-
query
protected QueryImpl query
-
-
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 conditionforThisSelector
- 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 yesouterJoinRightHandSide
- true if yes
-
getSelector
public abstract SelectorImpl getSelector(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(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 String getPlan(NodeState rootState)
Get the query plan.- Parameters:
rootState
- the root- Returns:
- the query plan
-
getIndexCostInfo
public abstract 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 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 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 precisionmax
- the maximum nodes read (for an exact size)- Returns:
- the size, or -1 if unknown
-
setQuery
public void setQuery(QueryImpl query)
-
normalizePropertyName
protected String normalizePropertyName(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 String normalizePath(String path)
Validate and normalize the path.- Parameters:
path
- the path to validate- Returns:
- the validated and normalized path
-
convertValueToType
protected PropertyValue convertValueToType(PropertyValue v, PropertyValue targetType)
-
getLocalPath
protected String getLocalPath(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 tothis
.
-
-