Search in sources :

Example 1 with RemoteSourceNode

use of io.prestosql.sql.planner.plan.RemoteSourceNode in project hetu-core by openlookeng.

the class TestDynamicFilterUtil method registerDf.

public static void registerDf(String filterId, Session session, JoinNode.DistributionType joinType, DynamicFilterService dynamicFilterService) {
    JoinNode node = mock(JoinNode.class);
    HashMap<String, Symbol> dfs = new HashMap<>();
    List<JoinNode.EquiJoinClause> criteria = new ArrayList<JoinNode.EquiJoinClause>();
    Symbol right = new Symbol("rightCol");
    Symbol left = new Symbol("leftCol");
    JoinNode.EquiJoinClause clause = new JoinNode.EquiJoinClause(left, right);
    criteria.add(clause);
    dfs.put(filterId, right);
    when(node.getCriteria()).thenReturn(criteria);
    when(node.getDynamicFilters()).thenReturn(dfs);
    when(node.getDistributionType()).thenReturn(Optional.of(joinType));
    RemoteSourceNode leftNode = mock(RemoteSourceNode.class);
    when(node.getLeft()).thenReturn(leftNode);
    HashSet<TaskId> tasks = new HashSet<>();
    tasks.add(new TaskId("task1.0"));
    tasks.add(new TaskId("task1.1"));
    StageStateMachine stateMachine = mock(StageStateMachine.class);
    when(stateMachine.getSession()).thenReturn(session);
    InternalNode worker = mock(InternalNode.class);
    InternalNode worker2 = mock(InternalNode.class);
    HashSet<InternalNode> workers = new HashSet<>();
    when(worker.getNodeIdentifier()).thenReturn("w1");
    when(worker2.getNodeIdentifier()).thenReturn("w2");
    workers.add(worker);
    workers.add(worker2);
    dynamicFilterService.registerTasks(node, tasks, workers, stateMachine);
}
Also used : TaskId(io.prestosql.execution.TaskId) HashMap(java.util.HashMap) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) StageStateMachine(io.prestosql.execution.StageStateMachine) InternalNode(io.prestosql.metadata.InternalNode) HashSet(java.util.HashSet)

Example 2 with RemoteSourceNode

use of io.prestosql.sql.planner.plan.RemoteSourceNode in project hetu-core by openlookeng.

the class DistributedExecutionPlanner method collectSources.

private List<MarkerSplitSource> collectSources(Map<PlanFragmentId, Object> leftmostSources, Object source) {
    if (source instanceof ValuesNode) {
        // TODO-cp-I2X9J6: should we worry about dependencies about Values operators, when it's the "left" of a join?
        return ImmutableList.of();
    }
    if (source instanceof RemoteSourceNode) {
        List<PlanFragmentId> fragments = ((RemoteSourceNode) source).getSourceFragmentIds();
        if (fragments.size() == 1) {
            return collectSources(leftmostSources, leftmostSources.get(fragments.get(0)));
        }
        List<MarkerSplitSource> sources = new ArrayList<>();
        for (PlanFragmentId id : fragments) {
            sources.addAll(collectSources(leftmostSources, leftmostSources.get(id)));
        }
        // Adding all these sources as "union dependencies" for each other, to make sure they produce the same set of markers.
        for (MarkerSplitSource unionSource : sources) {
            unionSource.addUnionSources(sources);
        }
        return sources;
    }
    // Must be a split source
    return ImmutableList.of((MarkerSplitSource) source);
}
Also used : ValuesNode(io.prestosql.spi.plan.ValuesNode) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) MarkerSplitSource(io.prestosql.snapshot.MarkerSplitSource) ArrayList(java.util.ArrayList) PlanFragmentId(io.prestosql.sql.planner.plan.PlanFragmentId)

Example 3 with RemoteSourceNode

use of io.prestosql.sql.planner.plan.RemoteSourceNode in project hetu-core by openlookeng.

the class AllAtOnceExecutionSchedule method getPreferredScheduleOrder.

