use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.
the class TestSchedulingOrderVisitor method testSemiJoinOrder.
@Test
public void testSemiJoinOrder() {
PlanBuilder planBuilder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), METADATA);
VariableReferenceExpression sourceJoin = planBuilder.variable("sourceJoin");
TableScanNode a = planBuilder.tableScan(ImmutableList.of(sourceJoin), ImmutableMap.of(sourceJoin, new TestingColumnHandle("sourceJoin")));
VariableReferenceExpression filteringSource = planBuilder.variable("filteringSource");
TableScanNode b = planBuilder.tableScan(ImmutableList.of(filteringSource), ImmutableMap.of(filteringSource, new TestingColumnHandle("filteringSource")));
List<PlanNodeId> order = scheduleOrder(planBuilder.semiJoin(sourceJoin, filteringSource, planBuilder.variable("semiJoinOutput"), Optional.empty(), Optional.empty(), a, b));
assertEquals(order, ImmutableList.of(b.getId(), a.getId()));
}
use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.
the class AddIntermediateAggregations method apply.
@Override
public Result apply(AggregationNode aggregation, Captures captures, Context context) {
Lookup lookup = context.getLookup();
PlanNodeIdAllocator idAllocator = context.getIdAllocator();
Session session = context.getSession();
TypeProvider types = context.getVariableAllocator().getTypes();
Optional<PlanNode> rewrittenSource = recurseToPartial(lookup.resolve(aggregation.getSource()), lookup, idAllocator, types);
if (!rewrittenSource.isPresent()) {
return Result.empty();
}
PlanNode source = rewrittenSource.get();
if (getTaskConcurrency(session) > 1) {
Map<VariableReferenceExpression, Aggregation> variableToAggregations = inputsAsOutputs(aggregation.getAggregations(), types);
if (variableToAggregations.isEmpty()) {
return Result.empty();
}
source = roundRobinExchange(idAllocator.getNextId(), LOCAL, source);
source = new AggregationNode(aggregation.getSourceLocation(), idAllocator.getNextId(), source, variableToAggregations, aggregation.getGroupingSets(), aggregation.getPreGroupedVariables(), INTERMEDIATE, aggregation.getHashVariable(), aggregation.getGroupIdVariable());
source = gatheringExchange(idAllocator.getNextId(), LOCAL, source);
}
return Result.ofPlanNode(aggregation.replaceChildren(ImmutableList.of(source)));
}
Aggregations