private CrateCollector getCollector(CollectNode collectNode,
FlatProjectorChain projectorChain) throws Exception {
if (collectNode instanceof FileUriCollectNode) {
FileCollectInputSymbolVisitor.Context context = fileInputSymbolVisitor.process(collectNode);
FileUriCollectNode fileUriCollectNode = (FileUriCollectNode) collectNode;
String[] readers = fileUriCollectNode.executionNodes().toArray(
new String[fileUriCollectNode.executionNodes().size()]);
Arrays.sort(readers);
return new FileReadingCollector(
StringValueSymbolVisitor.INSTANCE.process(fileUriCollectNode.targetUri()),
context.topLevelInputs(),
context.expressions(),
projectorChain.firstProjector(),
fileUriCollectNode.fileFormat(),
fileUriCollectNode.compression(),
ImmutableMap.<String, FileInputFactory>of(),
fileUriCollectNode.sharedStorage(),
readers.length,
Arrays.binarySearch(readers, clusterService.localNode().id())
);
} else {
CollectService service = collectServiceResolver.getService(collectNode.routing());