Search in sources :

Example 1 with QueryExecutor

use of com.bakdata.conquery.models.query.QueryExecutor in project conquery by bakdata.

the class ExecuteForm method react.

@Override
public void react(Worker worker) throws Exception {
    log.info("Started Form {}", formId);
    // Execution might have been cancelled before so we uncancel it here.
    final QueryExecutor queryExecutor = worker.getQueryExecutor();
    queryExecutor.unsetQueryCancelled(formId);
    // Execute all plans.
    for (Entry<ManagedExecutionId, Query> entry : queries.entrySet()) {
        final Query query = entry.getValue();
        ShardResult result = createResult(worker, entry.getKey());
        // Before we start the query, we create it once to test if it will succeed before creating it multiple times for evaluation per core.
        try {
            query.createQueryPlan(new QueryPlanContext(worker));
        } catch (Exception e) {
            ConqueryError err = asConqueryError(e);
            log.warn("Failed to create query plans for {}.", formId, err);
            queryExecutor.sendFailureToManagerNode(result, err);
            return;
        }
        final QueryExecutionContext subQueryContext = new QueryExecutionContext(formId, queryExecutor, worker.getStorage(), worker.getBucketManager());
        if (!queryExecutor.execute(query, subQueryContext, result)) {
            return;
        }
    }
}
Also used : ConqueryError.asConqueryError(com.bakdata.conquery.models.error.ConqueryError.asConqueryError) ConqueryError(com.bakdata.conquery.models.error.ConqueryError) Query(com.bakdata.conquery.apiv1.query.Query) QueryExecutionContext(com.bakdata.conquery.models.query.QueryExecutionContext) QueryExecutor(com.bakdata.conquery.models.query.QueryExecutor) ManagedExecutionId(com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId) FormShardResult(com.bakdata.conquery.models.query.results.FormShardResult) ShardResult(com.bakdata.conquery.models.query.results.ShardResult) QueryPlanContext(com.bakdata.conquery.models.query.QueryPlanContext)

Example 2 with QueryExecutor

use of com.bakdata.conquery.models.query.QueryExecutor in project conquery by bakdata.

the class ExecuteQuery method react.

@Override
public void react(Worker worker) throws Exception {
    final ManagedExecutionId executionId = id;
    log.info("Started {} {}", query.getClass().getSimpleName(), executionId);
    // Execution might have been cancelled before so we uncancel it here.
    final QueryExecutor queryExecutor = worker.getQueryExecutor();
    queryExecutor.unsetQueryCancelled(executionId);
    final ShardResult result = createShardResult(worker);
    // Before we start the query, we create it once to test if it will succeed before creating it multiple times for evaluation per core.
    try {
        query.createQueryPlan(new QueryPlanContext(worker));
    } catch (Exception e) {
        ConqueryError err = asConqueryError(e);
        log.warn("Failed to create query plans for {}.", executionId, err);
        queryExecutor.sendFailureToManagerNode(result, err);
        return;
    }
    final QueryExecutionContext executionContext = new QueryExecutionContext(executionId, queryExecutor, worker.getStorage(), worker.getBucketManager());
    queryExecutor.execute(query, executionContext, result);
}
Also used : ConqueryError.asConqueryError(com.bakdata.conquery.models.error.ConqueryError.asConqueryError) ConqueryError(com.bakdata.conquery.models.error.ConqueryError) QueryExecutionContext(com.bakdata.conquery.models.query.QueryExecutionContext) QueryExecutor(com.bakdata.conquery.models.query.QueryExecutor) ManagedExecutionId(com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId) ShardResult(com.bakdata.conquery.models.query.results.ShardResult) QueryPlanContext(com.bakdata.conquery.models.query.QueryPlanContext)

Aggregations

ConqueryError (com.bakdata.conquery.models.error.ConqueryError)2 ConqueryError.asConqueryError (com.bakdata.conquery.models.error.ConqueryError.asConqueryError)2 ManagedExecutionId (com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId)2 QueryExecutionContext (com.bakdata.conquery.models.query.QueryExecutionContext)2 QueryExecutor (com.bakdata.conquery.models.query.QueryExecutor)2 QueryPlanContext (com.bakdata.conquery.models.query.QueryPlanContext)2 ShardResult (com.bakdata.conquery.models.query.results.ShardResult)2 Query (com.bakdata.conquery.apiv1.query.Query)1 FormShardResult (com.bakdata.conquery.models.query.results.FormShardResult)1