Class 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.

    QueryCursor delivers sorted cache entries by the order defined for queried index.

    IndexQuery has to be initialized with cache value class or type. The algorithm of discovering index is as follows:

    • If idxName is set, then use it.
    • If idxName is not set, then find an index that matches criteria fields.
    • If neither idxName, nor setCriteria(List) is used, then perform index scan over PK index for specified Value type.
    Conjuction of items in criteria has to represent a valid range to traverse the index tree.
    See Also:
    Serialized Form
    • 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.
      • IndexQuery

        public IndexQuery​(String valType,
                          @Nullable
                          @Nullable String idxName)
        Specify index with cache value type and index name.
        Parameters:
        valType - Cache value type.
        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:
        this for chaining.
      • setCriteria

        public IndexQuery<K,​V> setCriteria​(List<IndexQueryCriterion> criteria)
        Sets conjunction (AND) criteria for index query.
        Parameters:
        criteria - Criteria to set.
        Returns:
        this for 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:
        this For 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:
        this for 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. If null, 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:
        this for chaining.
      • getPartition

        @Nullable
        public @Nullable Integer getPartition()
        Gets partition number over which this query should iterate. Will return null if partition was not set. In this case query will iterate over all partitions in the cache.
        Returns:
        Partition number or null.