use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.
the class TestDynamicFilterService method createPlan.
private static PlanFragment createPlan(DynamicFilterId consumedDynamicFilterId, DynamicFilterId producedDynamicFilterId, PartitioningHandle stagePartitioning, ExchangeNode.Type exchangeType) {
Symbol symbol = new Symbol("column");
Symbol buildSymbol = new Symbol("buildColumn");
PlanNodeId tableScanNodeId = new PlanNodeId("plan_id");
TableScanNode tableScan = TableScanNode.newInstance(tableScanNodeId, TEST_TABLE_HANDLE, ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingMetadata.TestingColumnHandle("column")), false, Optional.empty());
FilterNode filterNode = new FilterNode(new PlanNodeId("filter_node_id"), tableScan, createDynamicFilterExpression(session, createTestMetadataManager(), consumedDynamicFilterId, VARCHAR, symbol.toSymbolReference()));
RemoteSourceNode remote = new RemoteSourceNode(new PlanNodeId("remote_id"), new PlanFragmentId("plan_fragment_id"), ImmutableList.of(buildSymbol), Optional.empty(), exchangeType, RetryPolicy.NONE);
return new PlanFragment(new PlanFragmentId("plan_id"), new JoinNode(new PlanNodeId("join_id"), INNER, filterNode, remote, ImmutableList.of(), tableScan.getOutputSymbols(), remote.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(producedDynamicFilterId, buildSymbol), Optional.empty()), ImmutableMap.of(symbol, VARCHAR), stagePartitioning, ImmutableList.of(tableScanNodeId), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), ImmutableList.of(symbol)), ungroupedExecution(), StatsAndCosts.empty(), Optional.empty());
}
use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.
the class PlanUtils method createJoinPlanFragment.
static PlanFragment createJoinPlanFragment(JoinNode.Type joinType, JoinNode.DistributionType distributionType, String name, PlanFragment buildFragment, PlanFragment probeFragment) {
RemoteSourceNode probe = new RemoteSourceNode(new PlanNodeId("probe_id"), probeFragment.getId(), ImmutableList.of(), Optional.empty(), REPARTITION, RetryPolicy.NONE);
RemoteSourceNode build = new RemoteSourceNode(new PlanNodeId("build_id"), buildFragment.getId(), ImmutableList.of(), Optional.empty(), REPARTITION, RetryPolicy.NONE);
PlanNode planNode = new JoinNode(new PlanNodeId(name + "_id"), joinType, probe, build, ImmutableList.of(), probe.getOutputSymbols(), build.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(distributionType), Optional.empty(), ImmutableMap.of(), Optional.empty());
return createFragment(planNode);
}
use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.
the class StageTaskSourceFactory method getInputsForRemoteSources.
private static ListMultimap<PlanNodeId, ExchangeSourceHandle> getInputsForRemoteSources(List<RemoteSourceNode> remoteSources, Multimap<PlanFragmentId, ExchangeSourceHandle> exchangeSourceHandles) {
ImmutableListMultimap.Builder<PlanNodeId, ExchangeSourceHandle> result = ImmutableListMultimap.builder();
for (RemoteSourceNode remoteSource : remoteSources) {
for (PlanFragmentId fragmentId : remoteSource.getSourceFragmentIds()) {
Collection<ExchangeSourceHandle> handles = requireNonNull(exchangeSourceHandles.get(fragmentId), () -> "exchange source handle is missing for fragment: " + fragmentId);
if (remoteSource.getExchangeType() == GATHER || remoteSource.getExchangeType() == REPLICATE) {
checkArgument(handles.size() <= 1, "at most 1 exchange source handle is expected, got: %s", handles);
}
result.putAll(remoteSource.getId(), handles);
}
}
return result.build();
}
use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.
the class PipelinedStageExecution method createPipelinedStageExecution.
public static PipelinedStageExecution createPipelinedStageExecution(SqlStage stage, Map<PlanFragmentId, OutputBufferManager> outputBufferManagers, TaskLifecycleListener taskLifecycleListener, FailureDetector failureDetector, Executor executor, Optional<int[]> bucketToPartition, int attempt) {
PipelinedStageStateMachine stateMachine = new PipelinedStageStateMachine(stage.getStageId(), executor);
ImmutableMap.Builder<PlanFragmentId, RemoteSourceNode> exchangeSources = ImmutableMap.builder();
for (RemoteSourceNode remoteSourceNode : stage.getFragment().getRemoteSourceNodes()) {
for (PlanFragmentId planFragmentId : remoteSourceNode.getSourceFragmentIds()) {
exchangeSources.put(planFragmentId, remoteSourceNode);
}
}
PipelinedStageExecution execution = new PipelinedStageExecution(stateMachine, stage, outputBufferManagers, taskLifecycleListener, failureDetector, executor, bucketToPartition, exchangeSources.buildOrThrow(), attempt);
execution.initialize();
return execution;
}
use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.
the class PipelinedStageExecution method noMoreSourceTasks.
private synchronized void noMoreSourceTasks(PlanFragmentId fragmentId) {
RemoteSourceNode remoteSource = exchangeSources.get(fragmentId);
checkArgument(remoteSource != null, "Unknown remote source %s. Known sources are %s", fragmentId, exchangeSources.keySet());
completeSourceFragments.add(fragmentId);
// is the source now complete?
if (completeSourceFragments.containsAll(remoteSource.getSourceFragmentIds())) {
completeSources.add(remoteSource.getId());
for (RemoteTask task : getAllTasks()) {
task.noMoreSplits(remoteSource.getId());
}
}
}
Aggregations