예제 #1
0
  private static void findSources(
      PlanNode node, Builder<PlanNode> builder, PlanNodeId partitionedSource) {
    for (PlanNode source : node.getSources()) {
      findSources(source, builder, partitionedSource);
    }

    if (node.getSources().isEmpty() || node.getId().equals(partitionedSource)) {
      builder.add(node);
    }
  }
예제 #2
0
  @JsonCreator
  public PlanFragment(
      @JsonProperty("id") PlanFragmentId id,
      @JsonProperty("root") PlanNode root,
      @JsonProperty("symbols") Map<Symbol, Type> symbols,
      @JsonProperty("distribution") PlanDistribution distribution,
      @JsonProperty("partitionedSource") PlanNodeId partitionedSource,
      @JsonProperty("outputPartitioning") OutputPartitioning outputPartitioning) {
    this.id = checkNotNull(id, "id is null");
    this.root = checkNotNull(root, "root is null");
    this.symbols = checkNotNull(symbols, "symbols is null");
    this.distribution = checkNotNull(distribution, "distribution is null");
    this.partitionedSource = partitionedSource;

    tupleInfos =
        IterableTransformer.on(root.getOutputSymbols())
            .transform(Functions.forMap(symbols))
            .transform(Type.toRaw())
            .transform(
                new Function<TupleInfo.Type, TupleInfo>() {
                  @Override
                  public TupleInfo apply(TupleInfo.Type input) {
                    return new TupleInfo(input);
                  }
                })
            .list();

    ImmutableList.Builder<PlanNode> sources = ImmutableList.builder();
    findSources(root, sources, partitionedSource);
    this.sources = sources.build();

    ImmutableSet.Builder<PlanNodeId> sourceIds = ImmutableSet.builder();
    for (PlanNode source : this.sources) {
      sourceIds.add(source.getId());
    }
    if (partitionedSource != null) {
      sourceIds.add(partitionedSource);
    }
    this.sourceIds = sourceIds.build();

    this.outputPartitioning = checkNotNull(outputPartitioning, "outputPartitioning is null");
  }