use of com.hazelcast.map.impl.query.MapQueryEngine in project hazelcast by hazelcast.
the class MapProxyImpl method aggregate.
@Override
public <R> R aggregate(Aggregator<Map.Entry<K, V>, R> aggregator, Predicate<K, V> predicate) {
checkNotNull(aggregator, NULL_AGGREGATOR_IS_NOT_ALLOWED);
checkNotNull(predicate, NULL_PREDICATE_IS_NOT_ALLOWED);
aggregator = serializationService.toObject(serializationService.toData(aggregator));
MapQueryEngine queryEngine = getMapQueryEngine();
if (predicate instanceof PagingPredicate) {
throw new IllegalArgumentException("PagingPredicate now allowed with EntryAggregator.");
}
Query query = Query.of().mapName(getName()).predicate(predicate).iterationType(IterationType.ENTRY).aggregator(aggregator).build();
AggregationResult result = queryEngine.execute(query, Target.ALL_NODES);
return result.<R>getAggregator().aggregate();
}
use of com.hazelcast.map.impl.query.MapQueryEngine in project hazelcast by hazelcast.
the class MapProxyImpl method aggregate.
@Override
public <R> R aggregate(Aggregator<Map.Entry<K, V>, R> aggregator) {
checkNotNull(aggregator, NULL_AGGREGATOR_IS_NOT_ALLOWED);
MapQueryEngine queryEngine = getMapQueryEngine();
aggregator = serializationService.toObject(serializationService.toData(aggregator));
Query query = Query.of().mapName(getName()).predicate(TruePredicate.INSTANCE).iterationType(IterationType.ENTRY).aggregator(aggregator).build();
AggregationResult result = queryEngine.execute(query, Target.ALL_NODES);
return result.<R>getAggregator().aggregate();
}
use of com.hazelcast.map.impl.query.MapQueryEngine in project hazelcast by hazelcast.
the class MapProxyImpl method project.
@Override
public <R> Collection<R> project(Projection<Map.Entry<K, V>, R> projection, Predicate<K, V> predicate) {
checkNotNull(projection, NULL_PROJECTION_IS_NOT_ALLOWED);
checkNotNull(predicate, NULL_PREDICATE_IS_NOT_ALLOWED);
projection = serializationService.toObject(serializationService.toData(projection));
MapQueryEngine queryEngine = getMapQueryEngine();
Query query = Query.of().mapName(getName()).predicate(predicate).iterationType(IterationType.VALUE).projection(projection).build();
queryEngine.execute(query, Target.ALL_NODES);
QueryResult result = queryEngine.execute(query, Target.ALL_NODES);
return QueryResultUtils.transformToSet(serializationService, result, predicate, IterationType.VALUE, false);
}
use of com.hazelcast.map.impl.query.MapQueryEngine in project hazelcast by hazelcast.
the class MapProxyImpl method project.
@Override
public <R> Collection<R> project(Projection<Map.Entry<K, V>, R> projection) {
checkNotNull(projection, NULL_PROJECTION_IS_NOT_ALLOWED);
MapQueryEngine queryEngine = getMapQueryEngine();
projection = serializationService.toObject(serializationService.toData(projection));
Query query = Query.of().mapName(getName()).predicate(TruePredicate.INSTANCE).iterationType(IterationType.VALUE).projection(projection).build();
QueryResult result = queryEngine.execute(query, Target.ALL_NODES);
return QueryResultUtils.transformToSet(serializationService, result, TruePredicate.INSTANCE, IterationType.VALUE, false);
}
use of com.hazelcast.map.impl.query.MapQueryEngine in project hazelcast by hazelcast.
the class MapProxyImpl method executePredicate.
private Set executePredicate(Predicate predicate, IterationType iterationType, boolean uniqueResult) {
checkNotNull(predicate, NULL_PREDICATE_IS_NOT_ALLOWED);
MapQueryEngine queryEngine = getMapQueryEngine();
QueryResult result;
if (predicate instanceof PartitionPredicate) {
PartitionPredicate partitionPredicate = (PartitionPredicate) predicate;
Data key = toData(partitionPredicate.getPartitionKey());
int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
Query query = Query.of().mapName(getName()).predicate(partitionPredicate.getTarget()).iterationType(iterationType).build();
result = queryEngine.execute(query, Target.of().partitionOwner(partitionId).build());
} else {
Query query = Query.of().mapName(getName()).predicate(predicate).iterationType(iterationType).build();
result = queryEngine.execute(query, Target.ALL_NODES);
}
return QueryResultUtils.transformToSet(serializationService, result, predicate, iterationType, uniqueResult);
}
Aggregations