Пример #1
0
 @Nullable
 private Function rewriteAndValidateFields(Function function, Context context) {
   if (function.arguments().size() == 2) {
     Symbol left = function.arguments().get(0);
     Symbol right = function.arguments().get(1);
     if (left.symbolType() == SymbolType.REFERENCE && right.symbolType().isValueSymbol()) {
       Reference ref = (Reference) left;
       if (ref.info().ident().columnIdent().equals(DocSysColumns.ID)) {
         function.setArgument(
             0,
             new Reference(DocSysColumns.forTable(ref.ident().tableIdent(), DocSysColumns.UID)));
         function.setArgument(
             1,
             Literal.newLiteral(
                 Uid.createUid(
                     Constants.DEFAULT_MAPPING_TYPE, ValueSymbolVisitor.STRING.process(right))));
       } else {
         String unsupportedMessage =
             context.unsupportedMessage(ref.info().ident().columnIdent().name());
         if (unsupportedMessage != null) {
           throw new UnsupportedFeatureException(unsupportedMessage);
         }
       }
     }
   }
   return function;
 }
Пример #2
0
  @Override
  public Collection<CrateCollector> getCollectors(
      CollectPhase collectPhase, RowDownstream downstream, JobCollectContext jobCollectContext) {

    FileCollectInputSymbolVisitor.Context context =
        fileInputSymbolVisitor.extractImplementations(collectPhase);
    FileUriCollectPhase fileUriCollectPhase = (FileUriCollectPhase) collectPhase;

    String[] readers =
        fileUriCollectPhase
            .executionNodes()
            .toArray(new String[fileUriCollectPhase.executionNodes().size()]);
    Arrays.sort(readers);
    return ImmutableList.<CrateCollector>of(
        new FileReadingCollector(
            ValueSymbolVisitor.STRING.process(fileUriCollectPhase.targetUri()),
            context.topLevelInputs(),
            context.expressions(),
            downstream,
            fileUriCollectPhase.fileFormat(),
            fileUriCollectPhase.compression(),
            ImmutableMap.<String, FileInputFactory>of(),
            fileUriCollectPhase.sharedStorage(),
            readers.length,
            Arrays.binarySearch(readers, clusterService.state().nodes().localNodeId())));
  }