MCPcopy Create free account
hub / github.com/apache/pig / buildPlan

Method buildPlan

src/org/apache/pig/PigServer.java:1620–1689  ·  view source on GitHub ↗

Build a plan for the given alias. Extra branches and child branch under alias will be ignored. Dependent branch (i.e. scalar) will be kept. @throws IOException

(String alias)

Source from the content-addressed store, hash-verified

1618 * @throws IOException
1619 */
1620 void buildPlan(String alias) throws IOException {
1621 if( alias == null )
1622 skipStores();
1623
1624 final Queue<Operator> queue = new LinkedList<Operator>();
1625 if( alias != null ) {
1626 Operator op = getOperator( alias );
1627 if (op == null) {
1628 String msg = "Unable to find an operator for alias " + alias;
1629 throw new FrontendException( msg, 1003, PigException.INPUT );
1630 }
1631 queue.add( op );
1632 } else {
1633 List<LOStore> stores = Util.getLogicalRelationalOperators(lp, LOStore.class);
1634 for (LOStore op : stores) {
1635 boolean addSink = true;
1636 // Only add if all the successors are loads
1637 List<Operator> succs = lp.getSuccessors(op);
1638 if (succs != null && succs.size() > 0) {
1639 for (Operator succ : succs) {
1640 if (!(succ instanceof LOLoad)) {
1641 addSink = false;
1642 break;
1643 }
1644 }
1645 }
1646 if (addSink) {
1647 queue.add(op);
1648 }
1649 }
1650 }
1651
1652 LogicalPlan plan = new LogicalPlan();
1653
1654 while( !queue.isEmpty() ) {
1655 Operator currOp = queue.poll();
1656 plan.add( currOp );
1657
1658 List<Operator> preds = lp.getPredecessors( currOp );
1659 if( preds != null ) {
1660 List<Operator> ops = new ArrayList<Operator>( preds );
1661 for( Operator pred : ops ) {
1662 if( !queue.contains( pred ) )
1663 queue.add( pred );
1664 plan.connect( pred, currOp );
1665 }
1666 }
1667
1668 // visit expression associated with currOp. If it refers to any other operator
1669 // that operator is also going to be enqueued.
1670 currOp.accept( new AllExpressionVisitor( plan, new DependencyOrderWalker( plan ) ) {
1671 @Override
1672 protected LogicalExpressionVisitor getVisitor(LogicalExpressionPlan exprPlan)
1673 throws FrontendException {
1674 return new LogicalExpressionVisitor( exprPlan, new DependencyOrderWalker( exprPlan ) ) {
1675 @Override
1676 public void visit(ScalarExpression expr) throws FrontendException {
1677 Operator refOp = expr.getImplicitReferencedOperator();

Callers 6

registerQueryMethod · 0.95
parseAndBuildMethod · 0.45
storeExMethod · 0.45
getExamplesMethod · 0.45
buildStorePlanMethod · 0.45
buildLpMethod · 0.45

Calls 12

skipStoresMethod · 0.95
getOperatorMethod · 0.95
acceptMethod · 0.95
setPlanMethod · 0.95
addMethod · 0.65
getSuccessorsMethod · 0.65
sizeMethod · 0.65
getPredecessorsMethod · 0.65
connectMethod · 0.65
isEmptyMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected