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 intMAX_UNIONstatic UnsupportedOperationExceptionTOO_MANY_UNION
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbindValue(String varName, PropertyValue value)QuerybuildAlternativeQuery()Try to convert the query to an alternative form, specially a "union".booleancontainsUnfilteredFullTextCondition()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')".QuerycopyOf()returns a clone of the current object.ResultImplexecuteQuery()SelectorExecutionPlangetBestSelectorExecutionPlan(FilterImpl filter)List<String>getBindVariableNames()PropertyValuegetBindVariableValue(String bindVariableName)intgetColumnIndex(String columnName)ColumnImpl[]getColumns()ConstraintImplgetConstraint()doublegetEstimatedCost()Get the estimated cost.ExecutionContextgetExecutionContext()StringgetIndexCostInfo()Get the index cost as a JSON string.Optional<Long>getLimit()NamePathMappergetNamePathMapper()StringgetOakPath(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()StringgetPlan()Get the query plan.QueryStatsData.QueryExecutionStatsgetQueryExecutionStats()QueryOptionsgetQueryOptions()Iterator<ResultRowImpl>getRows()intgetSelectorIndex(String selectorName)String[]getSelectorNames()QueryEngineSettingsgetSettings()longgetSize()Get the size if known.longgetSize(Result.SizePrecision precision, long max)Get the size if known.SourceImplgetSource()StringgetStatement()TreegetTree(String path)voidinit()Initialize the query.booleanisInit()booleanisInternal()booleanisMeasureOrExplainEnabled()booleanisPotentiallySlow()Whether the query is potentially slow.booleanisSortedByIndex()Returns whether the results will be sorted by index.voidprepare()Prepare the query.static longsaturatedAdd(long x, long y)Add two values, but don't let it overflow or underflow.voidsetDistinct(boolean distinct)voidsetExecutionContext(ExecutionContext context)voidsetExplain(boolean explain)voidsetInternal(boolean isInternal)voidsetLimit(long limit)voidsetMeasure(boolean measure)voidsetOffset(long offset)voidsetOrderings(OrderingImpl[] orderings)voidsetQueryOptions(QueryOptions options)Set the query option to be used for this query.voidsetTraversalEnabled(boolean traversalEnabled)StringtoString()voidverifyNotPotentiallySlow()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:QueryInitialize 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:
getColumnsin 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:
setExplainin interfaceQuery
-
setMeasure
public void setMeasure(boolean measure)
- Specified by:
setMeasurein interfaceQuery
-
setDistinct
public void setDistinct(boolean distinct)
-
executeQuery
public ResultImpl executeQuery()
- Specified by:
executeQueryin interfaceQuery
-
getRows
public Iterator<ResultRowImpl> getRows()
-
isSortedByIndex
public boolean isSortedByIndex()
Description copied from interface:QueryReturns whether the results will be sorted by index. The query must already be prepared.- Specified by:
isSortedByIndexin interfaceQuery- Returns:
- if sorted by index
-
getPlan
public String getPlan()
Description copied from interface:QueryGet the query plan. The query must already be prepared.
-
getIndexCostInfo
public String getIndexCostInfo()
Description copied from interface:QueryGet the index cost as a JSON string. The query must already be prepared.- Specified by:
getIndexCostInfoin interfaceQuery- Returns:
- the index cost
-
getEstimatedCost
public double getEstimatedCost()
Description copied from interface:QueryGet the estimated cost.- Specified by:
getEstimatedCostin interfaceQuery- Returns:
- the estimated cost
-
prepare
public void prepare()
Description copied from interface:QueryPrepare the query. The cost is estimated and the execution plan is decided here.
-
getSelectorIndex
public int getSelectorIndex(String selectorName)
- Specified by:
getSelectorIndexin interfaceQuery
-
getColumnIndex
public int getColumnIndex(String columnName)
- Specified by:
getColumnIndexin interfaceQuery
-
getBindVariableValue
public PropertyValue getBindVariableValue(String bindVariableName)
-
getSelectorNames
public String[] getSelectorNames()
- Specified by:
getSelectorNamesin interfaceQuery
-
getBindVariableNames
public List<String> getBindVariableNames()
- Specified by:
getBindVariableNamesin interfaceQuery
-
setTraversalEnabled
public void setTraversalEnabled(boolean traversalEnabled)
- Specified by:
setTraversalEnabledin interfaceQuery
-
setQueryOptions
public void setQueryOptions(QueryOptions options)
Description copied from interface:QuerySet the query option to be used for this query.- Specified by:
setQueryOptionsin interfaceQuery- Parameters:
options- the options
-
getBestSelectorExecutionPlan
public SelectorExecutionPlan getBestSelectorExecutionPlan(FilterImpl filter)
-
isPotentiallySlow
public boolean isPotentiallySlow()
Description copied from interface:QueryWhether the query is potentially slow. Only supported for prepared queries.- Specified by:
isPotentiallySlowin interfaceQuery- Returns:
- true if traversal is the only option
-
verifyNotPotentiallySlow
public void verifyNotPotentiallySlow()
Description copied from interface:QueryVerify the query is not potentially slow. Only supported for prepared queries.- Specified by:
verifyNotPotentiallySlowin interfaceQuery
-
setExecutionContext
public void setExecutionContext(ExecutionContext context)
- Specified by:
setExecutionContextin interfaceQuery
-
setOrderings
public void setOrderings(OrderingImpl[] orderings)
- Specified by:
setOrderingsin interfaceQuery
-
getNamePathMapper
public NamePathMapper getNamePathMapper()
-
isMeasureOrExplainEnabled
public boolean isMeasureOrExplainEnabled()
- Specified by:
isMeasureOrExplainEnabledin 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:QueryGet the size if known.
-
getSize
public long getSize(Result.SizePrecision precision, long max)
Description copied from interface:QueryGet the size if known.
-
getStatement
public String getStatement()
- Specified by:
getStatementin 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:
setInternalin 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:QueryTry 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:
buildAlternativeQueryin interfaceQuery- Returns:
thisif no conversions are possible or a new instance of aQuery. Cannot return null.
-
copyOf
public Query copyOf()
Description copied from interface:Queryreturns a clone of the current object. Will throw an exception in case it's invoked in a non appropriate moment. For example the default
QueryImplcannot be cloned once theQuery.init()has been executed.May return null if not implemented.
-
isInit
public boolean isInit()
-
isInternal
public boolean isInternal()
- Specified by:
isInternalin interfaceQuery- Returns:
trueif the current query is internal.falseotherwise.
-
containsUnfilteredFullTextCondition
public boolean containsUnfilteredFullTextCondition()
Description copied from interface:QueryWhether 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:
containsUnfilteredFullTextConditionin interfaceQuery- Returns:
- true if yes
-
getQueryOptions
public QueryOptions getQueryOptions()
-
getQueryExecutionStats
public QueryStatsData.QueryExecutionStats getQueryExecutionStats()
- Specified by:
getQueryExecutionStatsin interfaceQuery
-
-