Fixed issue 233. Reviewed by Raman.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@1002 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/aqlj/server/APIClientThread.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/aqlj/server/APIClientThread.java
index 470201d..9879a2d 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/aqlj/server/APIClientThread.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/aqlj/server/APIClientThread.java
@@ -220,8 +220,7 @@
AQLParser parser = new AQLParser(new StringReader(stmt));
List<Statement> statements = parser.Statement();
SessionConfig pc = new SessionConfig(AsterixHyracksIntegrationUtil.DEFAULT_HYRACKS_CC_CLIENT_PORT, true,
- false, false, false, false, false, false);
- pc.setGenerateJobSpec(true);
+ false, false, false, false, false, true, false);
MetadataManager.INSTANCE.init();
if (statements != null && statements.size() > 0) {
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
index 95ec76c..1aad2ec 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
@@ -298,6 +298,10 @@
}
}
+ if (!pc.isGenerateJobSpec()) {
+ return null;
+ }
+
AlgebricksPartitionConstraint clusterLocs = queryMetadataProvider.getClusterLocations();
builder.setBinaryBooleanInspectorFactory(format.getBinaryBooleanInspectorFactory());
builder.setBinaryIntegerInspectorFactory(format.getBinaryIntegerInspectorFactory());
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/SessionConfig.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/SessionConfig.java
index 8050a3f..4ae6edd 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/SessionConfig.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/SessionConfig.java
@@ -1,100 +1,62 @@
-/**
- *
- */
package edu.uci.ics.asterix.api.common;
public class SessionConfig {
- private int port;
- private boolean printExprParam;
- private boolean printRewrittenExprParam;
- private boolean printLogicalPlanParam;
- private boolean printOptimizedLogicalPlanParam;
- private boolean printPhysicalOpsOnly;
- private boolean printJob;
- private boolean optimize;
- private boolean generateJobSpec = true;
+ private final int port;
+ private final boolean optimize;
+ private final boolean printExprParam;
+ private final boolean printRewrittenExprParam;
+ private final boolean printLogicalPlanParam;
+ private final boolean printOptimizedLogicalPlanParam;
+ private final boolean printPhysicalOpsOnly;
+ private final boolean generateJobSpec;
+ private final boolean printJob;
public SessionConfig(int port, boolean optimize, boolean printExprParam, boolean printRewrittenExprParam,
boolean printLogicalPlanParam, boolean printOptimizedLogicalPlanParam, boolean printPhysicalOpsOnly,
- boolean printJob) {
- this.setPort(port);
- this.setOptimize(optimize);
- this.setPrintExprParam(printExprParam);
- this.setPrintRewrittenExprParam(printRewrittenExprParam);
- this.setPrintLogicalPlanParam(printLogicalPlanParam);
- this.setPrintOptimizedLogicalPlanParam(printOptimizedLogicalPlanParam);
- this.setPrintPhysicalOpsOnly(printPhysicalOpsOnly);
- this.setPrintJob(printJob);
- }
-
- public void setPort(int port) {
+ boolean generateJobSpec, boolean printJob) {
this.port = port;
+ this.optimize = optimize;
+ this.printExprParam = printExprParam;
+ this.printRewrittenExprParam = printRewrittenExprParam;
+ this.printLogicalPlanParam = printLogicalPlanParam;
+ this.printOptimizedLogicalPlanParam = printOptimizedLogicalPlanParam;
+ this.printPhysicalOpsOnly = printPhysicalOpsOnly;
+ this.generateJobSpec = generateJobSpec;
+ this.printJob = printJob;
}
public int getPort() {
return port;
}
- public void setPrintExprParam(boolean printExprParam) {
- this.printExprParam = printExprParam;
- }
-
public boolean isPrintExprParam() {
return printExprParam;
}
- public void setPrintRewrittenExprParam(boolean printRewrittenExprParam) {
- this.printRewrittenExprParam = printRewrittenExprParam;
- }
-
public boolean isPrintRewrittenExprParam() {
return printRewrittenExprParam;
}
- public void setPrintLogicalPlanParam(boolean printLogicalPlanParam) {
- this.printLogicalPlanParam = printLogicalPlanParam;
- }
-
public boolean isPrintLogicalPlanParam() {
return printLogicalPlanParam;
}
- public void setPrintOptimizedLogicalPlanParam(boolean printOptimizedLogicalPlanParam) {
- this.printOptimizedLogicalPlanParam = printOptimizedLogicalPlanParam;
- }
-
public boolean isPrintOptimizedLogicalPlanParam() {
return printOptimizedLogicalPlanParam;
}
- public void setPrintJob(boolean printJob) {
- this.printJob = printJob;
- }
-
public boolean isPrintJob() {
return printJob;
}
- public void setPrintPhysicalOpsOnly(boolean prinPhysicalOpsOnly) {
- this.printPhysicalOpsOnly = prinPhysicalOpsOnly;
- }
-
public boolean isPrintPhysicalOpsOnly() {
return printPhysicalOpsOnly;
}
- public void setOptimize(boolean optimize) {
- this.optimize = optimize;
- }
-
public boolean isOptimize() {
return optimize;
}
- public void setGenerateJobSpec(boolean generateJobSpec) {
- this.generateJobSpec = generateJobSpec;
- }
-
public boolean isGenerateJobSpec() {
return generateJobSpec;
}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
index 436673b..034e1f4 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
@@ -58,8 +58,7 @@
List<Statement> aqlStatements = parser.Statement();
SessionConfig sessionConfig = new SessionConfig(port, true, isSet(printExprParam),
isSet(printRewrittenExprParam), isSet(printLogicalPlanParam),
- isSet(printOptimizedLogicalPlanParam), false, isSet(printJob));
- sessionConfig.setGenerateJobSpec(true);
+ isSet(printOptimizedLogicalPlanParam), false, true, isSet(printJob));
MetadataManager.INSTANCE.init();
AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, out, sessionConfig, DisplayFormat.HTML);
List<QueryResult> executionResults = null;
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
index f007cbb..7e72d94 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
@@ -64,8 +64,8 @@
MetadataManager.INSTANCE.init();
SessionConfig pc = new SessionConfig(AsterixHyracksIntegrationUtil.DEFAULT_HYRACKS_CC_CLIENT_PORT, optimize,
- false, printRewrittenExpressions, printLogicalPlan, printOptimizedPlan, printPhysicalOpsOnly, printJob);
- pc.setGenerateJobSpec(generateBinaryRuntime);
+ false, printRewrittenExpressions, printLogicalPlan, printOptimizedPlan, printPhysicalOpsOnly,
+ generateBinaryRuntime, printJob);
AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, writer, pc, DisplayFormat.TEXT);
aqlTranslator.compileAndExecute(hcc);
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
index 08e1c5f..80293b0 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -650,7 +650,9 @@
.getDatasetName().getValue(), st1.getQuery(), st1.getVarCounter());
Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
- jobsToExecute.add(compiled.first);
+ if (compiled.first != null) {
+ jobsToExecute.add(compiled.first);
+ }
}
private void handleInsertStatement(AqlMetadataProvider metadataProvider, Statement stmt,
@@ -662,7 +664,9 @@
CompiledInsertStatement clfrqs = new CompiledInsertStatement(dataverseName, stmtInsert.getDatasetName()
.getValue(), stmtInsert.getQuery(), stmtInsert.getVarCounter());
Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
- jobsToExecute.add(compiled.first);
+ if (compiled.first != null) {
+ jobsToExecute.add(compiled.first);
+ }
}
private void handleDeleteStatement(AqlMetadataProvider metadataProvider, Statement stmt,
@@ -675,7 +679,9 @@
stmtDelete.getDatasetName().getValue(), stmtDelete.getCondition(), stmtDelete.getDieClause(),
stmtDelete.getVarCounter(), metadataProvider);
Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
- jobsToExecute.add(compiled.first);
+ if (compiled.first != null) {
+ jobsToExecute.add(compiled.first);
+ }
}
private Pair<JobSpecification, FileSplit> rewriteCompileQuery(AqlMetadataProvider metadataProvider, Query query,
@@ -686,15 +692,12 @@
Pair<Query, Integer> reWrittenQuery = APIFramework.reWriteQuery(declaredFunctions, metadataProvider, query,
sessionConfig, out, pdf);
- // Query Compilation (happens under the same ongoing metadata
- // transaction)
- sessionConfig.setGenerateJobSpec(true);
+ // Query Compilation (happens under the same ongoing metadata transaction)
if (metadataProvider.isWriteTransaction()) {
metadataProvider.setJobTxnId(TransactionIDFactory.generateTransactionId());
}
JobSpecification spec = APIFramework.compileQuery(declaredFunctions, metadataProvider, query,
reWrittenQuery.second, stmt == null ? null : stmt.getDatasetName(), sessionConfig, out, pdf, stmt);
- sessionConfig.setGenerateJobSpec(false);
Pair<JobSpecification, FileSplit> compiled = new Pair<JobSpecification, FileSplit>(spec,
metadataProvider.getOutputFile());
@@ -721,7 +724,9 @@
bfs.initialize(metadataProvider.getMetadataTxnContext(), dataset);
cbfs.setQuery(bfs.getQuery());
Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, bfs.getQuery(), cbfs);
- jobsToExecute.add(compiled.first);
+ if (compiled.first != null) {
+ jobsToExecute.add(compiled.first);
+ }
}
private void handleControlFeedStatement(AqlMetadataProvider metadataProvider, Statement stmt,
@@ -737,8 +742,10 @@
private QueryResult handleQuery(AqlMetadataProvider metadataProvider, Query query, IHyracksClientConnection hcc,
List<JobSpecification> jobsToExecute) throws Exception {
Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, query, null);
- GlobalConfig.ASTERIX_LOGGER.info(compiled.first.toJSON().toString(1));
- jobsToExecute.add(compiled.first);
+ if (compiled.first != null) {
+ GlobalConfig.ASTERIX_LOGGER.info(compiled.first.toJSON().toString(1));
+ jobsToExecute.add(compiled.first);
+ }
return new QueryResult(query, compiled.second.getLocalFile().getFile().getAbsolutePath());
}
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
index 0c0b104..43c6c0c 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
@@ -126,7 +126,7 @@
AsterixJavaClient asterix = new AsterixJavaClient(
AsterixHyracksIntegrationUtil.getHyracksClientConnection(), query, plan);
try {
- asterix.compile(true, false, false, true, true, true, false);
+ asterix.compile(true, false, false, true, true, false, false);
} catch (AsterixException e) {
plan.close();
query.close();