Search in sources :

Example 1 with AndResultSet

use of com.hazelcast.query.impl.AndResultSet in project hazelcast by hazelcast.

the class AndPredicate method filter.

@Override
public Set<QueryableEntry> filter(QueryContext queryContext) {
    Set<QueryableEntry> smallestIndexedResult = null;
    List<Set<QueryableEntry>> otherIndexedResults = new LinkedList<Set<QueryableEntry>>();
    List<Predicate> lsNoIndexPredicates = null;
    for (Predicate predicate : predicates) {
        boolean indexed = false;
        if (predicate instanceof IndexAwarePredicate) {
            IndexAwarePredicate iap = (IndexAwarePredicate) predicate;
            if (iap.isIndexed(queryContext)) {
                indexed = true;
                Set<QueryableEntry> s = iap.filter(queryContext);
                if (smallestIndexedResult == null) {
                    smallestIndexedResult = s;
                } else if (size(s) < size(smallestIndexedResult)) {
                    otherIndexedResults.add(smallestIndexedResult);
                    smallestIndexedResult = s;
                } else {
                    otherIndexedResults.add(s);
                }
            }
        }
        if (!indexed) {
            if (lsNoIndexPredicates == null) {
                lsNoIndexPredicates = new LinkedList<Predicate>();
            }
            lsNoIndexPredicates.add(predicate);
        }
    }
    if (smallestIndexedResult == null) {
        return null;
    }
    return new AndResultSet(smallestIndexedResult, otherIndexedResults, lsNoIndexPredicates);
}
Also used : OrResultSet(com.hazelcast.query.impl.OrResultSet) Set(java.util.Set) AndResultSet(com.hazelcast.query.impl.AndResultSet) AndResultSet(com.hazelcast.query.impl.AndResultSet) IndexAwarePredicate(com.hazelcast.query.IndexAwarePredicate) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) LinkedList(java.util.LinkedList) IndexAwarePredicate(com.hazelcast.query.IndexAwarePredicate) Predicate(com.hazelcast.query.Predicate) VisitablePredicate(com.hazelcast.query.VisitablePredicate)

Aggregations

IndexAwarePredicate (com.hazelcast.query.IndexAwarePredicate)1 Predicate (com.hazelcast.query.Predicate)1 VisitablePredicate (com.hazelcast.query.VisitablePredicate)1 AndResultSet (com.hazelcast.query.impl.AndResultSet)1 OrResultSet (com.hazelcast.query.impl.OrResultSet)1 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1