@Override public boolean accept(PlanVisitor v) { if (v.visitEnter(this)) { if (input != null) input.accept(v); } return v.visitLeave(this); }
@JsonCreator public TopNNode( @JsonProperty("id") PlanNodeId id, @JsonProperty("source") PlanNode source, @JsonProperty("count") long count, @JsonProperty("orderBy") List<Symbol> orderBy, @JsonProperty("orderings") Map<Symbol, SortOrder> orderings, @JsonProperty("partial") boolean partial, @JsonProperty("sampleWeight") Optional<Symbol> sampleWeight) { super(id); Preconditions.checkNotNull(source, "source is null"); Preconditions.checkArgument(count > 0, "count must be positive"); Preconditions.checkNotNull(orderBy, "orderBy is null"); Preconditions.checkArgument(!orderBy.isEmpty(), "orderBy is empty"); Preconditions.checkArgument( orderings.size() == orderBy.size(), "orderBy and orderings sizes don't match"); Preconditions.checkNotNull(sampleWeight, "sampleWeight is null"); if (sampleWeight.isPresent()) { Preconditions.checkArgument( source.getOutputSymbols().contains(sampleWeight.get()), "source does not output sample weight"); } this.source = source; this.count = count; this.orderBy = ImmutableList.copyOf(orderBy); this.orderings = ImmutableMap.copyOf(orderings); this.partial = partial; this.sampleWeight = sampleWeight; }
@Override public void replaceInput(PlanNode oldInput, PlanNode newInput) { if (input == oldInput) { input = newInput; input.setOutput(this); } }
@JsonCreator public UnnestNode( @JsonProperty("id") PlanNodeId id, @JsonProperty("source") PlanNode source, @JsonProperty("replicateSymbols") List<Symbol> replicateSymbols, @JsonProperty("unnestSymbols") Map<Symbol, List<Symbol>> unnestSymbols, @JsonProperty("ordinalitySymbol") Optional<Symbol> ordinalitySymbol) { super(id); this.source = requireNonNull(source, "source is null"); this.replicateSymbols = ImmutableList.copyOf(requireNonNull(replicateSymbols, "replicateSymbols is null")); checkArgument( source.getOutputSymbols().containsAll(replicateSymbols), "Source does not contain all replicateSymbols"); requireNonNull(unnestSymbols, "unnestSymbols is null"); checkArgument(!unnestSymbols.isEmpty(), "unnestSymbols is empty"); ImmutableMap.Builder<Symbol, List<Symbol>> builder = ImmutableMap.builder(); for (Map.Entry<Symbol, List<Symbol>> entry : unnestSymbols.entrySet()) { builder.put(entry.getKey(), ImmutableList.copyOf(entry.getValue())); } this.unnestSymbols = builder.build(); this.ordinalitySymbol = requireNonNull(ordinalitySymbol, "ordinalitySymbol is null"); }
@Override public List<Symbol> getOutputSymbols() { return source.getOutputSymbols(); }
@Override protected void deepCopy(DuplicateMap map) { super.deepCopy(map); if (input != null) setInput((PlanNode) input.duplicate(map)); // Which takes care of setting input's output. }
public void setInput(PlanNode input) { this.input = input; input.setOutput(this); }
protected BasePlanWithInput(PlanNode input) { this.input = input; if (input != null) input.setOutput(this); }