use of io.crate.operation.collect.CollectExpression in project crate by crate.
the class ProjectionToProjectorVisitor method visitWriterProjection.
@Override
public Projector visitWriterProjection(WriterProjection projection, Context context) {
InputFactory.Context<CollectExpression<Row, ?>> ctx = inputFactory.ctxForInputColumns();
List<Input<?>> inputs = null;
if (!projection.inputs().isEmpty()) {
ctx.add(projection.inputs());
inputs = ctx.topLevelInputs();
}
Map<ColumnIdent, Object> overwrites = symbolMapToObject(projection.overwrites(), ctx, context.transactionContext);
projection = projection.normalize(normalizer, context.transactionContext);
String uri = ValueSymbolVisitor.STRING.process(projection.uri());
assert uri != null : "URI must not be null";
StringBuilder sb = new StringBuilder(uri);
Symbol resolvedFileName = normalizer.normalize(WriterProjection.DIRECTORY_TO_FILENAME, context.transactionContext);
assert resolvedFileName instanceof Literal : "resolvedFileName must be a Literal, but is: " + resolvedFileName;
assert resolvedFileName.valueType() == StringType.INSTANCE : "resolvedFileName.valueType() must be " + StringType.INSTANCE;
String fileName = ValueSymbolVisitor.STRING.process(resolvedFileName);
if (!uri.endsWith("/")) {
sb.append("/");
}
sb.append(fileName);
if (projection.compressionType() == WriterProjection.CompressionType.GZIP) {
sb.append(".gz");
}
uri = sb.toString();
return new FileWriterProjector(((ThreadPoolExecutor) threadPool.generic()), uri, projection.compressionType(), inputs, ctx.expressions(), overwrites, projection.outputNames(), projection.outputFormat());
}
use of io.crate.operation.collect.CollectExpression 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();
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);
return new IndexWriterProjector(clusterService, functions, indexNameExpressionResolver, clusterService.state().metaData().settings(), transportActionProvider.transportBulkCreateIndicesAction(), transportActionProvider.transportShardUpsertAction()::execute, indexNameResolver, bulkRetryCoordinatorPool, 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);
}
use of io.crate.operation.collect.CollectExpression in project crate by crate.
the class ProjectionToProjectorVisitor method visitColumnIndexWriterProjection.
@Override
public Projector visitColumnIndexWriterProjection(ColumnIndexWriterProjection projection, Context context) {
InputFactory.Context<CollectExpression<Row, ?>> ctx = inputFactory.ctxForInputColumns();
List<Input<?>> partitionedByInputs = new ArrayList<>(projection.partitionedBySymbols().size());
for (Symbol partitionedBySymbol : projection.partitionedBySymbols()) {
partitionedByInputs.add(ctx.add(partitionedBySymbol));
}
List<Input<?>> insertInputs = new ArrayList<>(projection.columnSymbols().size());
for (Symbol symbol : projection.columnSymbols()) {
insertInputs.add(ctx.add(symbol));
}
return new ColumnIndexWriterProjector(clusterService, functions, indexNameExpressionResolver, clusterService.state().metaData().settings(), IndexNameResolver.create(projection.tableIdent(), projection.partitionIdent(), partitionedByInputs), transportActionProvider, bulkRetryCoordinatorPool, projection.primaryKeys(), projection.ids(), projection.clusteredBy(), projection.clusteredByIdent(), projection.columnReferences(), insertInputs, ctx.expressions(), projection.onDuplicateKeyAssignments(), projection.bulkActions(), projection.autoCreateIndices(), context.jobId);
}
Aggregations