Package org.apache.jackrabbit.oak.query
Class QueryImpl
- java.lang.Object
-
- org.apache.jackrabbit.oak.query.QueryImpl
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_UNION
static UnsupportedOperationException
TOO_MANY_UNION
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindValue(String varName, PropertyValue value)
Query
buildAlternativeQuery()
Try to convert the query to an alternative form, specially a "union".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')".Query
copyOf()
returns a clone of the current object.ResultImpl
executeQuery()
SelectorExecutionPlan
getBestSelectorExecutionPlan(FilterImpl filter)
List<String>
getBindVariableNames()
PropertyValue
getBindVariableValue(String bindVariableName)
int
getColumnIndex(String columnName)
ColumnImpl[]
getColumns()
ConstraintImpl
getConstraint()
double
getEstimatedCost()
Get the estimated cost.ExecutionContext
getExecutionContext()
String
getIndexCostInfo()
Get the index cost as a JSON string.Optional<Long>
getLimit()
NamePathMapper
getNamePathMapper()
String
getOakPath(String path)
Validate the path is syntactically correct, and convert it to an Oak internal path (including namespace remapping if needed).Optional<Long>
getOffset()
OrderingImpl[]
getOrderings()
String
getPlan()
Get the query plan.QueryStatsData.QueryExecutionStats
getQueryExecutionStats()
QueryOptions
getQueryOptions()
Iterator<ResultRowImpl>
getRows()
int
getSelectorIndex(String selectorName)
String[]
getSelectorNames()
QueryEngineSettings
getSettings()
long
getSize()
Get the size if known.long
getSize(Result.SizePrecision precision, long max)
Get the size if known.SourceImpl
getSource()
String
getStatement()
Tree
getTree(String path)
void
init()
Initialize the query.boolean
isInit()
boolean
isInternal()
boolean
isMeasureOrExplainEnabled()
boolean
isPotentiallySlow()
Whether the query is potentially slow.boolean
isSortedByIndex()
Returns whether the results will be sorted by index.void
prepare()
Prepare the query.static long
saturatedAdd(long x, long y)
Add two values, but don't let it overflow or underflow.void
setDistinct(boolean distinct)
void
setExecutionContext(ExecutionContext context)
void
setExplain(boolean explain)
void
setInternal(boolean isInternal)
void
setLimit(long limit)
void
setMeasure(boolean measure)
void
setOffset(long offset)
void
setOrderings(OrderingImpl[] orderings)
void
setQueryOptions(QueryOptions options)
Set the query option to be used for this query.void
setTraversalEnabled(boolean traversalEnabled)
String
toString()
void
verifyNotPotentiallySlow()
Verify the query is not potentially slow.
-
-
-
Field Detail
-
TOO_MANY_UNION
public static final UnsupportedOperationException TOO_MANY_UNION
-
MAX_UNION
public static final int MAX_UNION
-
-
Method Detail
-
init
public void init()
Description copied from interface:Query
Initialize the query. This will 'wire' selectors into constraints, and collect bind variable names. It will also simplify expressions if possible, but will not prepare the query.
-
getColumns
public ColumnImpl[] getColumns()
- Specified by:
getColumns
in interfaceQuery
-
getConstraint
public ConstraintImpl getConstraint()
-
getOrderings
public OrderingImpl[] getOrderings()
-
getSource
public SourceImpl getSource()
-
bindValue
public void bindValue(String varName, PropertyValue value)
-
setExplain
public void setExplain(boolean explain)
- Specified by:
setExplain
in interfaceQuery
-
setMeasure
public void setMeasure(boolean measure)
- Specified by:
setMeasure
in interfaceQuery
-
setDistinct
public void setDistinct(boolean distinct)
-
executeQuery
public ResultImpl executeQuery()
- Specified by:
executeQuery
in interfaceQuery
-
getRows
public Iterator<ResultRowImpl> getRows()
-
isSortedByIndex
public boolean isSortedByIndex()
Description copied from interface:Query
Returns whether the results will be sorted by index. The query must already be prepared.- Specified by:
isSortedByIndex
in interfaceQuery
- Returns:
- if sorted by index
-
getPlan
public String getPlan()
Description copied from interface:Query
Get the query plan. The query must already be prepared.
-
getIndexCostInfo
public String getIndexCostInfo()
Description copied from interface:Query
Get the index cost as a JSON string. The query must already be prepared.- Specified by:
getIndexCostInfo
in interfaceQuery
- Returns:
- the index cost
-
getEstimatedCost
public double getEstimatedCost()
Description copied from interface:Query
Get the estimated cost.- Specified by:
getEstimatedCost
in interfaceQuery
- Returns:
- the estimated cost
-
prepare
public void prepare()
Description copied from interface:Query
Prepare the query. The cost is estimated and the execution plan is decided here.
-
getSelectorIndex
public int getSelectorIndex(String selectorName)
- Specified by:
getSelectorIndex
in interfaceQuery
-
getColumnIndex
public int getColumnIndex(String columnName)
- Specified by:
getColumnIndex
in interfaceQuery
-
getBindVariableValue
public PropertyValue getBindVariableValue(String bindVariableName)
-
getSelectorNames
public String[] getSelectorNames()
- Specified by:
getSelectorNames
in interfaceQuery
-
getBindVariableNames
public List<String> getBindVariableNames()
- Specified by:
getBindVariableNames
in interfaceQuery
-
setTraversalEnabled
public void setTraversalEnabled(boolean traversalEnabled)
- Specified by:
setTraversalEnabled
in interfaceQuery
-
setQueryOptions
public void setQueryOptions(QueryOptions options)
Description copied from interface:Query
Set the query option to be used for this query.- Specified by:
setQueryOptions
in interfaceQuery
- Parameters:
options
- the options
-
getBestSelectorExecutionPlan
public SelectorExecutionPlan getBestSelectorExecutionPlan(FilterImpl filter)
-
isPotentiallySlow
public boolean isPotentiallySlow()
Description copied from interface:Query
Whether the query is potentially slow. Only supported for prepared queries.- Specified by:
isPotentiallySlow
in interfaceQuery
- Returns:
- true if traversal is the only option
-
verifyNotPotentiallySlow
public void verifyNotPotentiallySlow()
Description copied from interface:Query
Verify the query is not potentially slow. Only supported for prepared queries.- Specified by:
verifyNotPotentiallySlow
in interfaceQuery
-
setExecutionContext
public void setExecutionContext(ExecutionContext context)
- Specified by:
setExecutionContext
in interfaceQuery
-
setOrderings
public void setOrderings(OrderingImpl[] orderings)
- Specified by:
setOrderings
in interfaceQuery
-
getNamePathMapper
public NamePathMapper getNamePathMapper()
-
isMeasureOrExplainEnabled
public boolean isMeasureOrExplainEnabled()
- Specified by:
isMeasureOrExplainEnabled
in interfaceQuery
-
getOakPath
public String getOakPath(String path)
Validate the path is syntactically correct, and convert it to an Oak internal path (including namespace remapping if needed).- Parameters:
path
- the path- Returns:
- the the converted path
-
getSize
public long getSize()
Description copied from interface:Query
Get the size if known.
-
getSize
public long getSize(Result.SizePrecision precision, long max)
Description copied from interface:Query
Get the size if known.
-
getStatement
public String getStatement()
- Specified by:
getStatement
in interfaceQuery
- Returns:
- the original statement as it was used to construct the object. If not provided the toString() will be used instead.
-
getSettings
public QueryEngineSettings getSettings()
-
setInternal
public void setInternal(boolean isInternal)
- Specified by:
setInternal
in interfaceQuery
-
getExecutionContext
public ExecutionContext getExecutionContext()
-
saturatedAdd
public static long saturatedAdd(long x, long y)
Add two values, but don't let it overflow or underflow.- Parameters:
x
- the first valuey
- the second value- Returns:
- the sum, or Long.MIN_VALUE for underflow, or Long.MAX_VALUE for overflow
-
buildAlternativeQuery
public Query buildAlternativeQuery()
Description copied from interface:Query
Try to convert the query to an alternative form, specially a "union". To avoid any potential error due to state variables perform the conversion before theQuery.init()
.- Specified by:
buildAlternativeQuery
in interfaceQuery
- Returns:
this
if no conversions are possible or a new instance of aQuery
. Cannot return null.
-
copyOf
public Query copyOf()
Description copied from interface:Query
returns a clone of the current object. Will throw an exception in case it's invoked in a non appropriate moment. For example the default
QueryImpl
cannot be cloned once theQuery.init()
has been executed.May return null if not implemented.
-
isInit
public boolean isInit()
-
isInternal
public boolean isInternal()
- Specified by:
isInternal
in interfaceQuery
- Returns:
true
if the current query is internal.false
otherwise.
-
containsUnfilteredFullTextCondition
public boolean containsUnfilteredFullTextCondition()
Description copied from interface:Query
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')".- Specified by:
containsUnfilteredFullTextCondition
in interfaceQuery
- Returns:
- true if yes
-
getQueryOptions
public QueryOptions getQueryOptions()
-
getQueryExecutionStats
public QueryStatsData.QueryExecutionStats getQueryExecutionStats()
- Specified by:
getQueryExecutionStats
in interfaceQuery
-
-