private Set<Integer> getAllReferences(PlanNode node) { return node.getSources().stream() .map(GroupReference.class::cast) .map(GroupReference::getGroupId) .collect(Collectors.toSet()); }
@Override protected Void visitPlan(PlanNode node, Void context) { for (PlanNode child : node.getSources()) { child.accept(this, context); } return null; }
public static Property<PlanNode, Lookup, PlanNode> source() { return optionalProperty( "source", (node, lookup) -> { if (node.getSources().size() == 1) { PlanNode source = getOnlyElement(node.getSources()); return Optional.of(lookup.resolve(source)); } return Optional.empty(); }); }
@Override protected Void visitPlan(PlanNode node, C context) { for (PlanNode source : node.getSources()) { source.accept(this, context); } return null; } }
@Override protected Optional<SeenExchanges> visitPlan(PlanNode node, Void context) { return aggregatedSeenExchanges(node.getSources()); }
private Void processChildren(PlanNode node, int indent) { for (PlanNode child : node.getSources()) { child.accept(this, indent); } return null; }
@Override protected Void visitPlan(PlanNode node, Void context) { node.getSources().forEach(source -> source.accept(this, context)); return null; }
@Override protected Void visitPlan(PlanNode node, C context) { for (PlanNode source : node.getSources()) { source.accept(this, context); } return null; } }
@Override protected PlanNode visitPlan(PlanNode node, Void context) { List<PlanNode> children = node.getSources().stream() .map(child -> child.accept(this, context)) .collect(Collectors.toList()); return node.replaceChildren(children); }
private static void findSources(PlanNode node, Set<PlanNodeId> nodeIds, ImmutableSet.Builder<PlanNode> nodes) { if (nodeIds.contains(node.getId())) { nodes.add(node); } for (PlanNode source : node.getSources()) { nodes.addAll(findSources(source, nodeIds)); } }
private static void findSources(PlanNode node, Set<PlanNodeId> nodeIds, ImmutableSet.Builder<PlanNode> nodes) { if (nodeIds.contains(node.getId())) { nodes.add(node); } for (PlanNode source : node.getSources()) { nodes.addAll(findSources(source, nodeIds)); } }
/** * Transforms a plan like P->C->X to C->P->X */ public static PlanNode transpose(PlanNode parent, PlanNode child) { return child.replaceChildren(ImmutableList.of( parent.replaceChildren( child.getSources()))); }
@Override protected GroupedExecutionProperties visitPlan(PlanNode node, Void context) { if (node.getSources().isEmpty()) { return GroupedExecutionProperties.notCapable(); } return processChildren(node); }
public static ActualProperties derivePropertiesRecursively(PlanNode node, Metadata metadata, Session session, TypeProvider types, SqlParser parser) { List<ActualProperties> inputProperties = node.getSources().stream() .map(source -> derivePropertiesRecursively(source, metadata, session, types, parser)) .collect(toImmutableList()); return deriveProperties(node, inputProperties, metadata, session, types, parser); }
public StatsCalculatorAssertion withSourceStats(int sourceIndex, PlanNodeStatsEstimate sourceStats) { checkArgument(sourceIndex < planNode.getSources().size(), "invalid sourceIndex %s; planNode has %s sources", sourceIndex, planNode.getSources().size()); sourcesStats.put(planNode.getSources().get(sourceIndex), sourceStats); return this; }
public StatsCalculatorAssertion withSourceStats(int sourceIndex, PlanNodeStatsEstimate sourceStats) { checkArgument(sourceIndex < planNode.getSources().size(), "invalid sourceIndex %s; planNode has %s sources", sourceIndex, planNode.getSources().size()); sourcesStats.put(planNode.getSources().get(sourceIndex), sourceStats); return this; }
public StatsCalculatorAssertion(StatsCalculator statsCalculator, Session session, PlanNode planNode, TypeProvider types) { this.statsCalculator = requireNonNull(statsCalculator, "statsCalculator can not be null"); this.session = requireNonNull(session, "sesssion can not be null"); this.planNode = requireNonNull(planNode, "planNode is null"); this.types = requireNonNull(types, "types is null"); sourcesStats = new HashMap<>(); planNode.getSources().forEach(child -> sourcesStats.put(child, PlanNodeStatsEstimate.unknown())); }
public StatsCalculatorAssertion withSourceStats(PlanNodeStatsEstimate sourceStats) { checkState(planNode.getSources().size() == 1, "expected single source"); return withSourceStats(0, sourceStats); }
public StatsCalculatorAssertion withSourceStats(PlanNodeStatsEstimate sourceStats) { checkState(planNode.getSources().size() == 1, "expected single source"); return withSourceStats(0, sourceStats); }
private PlanNodeCostEstimate calculateCumulativeCost(PlanNode node) { PlanNodeCostEstimate sourcesCost = node.getSources().stream() .map(this::getCumulativeCost) .reduce(PlanNodeCostEstimate.zero(), PlanNodeCostEstimate::add); return costCalculator.calculateCost(node, statsProvider, session, types).add(sourcesCost); } }