Package org.apache.jackrabbit.oak.query
Interface Query
-
- All Known Implementing Classes:
QueryImpl
,UnionQueryImpl
@ProviderType public interface Query
A "select" or "union" query.Lifecycle: use the constructor to create a new object. Call init() to initialize the bind variable map. If the query is re-executed, a new instance is created.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
bindValue(String key, PropertyValue value)
@NotNull 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')".@Nullable Query
copyOf()
returns a clone of the current object.Result
executeQuery()
List<String>
getBindVariableNames()
int
getColumnIndex(String columnName)
ColumnImpl[]
getColumns()
double
getEstimatedCost()
Get the estimated cost.String
getIndexCostInfo()
Get the index cost as a JSON string.Optional<Long>
getLimit()
Optional<Long>
getOffset()
String
getPlan()
Get the query plan.QueryStatsData.QueryExecutionStats
getQueryExecutionStats()
Iterator<ResultRowImpl>
getRows()
int
getSelectorIndex(String selectorName)
String[]
getSelectorNames()
long
getSize()
Get the size if known.long
getSize(Result.SizePrecision precision, long max)
Get the size if known.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.void
setExecutionContext(ExecutionContext context)
void
setExplain(boolean explain)
void
setInternal(boolean internal)
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)
void
verifyNotPotentiallySlow()
Verify the query is not potentially slow.
-
-
-
Method Detail
-
setExecutionContext
void setExecutionContext(ExecutionContext context)
-
setLimit
void setLimit(long limit)
-
setOffset
void setOffset(long offset)
-
bindValue
void bindValue(String key, PropertyValue value)
-
setTraversalEnabled
void setTraversalEnabled(boolean traversalEnabled)
-
executeQuery
Result executeQuery()
-
getColumns
ColumnImpl[] getColumns()
-
getColumnIndex
int getColumnIndex(String columnName)
-
getSelectorNames
String[] getSelectorNames()
-
getSelectorIndex
int getSelectorIndex(String selectorName)
-
getRows
Iterator<ResultRowImpl> getRows()
-
getSize
long getSize()
Get the size if known.- Returns:
- the size, or -1 if unknown
-
getSize
long getSize(Result.SizePrecision precision, long max)
Get the size if known.- Parameters:
precision
- the required precisionmax
- the maximum nodes read (for an exact size)- Returns:
- the size, or -1 if unknown
-
setExplain
void setExplain(boolean explain)
-
setMeasure
void setMeasure(boolean measure)
-
setOrderings
void setOrderings(OrderingImpl[] orderings)
-
init
void init()
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.
-
prepare
void prepare()
Prepare the query. The cost is estimated and the execution plan is decided here.
-
getPlan
String getPlan()
Get the query plan. The query must already be prepared.- Returns:
- the query plan
-
getIndexCostInfo
String getIndexCostInfo()
Get the index cost as a JSON string. The query must already be prepared.- Returns:
- the index cost
-
getEstimatedCost
double getEstimatedCost()
Get the estimated cost.- Returns:
- the estimated cost
-
isMeasureOrExplainEnabled
boolean isMeasureOrExplainEnabled()
-
setInternal
void setInternal(boolean internal)
-
isSortedByIndex
boolean isSortedByIndex()
Returns whether the results will be sorted by index. The query must already be prepared.- Returns:
- if sorted by index
-
buildAlternativeQuery
@NotNull @NotNull Query buildAlternativeQuery()
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 theinit()
.- Returns:
this
if no conversions are possible or a new instance of aQuery
. Cannot return null.
-
copyOf
@Nullable @Nullable Query copyOf() throws IllegalStateException
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 theinit()
has been executed.May return null if not implemented.
- Returns:
- a clone of self
- Throws:
IllegalStateException
-
isInit
boolean isInit()
- Returns:
true
if the query has been already initialised.false
otherwise.
-
getStatement
String getStatement()
- Returns:
- the original statement as it was used to construct the object. If not provided the toString() will be used instead.
-
isInternal
boolean isInternal()
- Returns:
true
if the current query is internal.false
otherwise.
-
containsUnfilteredFullTextCondition
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
-
setQueryOptions
void setQueryOptions(QueryOptions options)
Set the query option to be used for this query.- Parameters:
options
- the options
-
isPotentiallySlow
boolean isPotentiallySlow()
Whether the query is potentially slow. Only supported for prepared queries.- Returns:
- true if traversal is the only option
-
verifyNotPotentiallySlow
void verifyNotPotentiallySlow()
Verify the query is not potentially slow. Only supported for prepared queries.- Throws:
IllegalArgumentException
- if potentially slow, and configured to fail in this case
-
getQueryExecutionStats
QueryStatsData.QueryExecutionStats getQueryExecutionStats()
-
-