public PlanNodeId getNextId() { return new PlanNodeId(Integer.toString(nextId++)); } }
private PlanNode reportDuplicateId(PlanNode first, PlanNode second) { requireNonNull(first, "first is null"); requireNonNull(second, "second is null"); checkArgument(first.getId().equals(second.getId())); throw new IllegalStateException(format( "Generated plan contains nodes with duplicated id %s: %s and %s", first.getId(), first, second)); } }
private static int compare(WindowNode o1, WindowNode o2) { int comparison = comparePartitionBy(o1, o2); if (comparison != 0) { return comparison; } comparison = compareOrderBy(o1, o2); if (comparison != 0) { return comparison; } // If PartitionBy and OrderBy clauses are identical, let's establish an arbitrary order to prevent non-deterministic results of swapping WindowNodes in such a case return o1.getId().toString().compareTo(o2.getId().toString()); }
public PlanNodeId getNextId() { return new PlanNodeId(Integer.toString(nextId++)); } }
private static int compare(WindowNode o1, WindowNode o2) { int comparison = comparePartitionBy(o1, o2); if (comparison != 0) { return comparison; } comparison = compareOrderBy(o1, o2); if (comparison != 0) { return comparison; } // If PartitionBy and OrderBy clauses are identical, let's establish an arbitrary order to prevent non-deterministic results of swapping WindowNodes in such a case return o1.getId().toString().compareTo(o2.getId().toString()); }
private PlanNode reportDuplicateId(PlanNode first, PlanNode second) { requireNonNull(first, "first is null"); requireNonNull(second, "second is null"); checkArgument(first.getId().equals(second.getId())); throw new IllegalStateException(format( "Generated plan contains nodes with duplicated id %s: %s and %s", first.getId(), first, second)); } }
@Override protected List<? extends OperatorFactory> createOperatorFactories() { OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice"); return ImmutableList.of(tableScanOperator); }
private StatsCalculator statsCalculator(Map<String, PlanNodeStatsEstimate> stats) { return (node, sourceStats, lookup, session, types) -> requireNonNull(stats.get(node.getId().toString()), "no stats for node"); }
public void updateSource(TaskSource sourceUpdate) { checkLockNotHeld("Can not update sources while holding the driver lock"); checkArgument( sourceOperator.isPresent() && sourceOperator.get().getSourceId().equals(sourceUpdate.getPlanNodeId()), "sourceUpdate is for a plan node that is different from this Driver's source node"); // stage the new updates pendingTaskSourceUpdates.updateAndGet(current -> current == null ? sourceUpdate : current.update(sourceUpdate)); // attempt to get the lock and process the updates we staged above // updates will be processed in close if and only if we got the lock tryWithLock(() -> TRUE); }
@Override protected List<? extends OperatorFactory> createOperatorFactories() { OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice"); return ImmutableList.of(tableScanOperator); }
private StatsCalculator statsCalculator(Map<String, PlanNodeStatsEstimate> stats) { return (node, sourceStats, lookup, session, types) -> requireNonNull(stats.get(node.getId().toString()), "no stats for node"); }
public void updateSource(TaskSource sourceUpdate) { checkLockNotHeld("Can not update sources while holding the driver lock"); checkArgument( sourceOperator.isPresent() && sourceOperator.get().getSourceId().equals(sourceUpdate.getPlanNodeId()), "sourceUpdate is for a plan node that is different from this Driver's source node"); // stage the new updates pendingTaskSourceUpdates.updateAndGet(current -> current == null ? sourceUpdate : current.update(sourceUpdate)); // attempt to get the lock and process the updates we staged above // updates will be processed in close if and only if we got the lock tryWithLock(() -> TRUE); }
@Override protected List<? extends OperatorFactory> createOperatorFactories() { List<Type> tableScanTypes = getColumnTypes("orders", "totalprice"); OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice"); TopNOperatorFactory topNOperator = new TopNOperatorFactory( 1, new PlanNodeId("test"), tableScanTypes, 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST)); return ImmutableList.of(tableScanOperator, topNOperator); }
public StatsCalculatorAssertion withSourceStats(PlanNodeId planNodeId, PlanNodeStatsEstimate sourceStats) { PlanNode sourceNode = PlanNodeSearcher.searchFrom(planNode).where(node -> node.getId().equals(planNodeId)).findOnlyElement(); sourcesStats.put(sourceNode, sourceStats); return this; }
@Override protected List<? extends OperatorFactory> createOperatorFactories() { List<Type> tableScanTypes = getColumnTypes("orders", "totalprice"); OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice"); TopNOperatorFactory topNOperator = new TopNOperatorFactory( 1, new PlanNodeId("test"), tableScanTypes, 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST)); return ImmutableList.of(tableScanOperator, topNOperator); }
public StatsCalculatorAssertion withSourceStats(PlanNodeId planNodeId, PlanNodeStatsEstimate sourceStats) { PlanNode sourceNode = PlanNodeSearcher.searchFrom(planNode).where(node -> node.getId().equals(planNodeId)).findOnlyElement(); sourcesStats.put(sourceNode, sourceStats); return this; }
protected DriverFactory createDriverFactory() { List<OperatorFactory> operatorFactories = new ArrayList<>(createOperatorFactories()); operatorFactories.add(new NullOutputOperatorFactory(999, new PlanNodeId("test"))); return new DriverFactory(0, true, true, operatorFactories, OptionalInt.empty(), UNGROUPED_EXECUTION); }
private CostAssertionBuilder assertCost( CostCalculator costCalculator, PlanNode node, Map<String, PlanNodeCostEstimate> costs, Map<String, PlanNodeStatsEstimate> stats, Map<String, Type> types) { PlanNodeCostEstimate cumulativeCost = calculateCumulativeCost( costCalculator, node, planNode -> costs.get(planNode.getId().toString()), planNode -> stats.get(planNode.getId().toString()), types); return new CostAssertionBuilder(cumulativeCost); }