Search in sources :

Example 1 with ShardRequestExecutor

use of io.crate.execution.dml.ShardRequestExecutor in project crate by crate.

the class UpdateById method createExecutor.

private ShardRequestExecutor<ShardUpsertRequest> createExecutor(DependencyCarrier dependencies, PlannerContext plannerContext) {
    ClusterService clusterService = dependencies.clusterService();
    CoordinatorTxnCtx txnCtx = plannerContext.transactionContext();
    ShardUpsertRequest.Builder requestBuilder = new ShardUpsertRequest.Builder(txnCtx.sessionSettings(), ShardingUpsertExecutor.BULK_REQUEST_TIMEOUT_SETTING.get(clusterService.state().metadata().settings()), ShardUpsertRequest.DuplicateKeyAction.UPDATE_OR_FAIL, true, assignments.targetNames(), // missing assignments are for INSERT .. ON DUPLICATE KEY UPDATE
    null, returnValues, plannerContext.jobId(), false);
    UpdateRequests updateRequests = new UpdateRequests(requestBuilder, table, assignments);
    return new ShardRequestExecutor<>(clusterService, txnCtx, dependencies.nodeContext(), table, updateRequests, dependencies.transportActionProvider().transportShardUpsertAction()::execute, docKeys);
}
Also used : CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) ClusterService(org.elasticsearch.cluster.service.ClusterService) ShardRequestExecutor(io.crate.execution.dml.ShardRequestExecutor) ShardUpsertRequest(io.crate.execution.dml.upsert.ShardUpsertRequest)

Example 2 with ShardRequestExecutor

use of io.crate.execution.dml.ShardRequestExecutor in project crate by crate.

the class DeleteById method createExecutor.

private ShardRequestExecutor<ShardDeleteRequest> createExecutor(DependencyCarrier dependencies, PlannerContext plannerContext) {
    ClusterService clusterService = dependencies.clusterService();
    TimeValue requestTimeout = ShardingUpsertExecutor.BULK_REQUEST_TIMEOUT_SETTING.get(clusterService.state().metadata().settings());
    return new ShardRequestExecutor<>(clusterService, plannerContext.transactionContext(), dependencies.nodeContext(), table, new DeleteRequests(plannerContext.jobId(), requestTimeout), dependencies.transportActionProvider().transportShardDeleteAction()::execute, docKeys);
}
Also used : ClusterService(org.elasticsearch.cluster.service.ClusterService) ShardRequestExecutor(io.crate.execution.dml.ShardRequestExecutor) TimeValue(io.crate.common.unit.TimeValue)

Aggregations

ShardRequestExecutor (io.crate.execution.dml.ShardRequestExecutor)2 ClusterService (org.elasticsearch.cluster.service.ClusterService)2 TimeValue (io.crate.common.unit.TimeValue)1 ShardUpsertRequest (io.crate.execution.dml.upsert.ShardUpsertRequest)1 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)1