use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class JoinByEquiJoinProcessorSupplier method get.
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
List<Processor> processors = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
PartitionIdSet partitions = this.partitions == null ? null : new PartitionIdSet(partitionCount, this.partitions);
QueryPath[] rightPaths = rightRowProjectorSupplier.paths();
KvRowProjector rightProjector = rightRowProjectorSupplier.get(evalContext, extractors);
Processor processor = new TransformP<JetSqlRow, JetSqlRow>(joinFn(joinInfo, map, partitions, rightPaths, rightProjector, evalContext)) {
@Override
public boolean isCooperative() {
return false;
}
};
processors.add(processor);
}
return processors;
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method call.
@Override
protected final Object call() throws Exception {
Collection<AccumulatedResults> result = new LinkedList<AccumulatedResults>();
try {
Predicate predicate = getPredicate();
if (predicate instanceof PartitionPredicate) {
int partitionId = clientMessage.getPartitionId();
QueryResult queryResult = invokeOnPartition((PartitionPredicate) predicate, partitionId);
extractAndAppendResult(result, queryResult);
return reduce(result);
}
int partitionCount = clientEngine.getPartitionService().getPartitionCount();
PartitionIdSet finishedPartitions = invokeOnMembers(result, predicate, partitionCount);
invokeOnMissingPartitions(result, predicate, finishedPartitions);
} catch (Throwable t) {
throw rethrow(t);
}
return reduce(result);
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method collectResults.
@SuppressWarnings("unchecked")
private PartitionIdSet collectResults(Collection<AccumulatedResults> result, List<Future> futures, int partitionCount) {
PartitionIdSet finishedPartitions = new PartitionIdSet(partitionCount);
for (Future future : futures) {
try {
QueryResult queryResult = (QueryResult) future.get();
if (queryResult != null) {
PartitionIdSet partitionIds = queryResult.getPartitionIds();
if (partitionIds != null && !partitionIds.intersects(finishedPartitions)) {
// Collect results only if there is no overlap with already collected partitions.
// If there is an overlap it means there was a partition migration while QueryOperation(s) were
// running. In this case we discard all results from this member and will target the missing
// partition separately later.
finishedPartitions.union(partitionIds);
extractAndAppendResult(result, queryResult);
}
}
} 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 on member failed with exception", t);
}
}
}
}
return finishedPartitions;
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method invokeOnMissingPartitions.
private void invokeOnMissingPartitions(Collection<AccumulatedResults> result, Predicate predicate, PartitionIdSet finishedPartitions) throws InterruptedException, ExecutionException {
if (finishedPartitions.isMissingPartitions()) {
PartitionIdSet missingPartitions = new PartitionIdSet(finishedPartitions);
missingPartitions.complement();
List<Future> missingFutures = new ArrayList<>(missingPartitions.size());
createInvocationsForMissingPartitions(missingPartitions, missingFutures, predicate);
collectResultsFromMissingPartitions(finishedPartitions, result, missingFutures);
}
assertAllPartitionsQueried(finishedPartitions);
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class SetUtil method allPartitionIds.
public static PartitionIdSet allPartitionIds(int partitionCount) {
PartitionIdSet set = new PartitionIdSet(partitionCount);
set.complement();
return set;
}
Aggregations