com.hazelcast.query

## Interface IndexAwarePredicate<K,V>

- Type Parameters:
    `K` - the type of keys the predicate operates on.
    `V` - the type of values the predicate operates on.
  All Superinterfaces:
    Predicate<K,V>, Serializable
  All Known Implementing Classes:
    PagingPredicate, PredicateBuilder, SqlPredicate

      public interface IndexAwarePredicate<K,V>
      extends Predicate<K,V>

  Extends the `Predicate` interface with the ability to support indexes.

  The general contract is:

  - While performing a query, the query engine invokes the `isIndexed(com.hazelcast.query.impl.QueryContext)` method of the index-aware predicate and provides it with the `QueryContext` instance. The predicate may consult the passed query context regarding the indexes configured for the map in question and decide whether it is possible to use the indexes to speed up the query processing or not.
  - If the predicate decides to use the indexes, its `filter(com.hazelcast.query.impl.QueryContext)` method is invoked by the query engine to obtain a filtered entry set. The query engine assumes that this obtained result set is consistent with the entry set at the time the result set was produced. In other words, all the entries for which the predicate `evaluates` to `true` are included in the result set and all the entries for which the predicate evaluates to `false` are excluded from the result set.
  - If the predicate decides not to use indexes, the query engine produces the result set on its own and evaluates the predicate for every entry by invoking the `Predicate.apply(java.util.Map.Entry<K, V>)` method of the predicate.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Set<com.hazelcast.query.impl.QueryableEntry<K,V>>` | `filter(com.hazelcast.query.impl.QueryContext queryContext)` Produces a filtered entry set by utilizing the indexes available while executing the query in the given query context.
    `boolean` | `isIndexed(com.hazelcast.query.impl.QueryContext queryContext)` Signals to the query engine that this predicate is able to utilize the indexes available while executing the query in the given query context.

    - ### Methods inherited from interface com.hazelcast.query.Predicate

      `apply`

- - ### Method Detail

    - #### filter

          Set<com.hazelcast.query.impl.QueryableEntry<K,V>> filter(com.hazelcast.query.impl.QueryContext queryContext)

      Produces a filtered entry set by utilizing the indexes available while executing the query in the given query context.

      The query engine assumes this method produces the result set faster than a simple evaluation of the predicate on every entry.

      Parameters:
        `queryContext` - the query context to access the indexes.
      Returns:
        the produced filtered entry set.

    - #### isIndexed

          boolean isIndexed(com.hazelcast.query.impl.QueryContext queryContext)

      Signals to the query engine that this predicate is able to utilize the indexes available while executing the query in the given query context.
      Parameters:
        `queryContext` - the query context to consult for the available indexes.
      Returns:
        `true` if this predicate is able to use the indexes to speed up the processing, `false` otherwise.

Copyright © 2018. All rights reserved.