use of io.crate.execution.engine.indexing.IndexWriterProjector in project crate by crate.
the class ProjectionToProjectorVisitor method visitSourceIndexWriterProjection.
@Override
public Projector visitSourceIndexWriterProjection(SourceIndexWriterProjection projection, Context context) {
InputFactory.Context<CollectExpression<Row, ?>> ctx = inputFactory.ctxForInputColumns(context.txnCtx);
List<Input<?>> partitionedByInputs = new ArrayList<>(projection.partitionedBySymbols().size());
for (Symbol partitionedBySymbol : projection.partitionedBySymbols()) {
partitionedByInputs.add(ctx.add(partitionedBySymbol));
}
Input<?> sourceInput = ctx.add(projection.rawSource());
Supplier<String> indexNameResolver = IndexNameResolver.create(projection.tableIdent(), projection.partitionIdent(), partitionedByInputs);
ClusterState state = clusterService.state();
Settings tableSettings = TableSettingsResolver.get(state.getMetadata(), projection.tableIdent(), !projection.partitionedBySymbols().isEmpty());
int targetTableNumShards = IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.get(tableSettings);
int targetTableNumReplicas = NumberOfReplicas.fromSettings(tableSettings, state.getNodes().getSize());
UpsertResultContext upsertResultContext;
if (projection instanceof SourceIndexWriterReturnSummaryProjection) {
upsertResultContext = UpsertResultContext.forReturnSummary(context.txnCtx, (SourceIndexWriterReturnSummaryProjection) projection, clusterService.localNode(), inputFactory);
} else {
upsertResultContext = UpsertResultContext.forRowCount();
}
return new IndexWriterProjector(clusterService, nodeJobsCounter, circuitBreakerService.getBreaker(HierarchyCircuitBreakerService.QUERY), context.ramAccounting, threadPool.scheduler(), threadPool.executor(ThreadPool.Names.SEARCH), context.txnCtx, nodeCtx, state.metadata().settings(), targetTableNumShards, targetTableNumReplicas, transportActionProvider.transportBulkCreateIndicesAction(), transportActionProvider.transportShardUpsertAction()::execute, indexNameResolver, projection.rawSourceReference(), projection.primaryKeys(), projection.ids(), projection.clusteredBy(), projection.clusteredByIdent(), sourceInput, ctx.expressions(), projection.bulkActions(), projection.includes(), projection.excludes(), projection.autoCreateIndices(), projection.overwriteDuplicates(), context.jobId, upsertResultContext, projection.failFast());
}
Aggregations