Search in sources :

Example 1 with PartitionIdSet

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;
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) KvRowProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector) Processor(com.hazelcast.jet.core.Processor) TransformP(com.hazelcast.jet.impl.processor.TransformP) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Example 2 with PartitionIdSet

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);
}
Also used : PartitionPredicate(com.hazelcast.query.PartitionPredicate) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) LinkedList(java.util.LinkedList) PartitionPredicate(com.hazelcast.query.PartitionPredicate) Predicate(com.hazelcast.query.Predicate)

Example 3 with PartitionIdSet

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;
}
Also used : PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) Future(java.util.concurrent.Future) QueryResultSizeExceededException(com.hazelcast.map.QueryResultSizeExceededException)

Example 4 with PartitionIdSet

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);
}
Also used : PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future)

Example 5 with PartitionIdSet

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;
}
Also used : PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) ImmutablePartitionIdSet(com.hazelcast.internal.util.collection.ImmutablePartitionIdSet)

Aggregations

PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)55 QuickTest (com.hazelcast.test.annotation.QuickTest)24 Test (org.junit.Test)24 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)23 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)13 Address (com.hazelcast.cluster.Address)12 IndexIterationPointer (com.hazelcast.internal.iteration.IndexIterationPointer)11 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)11 MapFetchIndexOperationResult (com.hazelcast.map.impl.operation.MapFetchIndexOperation.MapFetchIndexOperationResult)10 HashSet (java.util.HashSet)10 Predicate (com.hazelcast.query.Predicate)7 ArrayList (java.util.ArrayList)7 Data (com.hazelcast.internal.serialization.Data)5 UUID (java.util.UUID)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 IPartitionService (com.hazelcast.internal.partition.IPartitionService)4 Indexes (com.hazelcast.query.impl.Indexes)4 List (java.util.List)4 SetUtil.singletonPartitionIdSet (com.hazelcast.internal.util.SetUtil.singletonPartitionIdSet)3 QueryResultSizeExceededException (com.hazelcast.map.QueryResultSizeExceededException)3