use of com.hazelcast.query.impl.predicates.QueryOptimizer in project hazelcast by hazelcast.
the class PartitionWideEntryWithPredicateOperationFactory method getKeysFromIndex.
private Set<Data> getKeysFromIndex(NodeEngine nodeEngine) {
// Do not use index in this case, because it requires full-table-scan.
if (predicate == TruePredicate.INSTANCE) {
return emptySet();
}
// get indexes
MapService mapService = nodeEngine.getService(SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
Indexes indexes = mapServiceContext.getMapContainer(name).getIndexes();
// optimize predicate
QueryOptimizer queryOptimizer = mapServiceContext.getQueryOptimizer();
predicate = queryOptimizer.optimize(predicate, indexes);
Set<QueryableEntry> querySet = indexes.query(predicate);
if (querySet == null) {
return emptySet();
}
List<Data> keys = null;
for (QueryableEntry e : querySet) {
if (keys == null) {
keys = new ArrayList<Data>(querySet.size());
}
keys.add(e.getKeyData());
}
return keys == null ? Collections.<Data>emptySet() : newBuilder(keys).build();
}
Aggregations