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));
}
}
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;
}
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;
}
Aggregations