use of org.apache.drill.exec.planner.fragment.Fragment.ExchangeFragmentPair in project drill by apache.
the class SimpleParallelizer method constructFragmentDependencyGraph.
/**
* Based on the affinity of the Exchange that separates two fragments, setup fragment dependencies.
*
* @param planningSet
* @return Returns a list of leaf fragments in fragment dependency graph.
*/
private static Set<Wrapper> constructFragmentDependencyGraph(PlanningSet planningSet) {
// Set up dependency of fragments based on the affinity of exchange that separates the fragments.
for (Wrapper currentFragmentWrapper : planningSet) {
ExchangeFragmentPair sendingExchange = currentFragmentWrapper.getNode().getSendingExchangePair();
if (sendingExchange != null) {
ParallelizationDependency dependency = sendingExchange.getExchange().getParallelizationDependency();
Wrapper receivingFragmentWrapper = planningSet.get(sendingExchange.getNode());
if (dependency == ParallelizationDependency.RECEIVER_DEPENDS_ON_SENDER) {
receivingFragmentWrapper.addFragmentDependency(currentFragmentWrapper);
} else if (dependency == ParallelizationDependency.SENDER_DEPENDS_ON_RECEIVER) {
currentFragmentWrapper.addFragmentDependency(receivingFragmentWrapper);
}
}
}
// Identify leaf fragments. Leaf fragments are fragments that have no other fragments depending on them for
// parallelization info. First assume all fragments are leaf fragments. Go through the fragments one by one and
// remove the fragment on which the current fragment depends on.
final Set<Wrapper> roots = Sets.newHashSet();
for (Wrapper w : planningSet) {
roots.add(w);
}
for (Wrapper wrapper : planningSet) {
final List<Wrapper> fragmentDependencies = wrapper.getFragmentDependencies();
if (fragmentDependencies != null && fragmentDependencies.size() > 0) {
for (Wrapper dependency : fragmentDependencies) {
if (roots.contains(dependency)) {
roots.remove(dependency);
}
}
}
}
return roots;
}
use of org.apache.drill.exec.planner.fragment.Fragment.ExchangeFragmentPair in project drill by apache.
the class StatsCollector method visitReceivingExchange.
@Override
public Void visitReceivingExchange(Exchange exchange, Wrapper wrapper) throws RuntimeException {
// Handle the receiving side Exchange
final List<ExchangeFragmentPair> receivingExchangePairs = wrapper.getNode().getReceivingExchangePairs();
// List to contain the endpoints where the fragment that send dat to this fragment are running.
final List<DrillbitEndpoint> sendingEndpoints = Lists.newArrayList();
for (ExchangeFragmentPair pair : receivingExchangePairs) {
if (pair.getExchange() == exchange) {
Wrapper sendingFragment = planningSet.get(pair.getNode());
if (sendingFragment.isEndpointsAssignmentDone()) {
sendingEndpoints.addAll(sendingFragment.getAssignedEndpoints());
}
}
}
wrapper.getStats().addParallelizationInfo(exchange.getReceiverParallelizationInfo(sendingEndpoints));
// no traversal since it would cross current fragment boundary.
return null;
}
use of org.apache.drill.exec.planner.fragment.Fragment.ExchangeFragmentPair in project drill by apache.
the class Wrapper method assignEndpoints.
public void assignEndpoints(List<DrillbitEndpoint> assignedEndpoints) throws PhysicalOperatorSetupException {
Preconditions.checkState(!endpointsAssigned);
endpointsAssigned = true;
endpoints.addAll(assignedEndpoints);
// Set scan and store endpoints.
AssignEndpointsToScanAndStore visitor = new AssignEndpointsToScanAndStore();
node.getRoot().accept(visitor, endpoints);
// Set the endpoints for this (one at most) sending exchange.
if (node.getSendingExchange() != null) {
node.getSendingExchange().setupSenders(majorFragmentId, endpoints);
}
// Set the endpoints for each incoming exchange within this fragment.
for (ExchangeFragmentPair e : node.getReceivingExchangePairs()) {
e.getExchange().setupReceivers(majorFragmentId, endpoints);
}
}
Aggregations