Search in sources :

Example 6 with ExchangePrel

use of org.apache.drill.exec.planner.physical.ExchangePrel in project drill by axbaretto.

the class ExcessiveExchangeIdentifier method visitExchange.

@Override
public Prel visitExchange(ExchangePrel prel, MajorFragmentStat parent) throws RuntimeException {
    parent.add(prel);
    MajorFragmentStat newFrag = new MajorFragmentStat();
    Prel newChild = ((Prel) prel.getInput()).accept(this, newFrag);
    if (newFrag.isSingular() && parent.isSingular() && // if one of them has strict distribution or none, we can remove the exchange
    (!newFrag.isDistributionStrict() || !parent.isDistributionStrict())) {
        return newChild;
    } else {
        return (Prel) prel.copy(prel.getTraitSet(), Collections.singletonList((RelNode) newChild));
    }
}
Also used : ScanPrel(org.apache.drill.exec.planner.physical.ScanPrel) Prel(org.apache.drill.exec.planner.physical.Prel) ExchangePrel(org.apache.drill.exec.planner.physical.ExchangePrel) ScreenPrel(org.apache.drill.exec.planner.physical.ScreenPrel)

Example 7 with ExchangePrel

use of org.apache.drill.exec.planner.physical.ExchangePrel in project drill by apache.

the class PrelSequencer method go.

public Map<Prel, OpId> go(Prel root) {
    // get fragments.
    Frag rootFrag = new Frag(root);
    frags.add(rootFrag);
    root.accept(this, rootFrag);
    // do depth first traversal of fragments to assign major fragment ids.
    Queue<Frag> q = Lists.newLinkedList();
    q.add(rootFrag);
    int majorFragmentId = 0;
    while (!q.isEmpty()) {
        Frag frag = q.remove();
        frag.majorFragmentId = majorFragmentId++;
        for (Frag child : frag) {
            q.add(child);
        }
    }
    // for each fragment, do a dfs of operators to assign operator ids.
    Map<Prel, OpId> ids = Maps.newIdentityHashMap();
    ids.put(rootFrag.root, new OpId(0, 0));
    for (Frag f : frags) {
        int id = 1;
        Queue<Prel> ops = Lists.newLinkedList();
        ops.add(f.root);
        while (!ops.isEmpty()) {
            Prel p = ops.remove();
            boolean isExchange = p instanceof ExchangePrel;
            if (p != f.root) {
                // we account for exchanges as receviers to guarantee unique identifiers.
                ids.put(p, new OpId(f.majorFragmentId, id++));
            }
            if (!isExchange || p == f.root) {
                List<Prel> children = Lists.reverse(Lists.newArrayList(p.iterator()));
                for (Prel child : children) {
                    ops.add(child);
                }
            }
        }
    }
    return ids;
}
Also used : ExchangePrel(org.apache.drill.exec.planner.physical.ExchangePrel) ExchangePrel(org.apache.drill.exec.planner.physical.ExchangePrel) Prel(org.apache.drill.exec.planner.physical.Prel)

Example 8 with ExchangePrel

use of org.apache.drill.exec.planner.physical.ExchangePrel in project drill by apache.

the class PrelSequencer method visitExchange.

@Override
public Void visitExchange(ExchangePrel prel, Frag value) throws RuntimeException {
    Frag newFrag = new Frag(prel);
    frags.add(newFrag);
    value.children.add(newFrag);
    for (Prel child : prel) {
        child.accept(this, newFrag);
    }
    return null;
}
Also used : ExchangePrel(org.apache.drill.exec.planner.physical.ExchangePrel) Prel(org.apache.drill.exec.planner.physical.Prel)

Aggregations

ExchangePrel (org.apache.drill.exec.planner.physical.ExchangePrel)8 Prel (org.apache.drill.exec.planner.physical.Prel)7 ScanPrel (org.apache.drill.exec.planner.physical.ScanPrel)3 RelNode (org.apache.calcite.rel.RelNode)2 RelDataType (org.apache.calcite.rel.type.RelDataType)2 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)2 ProjectPrel (org.apache.drill.exec.planner.physical.ProjectPrel)2 ScreenPrel (org.apache.drill.exec.planner.physical.ScreenPrel)2 ArrayList (java.util.ArrayList)1 JoinInfo (org.apache.calcite.rel.core.JoinInfo)1 JoinRelType (org.apache.calcite.rel.core.JoinRelType)1 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)1 RexBuilder (org.apache.calcite.rex.RexBuilder)1 RexNode (org.apache.calcite.rex.RexNode)1 BroadcastExchangePrel (org.apache.drill.exec.planner.physical.BroadcastExchangePrel)1 DistributionField (org.apache.drill.exec.planner.physical.DrillDistributionTrait.DistributionField)1 FilterPrel (org.apache.drill.exec.planner.physical.FilterPrel)1 HashToMergeExchangePrel (org.apache.drill.exec.planner.physical.HashToMergeExchangePrel)1 HashToRandomExchangePrel (org.apache.drill.exec.planner.physical.HashToRandomExchangePrel)1 LateralJoinPrel (org.apache.drill.exec.planner.physical.LateralJoinPrel)1