Search in sources :

Example 1 with IndexAwarePredicate

use of com.hazelcast.query.impl.predicates.IndexAwarePredicate in project hazelcast by hazelcast.

the class Indexes method query.

/**
 * Performs a query on this indexes instance using the given predicate.
 *
 * @param predicate           the predicate to evaluate.
 * @param ownedPartitionCount a count of owned partitions a query runs on.
 *                            Negative value indicates that the value is not defined.
 * @return the produced iterable result object or {@code null} if the query can't be
 * performed using the indexes known to this indexes instance.
 */
@SuppressWarnings("unchecked")
public Iterable<QueryableEntry> query(Predicate predicate, int ownedPartitionCount) {
    stats.incrementQueryCount();
    if (!canQueryOverIndex(predicate)) {
        return null;
    }
    IndexAwarePredicate indexAwarePredicate = (IndexAwarePredicate) predicate;
    QueryContext queryContext = queryContextProvider.obtainContextFor(this, ownedPartitionCount);
    if (!indexAwarePredicate.isIndexed(queryContext)) {
        return null;
    }
    Set<QueryableEntry> result = indexAwarePredicate.filter(queryContext);
    if (result != null) {
        stats.incrementIndexedQueryCount();
        queryContext.applyPerQueryStats();
    }
    if (result != null && resultFilterFactory != null) {
        return IterableUtil.filter(result, resultFilterFactory.get());
    } else {
        return result;
    }
}
Also used : IndexAwarePredicate(com.hazelcast.query.impl.predicates.IndexAwarePredicate)

Aggregations

IndexAwarePredicate (com.hazelcast.query.impl.predicates.IndexAwarePredicate)1