Author: gates Date: Tue May 27 14:07:02 2008 New Revision: 660705 URL: http://svn.apache.org/viewvc?rev=660705&view=rev Log: PIG-158 Santhosh's fixes for properly visiting lo user func and properly handling stores.
Modified: incubator/pig/branches/types/src/org/apache/pig/PigServer.java incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOVisitor.java incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt Modified: incubator/pig/branches/types/src/org/apache/pig/PigServer.java URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/PigServer.java?rev=660705&r1=660704&r2=660705&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/PigServer.java (original) +++ incubator/pig/branches/types/src/org/apache/pig/PigServer.java Tue May 27 14:07:02 2008 @@ -301,7 +301,7 @@ String func) throws IOException { try { LogicalPlan storePlan = QueryParser.generateStorePlan(opTable, - scope, readFrom, filename, func, pigContext); + scope, readFrom, filename, func, aliasOp.get(id)); execute(id); } catch (Exception e) { throw WrappedIOException.wrap("Unable to store for alias: " + Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOVisitor.java URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOVisitor.java?rev=660705&r1=660704&r2=660705&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOVisitor.java (original) +++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOVisitor.java Tue May 27 14:07:02 2008 @@ -224,11 +224,7 @@ * @throws VisitorException */ protected void visit(LOUserFunc func) throws VisitorException { - // Visit each of the arguments - Iterator<ExpressionOperator> i = func.getArguments().iterator(); - while (i.hasNext()) { - i.next().visit(this); - } + } /** @@ -237,14 +233,7 @@ * @throws VisitorException */ protected void visit(LOBinCond binCond) throws VisitorException { - /* - * Visit the conditional expression followed by the left hand operator - * and the right hand operator respectively - */ - - binCond.getCond().visit(this); - binCond.getLhsOp().visit(this); - binCond.getRhsOp().visit(this); + } /** @@ -254,9 +243,7 @@ * @throws VisitorException */ protected void visit(LOCast cast) throws VisitorException { - // Visit the expression to be cast - cast.getExpression().visit(this); } /** @@ -266,8 +253,7 @@ * @throws ParseException */ protected void visit(LORegexp regexp) throws VisitorException { - // Visit the operand of the regexp - regexp.getOperand().visit(this); + } protected void visit(LOLoad load) throws VisitorException{ Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt?rev=660705&r1=660704&r2=660705&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt (original) +++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt Tue May 27 14:07:02 2008 @@ -103,7 +103,8 @@ LogicalPlan readFrom, String fileName, String func, - PigContext pigContext) throws IOException { + LogicalOperator input) throws FrontendException { + if (func == null) { func = PigStorage.class.getName(); } @@ -112,12 +113,25 @@ long storeNodeId = NodeIdGenerator.getGenerator().getNextNodeId(scope); - LogicalOperator root = new LOStore(readFrom, - new OperatorKey(scope, storeNodeId), - new FileSpec(fileName, func)); - - - readFrom.add(root); + LogicalPlan rootPlan = new LogicalPlan(); + + LogicalOperator store; + try { + store = new LOStore(rootPlan, + new OperatorKey(scope, storeNodeId), + new FileSpec(fileName, func)); + } catch (IOException ioe) { + throw new FrontendException(ioe.getMessage()); + } + + try { + rootPlan.add(store); + rootPlan.add(input); + rootPlan.connect(input, store); + attachPlan(rootPlan, input, readFrom); + } catch (ParseException pe) { + throw new FrontendException(pe.getMessage()); + } return readFrom; } @@ -344,7 +358,7 @@ return aliases.get(op); } - public void attachPlan(LogicalPlan lp, LogicalOperator root, LogicalPlan rootPlan) throws ParseException { + public static void attachPlan(LogicalPlan lp, LogicalOperator root, LogicalPlan rootPlan) throws ParseException { log.trace("Entering attachPlan"); lp.add(root); log.debug("Added operator " + root + " to the logical plan " + lp); @@ -363,6 +377,7 @@ } log.trace("Exiting attachPlan"); } + }