Search in sources :

Example 1 with QueryRunner

use of com.hazelcast.map.impl.query.QueryRunner in project hazelcast by hazelcast.

the class MapServiceContextImpl method createMapQueryRunner.

protected QueryRunner createMapQueryRunner(NodeEngine nodeEngine, QueryOptimizer queryOptimizer, ResultProcessorRegistry resultProcessorRegistry, PartitionScanRunner partitionScanRunner) {
    boolean parallelEvaluation = nodeEngine.getProperties().getBoolean(QUERY_PREDICATE_PARALLEL_EVALUATION);
    PartitionScanExecutor partitionScanExecutor;
    if (parallelEvaluation) {
        int opTimeoutInMillis = nodeEngine.getProperties().getInteger(OPERATION_CALL_TIMEOUT_MILLIS);
        ManagedExecutorService queryExecutorService = nodeEngine.getExecutionService().getExecutor(QUERY_EXECUTOR);
        partitionScanExecutor = new ParallelPartitionScanExecutor(partitionScanRunner, queryExecutorService, opTimeoutInMillis);
    } else {
        partitionScanExecutor = new CallerRunsPartitionScanExecutor(partitionScanRunner);
    }
    return new QueryRunner(this, queryOptimizer, partitionScanExecutor, resultProcessorRegistry);
}
Also used : ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) CallerRunsPartitionScanExecutor(com.hazelcast.map.impl.query.CallerRunsPartitionScanExecutor) ParallelPartitionScanExecutor(com.hazelcast.map.impl.query.ParallelPartitionScanExecutor) PartitionScanExecutor(com.hazelcast.map.impl.query.PartitionScanExecutor) ParallelPartitionScanExecutor(com.hazelcast.map.impl.query.ParallelPartitionScanExecutor) CallerRunsPartitionScanExecutor(com.hazelcast.map.impl.query.CallerRunsPartitionScanExecutor) QueryRunner(com.hazelcast.map.impl.query.QueryRunner)

Example 2 with QueryRunner

use of com.hazelcast.map.impl.query.QueryRunner in project hazelcast by hazelcast.

the class MapFetchWithQueryOperation method runInternal.

@Override
protected void runInternal() {
    QueryRunner runner = mapServiceContext.getMapQueryRunner(query.getMapName());
    response = runner.runPartitionScanQueryOnPartitionChunk(query, getPartitionId(), pointers, fetchSize);
}
Also used : QueryRunner(com.hazelcast.map.impl.query.QueryRunner)

Example 3 with QueryRunner

use of com.hazelcast.map.impl.query.QueryRunner in project hazelcast by hazelcast.

the class PartitionWideEntryWithPredicateOperationFactory method tryToObtainKeysFromIndexes.

/**
 * Attempts to get keys by running an index query. This method may return
 * {@code null} if there is an ongoing migration, which means that it is not
 * safe to return results from a non-partition thread. The caller must then
 * run a partition query to obtain the results.
 *
 * @param nodeEngine nodeEngine of this cluster node
 * @return the set of keys or {@code null} if we failed to fetch the keys
 * because of ongoing migrations
 */
private Set<Data> tryToObtainKeysFromIndexes(NodeEngine nodeEngine) {
    // Do not use index in this case, because it requires full-table-scan.
    if (predicate == Predicates.alwaysTrue()) {
        return null;
    }
    MapService mapService = nodeEngine.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapContainer mapContainer = mapServiceContext.getMapContainer(name);
    if (!mapContainer.shouldUseGlobalIndex()) {
        return null;
    }
    QueryRunner runner = mapServiceContext.getMapQueryRunner(name);
    Query query = Query.of().mapName(name).predicate(predicate).iterationType(IterationType.KEY).build();
    final QueryResult result = (QueryResult) runner.runIndexQueryOnOwnedPartitions(query);
    if (result.getPartitionIds() == null) {
        // failed to run query because of ongoing migrations
        return null;
    }
    final Builder<Data> setBuilder = InflatableSet.newBuilder(result.size());
    for (QueryResultRow row : result.getRows()) {
        setBuilder.add(row.getKey());
    }
    return setBuilder.build();
}
Also used : QueryResult(com.hazelcast.map.impl.query.QueryResult) Query(com.hazelcast.map.impl.query.Query) QueryResultRow(com.hazelcast.map.impl.query.QueryResultRow) Data(com.hazelcast.internal.serialization.Data) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer) QueryRunner(com.hazelcast.map.impl.query.QueryRunner)

Aggregations

QueryRunner (com.hazelcast.map.impl.query.QueryRunner)3 Data (com.hazelcast.internal.serialization.Data)1 ManagedExecutorService (com.hazelcast.internal.util.executor.ManagedExecutorService)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 CallerRunsPartitionScanExecutor (com.hazelcast.map.impl.query.CallerRunsPartitionScanExecutor)1 ParallelPartitionScanExecutor (com.hazelcast.map.impl.query.ParallelPartitionScanExecutor)1 PartitionScanExecutor (com.hazelcast.map.impl.query.PartitionScanExecutor)1 Query (com.hazelcast.map.impl.query.Query)1 QueryResult (com.hazelcast.map.impl.query.QueryResult)1 QueryResultRow (com.hazelcast.map.impl.query.QueryResultRow)1