Search in sources :

Example 6 with QueryResultSizeExceededException

use of com.hazelcast.map.QueryResultSizeExceededException in project hazelcast by hazelcast.

the class QueryEngineImpl method addResultsOfPredicate.

@SuppressWarnings("unchecked")
private // modifies partitionIds list! Optimization not to allocate an extra collection with collected partitionIds
void addResultsOfPredicate(List<Future<Result>> futures, Result result, PartitionIdSet unfinishedPartitionIds, boolean rethrowAll) {
    for (Future<Result> future : futures) {
        Result queryResult = null;
        try {
            queryResult = future.get();
        } catch (Throwable t) {
            if (t.getCause() instanceof QueryResultSizeExceededException || rethrowAll) {
                throw rethrow(t);
            }
            logger.fine("Could not get query results", t);
        }
        if (queryResult == null) {
            continue;
        }
        PartitionIdSet queriedPartitionIds = queryResult.getPartitionIds();
        if (queriedPartitionIds != null) {
            if (!unfinishedPartitionIds.containsAll(queriedPartitionIds)) {
                // see also https://github.com/hazelcast/hazelcast/issues/6471
                continue;
            }
            unfinishedPartitionIds.removeAll(queriedPartitionIds);
            result.combine(queryResult);
        }
    }
}
Also used : PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) QueryResultSizeExceededException(com.hazelcast.map.QueryResultSizeExceededException)

Example 7 with QueryResultSizeExceededException

use of com.hazelcast.map.QueryResultSizeExceededException in project hazelcast by hazelcast.

the class QueryResultSizeLimiter method precheckMaxResultLimitOnLocalPartitions.

void precheckMaxResultLimitOnLocalPartitions(String mapName) {
    // check if feature is enabled
    if (!isPreCheckEnabled) {
        return;
    }
    // limit number of local partitions to check to keep runtime constant
    PartitionIdSet localPartitions = mapServiceContext.getOrInitCachedMemberPartitions();
    int partitionsToCheck = min(localPartitions.size(), maxLocalPartitionsLimitForPreCheck);
    if (partitionsToCheck == 0) {
        return;
    }
    // calculate size of local partitions
    int localPartitionSize = getLocalPartitionSize(mapName, localPartitions, partitionsToCheck);
    if (localPartitionSize == 0) {
        return;
    }
    // check local result size
    long localResultLimit = getNodeResultLimit(partitionsToCheck);
    if (localPartitionSize > localResultLimit * MAX_RESULT_LIMIT_FACTOR_FOR_PRECHECK) {
        throw new QueryResultSizeExceededException(maxResultLimit, " Result size exceeded in local pre-check.");
    }
}
Also used : PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) QueryResultSizeExceededException(com.hazelcast.map.QueryResultSizeExceededException)

Aggregations

QueryResultSizeExceededException (com.hazelcast.map.QueryResultSizeExceededException)7 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)3 Future (java.util.concurrent.Future)2 Member (com.hazelcast.cluster.Member)1 HazelcastException (com.hazelcast.core.HazelcastException)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 Query (com.hazelcast.map.impl.query.Query)1 Data (com.hazelcast.nio.serialization.Data)1 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 TransactionContext (com.hazelcast.transaction.TransactionContext)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1