You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ga...@apache.org on 2008/05/22 22:53:06 UTC
svn commit: r659250 - in /incubator/pig/branches/types/src/org/apache/pig:
PigServer.java backend/executionengine/ExecutionEngine.java
backend/hadoop/executionengine/HExecutionEngine.java
backend/local/executionengine/LocalExecutionEngine.java
Author: gates
Date: Thu May 22 13:53:05 2008
New Revision: 659250
URL: http://svn.apache.org/viewvc?rev=659250&view=rev
Log:
Changed ExecutionEngine.compile implementations and PigServer to work with the new way logical plans are stitched together.
Modified:
incubator/pig/branches/types/src/org/apache/pig/PigServer.java
incubator/pig/branches/types/src/org/apache/pig/backend/executionengine/ExecutionEngine.java
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java
incubator/pig/branches/types/src/org/apache/pig/backend/local/executionengine/LocalExecutionEngine.java
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=659250&r1=659249&r2=659250&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/PigServer.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/PigServer.java Thu May 22 13:53:05 2008
@@ -54,8 +54,10 @@
import org.apache.pig.impl.logicalLayer.parser.ParseException;
import org.apache.pig.impl.logicalLayer.parser.QueryParser;
import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.logicalLayer.validators.LogicalPlanValidationExecutor;
import org.apache.pig.impl.physicalLayer.POPrinter;
import org.apache.pig.impl.physicalLayer.plans.PhysicalPlan;
+import org.apache.pig.impl.plan.CompilationMessageCollector;
import org.apache.pig.impl.plan.VisitorException;
import org.apache.pig.impl.util.WrappedIOException;
@@ -356,8 +358,8 @@
public void explain(String alias,
PrintStream stream) throws IOException {
try {
+ LogicalPlan lp = compileLp(alias, "explain");
stream.println("Logical Plan:");
- LogicalPlan lp = compileLp();
LOPrinter lv = new LOPrinter(stream, lp);
lv.visit();
@@ -493,18 +495,53 @@
private ExecJob execute(String jobName) throws ExecException {
ExecJob job = null;
- LogicalPlan lp = compileLp();
+ LogicalPlan lp = compileLp(jobName, "execute");
PhysicalPlan pp = compilePp(lp);
// execute using appropriate engine
return pigContext.getExecutionEngine().execute(pp, jobName);
}
- // TODO FIX
- private LogicalPlan compileLp() {
- LogicalPlan lp = null;
- // TODO, stitch together logical plans
+ private LogicalPlan compileLp(String alias, String op) throws ExecException {
+ // Look up the logical plan in the aliases map. That plan will be
+ // properly connected to all the others.
+ LogicalPlan lp = aliases.get(alias);
+ if (lp == null) {
+ throw new ExecException("No alias " + alias + " to " + op);
+ }
+
+ // run through validator
+ LogicalPlanValidationExecutor validator =
+ new LogicalPlanValidationExecutor(lp, pigContext);
+ CompilationMessageCollector collector = new CompilationMessageCollector() ;
+ validator.validate(lp, collector);
+ // Check to see if we had any problems.
+ StringBuilder sb = new StringBuilder();
+ for (CompilationMessageCollector.Message msg : collector) {
+ switch (msg.getMessageType()) {
+ case Info:
+ log.info(msg.getMessage());
+ break;
+
+ case Warning:
+ log.warn(msg.getMessage());
+ break;
+
+ case Unknown:
+ case Error:
+ log.error(msg.getMessage());
+ sb.append(msg.getMessage());
+ break;
+
+ default:
+ throw new AssertionError("Unknown message type " +
+ msg.getMessageType());
- // TODO run through validator
+ }
+ }
+
+ if (sb.length() > 0) {
+ throw new ExecException(sb.toString());
+ }
// TODO optimize
Modified: incubator/pig/branches/types/src/org/apache/pig/backend/executionengine/ExecutionEngine.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/backend/executionengine/ExecutionEngine.java?rev=659250&r1=659249&r2=659250&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/backend/executionengine/ExecutionEngine.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/backend/executionengine/ExecutionEngine.java Thu May 22 13:53:05 2008
@@ -93,8 +93,10 @@
public PhysicalPlan compile(LogicalPlan plan,
Properties properties) throws ExecException;
+ /*
public PhysicalPlan compile(LogicalPlan[] plans,
Properties properties) throws ExecException;
+ */
/**
* Execute the physical plan in blocking mode.
Modified: incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java?rev=659250&r1=659249&r2=659250&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java Thu May 22 13:53:05 2008
@@ -216,20 +216,20 @@
public PhysicalPlan compile(LogicalPlan plan,
Properties properties) throws ExecException {
+ /*
return compile(new LogicalPlan[] { plan }, properties);
}
public PhysicalPlan compile(LogicalPlan[] plans,
Properties properties) throws ExecException {
- if (plans == null) {
- throw new ExecException("No Plans to compile");
+ */
+ if (plan == null) {
+ throw new ExecException("No Plan to compile");
}
- // TODO FIX Need to stich togther the plans.
try {
- LogicalPlan lp = null;
LogToPhyTranslationVisitor translator =
- new LogToPhyTranslationVisitor(lp);
+ new LogToPhyTranslationVisitor(plan);
translator.setPigContext(pigContext);
translator.visit();
return translator.getPhysicalPlan();
Modified: incubator/pig/branches/types/src/org/apache/pig/backend/local/executionengine/LocalExecutionEngine.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/backend/local/executionengine/LocalExecutionEngine.java?rev=659250&r1=659249&r2=659250&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/backend/local/executionengine/LocalExecutionEngine.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/backend/local/executionengine/LocalExecutionEngine.java Thu May 22 13:53:05 2008
@@ -108,6 +108,7 @@
public PhysicalPlan compile(LogicalPlan plan,
Properties properties) throws ExecException {
+ /*
if (plan == null) {
throw new ExecException("No Plan to compile");
}
@@ -117,15 +118,14 @@
public PhysicalPlan compile(LogicalPlan[] plans,
Properties properties) throws ExecException {
- if (plans == null) {
- throw new ExecException("No Plans to compile");
+ */
+ if (plan == null) {
+ throw new ExecException("No Plan to compile");
}
- // TODO FIX Need to stich togther the plans.
try {
- LogicalPlan lp = null;
LogToPhyTranslationVisitor translator =
- new LogToPhyTranslationVisitor(lp);
+ new LogToPhyTranslationVisitor(plan);
translator.setPigContext(pigContext);
translator.visit();
return translator.getPhysicalPlan();