Package org.apache.ignite.cache.query
Class IndexQuery<K,V>
- java.lang.Object
-
- org.apache.ignite.cache.query.Query<javax.cache.Cache.Entry<K,V>>
-
- org.apache.ignite.cache.query.IndexQuery<K,V>
-
- All Implemented Interfaces:
Serializable
public final class IndexQuery<K,V> extends Query<javax.cache.Cache.Entry<K,V>>
Index queries work over distributed indexes and retrieve cache entries that match the specified criteria.QueryCursordelivers sorted cache entries by the order defined for queried index.IndexQueryhas to be initialized with cache value class or type. The algorithm of discovering index is as follows:- If
idxNameis set, then use it. - If
idxNameis not set, then find an index that matches criteria fields. - If neither
idxName, norsetCriteria(List)is used, then perform index scan over PK index for specified Value type.
criteriahas to represent a valid range to traverse the index tree.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.cache.query.Query
DFLT_PAGE_SIZE
-
-
Constructor Summary
Constructors Constructor Description IndexQuery(Class<?> valCls)Specify index with cache value class.IndexQuery(Class<?> valCls, @Nullable String idxName)Specify index with cache value class and index name.IndexQuery(String valType)Specify index with cache value type.IndexQuery(String valType, @Nullable String idxName)Specify index with cache value type and index name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<IndexQueryCriterion>getCriteria()Index query criteria.IgniteBiPredicate<K,V>getFilter()Gets remote cache entries filter.StringgetIndexName()Index name.intgetLimit()Gets limit to response records count.@Nullable IntegergetPartition()Gets partition number over which this query should iterate.StringgetValueType()Cache Value type.IndexQuery<K,V>setCriteria(List<IndexQueryCriterion> criteria)Sets conjunction (AND) criteria for index query.IndexQuery<K,V>setCriteria(IndexQueryCriterion... criteria)Sets conjunction (AND) criteria for index query.IndexQuery<K,V>setFilter(IgniteBiPredicate<K,V> filter)Sets remote cache entries filter.IndexQuery<K,V>setLimit(int limit)Sets limit to response records count.IndexQuery<K,V>setPartition(@Nullable Integer part)Sets partition number over which this query should iterate.-
Methods inherited from class org.apache.ignite.cache.query.Query
getPageSize, isLocal, prepare, setLocal, setPageSize, toString
-
-
-
-
Constructor Detail
-
IndexQuery
public IndexQuery(Class<?> valCls)
Specify index with cache value class.- Parameters:
valCls- Cache value class.
-
IndexQuery
public IndexQuery(String valType)
Specify index with cache value type.- Parameters:
valType- Cache value type.
-
IndexQuery
public IndexQuery(Class<?> valCls, @Nullable @Nullable String idxName)
Specify index with cache value class and index name.- Parameters:
valCls- Cache value class.idxName- Index name.
-
-
Method Detail
-
setCriteria
public IndexQuery<K,V> setCriteria(IndexQueryCriterion... criteria)
Sets conjunction (AND) criteria for index query.- Parameters:
criteria- Criteria to set.- Returns:
thisfor chaining.
-
setCriteria
public IndexQuery<K,V> setCriteria(List<IndexQueryCriterion> criteria)
Sets conjunction (AND) criteria for index query.- Parameters:
criteria- Criteria to set.- Returns:
thisfor chaining.
-
getCriteria
public List<IndexQueryCriterion> getCriteria()
Index query criteria.- Returns:
- List of criteria for this index query.
-
getValueType
public String getValueType()
Cache Value type.- Returns:
- Cache Value type.
-
getIndexName
public String getIndexName()
Index name.- Returns:
- Index name.
-
getLimit
public int getLimit()
Gets limit to response records count.- Returns:
- Limit value.
-
setLimit
public IndexQuery<K,V> setLimit(int limit)
Sets limit to response records count.- Parameters:
limit- POsitive limit to set.- Returns:
thisFor chaining.
-
setFilter
public IndexQuery<K,V> setFilter(IgniteBiPredicate<K,V> filter)
Sets remote cache entries filter.- Parameters:
filter- Predicate for remote filtering of query result cursor.- Returns:
thisfor chaining.
-
getFilter
public IgniteBiPredicate<K,V> getFilter()
Gets remote cache entries filter.- Returns:
- Filter.
-
setPartition
public IndexQuery<K,V> setPartition(@Nullable @Nullable Integer part)
Sets partition number over which this query should iterate. Ifnull, query will iterate over all partitions in the cache. Must be in the range [0, N) where N is partition number in the cache.- Parameters:
part- Partition number over which this query should iterate.- Returns:
thisfor chaining.
-
getPartition
@Nullable public @Nullable Integer getPartition()
Gets partition number over which this query should iterate. Will returnnullif partition was not set. In this case query will iterate over all partitions in the cache.- Returns:
- Partition number or
null.
-
-