Class ConstraintImpl
- java.lang.Object
-
- org.apache.jackrabbit.oak.query.ast.ConstraintImpl
-
- Direct Known Subclasses:
AndImpl
,ChildNodeImpl
,ComparisonImpl
,DescendantNodeImpl
,FullTextSearchImpl
,InImpl
,NativeFunctionImpl
,NotImpl
,OrImpl
,PropertyExistenceImpl
,PropertyInexistenceImpl
,SameNodeImpl
,SimilarImpl
,SpellcheckImpl
,SuggestImpl
public abstract class ConstraintImpl extends Object
The base class for constraints.
-
-
Constructor Summary
Constructors Constructor Description ConstraintImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
containsUnfilteredFullTextCondition()
Whether the condition contains a fulltext condition that can not be applied to the filter, for example because it is part of an "or" condition of the form "where a=1 or contains(., 'x')".@NotNull Set<ConstraintImpl>
convertToUnion()
Compute a set of sub-constraints that could be used for composing UNION statements.protected PropertyValue
convertValueToType(PropertyValue v, PropertyValue targetType)
@NotNull org.apache.jackrabbit.oak.query.ast.AstElement
copyOf()
boolean
equals(Object other)
abstract boolean
evaluate()
Evaluate the result using the currently set values.boolean
evaluateStop()
Whether this condition will, from now on, always evaluate to false.FullTextExpression
getFullTextConstraint(SelectorImpl s)
Get the (combined) full-text constraint.protected String
getLocalPath(String path)
Calculate the session local path (the path excluding the workspace name) if possible.abstract Set<PropertyExistenceImpl>
getPropertyExistenceConditions()
Get the set of property existence conditions that can be derived for this condition.abstract Set<SelectorImpl>
getSelectors()
Get the set of selectors for the given condition.int
hashCode()
protected String
normalizePath(String path)
Validate and normalize the path.protected String
normalizePropertyName(String propertyName)
Normalize the property name (including namespace remapping).protected String
protect(Object expression)
protected String
quote(String pathOrName)
protected String
quoteJson(String string)
boolean
requiresFullTextIndex()
Whether the constraint contains a fulltext condition that requires using a fulltext index, because the condition can only be evaluated there.abstract void
restrict(FilterImpl f)
Apply the condition to the filter, further restricting the filter if possible.abstract void
restrictPushDown(SelectorImpl s)
Push as much of the condition down to this selector, further restricting the selector condition if possible.void
setQuery(QueryImpl query)
ConstraintImpl
simplify()
Simplify the expression if possible, for example by removing duplicate expressions.
-
-
-
Field Detail
-
query
protected QueryImpl query
-
-
Method Detail
-
simplify
public ConstraintImpl simplify()
Simplify the expression if possible, for example by removing duplicate expressions. For example, "x=1 or x=1" should be simplified to "x=1".- Returns:
- the simplified constraint, or "this" if it is not possible to simplify
-
evaluate
public abstract boolean evaluate()
Evaluate the result using the currently set values.- Returns:
- true if the constraint matches
-
evaluateStop
public boolean evaluateStop()
Whether this condition will, from now on, always evaluate to false. This is the case for example for full-text constraints if there is no full-text index (unless FullTextComparisonWithoutIndex is enabled). This will also allow is to add conditions that stop further processing for other reasons, similar to"WHERE ROWNUM < 10"
in Oracle.- Returns:
- true if further processing should be stopped
-
getPropertyExistenceConditions
public abstract Set<PropertyExistenceImpl> getPropertyExistenceConditions()
Get the set of property existence conditions that can be derived for this condition. For example, for the condition "x=1 or x=2", the property existence condition is "x is not null". For the condition "x=1 or y=2", there is no such condition. For the condition "x=1 and y=1", there are two (x is not null, and y is not null).- Returns:
- the common property existence condition (possibly empty)
-
getFullTextConstraint
public FullTextExpression getFullTextConstraint(SelectorImpl s)
Get the (combined) full-text constraint. For constraints of the form "contains(*, 'x') or contains(*, 'y')", the combined expression is returned. If there is none, null is returned. For constraints of the form "contains(*, 'x') or z=1", null is returned as the full-text index cannot be used in this case for filtering (as it might filter out the z=1 nodes).- Parameters:
s
- the selector- Returns:
- the full-text constraint, if there is any, or null if not
-
getSelectors
public abstract Set<SelectorImpl> getSelectors()
Get the set of selectors for the given condition.- Returns:
- the set of selectors (possibly empty)
-
restrict
public abstract void restrict(FilterImpl f)
Apply the condition to the filter, further restricting the filter if possible. This may also verify the data types are compatible, and that paths are valid.- Parameters:
f
- the filter
-
restrictPushDown
public abstract void restrictPushDown(SelectorImpl s)
Push as much of the condition down to this selector, further restricting the selector condition if possible. This is important for a join: for example, the query "select * from a inner join b on a.x=b.x where a.y=1 and b.y=1", the condition "a.y=1" can be pushed down to "a", and the condition "b.y=1" can be pushed down to "b". That means it is possible to use an index in this case.- Parameters:
s
- the selector
-
requiresFullTextIndex
public boolean requiresFullTextIndex()
Whether the constraint contains a fulltext condition that requires using a fulltext index, because the condition can only be evaluated there.- Returns:
- true if yes
-
containsUnfilteredFullTextCondition
public boolean containsUnfilteredFullTextCondition()
Whether the condition contains a fulltext condition that can not be applied to the filter, for example because it is part of an "or" condition of the form "where a=1 or contains(., 'x')".- Returns:
- true if yes
-
convertToUnion
@NotNull public @NotNull Set<ConstraintImpl> convertToUnion()
Compute a set of sub-constraints that could be used for composing UNION statements. For example in case of "c=1 or c=2", it will return to the caller[c=1, c=2]
. Those can be later on used for re-composing conditions.If it is not possible to convert to a union, it must return an empty set.
The default implementation in
convertToUnion()
always return an empty set.- Returns:
- the set of union constraints, if available, or an empty set if conversion is not possible
-
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
.
-
-