Search in sources :

Example 1 with QueryableEntry

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

the class QueryRunner method runPartitionScanQueryOnGivenOwnedPartition.

Result runPartitionScanQueryOnGivenOwnedPartition(Query query, int partitionId) throws ExecutionException, InterruptedException {
    MapContainer mapContainer = mapServiceContext.getMapContainer(query.getMapName());
    Predicate predicate = queryOptimizer.optimize(query.getPredicate(), mapContainer.getIndexes());
    Collection<QueryableEntry> entries = partitionScanExecutor.execute(query.getMapName(), predicate, Collections.singletonList(partitionId));
    return populateTheResult(query, entries, Collections.singletonList(partitionId));
}
Also used : MapContainer(com.hazelcast.map.impl.MapContainer) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) Predicate(com.hazelcast.query.Predicate)

Example 2 with QueryableEntry

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

the class QueryEventFilter method eval.

@Override
public boolean eval(Object arg) {
    QueryableEntry entry = (QueryableEntry) arg;
    Data keyData = entry.getKeyData();
    return (key == null || key.equals(keyData)) && predicate.apply((Map.Entry) arg);
}
Also used : QueryableEntry(com.hazelcast.query.impl.QueryableEntry) Data(com.hazelcast.nio.serialization.Data) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Example 3 with QueryableEntry

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

the class QueryResultProcessor method populateResult.

@Override
public QueryResult populateResult(Query query, long resultLimit, Collection<QueryableEntry> entries, Collection<Integer> partitionIds) {
    QueryResult result = new QueryResult(query.getIterationType(), resultLimit);
    for (QueryableEntry entry : entries) {
        result.add(entry, query.getProjection(), serializationService);
    }
    result.setPartitionIds(partitionIds);
    return result;
}
Also used : QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Example 4 with QueryableEntry

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

the class DefaultQueryCache method values.

@Override
public Collection<V> values(Predicate predicate) {
    checkNotNull(predicate, "Predicate cannot be null!");
    if (!includeValue) {
        return Collections.emptySet();
    }
    Set<V> resultingSet = new HashSet<V>();
    Set<QueryableEntry> query = indexes.query(predicate);
    if (query != null) {
        for (QueryableEntry entry : query) {
            resultingSet.add((V) entry.getValue());
        }
    } else {
        doFullValueScan(predicate, resultingSet);
    }
    return resultingSet;
}
Also used : QueryableEntry(com.hazelcast.query.impl.QueryableEntry) HashSet(java.util.HashSet)

Example 5 with QueryableEntry

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

the class DefaultQueryCache method entrySet.

@Override
public Set<Map.Entry<K, V>> entrySet(Predicate predicate) {
    checkNotNull(predicate, "Predicate cannot be null!");
    Set<Map.Entry<K, V>> resultingSet = new HashSet<Map.Entry<K, V>>();
    Set<QueryableEntry> query = indexes.query(predicate);
    if (query != null) {
        if (query.isEmpty()) {
            return Collections.emptySet();
        }
        for (QueryableEntry entry : query) {
            resultingSet.add(entry);
        }
    } else {
        doFullEntryScan(predicate, resultingSet);
    }
    return resultingSet;
}
Also used : QueryEntry(com.hazelcast.query.impl.QueryEntry) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) HashSet(java.util.HashSet)

Aggregations

QueryableEntry (com.hazelcast.query.impl.QueryableEntry)34 Data (com.hazelcast.nio.serialization.Data)14 Predicate (com.hazelcast.query.Predicate)10 ParallelTest (com.hazelcast.test.annotation.ParallelTest)10 QuickTest (com.hazelcast.test.annotation.QuickTest)10 Test (org.junit.Test)10 TruePredicate (com.hazelcast.query.TruePredicate)5 FalsePredicate (com.hazelcast.query.impl.FalsePredicate)5 HashSet (java.util.HashSet)5 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)4 Indexes (com.hazelcast.query.impl.Indexes)4 Extractors (com.hazelcast.query.impl.getters.Extractors)4 SerializationService (com.hazelcast.spi.serialization.SerializationService)4 Map (java.util.Map)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 MapContainer (com.hazelcast.map.impl.MapContainer)3 Record (com.hazelcast.map.impl.record.Record)3 TransactionalMap (com.hazelcast.core.TransactionalMap)2 MapQueryEngine (com.hazelcast.map.impl.query.MapQueryEngine)2 Query (com.hazelcast.map.impl.query.Query)2