use of com.hazelcast.map.impl.query.Query in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method createInvocationsForMissingPartitions.
private void createInvocationsForMissingPartitions(List<Integer> missingPartitionsList, List<Future> futures, Predicate predicate) {
final InternalOperationService operationService = nodeEngine.getOperationService();
Query query = buildQuery(predicate);
for (Integer partitionId : missingPartitionsList) {
QueryPartitionOperation queryPartitionOperation = new QueryPartitionOperation(query);
queryPartitionOperation.setPartitionId(partitionId);
try {
Future future = operationService.invokeOnPartition(SERVICE_NAME, queryPartitionOperation, partitionId);
futures.add(future);
} catch (Throwable t) {
throw rethrow(t);
}
}
}
use of com.hazelcast.map.impl.query.Query in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method createInvocations.
private List<Future> createInvocations(Collection<Member> members, Predicate predicate) {
List<Future> futures = new ArrayList<Future>(members.size());
final InternalOperationService operationService = nodeEngine.getOperationService();
final Query query = buildQuery(predicate);
for (Member member : members) {
try {
Future future = operationService.createInvocationBuilder(SERVICE_NAME, new QueryOperation(query), member.getAddress()).invoke();
futures.add(future);
} catch (Throwable t) {
if (t.getCause() instanceof QueryResultSizeExceededException) {
throw rethrow(t);
} else {
// the missing partition IDs will be queried anyway, so it's not a terminal failure
if (logger.isFineEnabled()) {
logger.fine("Query invocation failed on member " + member, t);
}
}
}
}
return futures;
}
use of com.hazelcast.map.impl.query.Query 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.Query 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.Query 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);
}
Aggregations