Class SelectorImpl
- java.lang.Object
-
- org.apache.jackrabbit.oak.query.ast.SourceImpl
-
- org.apache.jackrabbit.oak.query.ast.SelectorImpl
-
public class SelectorImpl extends SourceImpl
A selector within a query.
-
-
Constructor Summary
Constructors Constructor Description SelectorImpl(NodeTypeInfo nodeTypeInfo, java.lang.String selectorName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addJoinCondition(JoinConditionImpl joinCondition, boolean forThisSelector)
Add the join condition (the ON ...protected PropertyValue
convertValueToType(PropertyValue v, PropertyValue targetType)
SourceImpl
copyOf()
FilterImpl
createFilter(boolean preparing)
Create the filter condition for planning or execution.PropertyValue
currentOakProperty(java.lang.String oakPropertyName)
Get the property value.java.lang.String
currentPath()
Get the current absolute Oak path (normalized).PropertyValue
currentProperty(java.lang.String propertyName)
The value for the given selector for the current node.PropertyValue
currentProperty(java.lang.String propertyName, int propertyType)
The value for the given selector for the current node, filtered by property type.@Nullable Tree
currentTree()
Get the tree at the current path.boolean
equals(java.lang.Object other)
void
execute(NodeState rootState)
Execute the query.SelectorExecutionPlan
getExecutionPlan()
java.lang.String
getIndexCostInfo(NodeState rootState)
Get the index cost as a JSON string.java.util.ArrayList<SourceImpl>
getInnerJoinSelectors()
Get all sources that are joined via inner join.protected java.lang.String
getLocalPath(java.lang.String path)
Calculate the session local path (the path excluding the workspace name) if possible.@NotNull java.util.Set<java.lang.String>
getMixinTypes()
java.lang.String
getNodeType()
java.lang.String
getPlan(NodeState rootState)
Get the query plan.@NotNull java.util.Set<java.lang.String>
getPrimaryTypes()
QueryImpl
getQuery()
long
getScanCount()
SelectorImpl
getSelector(java.lang.String selectorName)
Get the selector with the given name, or null if not found.java.util.List<ConstraintImpl>
getSelectorConstraints()
java.lang.String
getSelectorName()
long
getSize(NodeState rootState, Result.SizePrecision precision, long max)
Get the size if known.@NotNull java.util.Set<java.lang.String>
getSupertypes()
java.lang.Iterable<java.lang.String>
getWildcardColumns()
int
hashCode()
boolean
isOuterJoinRightHandSide()
Whether any selector is the outer-join right hand side.boolean
isPrepared()
boolean
isVirtualRow()
boolean
matchesAllTypes()
boolean
next()
Go to the next node for the given source.protected java.lang.String
normalizePath(java.lang.String path)
Validate and normalize the path.protected java.lang.String
normalizePropertyName(java.lang.String propertyName)
Normalize the property name (including namespace remapping).ExecutionPlan
prepare()
Prepare executing the query (recursively).void
prepare(ExecutionPlan p)
Re-apply a previously prepared plan.protected java.lang.String
protect(java.lang.Object expression)
protected java.lang.String
quote(java.lang.String pathOrName)
protected java.lang.String
quoteJson(java.lang.String string)
void
restrictSelector(ConstraintImpl constraint)
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)
void
setQueryConstraint(ConstraintImpl queryConstraint)
Set the complete constraint of the query (the WHERE ...java.lang.String
toString()
void
unprepare()
Undo a prepare.-
Methods inherited from class org.apache.jackrabbit.oak.query.ast.SourceImpl
getExistingSelector, getInnerJoinConditions
-
-
-
-
Field Detail
-
query
protected QueryImpl query
-
-
Constructor Detail
-
SelectorImpl
public SelectorImpl(NodeTypeInfo nodeTypeInfo, java.lang.String selectorName)
-
-
Method Detail
-
getSelectorName
public java.lang.String getSelectorName()
-
getNodeType
public java.lang.String getNodeType()
-
matchesAllTypes
public boolean matchesAllTypes()
-
getSupertypes
@NotNull public @NotNull java.util.Set<java.lang.String> getSupertypes()
- Returns:
- all of the matching supertypes, or empty if the
matchesAllTypes
flag is set
-
getPrimaryTypes
@NotNull public @NotNull java.util.Set<java.lang.String> getPrimaryTypes()
- Returns:
- all of the matching primary subtypes, or empty if the
matchesAllTypes
flag is set
-
getMixinTypes
@NotNull public @NotNull java.util.Set<java.lang.String> getMixinTypes()
- Returns:
- all of the matching mixin types, or empty if the
matchesAllTypes
flag is set
-
getWildcardColumns
public java.lang.Iterable<java.lang.String> getWildcardColumns()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isPrepared
public boolean isPrepared()
-
unprepare
public void unprepare()
Description copied from class:SourceImpl
Undo a prepare.- Specified by:
unprepare
in classSourceImpl
-
prepare
public void prepare(ExecutionPlan p)
Description copied from class:SourceImpl
Re-apply a previously prepared plan. This will also 're-wire' the selectors with the join constraints- Specified by:
prepare
in classSourceImpl
- Parameters:
p
- the plan to use
-
prepare
public ExecutionPlan prepare()
Description copied from class:SourceImpl
Prepare executing the query (recursively). This will 'wire' the selectors with the join constraints, and decide which index to use.- Specified by:
prepare
in classSourceImpl
- Returns:
- the execution plan
-
getExecutionPlan
public SelectorExecutionPlan getExecutionPlan()
-
setQueryConstraint
public void setQueryConstraint(ConstraintImpl queryConstraint)
Description copied from class:SourceImpl
Set the complete constraint of the query (the WHERE ... condition).- Specified by:
setQueryConstraint
in classSourceImpl
- Parameters:
queryConstraint
- the constraint
-
setOuterJoin
public void setOuterJoin(boolean outerJoinLeftHandSide, boolean outerJoinRightHandSide)
Description copied from class:SourceImpl
Set whether this source is the left hand side or right hand side of a left outer join.- Specified by:
setOuterJoin
in classSourceImpl
- Parameters:
outerJoinLeftHandSide
- true if yesouterJoinRightHandSide
- true if yes
-
addJoinCondition
public void addJoinCondition(JoinConditionImpl joinCondition, boolean forThisSelector)
Description copied from class:SourceImpl
Add the join condition (the ON ... condition).- Specified by:
addJoinCondition
in classSourceImpl
- Parameters:
joinCondition
- the join conditionforThisSelector
- if set, the join condition can only be evaluated when all previous selectors are executed.
-
execute
public void execute(NodeState rootState)
Description copied from class:SourceImpl
Execute the query. The current node is set to before the first row.- Specified by:
execute
in classSourceImpl
- Parameters:
rootState
- root state of the given revision
-
getPlan
public java.lang.String getPlan(NodeState rootState)
Description copied from class:SourceImpl
Get the query plan.- Specified by:
getPlan
in classSourceImpl
- Parameters:
rootState
- the root- Returns:
- the query plan
-
getIndexCostInfo
public java.lang.String getIndexCostInfo(NodeState rootState)
Description copied from class:SourceImpl
Get the index cost as a JSON string.- Specified by:
getIndexCostInfo
in classSourceImpl
- Parameters:
rootState
- the root- Returns:
- the cost
-
createFilter
public FilterImpl createFilter(boolean preparing)
Create the filter condition for planning or execution.- Specified by:
createFilter
in classSourceImpl
- Parameters:
preparing
- whether a filter for the prepare phase should be made- Returns:
- the filter
-
next
public boolean next()
Description copied from class:SourceImpl
Go to the next node for the given source. This will also filter the result for the right node type if required.- Specified by:
next
in classSourceImpl
- Returns:
- true if there is a next row
-
currentPath
public java.lang.String currentPath()
Get the current absolute Oak path (normalized).- Returns:
- the path
-
currentTree
@Nullable public @Nullable Tree currentTree()
Get the tree at the current path.- Returns:
- the current tree, or null
-
currentProperty
public PropertyValue currentProperty(java.lang.String propertyName)
The value for the given selector for the current node.- Parameters:
propertyName
- the JCR (not normalized) property name- Returns:
- the property value
-
currentProperty
public PropertyValue currentProperty(java.lang.String propertyName, int propertyType)
The value for the given selector for the current node, filtered by property type.- Parameters:
propertyName
- the JCR (not normalized) property namepropertyType
- only include properties of this type- Returns:
- the property value (possibly null)
-
currentOakProperty
public PropertyValue currentOakProperty(java.lang.String oakPropertyName)
Get the property value. The property name may be relative. The special property names "jcr:path", "jcr:score" and "rep:excerpt" are supported.- Parameters:
oakPropertyName
- (must already be normalized)- Returns:
- the property value or null if not found
-
isVirtualRow
public boolean isVirtualRow()
-
getSelector
public SelectorImpl getSelector(java.lang.String selectorName)
Description copied from class:SourceImpl
Get the selector with the given name, or null if not found.- Specified by:
getSelector
in classSourceImpl
- Parameters:
selectorName
- the selector name- Returns:
- the selector, or null
-
getScanCount
public long getScanCount()
-
restrictSelector
public void restrictSelector(ConstraintImpl constraint)
-
getSelectorConstraints
public java.util.List<ConstraintImpl> getSelectorConstraints()
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getInnerJoinSelectors
public java.util.ArrayList<SourceImpl> getInnerJoinSelectors()
Description copied from class:SourceImpl
Get all sources that are joined via inner join. (These can be swapped.)- Specified by:
getInnerJoinSelectors
in classSourceImpl
- Returns:
- the list of selectors (sorted from left to right)
-
isOuterJoinRightHandSide
public boolean isOuterJoinRightHandSide()
Description copied from class:SourceImpl
Whether any selector is the outer-join right hand side.- Specified by:
isOuterJoinRightHandSide
in classSourceImpl
- Returns:
- true if there is any
-
getQuery
public QueryImpl getQuery()
-
getSize
public long getSize(NodeState rootState, Result.SizePrecision precision, long max)
Description copied from class:SourceImpl
Get the size if known.- Specified by:
getSize
in classSourceImpl
- 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
-
copyOf
public SourceImpl copyOf()
- Returns:
- a clone of self. Default implementation in
AstElement
returns same reference tothis
.
-
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
-
convertValueToType
protected PropertyValue convertValueToType(PropertyValue v, PropertyValue targetType)
-
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
-
-