@VisibleForTesting
static List<PlanFragmentId> getPreferredScheduleOrder(Collection<PlanFragment> fragments) {
    // determine output fragment
    Set<PlanFragmentId> remoteSources = fragments.stream().map(PlanFragment::getRemoteSourceNodes).flatMap(Collection::stream).map(RemoteSourceNode::getSourceFragmentIds).flatMap(Collection::stream).collect(toImmutableSet());
    Set<PlanFragment> rootFragments = fragments.stream().filter(fragment -> !remoteSources.contains(fragment.getId())).collect(toImmutableSet());
    checkArgument(rootFragments.size() == 1, "Expected one root fragment, but found: " + rootFragments);
    Visitor visitor = new Visitor(fragments);
    visitor.processFragment(getOnlyElement(rootFragments).getId());
    return visitor.getSchedulerOrder();
}
Also used : RUNNING(io.prestosql.execution.StageState.RUNNING) InternalPlanVisitor(io.prestosql.sql.planner.plan.InternalPlanVisitor) SCHEDULED(io.prestosql.execution.StageState.SCHEDULED) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) PlanFragmentId(io.prestosql.sql.planner.plan.PlanFragmentId) SemiJoinNode(io.prestosql.sql.planner.plan.SemiJoinNode) ExchangeNode(io.prestosql.sql.planner.plan.ExchangeNode) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) LinkedHashSet(java.util.LinkedHashSet) JoinNode(io.prestosql.spi.plan.JoinNode) PlanFragment(io.prestosql.sql.planner.PlanFragment) ImmutableSet(com.google.common.collect.ImmutableSet) Iterator(java.util.Iterator) Collection(java.util.Collection) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) PlanNode(io.prestosql.spi.plan.PlanNode) IndexJoinNode(io.prestosql.sql.planner.plan.IndexJoinNode) SpatialJoinNode(io.prestosql.sql.planner.plan.SpatialJoinNode) List(java.util.List) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) StageState(io.prestosql.execution.StageState) Ordering(com.google.common.collect.Ordering) Function.identity(java.util.function.Function.identity) UnionNode(io.prestosql.spi.plan.UnionNode) VisibleForTesting(com.google.common.annotations.VisibleForTesting) SqlStageExecution(io.prestosql.execution.SqlStageExecution) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) InternalPlanVisitor(io.prestosql.sql.planner.plan.InternalPlanVisitor) PlanFragmentId(io.prestosql.sql.planner.plan.PlanFragmentId) PlanFragment(io.prestosql.sql.planner.PlanFragment) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 4 with RemoteSourceNode

use of io.prestosql.sql.planner.plan.RemoteSourceNode in project hetu-core by openlookeng.

the class TestSqlStageExecution method createExchangePlanFragment.

private static PlanFragment createExchangePlanFragment() {
    PlanNode planNode = new RemoteSourceNode(new PlanNodeId("exchange"), ImmutableList.of(new PlanFragmentId("source")), ImmutableList.of(new Symbol("column")), Optional.empty(), REPARTITION);
    ImmutableMap.Builder<Symbol, Type> types = ImmutableMap.builder();
    for (Symbol symbol : planNode.getOutputSymbols()) {
        types.put(symbol, VARCHAR);
    }
    return new PlanFragment(new PlanFragmentId("exchange_fragment_id"), planNode, types.build(), SOURCE_DISTRIBUTION, ImmutableList.of(planNode.getId()), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), planNode.getOutputSymbols()), ungroupedExecution(), StatsAndCosts.empty(), Optional.empty(), Optional.empty(), Optional.empty());
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) Type(io.prestosql.spi.type.Type) PlanNode(io.prestosql.spi.plan.PlanNode) Symbol(io.prestosql.spi.plan.Symbol) PartitioningScheme(io.prestosql.sql.planner.PartitioningScheme) PlanFragmentId(io.prestosql.sql.planner.plan.PlanFragmentId) ImmutableMap(com.google.common.collect.ImmutableMap) PlanFragment(io.prestosql.sql.planner.PlanFragment)

Example 5 with RemoteSourceNode

use of io.prestosql.sql.planner.plan.RemoteSourceNode in project hetu-core by openlookeng.

the class SqlStageExecution method addExchangeLocations.

public synchronized void addExchangeLocations(PlanFragmentId fragmentId, Set<RemoteTask> sourceTasks, boolean noMoreExchangeLocations) {
    requireNonNull(fragmentId, "fragmentId is null");
    requireNonNull(sourceTasks, "sourceTasks is null");
    RemoteSourceNode remoteSource = exchangeSources.get(fragmentId);
    checkArgument(remoteSource != null, "Unknown remote source %s. Known sources are %s", fragmentId, exchangeSources.keySet());
    this.sourceTasks.putAll(remoteSource.getId(), sourceTasks);
    for (RemoteTask task : getAllTasks()) {
        ImmutableMultimap.Builder<PlanNodeId, Split> newSplits = ImmutableMultimap.builder();
        for (RemoteTask sourceTask : sourceTasks) {
            newSplits.put(remoteSource.getId(), newConnectSplit(task.getTaskId(), sourceTask));
        }
        task.addSplits(newSplits.build());
    }
    if (noMoreExchangeLocations) {
        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());
            }
        }
    }
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) Split(io.prestosql.metadata.Split) RemoteSplit(io.prestosql.split.RemoteSplit)

Aggregations

RemoteSourceNode (io.prestosql.sql.planner.plan.RemoteSourceNode)9 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)6 JoinNode (io.prestosql.spi.plan.JoinNode)5 Symbol (io.prestosql.spi.plan.Symbol)5 PlanFragmentId (io.prestosql.sql.planner.plan.PlanFragmentId)5 PlanNode (io.prestosql.spi.plan.PlanNode)4 UUID (java.util.UUID)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)2 PlanFragment (io.prestosql.sql.planner.PlanFragment)2 StageExecutionPlan (io.prestosql.sql.planner.StageExecutionPlan)2 TestingColumnHandle (io.prestosql.testing.TestingMetadata.TestingColumnHandle)2 ArrayList (java.util.ArrayList)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1