public class OjaiQuery
extends java.lang.Object
implements org.ojai.store.Query
| Modifier and Type | Field and Description |
|---|---|
static com.google.common.base.Equivalence<OjaiQuery> |
EQUIVALENCE |
static long |
LIMIT_NONE
Special value that indicates no limit has been set.
|
static int |
MAX_CLIENT_SORT_LIMIT |
static long |
OFFSET_NONE
Special value that indicates no offset has been set.
|
static long |
TIMEOUT_NONE
Special value that indicates no timeout has been set.
|
| Constructor and Description |
|---|
OjaiQuery(org.ojai.store.Query theQuery)
Copy Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
OjaiQuery |
build() |
java.lang.String |
buildSqlString(java.lang.String engineName,
java.lang.String tableName) |
org.ojai.DocumentStream |
createDrillStream(OjaiConnection ojaiConnection,
SharedTable sharedTable,
QueryContext queryContext) |
org.ojai.DocumentStream |
decorateStream(org.ojai.DocumentStream docStream,
OjaiConnection ojaiConnection,
boolean isIndexSorted,
java.util.List<org.ojai.FieldPath> sortLimitExtras,
SharedResource<com.mapr.db.impl.BaseJsonTable> sharedTable)
Adds final post-processing steps to a DocumentStream based on query options such as limit and offset.
|
com.mapr.db.impl.ConditionImpl |
getCondition()
Get the query condition.
|
java.util.List<EligibleIndex> |
getEligibleIndexes(com.mapr.db.Admin admin,
org.apache.hadoop.fs.Path tablePath,
SharedTable sharedPrimaryTable,
OjaiConnection ojaiConnection) |
com.mapr.db.index.IndexFieldDesc.Order |
getFieldOrdering(org.ojai.FieldPath fieldPath)
Get the Order for a sort key element.
|
boolean |
getForceDirect() |
boolean |
getForceDrill() |
boolean |
getForceNonCoveringSort() |
java.lang.String |
getIndexHint()
Get the index hint, if any.
|
long |
getLimit()
Returns the limit.
|
long |
getOffset()
Returns the offset.
|
java.lang.Object |
getOption(java.lang.String optionName) |
org.ojai.Document |
getOptions()
Allow other parts of the implementation to see the current options.
|
java.util.Set<org.ojai.FieldPath> |
getOrderByFields() |
java.util.Set<org.ojai.FieldPath> |
getProjectedFieldSet() |
double |
getRowCpuIoRatio() |
org.ojai.store.QueryCondition |
getScanCondition(OjaiConnection ojaiConnection,
EligibleIndex eligibleIndex) |
org.ojai.FieldPath[] |
getSelectListAsArray() |
java.util.List<org.ojai.FieldPath> |
getSortLimitExtras()
Return the list of extra fields that would be required in order to perform
a client-side sort for a sort limit case.
|
boolean |
hasCondition()
Indicate if the query has a condition or not.
|
boolean |
hasOrderBy() |
boolean |
hasProjectionWithArrayIndex() |
boolean |
includeId()
Indicates whether or not we should include the id field in the result.
|
boolean |
isIdIn()
Determines if the query is of the form "_id in (x, y, ...)"; also
recognizes "_id = x or _id = y or ..." for any number of ids.
|
boolean |
isPossiblyNeedProjection() |
boolean |
isSortLimit()
Indicates that the query has both a sort and a limit, and that the limit
is within the maximum allowed for a client-side sort.
|
boolean |
isSortOnId()
Returns true if the sort (orderBy) is on _id ascending.
|
boolean |
isStarQuery() |
OjaiQuery |
limit(long limit) |
OjaiQuery |
offset(long offset) |
OjaiQuery |
orderBy(org.ojai.FieldPath... fieldPaths) |
OjaiQuery |
orderBy(org.ojai.FieldPath fieldPath,
org.ojai.store.SortOrder sortOrder) |
OjaiQuery |
orderBy(java.lang.String... stringPaths) |
OjaiQuery |
orderBy(java.lang.String field,
org.ojai.store.SortOrder order) |
OjaiQuery |
orderBy(java.lang.String field,
java.lang.String order) |
OjaiQuery |
select(org.ojai.FieldPath... fieldPaths) |
OjaiQuery |
select(java.lang.String... fieldPaths) |
OjaiQuery |
setOption(java.lang.String optionName,
java.lang.Object value) |
OjaiQuery |
setOptions(org.ojai.Document options) |
OjaiQuery |
setTimeout(long timeoutInMilliseconds) |
boolean |
structuralEquals(OjaiQuery otherQuery)
Determines if two queries are structurally equal.
|
int |
structuralHashCode()
Computes the structural hashCode() for the query.
|
OjaiQuery |
waitForTrackedWrites(java.lang.String writesContext) |
OjaiQuery |
where(org.ojai.store.QueryCondition queryCond) |
OjaiQuery |
where(java.lang.String conditionJson) |
public static final long LIMIT_NONE
public static final int MAX_CLIENT_SORT_LIMIT
public static final long OFFSET_NONE
public static final com.google.common.base.Equivalence<OjaiQuery> EQUIVALENCE
public static final long TIMEOUT_NONE
public OjaiQuery(org.ojai.store.Query theQuery)
theQuery - original querypublic long getLimit()
LIMIT_NONE to indicate that no limit has been set.public long getOffset()
OFFSET_NONE to indicate that no offset has been set.public boolean hasCondition()
public com.mapr.db.impl.ConditionImpl getCondition()
hasCondition().public org.ojai.FieldPath[] getSelectListAsArray()
public OjaiQuery setOption(java.lang.String optionName, java.lang.Object value) throws java.lang.IllegalArgumentException
setOption in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic java.lang.Object getOption(java.lang.String optionName)
getOption in interface org.ojai.store.Querypublic OjaiQuery setOptions(org.ojai.Document options) throws java.lang.IllegalArgumentException
setOptions in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic org.ojai.Document getOptions()
public OjaiQuery select(java.lang.String... fieldPaths) throws java.lang.IllegalArgumentException
select in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic OjaiQuery select(org.ojai.FieldPath... fieldPaths) throws java.lang.IllegalArgumentException
select in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic OjaiQuery where(java.lang.String conditionJson) throws org.ojai.exceptions.OjaiException, java.lang.IllegalArgumentException
where in interface org.ojai.store.Queryorg.ojai.exceptions.OjaiExceptionjava.lang.IllegalArgumentExceptionpublic OjaiQuery where(org.ojai.store.QueryCondition queryCond) throws org.ojai.exceptions.OjaiException, java.lang.IllegalArgumentException
where in interface org.ojai.store.Queryorg.ojai.exceptions.OjaiExceptionjava.lang.IllegalArgumentExceptionpublic OjaiQuery orderBy(java.lang.String... stringPaths) throws java.lang.IllegalArgumentException
orderBy in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic OjaiQuery orderBy(org.ojai.FieldPath... fieldPaths) throws java.lang.IllegalArgumentException
orderBy in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic OjaiQuery orderBy(java.lang.String field, java.lang.String order) throws java.lang.IllegalArgumentException
orderBy in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic OjaiQuery orderBy(java.lang.String field, org.ojai.store.SortOrder order) throws java.lang.IllegalArgumentException
orderBy in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic OjaiQuery orderBy(org.ojai.FieldPath fieldPath, org.ojai.store.SortOrder sortOrder) throws java.lang.IllegalArgumentException
orderBy in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic OjaiQuery offset(long offset) throws java.lang.IllegalArgumentException
offset in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic OjaiQuery limit(long limit) throws java.lang.IllegalArgumentException
limit in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic java.lang.String buildSqlString(java.lang.String engineName,
java.lang.String tableName)
public boolean isIdIn()
public boolean structuralEquals(OjaiQuery otherQuery)
otherQuery - the other querypublic int structuralHashCode()
#isStructurallyEqual(OjaiQuery)public boolean isSortOnId()
public java.util.List<org.ojai.FieldPath> getSortLimitExtras()
public java.util.List<EligibleIndex> getEligibleIndexes(com.mapr.db.Admin admin, org.apache.hadoop.fs.Path tablePath, SharedTable sharedPrimaryTable, OjaiConnection ojaiConnection) throws java.io.IOException
java.io.IOExceptionpublic org.ojai.store.QueryCondition getScanCondition(OjaiConnection ojaiConnection, EligibleIndex eligibleIndex)
public java.util.Set<org.ojai.FieldPath> getProjectedFieldSet()
public boolean isStarQuery()
public boolean isPossiblyNeedProjection()
public OjaiQuery waitForTrackedWrites(java.lang.String writesContext) throws java.lang.IllegalArgumentException
waitForTrackedWrites in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic org.ojai.DocumentStream decorateStream(org.ojai.DocumentStream docStream,
OjaiConnection ojaiConnection,
boolean isIndexSorted,
java.util.List<org.ojai.FieldPath> sortLimitExtras,
SharedResource<com.mapr.db.impl.BaseJsonTable> sharedTable)
docStream - the DocumentStream to decorateojaiConnection - the OjaiConnectionisIndexSorted - is the index being used usable for the sort, if any?sortLimitExtras - any extra fields that were added to the select list if a sort limit is donepublic org.ojai.DocumentStream createDrillStream(OjaiConnection ojaiConnection, SharedTable sharedTable, QueryContext queryContext)
public double getRowCpuIoRatio()
public java.lang.String getIndexHint()
public boolean getForceNonCoveringSort()
public boolean getForceDrill()
public boolean getForceDirect()
public OjaiQuery setTimeout(long timeoutInMilliseconds) throws java.lang.IllegalArgumentException
setTimeout in interface org.ojai.store.Queryjava.lang.IllegalArgumentExceptionpublic boolean isSortLimit()
public OjaiQuery build()
build in interface org.ojai.Buildablebuild in interface org.ojai.store.Querypublic boolean includeId()
public boolean hasOrderBy()
public java.util.Set<org.ojai.FieldPath> getOrderByFields()
public com.mapr.db.index.IndexFieldDesc.Order getFieldOrdering(org.ojai.FieldPath fieldPath)
fieldPath - the sort key elementpublic boolean hasProjectionWithArrayIndex()