use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestNestedLoopJoinOperator method testEmptyProbePage.
@Test
public void testEmptyProbePage() throws Exception {
TaskContext taskContext = createTaskContext();
// build
List<Type> buildTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("A").row("B").pageBreak().row("C");
NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
// probe
List<Type> probeTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
List<Page> probeInput = probePages.pageBreak().build();
NestedLoopJoinOperatorFactory joinOperatorFactory = new NestedLoopJoinOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinPagesSupplier, ImmutableList.of(VARCHAR));
// expected
MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(probeTypes, buildPages.getTypes())).build();
assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true).addDriverContext(), probeInput, expected);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class TestNestedLoopJoinOperator method testCrossJoinWithNullProbe.
@Test
public void testCrossJoinWithNullProbe() throws Exception {
TaskContext taskContext = createTaskContext();
// build
List<Type> buildTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder buildPages = rowPagesBuilder(buildTypes).row("a").row("b");
NestedLoopJoinPagesSupplier nestedLoopJoinPagesSupplier = buildPageSource(taskContext, buildPages);
// probe
List<Type> probeTypes = ImmutableList.of(VARCHAR);
RowPagesBuilder probePages = rowPagesBuilder(probeTypes);
List<Page> probeInput = probePages.row("A").row((String) null).row((String) null).row("A").row("B").build();
NestedLoopJoinOperatorFactory joinOperatorFactory = new NestedLoopJoinOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinPagesSupplier, ImmutableList.of(VARCHAR));
// expected
MaterializedResult expected = resultBuilder(taskContext.getSession(), concat(probeTypes, buildPages.getTypes())).row("A", "a").row(null, "a").row(null, "a").row("A", "a").row("B", "a").row("A", "b").row(null, "b").row(null, "b").row("A", "b").row("B", "b").build();
assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true).addDriverContext(), probeInput, expected);
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class SqlTaskExecution method updateSources.
private synchronized Map<PlanNodeId, TaskSource> updateSources(List<TaskSource> sources) {
Map<PlanNodeId, TaskSource> updatedUnpartitionedSources = new HashMap<>();
// first remove any split that was already acknowledged
long currentMaxAcknowledgedSplit = this.maxAcknowledgedSplit;
sources = sources.stream().map(source -> new TaskSource(source.getPlanNodeId(), source.getSplits().stream().filter(scheduledSplit -> scheduledSplit.getSequenceId() > currentMaxAcknowledgedSplit).collect(Collectors.toSet()), source.isNoMoreSplits())).collect(toList());
// update task with new sources
for (TaskSource source : sources) {
if (partitionedDriverFactories.containsKey(source.getPlanNodeId())) {
schedulePartitionedSource(source);
} else {
scheduleUnpartitionedSource(source, updatedUnpartitionedSources);
}
}
// update maxAcknowledgedSplit
maxAcknowledgedSplit = sources.stream().flatMap(source -> source.getSplits().stream()).mapToLong(ScheduledSplit::getSequenceId).max().orElse(maxAcknowledgedSplit);
return updatedUnpartitionedSources;
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class SqlStageExecution method scheduleTask.
private synchronized RemoteTask scheduleTask(Node node, TaskId taskId, Multimap<PlanNodeId, Split> sourceSplits) {
checkArgument(!allTasks.contains(taskId), "A task with id %s already exists", taskId);
ImmutableMultimap.Builder<PlanNodeId, Split> initialSplits = ImmutableMultimap.builder();
initialSplits.putAll(sourceSplits);
for (Entry<PlanNodeId, URI> entry : exchangeLocations.entries()) {
initialSplits.put(entry.getKey(), createRemoteSplitFor(taskId, entry.getValue()));
}
OutputBuffers outputBuffers = this.outputBuffers.get();
checkState(outputBuffers != null, "Initial output buffers must be set before a task can be scheduled");
RemoteTask task = remoteTaskFactory.createRemoteTask(stateMachine.getSession(), taskId, node, stateMachine.getFragment(), initialSplits.build(), outputBuffers, nodeTaskMap.createPartitionedSplitCountTracker(node, taskId), summarizeTaskInfo);
completeSources.forEach(task::noMoreSplits);
allTasks.add(taskId);
tasks.computeIfAbsent(node, key -> newConcurrentHashSet()).add(task);
nodeTaskMap.addTask(node, task);
task.addStateChangeListener(new StageTaskListener());
if (!stateMachine.getState().isDone()) {
task.start();
} else {
// stage finished while we were scheduling this task
task.abort();
}
return task;
}
use of com.facebook.presto.sql.planner.plan.PlanNodeId in project presto by prestodb.
the class SqlTask method createTaskInfo.
private TaskInfo createTaskInfo(TaskHolder taskHolder) {
TaskStats taskStats = getTaskStats(taskHolder);
Set<PlanNodeId> noMoreSplits = getNoMoreSplits(taskHolder);
TaskStatus taskStatus = createTaskStatus(taskHolder);
return new TaskInfo(taskStatus, lastHeartbeat.get(), outputBuffer.getInfo(), noMoreSplits, taskStats, needsPlan.get(), taskStatus.getState().isDone());
}
Aggregations