Search in sources :

Example 1 with LineCollectorExpression

use of io.crate.operation.collect.files.LineCollectorExpression in project crate by crate.

the class FileCollectSource method getCollector.

@Override
public CrateCollector getCollector(CollectPhase collectPhase, BatchConsumer consumer, JobCollectContext jobCollectContext) {
    FileUriCollectPhase fileUriCollectPhase = (FileUriCollectPhase) collectPhase;
    InputFactory.Context<LineCollectorExpression<?>> ctx = inputFactory.ctxForRefs(FileLineReferenceResolver::getImplementation);
    ctx.add(collectPhase.toCollect());
    String[] readers = fileUriCollectPhase.nodeIds().toArray(new String[fileUriCollectPhase.nodeIds().size()]);
    Arrays.sort(readers);
    List<String> fileUris;
    fileUris = targetUriToStringList(fileUriCollectPhase.targetUri());
    BatchIterator fileReadingIterator = FileReadingIterator.newInstance(fileUris, ctx.topLevelInputs(), ctx.expressions(), fileUriCollectPhase.compression(), fileInputFactoryMap, fileUriCollectPhase.sharedStorage(), readers.length, Arrays.binarySearch(readers, clusterService.state().nodes().getLocalNodeId()));
    return BatchIteratorCollectorBridge.newInstance(fileReadingIterator, consumer);
}
Also used : FileInputFactory(io.crate.operation.collect.files.FileInputFactory) InputFactory(io.crate.operation.InputFactory) LineCollectorExpression(io.crate.operation.collect.files.LineCollectorExpression) FileLineReferenceResolver(io.crate.operation.reference.file.FileLineReferenceResolver) BatchIterator(io.crate.data.BatchIterator) FileUriCollectPhase(io.crate.planner.node.dql.FileUriCollectPhase)

Example 2 with LineCollectorExpression

use of io.crate.operation.collect.files.LineCollectorExpression in project crate by crate.

the class FileLineReferenceResolver method getImplementation.

public static LineCollectorExpression<?> getImplementation(Reference refInfo) {
    ColumnIdent columnIdent = refInfo.ident().columnIdent();
    Supplier<LineCollectorExpression<?>> supplier = EXPRESSION_BUILDER.get(columnIdent.name());
    if (supplier == null) {
        return new ColumnExtractingLineExpression(columnIdent);
    }
    return supplier.get();
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) LineCollectorExpression(io.crate.operation.collect.files.LineCollectorExpression)

Aggregations

LineCollectorExpression (io.crate.operation.collect.files.LineCollectorExpression)2 BatchIterator (io.crate.data.BatchIterator)1 ColumnIdent (io.crate.metadata.ColumnIdent)1 InputFactory (io.crate.operation.InputFactory)1 FileInputFactory (io.crate.operation.collect.files.FileInputFactory)1 FileLineReferenceResolver (io.crate.operation.reference.file.FileLineReferenceResolver)1 FileUriCollectPhase (io.crate.planner.node.dql.FileUriCollectPhase)1