teiid SVN: r781 - trunk/engine/src/main/java/com/metamatrix/query/processor/proc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-15 16:29:00 -0400 (Wed, 15 Apr 2009)
New Revision: 781
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
Log:
TEIID-127 changing from planner to dqp context
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java 2009-04-15 20:29:00 UTC (rev 781)
@@ -27,8 +27,8 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.LogConstants;
/**
* <p> This instruction updates the current variable context with a value for the Variable
@@ -60,7 +60,7 @@
protected void processValue(Object value, VariableContext varContext) throws MetaMatrixComponentException,
MetaMatrixProcessingException {
varContext.setValue(getVariable(), value);
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER,
+ LogManager.logTrace(LogConstants.CTX_DQP,
new Object[] {this.toString() + " The variable " //$NON-NLS-1$
+ getVariable() + " in the variablecontext is updated with the value :", value}); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java 2009-04-15 20:29:00 UTC (rev 781)
@@ -28,8 +28,8 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.ProcedureErrorInstructionException;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.LogConstants;
/**
* <p> This instruction updates the current variable context with the Variable defined using
@@ -67,7 +67,7 @@
*/
protected void processValue(Object value, VariableContext varContext) throws MetaMatrixComponentException,
MetaMatrixProcessingException {
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER,
+ LogManager.logTrace(LogConstants.CTX_DQP,
new Object[] {"Processing RaiseErrorInstruction with the value :", value}); //$NON-NLS-1$
throw new ProcedureErrorInstructionException(ERROR_PREFIX + (value != null ? value.toString() : "")); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2009-04-15 20:29:00 UTC (rev 781)
@@ -38,6 +38,7 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.id.IDGenerator;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -75,9 +76,7 @@
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.LogConstants;
/**
* <p>
@@ -152,7 +151,7 @@
LogManager
.logTrace(
- LogConstants.CTX_QUERY_PLANNER,
+ LogConstants.CTX_DQP,
"Processing ExecDynamicSqlInstruction as part of processing the update procedure"); //$NON-NLS-1$
ProcedureEnvironment procEnv = (ProcedureEnvironment) env;
@@ -167,7 +166,7 @@
.getString("ExecDynamicSqlInstruction.0")); //$NON-NLS-1$
}
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER,
+ LogManager.logTrace(LogConstants.CTX_DQP,
new Object[] { "Executing dynamic sql ", value }); //$NON-NLS-1$
Command command = QueryParser.getQueryParser().parseCommand(value.toString());
@@ -253,7 +252,7 @@
for (SetClause setClause : dynamicCommand.getUsing().getClauses()) {
Object assignment = procEnv.evaluateExpression(setClause.getValue());
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER,
+ LogManager.logTrace(LogConstants.CTX_DQP,
new Object[] { this, " The using variable ", //$NON-NLS-1$
setClause.getSymbol(), " has value :", assignment }); //$NON-NLS-1$
localContext.setValue(setClause.getSymbol(),
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java 2009-04-15 20:29:00 UTC (rev 781)
@@ -32,10 +32,10 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.program.ProgramEnvironment;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.LogConstants;
/**
* <p> Executes a SQL statement, and remove its results from the buffer manager. Executing this
@@ -73,7 +73,7 @@
public void process(ProgramEnvironment env)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, new Object[]{"Processing ExecSqlInstruction as part of processing the update procedure"}); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[]{"Processing ExecSqlInstruction as part of processing the update procedure"}); //$NON-NLS-1$
ProcedureEnvironment procEnv = (ProcedureEnvironment) env;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2009-04-15 20:29:00 UTC (rev 781)
@@ -32,11 +32,11 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.processor.program.Program;
import com.metamatrix.query.processor.program.ProgramEnvironment;
import com.metamatrix.query.processor.program.ProgramInstruction;
import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.util.LogConstants;
/**
* <p>This instruction an holds an if block and an else block and a criteria that determines
@@ -97,13 +97,13 @@
boolean evalValue = procEnv.evaluateCriteria(condition);
if(evalValue) {
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
" The criteria on the if block evaluated to true, processing the if block"}); //$NON-NLS-1$
//push the "if" Program onto the stack
procEnv.push(ifProgram);
} else if(elseProgram != null) {
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
" The criteria on the if block evaluated to false, processing the else block"}); //$NON-NLS-1$
//push the "else" Program onto the stack
procEnv.push(elseProgram);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-04-15 20:21:58 UTC (rev 780)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-04-15 20:29:00 UTC (rev 781)
@@ -40,6 +40,7 @@
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -60,7 +61,6 @@
import com.metamatrix.query.tempdata.TempTableStoreImpl;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
-import com.metamatrix.query.util.LogConstants;
/**
*/
public class ProcedurePlan extends BaseProcessorPlan {
@@ -126,7 +126,7 @@
env.getProgramStack().push(originalProgram);
}
env.reset();
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, "ProcedurePlan reset"); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, "ProcedurePlan reset"); //$NON-NLS-1$
}
public ProcessorDataManager getDataManager() {
@@ -169,7 +169,7 @@
} catch (MetaMatrixComponentException e) {
throw new MetaMatrixComponentException(e, ErrorMessageKeys.PROCESSOR_0022, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0022, (String) null));
}
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, new Object[]{"removed tuple source", tupleSourceID, "for result set"}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[]{"removed tuple source", tupleSourceID, "for result set"}); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -251,23 +251,23 @@
Program program = env.peek();
inst = program.getCurrentInstruction();
if (inst == null){
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, "Finished program", program); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, "Finished program", program); //$NON-NLS-1$
this.env.pop();
continue;
}
if (inst instanceof RepeatedInstruction) {
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, "Executing repeated instruction", inst); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, "Executing repeated instruction", inst); //$NON-NLS-1$
RepeatedInstruction loop = (RepeatedInstruction)inst;
if (loop.testCondition(env)) {
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, "Passed condition, executing program " + loop.getNestedProgram()); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, "Passed condition, executing program " + loop.getNestedProgram()); //$NON-NLS-1$
inst.process(env);
env.push(loop.getNestedProgram());
continue;
}
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, "Exiting repeated instruction", inst); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, "Exiting repeated instruction", inst); //$NON-NLS-1$
loop.postInstruction(env);
} else {
- LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, "Executing instruction", inst); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_DQP, "Executing instruction", inst); //$NON-NLS-1$
inst.process(this.env);
}
program.incrementProgramCounter();
15 years, 4 months
teiid SVN: r780 - in trunk: engine/src/main/java/com/metamatrix/query/optimizer and 36 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-15 16:21:58 -0400 (Wed, 15 Apr 2009)
New Revision: 780
Removed:
trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestEvaluation.java
Modified:
trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeNode.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/PreparedBatchUpdatePlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinUtil.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/batch/PreparedBatchUpdatePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CommandInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedureEnvironment.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramEnvironment.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureExecutionNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProjectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSelectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryProcessorUtility.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/StoredProcedure.java
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorProvider.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CorrelatedVariableSubstitutionVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluateExpressionVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/GroupCollectorVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/NeedsEvaluationVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ValueIteratorProviderCollectorVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java
trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentSelectNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
trunk/test-integration/src/test/java/com/metamatrix/server/integration/BaseQueryTest.java
trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java
Log:
TEIID-19 TEIID-492 update of reference handling and various cleanups of processing. reviewed by RR
Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -39,7 +39,6 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.types.Sequencable;
import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.Assertion;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.function.FunctionDescriptor;
@@ -58,6 +57,7 @@
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.CaseExpression;
import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.ExpressionSymbol;
import com.metamatrix.query.sql.symbol.Function;
@@ -482,20 +482,25 @@
throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
if(expression instanceof SingleElementSymbol) {
- // Case 5155: elements must be non-null
- Assertion.isNotNull( elements );
-
- // Try to evaluate by lookup in the elements map (may work for both ElementSymbol and ExpressionSymbol
- Integer index = (Integer) elements.get(expression);
- if(index != null) {
- return tuple.get(index.intValue());
- }
+ if (elements != null) {
+ // Try to evaluate by lookup in the elements map (may work for both ElementSymbol and ExpressionSymbol
+ Integer index = (Integer) elements.get(expression);
+ if(index != null) {
+ return tuple.get(index.intValue());
+ }
+ }
+
// Otherwise this should be an ExpressionSymbol and we just need to dive in and evaluate the expression itself
if (expression instanceof ExpressionSymbol && !(expression instanceof AggregateSymbol)) {
ExpressionSymbol exprSyb = (ExpressionSymbol) expression;
Expression expr = exprSyb.getExpression();
return internalEvaluate(expr, tuple);
}
+
+ if (expression instanceof ElementSymbol && this.context != null && this.context.getVariableContext() != null
+ && this.context.getVariableContext().containsVariable((ElementSymbol)expression)) {
+ return this.context.getVariableContext().getValue((ElementSymbol)expression);
+ }
// instead of assuming null, throw an exception. a problem in planning has occurred
throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
}
@@ -508,7 +513,8 @@
} else if(expression instanceof SearchedCaseExpression) {
return evaluate((SearchedCaseExpression) expression, tuple);
} else if(expression instanceof Reference) {
- return ((Reference) expression).getValue(dataMgr, context);
+ Reference ref = (Reference)expression;
+ return internalEvaluate(ref.getExpression(), tuple);
} else if(expression instanceof ScalarSubquery) {
return evaluate((ScalarSubquery) expression, tuple);
} else {
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,8 +22,9 @@
package com.metamatrix.query.optimizer;
-import java.util.*;
import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import com.metamatrix.query.processor.ProcessorPlan;
@@ -64,17 +65,14 @@
/** The Planner-specific canonical plan object */
private Object canonicalPlan;
- /** The processor-plan of this node (useful if this is a subnode) */
- private ProcessorPlan processorPlan;
-
/** Planner-specific node properties, as defined by each CommandPlanner implementation */
- private Map properties = new HashMap();
+ private Map<Integer, Object> properties = new HashMap<Integer, Object>();
/** The parent of this node, null if root. */
private CommandTreeNode parent;
/** Child nodes */
- private LinkedList children = new LinkedList();
+ private LinkedList<CommandTreeNode> children = new LinkedList<CommandTreeNode>();
// ====================================================
// API
@@ -143,7 +141,7 @@
* @return ProcessorPlan at this node, or null if none
*/
public ProcessorPlan getProcessorPlan() {
- return processorPlan;
+ return this.command.getProcessorPlan();
}
/**
@@ -152,7 +150,7 @@
* @param processorPlan The processorPlan to set
*/
public void setProcessorPlan(ProcessorPlan processorPlan) {
- this.processorPlan = processorPlan;
+ this.command.setProcessorPlan(processorPlan);
}
// ====================================================
@@ -167,7 +165,7 @@
this.parent = parent;
}
- public List getChildren() {
+ public List<CommandTreeNode> getChildren() {
return this.children;
}
@@ -176,11 +174,11 @@
}
public CommandTreeNode getFirstChild() {
- return (CommandTreeNode) this.children.getFirst();
+ return this.children.getFirst();
}
public CommandTreeNode getLastChild() {
- return (CommandTreeNode) this.children.getLast();
+ return this.children.getLast();
}
public void addFirstChild(CommandTreeNode child) {
@@ -191,7 +189,7 @@
this.children.addLast(child);
}
- public void addChildren(List otherChildren) {
+ public void addChildren(List<CommandTreeNode> otherChildren) {
this.children.addAll(otherChildren);
}
@@ -219,14 +217,6 @@
}
/**
- * Get the Map of all planner-specific properties
- * @return Map property keys to property values
- */
- public Map getAllProperties(){
- return this.properties;
- }
-
- /**
* Set a {@link CommandPlanner}-specific property. Each planner may have
* conflicting property keys, so an object of this Class should only be
* used for one CommandPlanner at a time.
@@ -237,15 +227,6 @@
properties.put(propertyID, value);
}
- /**
- * Remove one of the planner-specific properties. No action
- * is taken if the indicated property doesn't exist.
- * @param propertyID key of the property
- */
- public void removeProperty(Integer propertyID) {
- properties.remove(propertyID);
- }
-
// ====================================================
// Overriden Object Methods
// ====================================================
@@ -291,9 +272,7 @@
getCanonicalPlanString(str);
// Recursively add children at one greater tab level
- Iterator iter = children.iterator();
- while(iter.hasNext()) {
- CommandTreeNode child = (CommandTreeNode) iter.next();
+ for (CommandTreeNode child : this.children) {
child.getRecursiveString(str, tabLevel+1);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/PreparedBatchUpdatePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/PreparedBatchUpdatePlanner.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/PreparedBatchUpdatePlanner.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -132,7 +132,7 @@
while(valuesIter.hasNext()){
List values = (List)valuesIter.next();
batchUpdate = (PreparedBatchUpdate)commandIter.next();
- PreparedStatementRequest.resolveParameterValues(parameters, values);
+ PreparedStatementRequest.resolveParameterValues(parameters, values, context);
EvaluateExpressionVisitor.replaceExpressions(batchUpdate, true, null, context);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,7 +22,6 @@
package com.metamatrix.query.optimizer.proc;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -67,7 +66,6 @@
import com.metamatrix.query.sql.proc.WhileStatement;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
import com.metamatrix.query.util.CommandContext;
/**
@@ -112,9 +110,7 @@
// set state of the planner with child nodes
// to be used while planning
- List childNodes = node.getChildren();
- // index giving the next child node to be accessed in the list
- ChildIndexHolder childIndex = new ChildIndexHolder();
+ List<CommandTreeNode> childNodes = node.getChildren();
boolean debug = analysisRecord.recordDebug();
if(debug) {
@@ -128,7 +124,7 @@
Block block = ((CreateUpdateProcedureCommand) procCommand).getBlock();
- Program programBlock = planBlock(((CreateUpdateProcedureCommand)procCommand), block, metadata, childNodes, debug, childIndex, idGenerator, capFinder, analysisRecord);
+ Program programBlock = planBlock(((CreateUpdateProcedureCommand)procCommand), block, metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
if(debug) {
analysisRecord.println("\n####################################################"); //$NON-NLS-1$
@@ -168,14 +164,13 @@
* @param metadata Metadata used during planning
* @param childNodes list of CommandTreeNode objects that contain the ProcessorPlans of the child nodes of this procedure
* @param debug Boolean detemining if procedure plan needs to be printed for debug purposes
- * @param childIndex index giving the next child node to be accessed in the list
* @param analysisRecord TODO
* @return A Program resulting in the block planning
* @throws QueryPlannerException if invalid statement is encountered in the block
* @throws QueryMetadataException if there is an error accessing metadata
* @throws MetaMatrixComponentException if unexpected error occurs
*/
- private Program planBlock(CreateUpdateProcedureCommand parentProcCommand, Block block, QueryMetadataInterface metadata, List childNodes, boolean debug, ChildIndexHolder childIndex, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord)
+ private Program planBlock(CreateUpdateProcedureCommand parentProcCommand, Block block, QueryMetadataInterface metadata, List<CommandTreeNode> childNodes, boolean debug, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord)
throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
Iterator stmtIter = block.getStatements().iterator();
@@ -188,7 +183,7 @@
// plan each statement in the block
while(stmtIter.hasNext()) {
Statement statement = (Statement) stmtIter.next();
- Object instruction = planStatement(parentProcCommand, statement, metadata, childNodes, debug, childIndex, idGenerator, capFinder, analysisRecord);
+ Object instruction = planStatement(parentProcCommand, statement, metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
//childIndex = ((Integer) array[0]).intValue();
if(instruction instanceof ProgramInstruction){
programBlock.addInstruction((ProgramInstruction)instruction);
@@ -213,7 +208,6 @@
* @param metadata Metadata used during planning
* @param childNodes list of CommandTreeNode objects that contain the ProcessorPlans of the child nodes of this procedure
* @param debug Boolean detemining if procedure plan needs to be printed for debug purposes
- * @param childIndex index giving the next child node to be accessed in the list
* @param analysisRecord TODO
* @return An array containing index of the next child to be accessesd and the ProgramInstruction resulting
* in the statement planning
@@ -221,7 +215,7 @@
* @throws QueryMetadataException if there is an error accessing metadata
* @throws MetaMatrixComponentException if unexpected error occurs
*/
- private Object planStatement(CreateUpdateProcedureCommand parentProcCommand, Statement statement, QueryMetadataInterface metadata, List childNodes, boolean debug, ChildIndexHolder childIndex, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord)
+ private Object planStatement(CreateUpdateProcedureCommand parentProcCommand, Statement statement, QueryMetadataInterface metadata, List<CommandTreeNode> childNodes, boolean debug, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord)
throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
int stmtType = statement.getType();
@@ -248,16 +242,11 @@
ProcessorPlan assignPlan = null;
if(assignStmt.hasCommand()) {
- List references = ReferenceCollectorVisitor.getReferences(assignStmt.getCommand());
- assignPlan = ((CommandTreeNode)childNodes.get(childIndex.getChildIndex())).getProcessorPlan();
- childIndex.incrementChildIndex();
+ assignPlan = assignStmt.getCommand().getProcessorPlan();
assignInstr.setProcessPlan(assignPlan);
- assignInstr.setReferences(references);
} else if (assignStmt.hasExpression()) {
Expression asigExpr = assignStmt.getExpression();
assignInstr.setExpression(asigExpr);
- Collection references = ReferenceCollectorVisitor.getReferences(asigExpr);
- assignInstr.setReferences(references);
}
if(debug) {
analysisRecord.println("\t"+instruction.toString()+"\n" + statement); //$NON-NLS-1$ //$NON-NLS-2$
@@ -278,14 +267,12 @@
intoGroup = into.getGroup();
}
}
- List references = ReferenceCollectorVisitor.getReferences(command);
- ProcessorPlan commandPlan = ((CommandTreeNode)childNodes.get(childIndex.getChildIndex())).getProcessorPlan();
- childIndex.incrementChildIndex();
+ ProcessorPlan commandPlan = cmdStmt.getCommand().getProcessorPlan();
if (command.getType() == Command.TYPE_DYNAMIC){
- instruction = new ExecDynamicSqlInstruction(parentProcCommand,((DynamicCommand)command), references, metadata, idGenerator, capFinder );
+ instruction = new ExecDynamicSqlInstruction(parentProcCommand,((DynamicCommand)command), metadata, idGenerator, capFinder );
}else{
- instruction = new ExecSqlInstruction(commandPlan, references, intoGroup);
+ instruction = new ExecSqlInstruction(commandPlan, intoGroup);
}
if(debug) {
@@ -297,10 +284,10 @@
case Statement.TYPE_IF:
{
IfStatement ifStmt = (IfStatement)statement;
- Program ifProgram = planBlock(parentProcCommand, ifStmt.getIfBlock(), metadata, childNodes, debug, childIndex, idGenerator, capFinder, analysisRecord);
+ Program ifProgram = planBlock(parentProcCommand, ifStmt.getIfBlock(), metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
Program elseProgram = null;
if(ifStmt.hasElseBlock()) {
- elseProgram = planBlock(parentProcCommand, ifStmt.getElseBlock(), metadata, childNodes, debug, childIndex, idGenerator, capFinder, analysisRecord);
+ elseProgram = planBlock(parentProcCommand, ifStmt.getElseBlock(), metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
}
instruction = new IfInstruction(ifStmt.getCondition(), ifProgram, elseProgram);
if(debug) {
@@ -331,20 +318,16 @@
analysisRecord.println("\tLOOP STATEMENT:\n" + statement); //$NON-NLS-1$
}
String rsName = loopStmt.getCursorName();
- ProcessorPlan commandPlan = ((CommandTreeNode)childNodes.get(childIndex.getChildIndex())).getProcessorPlan();
- childIndex.incrementChildIndex();
+ ProcessorPlan commandPlan = loopStmt.getCommand().getProcessorPlan();
- Command command = loopStmt.getCommand();
- List references = ReferenceCollectorVisitor.getReferences(command);
-
- Program loopProgram = planBlock(parentProcCommand, loopStmt.getBlock(), metadata, childNodes, debug, childIndex, idGenerator, capFinder, analysisRecord);
- instruction = new LoopInstruction(loopProgram, rsName, commandPlan, references);
+ Program loopProgram = planBlock(parentProcCommand, loopStmt.getBlock(), metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
+ instruction = new LoopInstruction(loopProgram, rsName, commandPlan);
break;
}
case Statement.TYPE_WHILE:
{
WhileStatement whileStmt = (WhileStatement)statement;
- Program whileProgram = planBlock(parentProcCommand, whileStmt.getBlock(), metadata, childNodes, debug, childIndex, idGenerator, capFinder, analysisRecord);
+ Program whileProgram = planBlock(parentProcCommand, whileStmt.getBlock(), metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
if(debug) {
analysisRecord.println("\tWHILE STATEMENT:\n" + statement); //$NON-NLS-1$
}
@@ -357,15 +340,4 @@
return instruction;
}
- static class ChildIndexHolder{
- private int childIndex;
-
- int getChildIndex() {
- return childIndex;
- }
-
- void incrementChildIndex() {
- childIndex++;
- }
- }
} // END CLASS
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -188,22 +188,15 @@
} else {
List symbols = (List) node.getProperty(NodeConstants.Info.PROJECT_COLS);
- List subqueryPlans = (List)node.getProperty(NodeConstants.Info.SUBQUERY_PLANS);
- if (subqueryPlans == null){
- // This is a normal select node
- ProjectNode pnode = new ProjectNode(getID());
- processNode = pnode;
+ // This project node has one or more subqueries
+ List subqueries = node.getSubqueryContainers();
+ if (subqueries.isEmpty()){
+ ProjectNode pnode = new ProjectNode(getID());
+ processNode = pnode;
} else {
- // This project node has one or more subqueries
- List subqueries = (List)node.getProperty(NodeConstants.Info.SUBQUERY_VALUE_PROVIDERS);
- DependentProjectNode pnode = new DependentProjectNode(getID());
- pnode.setPlansAndValueProviders(subqueryPlans, subqueries);
+ SymbolMap correlatedReferences = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ DependentProjectNode pnode = new DependentProjectNode(getID(), correlatedReferences);
- List correlatedReferences = (List)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
- if (correlatedReferences != null){
- pnode.setCorrelatedReferences(correlatedReferences);
- }
-
processNode = pnode;
}
((ProjectNode)processNode).setSelectSymbols(symbols);
@@ -328,9 +321,9 @@
case NodeConstants.Types.SELECT:
- List subPlans = (List) node.getProperty(NodeConstants.Info.SUBQUERY_PLANS);
Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- if (subPlans == null){
+ List subCrits = node.getSubqueryContainers();
+ if (subCrits.isEmpty()){
// This is a normal select node
SelectNode selnode = new SelectNode(getID());
selnode.setCriteria(crit);
@@ -338,15 +331,11 @@
processNode = selnode;
} else {
// This select node has one or more subqueries
- List subCrits = (List)node.getProperty(NodeConstants.Info.SUBQUERY_VALUE_PROVIDERS);
+ SymbolMap correlatedReferences = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
- DependentSelectNode selnode = new DependentSelectNode(getID());
+ DependentSelectNode selnode = new DependentSelectNode(getID(), correlatedReferences);
selnode.setCriteria(crit);
- selnode.setPlansAndCriteriaMapping(subPlans, subCrits);
- List correlatedReferences = (List)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
- selnode.setCorrelatedReferences(correlatedReferences);
-
processNode = selnode;
}
possiblyDependentObject = crit;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -24,12 +24,9 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
-import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -50,15 +47,14 @@
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.relational.RelationalPlan;
import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.CorrelatedReferenceCollectorVisitor;
import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
import com.metamatrix.query.util.LogConstants;
@@ -109,7 +105,7 @@
// Distribute childPlans into relational plan
PlanNode plan = (PlanNode)node.getCanonicalPlan();
- Map planMap = connectChildPlans(plan, node);
+ connectChildPlans(plan);
// Check whether command has virtual groups
Command command = node.getCommand();
@@ -125,9 +121,9 @@
}
// Connect ProcessorPlan to SubqueryContainer (if any) of SELECT or PROJECT nodes
- if (!planMap.isEmpty()){
- connectSubqueryContainers(planMap, plan);
- }
+ if (node.getChildCount() > 0) {
+ connectSubqueryContainers(plan);
+ }
// Set top column information on top node
List projectCols = command.getProjectedSymbols();
@@ -168,44 +164,30 @@
* map of child plans, and create a new Map of ProcessorPlan to the
* SubqueryContainer object, and place that new Map as a property on the
* plan node. The Map will be used later during processing.</p>
- *
- * @param planMap Map <child Command - child ProcessorPlan>
* @param plan PlanNode
*/
- private static void connectSubqueryContainers(Map planMap, PlanNode plan) {
+ private static void connectSubqueryContainers(PlanNode plan) {
Set<GroupSymbol> groupSymbols = new HashSet<GroupSymbol>();
for (PlanNode source : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) {
groupSymbols.addAll(source.getGroups());
}
for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.PROJECT | NodeConstants.Types.SELECT)) {
- List subqueryContainers = new ArrayList();
-
- if (node.getType() == NodeConstants.Types.SELECT){
- Criteria criteria = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(criteria, subqueryContainers);
- } else {
- Collection projectCols = (Collection)node.getProperty(NodeConstants.Info.PROJECT_COLS);
- ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(projectCols, subqueryContainers);
+ List<SubqueryContainer> subqueryContainers = node.getSubqueryContainers();
+ if (subqueryContainers.isEmpty()){
+ continue;
}
- ArrayList<ElementSymbol> correlatedReferences = new ArrayList<ElementSymbol>();
- if (subqueryContainers.size() > 0){
- ArrayList plans = new ArrayList(subqueryContainers.size());
-
- Iterator i = subqueryContainers.iterator();
- while (i.hasNext()) {
- SubqueryContainer container = (SubqueryContainer) i.next();
-
- Command subCommand = container.getCommand();
- Object processorPlan = planMap.get(subCommand);
- CorrelatedReferenceCollectorVisitor.collectReferences(subCommand, groupSymbols, correlatedReferences);
- plans.add(processorPlan);
- }
- node.setProperty(NodeConstants.Info.SUBQUERY_PLANS, plans);
- node.setProperty(NodeConstants.Info.SUBQUERY_VALUE_PROVIDERS, subqueryContainers);
- node.setProperty(NodeConstants.Info.CORRELATED_REFERENCES, correlatedReferences);
- node.addGroups(GroupsUsedByElementsVisitor.getGroups(node.getCorrelatedReferenceElements()));
+ ArrayList<Reference> correlatedReferences = new ArrayList<Reference>();
+ for (SubqueryContainer container : subqueryContainers) {
+ Command subCommand = container.getCommand();
+ CorrelatedReferenceCollectorVisitor.collectReferences(subCommand, groupSymbols, correlatedReferences);
}
+ SymbolMap map = new SymbolMap();
+ for (Reference reference : correlatedReferences) {
+ map.addMapping(reference.getExpression(), reference.getExpression());
+ }
+ node.setProperty(NodeConstants.Info.CORRELATED_REFERENCES, map);
+ node.addGroups(GroupsUsedByElementsVisitor.getGroups(node.getCorrelatedReferenceElements()));
}
}
@@ -216,31 +198,14 @@
* @param metadata
* @return Map <Command - child ProcessorPlan>
*/
- private static Map connectChildPlans(PlanNode plan, CommandTreeNode commandNode) {
- // Quick check whether this is needed
- List commandChildren = commandNode.getChildren();
- if(commandChildren.size() == 0) {
- return Collections.EMPTY_MAP;
- }
-
- // Pull out subcommands and their plans
- Map planMap = new IdentityHashMap();
- Iterator childIter = commandChildren.iterator();
- for(int i=0; childIter.hasNext(); i++) {
- CommandTreeNode child = (CommandTreeNode) childIter.next();
- planMap.put(child.getCommand(), child.getProcessorPlan());
- }
-
+ private static void connectChildPlans(PlanNode plan) {
// Find all nodes that need subcommands attached
for (PlanNode source : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) {
- Object nodeCommand = source.getProperty(NodeConstants.Info.NESTED_COMMAND);
- ProcessorPlan subPlan = (ProcessorPlan) planMap.get(nodeCommand);
- if(subPlan != null) {
- source.setProperty(NodeConstants.Info.PROCESSOR_PLAN, subPlan);
+ Command nodeCommand = (Command)source.getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if(nodeCommand != null && nodeCommand.getProcessorPlan() != null) {
+ source.setProperty(NodeConstants.Info.PROCESSOR_PLAN, nodeCommand.getProcessorPlan());
}
}
-
- return planMap;
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -128,16 +128,7 @@
OUTPUT_COLS, // List <SingleElementSymbol>
// Plan node constants, common to any or multiple plan node types
- /** List of ProcessorPlan, directly maps to {@link #SUBQUERY_VALUE_PROVIDERS}*/
- SUBQUERY_PLANS,
- /** List of ValueIteratorProvider, directly maps to {@link #SUBQUERY_PLANS}*/
- SUBQUERY_VALUE_PROVIDERS,
- /**
- * List of References in correlated subqueries to an "outer" query. This
- * List is a property of an outer node which needs to provide data to the
- * References for each tuple that the outer node processes.
- */
- CORRELATED_REFERENCES,
+ CORRELATED_REFERENCES, // SymbolMap
// Plan Node Cost Estimate Constants
EST_SET_SIZE, // Integer represents the estimated set size this node would produce for a sibling node as the indenpendent node in a dependent join scenario
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,10 +22,27 @@
package com.metamatrix.query.optimizer.relational.plantree;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
-import com.metamatrix.query.sql.symbol.*;
+import com.metamatrix.query.sql.LanguageObject;
+import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.lang.SubqueryContainer;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
+import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
public class PlanNode {
@@ -279,18 +296,30 @@
}
public Set<ElementSymbol> getCorrelatedReferenceElements() {
- List<Reference> refs = (List<Reference>) this.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ SymbolMap refs = (SymbolMap) this.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
- if(refs == null || refs.isEmpty()) {
+ if(refs == null) {
return Collections.emptySet();
}
- HashSet<ElementSymbol> result = new HashSet<ElementSymbol>(refs.size());
- for (Reference ref : refs) {
- Expression expr = ref.getExpression();
+ List<Expression> values = refs.getValues();
+ HashSet<ElementSymbol> result = new HashSet<ElementSymbol>(values.size());
+ for (Expression expr : values) {
ElementCollectorVisitor.getElements(expr, result);
}
return result;
}
+
+ public List<SubqueryContainer> getSubqueryContainers() {
+ Collection<? extends LanguageObject> toSearch = Collections.emptyList();
+ if (this.getType() == NodeConstants.Types.SELECT){
+ Criteria criteria = (Criteria)this.getProperty(NodeConstants.Info.SELECT_CRITERIA);
+ toSearch = Arrays.asList(criteria);
+ }
+ if (this.getType() == NodeConstants.Types.PROJECT) {
+ toSearch = (Collection)this.getProperty(NodeConstants.Info.PROJECT_COLS);
+ }
+ return (List<SubqueryContainer>)ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(toSearch);
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -228,7 +228,7 @@
public void visit(Function obj) {
try {
//if the function can be evaluated then return as it will get replaced during the final rewrite
- if (EvaluateExpressionVisitor.willBecomeConstant(obj)) {
+ if (EvaluateExpressionVisitor.willBecomeConstant(obj, true)) {
return;
}
if(obj.getFunctionDescriptor().getPushdown() == FunctionMethod.CANNOT_PUSHDOWN || ! CapabilitiesUtil.supportsScalarFunction(modelID, obj, metadata, capFinder)) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -61,7 +61,6 @@
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.ExpressionSymbol;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
@@ -185,14 +184,12 @@
// Convert expressions from correlated subquery references;
// currently only for SELECT or PROJECT nodes
- List refs = (List)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ SymbolMap refs = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
if (refs != null){
- Iterator refIter = refs.iterator();
- while (refIter.hasNext()) {
- Reference ref = (Reference)refIter.next();
- Expression expr = ref.getExpression();
+ for (Map.Entry<ElementSymbol, Expression> ref : refs.asUpdatableMap().entrySet()) {
+ Expression expr = ref.getValue();
Expression convertedExpr = convertExpression(expr, symbolMap);
- ref.setExpression(convertedExpr);
+ ref.setValue(convertedExpr);
if (newGroup == null) {
GroupsUsedByElementsVisitor.getGroups(convertedExpr, groups);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinUtil.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinUtil.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -60,7 +60,7 @@
}
/**
- * Will attempt to optimize the join type based upon the criteria provied.
+ * Will attempt to optimize the join type based upon the criteria provided.
*
* Returns the new join type if one is found, otherwise null
*
@@ -72,7 +72,7 @@
* @return
*/
static final JoinType optimizeJoinType(PlanNode critNode, PlanNode joinNode, QueryMetadataInterface metadata) {
- if (critNode.getGroups().isEmpty() || !joinNode.getGroups().containsAll(critNode.getGroups()) || critNode.hasCollectionProperty(NodeConstants.Info.CORRELATED_REFERENCES)) {
+ if (critNode.getGroups().isEmpty() || !joinNode.getGroups().containsAll(critNode.getGroups()) || FrameUtil.hasSubquery(critNode)) {
return null;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -431,12 +431,9 @@
// Gather elements from correlated subquery references;
// currently only for SELECT or PROJECT nodes
- List refs = (List)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ SymbolMap refs = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
if (refs != null){
- Iterator refIter = refs.iterator();
- while (refIter.hasNext()) {
- Reference ref = (Reference)refIter.next();
- Expression expr = ref.getExpression();
+ for (Expression expr : refs.asMap().values()) {
AggregateSymbolCollectorVisitor.getAggregates(expr, requiredSymbols, requiredSymbols);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -23,7 +23,6 @@
package com.metamatrix.query.optimizer.relational.rules;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -62,10 +61,13 @@
import com.metamatrix.query.sql.lang.SubqueryFromClause;
import com.metamatrix.query.sql.lang.UnaryFromClause;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
+import com.metamatrix.query.sql.navigator.DeepPostOrderNavigator;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import com.metamatrix.query.sql.util.SymbolMap;
+import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
import com.metamatrix.query.util.CommandContext;
public final class RuleCollapseSource implements OptimizerRule {
@@ -243,12 +245,33 @@
case NodeConstants.Types.SELECT:
{
Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- Iterator valueIteratorProviders = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(crit).iterator();
- if (valueIteratorProviders.hasNext()){
- SubqueryContainer container = (SubqueryContainer)valueIteratorProviders.next();
- RelationalPlan subqueryPlan = (RelationalPlan)((Collection)node.getProperty(NodeConstants.Info.SUBQUERY_PLANS)).iterator().next();
+ List<SubqueryContainer> containers = node.getSubqueryContainers();
+ for (SubqueryContainer container : containers) {
+ RelationalPlan subqueryPlan = (RelationalPlan)container.getCommand().getProcessorPlan();
+ if (subqueryPlan == null) {
+ continue;
+ }
AccessNode child = (AccessNode)subqueryPlan.getRootNode();
- container.setCommand(child.getCommand());
+ Command command = child.getCommand();
+ final SymbolMap map = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ if (map != null) {
+ ExpressionMappingVisitor visitor = new ExpressionMappingVisitor(null) {
+ @Override
+ public Expression replaceExpression(
+ Expression element) {
+ if (element instanceof Reference) {
+ Reference ref = (Reference)element;
+ Expression replacement = map.getMappedExpression(ref.getExpression());
+ if (replacement != null) {
+ return replacement;
+ }
+ }
+ return element;
+ }
+ };
+ DeepPostOrderNavigator.doVisit(command, visitor);
+ }
+ container.setCommand(command);
}
if(!node.hasBooleanProperty(NodeConstants.Info.IS_HAVING)) {
query.setCriteria( CompoundCriteria.combineCriteria(query.getCriteria(), crit) );
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -39,6 +39,7 @@
import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
import com.metamatrix.query.util.CommandContext;
@@ -99,20 +100,16 @@
// Remove all of chain except root, collect crit from each
CompoundCriteria critParts = new CompoundCriteria();
- List subqueryPlans = null;
- List subqueryValueProviders = null;
- List correlatedReferences = null;
+ SymbolMap correlatedReferences = new SymbolMap();
PlanNode current = chainRoot;
boolean isDependentSet = false;
while(current.getType() == NodeConstants.Types.SELECT) {
critParts.addCriteria((Criteria)current.getProperty(NodeConstants.Info.SELECT_CRITERIA));
- subqueryPlans = addProperties(subqueryPlans, (List)current.getProperty(NodeConstants.Info.SUBQUERY_PLANS));
- subqueryValueProviders = addProperties(subqueryValueProviders, (List)current.getProperty(NodeConstants.Info.SUBQUERY_VALUE_PROVIDERS));
- correlatedReferences = addProperties(correlatedReferences, (List)current.getProperty(NodeConstants.Info.CORRELATED_REFERENCES));
-
isDependentSet |= current.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET);
+ correlatedReferences.merge((SymbolMap)current.getProperty(NodeConstants.Info.CORRELATED_REFERENCES));
+
// Recurse
PlanNode last = current;
current = current.getLastChild();
@@ -132,19 +129,15 @@
// Replace criteria at root with new combined criteria
chainRoot.setProperty(NodeConstants.Info.SELECT_CRITERIA, combinedCrit);
- if (subqueryPlans != null){
- chainRoot.setProperty(NodeConstants.Info.SUBQUERY_PLANS, subqueryPlans);
- }
- if (subqueryValueProviders != null){
- chainRoot.setProperty(NodeConstants.Info.SUBQUERY_VALUE_PROVIDERS, subqueryValueProviders);
- }
- if (correlatedReferences != null){
+ if (!correlatedReferences.asMap().isEmpty()){
chainRoot.setProperty(NodeConstants.Info.CORRELATED_REFERENCES, correlatedReferences);
}
// Reset group for node based on combined criteria
chainRoot.getGroups().clear();
+
chainRoot.addGroups(GroupsUsedByElementsVisitor.getGroups(combinedCrit));
+ chainRoot.addGroups(GroupsUsedByElementsVisitor.getGroups(chainRoot.getCorrelatedReferenceElements()));
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -292,6 +292,8 @@
PlanNode newAccess = RuleRaiseAccess.raiseAccessOverJoin(joinNode, entry.getKey(), false);
for (Iterator joinCriteriaIter = joinCriteriaNodes.iterator(); joinCriteriaIter.hasNext();) {
PlanNode critNode = (PlanNode)joinCriteriaIter.next();
+ critNode.removeFromParent();
+ critNode.removeAllChildren();
critNode.setProperty(NodeConstants.Info.IS_COPIED, Boolean.FALSE);
critNode.setProperty(NodeConstants.Info.IS_PUSHED, Boolean.FALSE);
newAccess.getFirstChild().addAsParent(critNode);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -73,17 +73,17 @@
QueryMetadataException,
MetaMatrixComponentException {
- List nodes = NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE, NodeConstants.Types.ACCESS);
-
- for (Iterator i = nodes.iterator(); i.hasNext();) {
- PlanNode node = (PlanNode)i.next();
-
+ for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE, NodeConstants.Types.ACCESS)) {
if (!FrameUtil.isProcedure(node.getFirstChild())) {
continue;
}
StoredProcedure proc = (StoredProcedure)node.getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if (!proc.isProcedureRelational()) {
+ continue;
+ }
+
HashSet inputSymbols = new HashSet();
List inputReferences = new LinkedList();
@@ -92,11 +92,7 @@
List conjuncts = new LinkedList();
HashSet coveredParams = new HashSet();
//List preExecNodes = new LinkedList();
-
- if (!proc.isProcedureRelational()) {
- continue;
- }
-
+
for (Iterator params = proc.getInputParameters().iterator(); params.hasNext();) {
SPParameter param = (SPParameter)params.next();
ElementSymbol symbol = param.getParameterSymbol();
@@ -111,7 +107,7 @@
for (Iterator params = inputReferences.iterator(); params.hasNext();) {
Reference ref = (Reference)params.next();
- ElementSymbol symbol = (ElementSymbol)ref.getExpression();
+ ElementSymbol symbol = ref.getExpression();
Expression defaultValue = null;
@@ -128,13 +124,13 @@
}
}
- if (conjuncts.isEmpty()) {
+ /*if (conjuncts.isEmpty()) {
for (int j = 0; j < inputReferences.size(); j++) {
Reference ref = (Reference)inputReferences.get(j);
ref.setValue(defaults.get(j));
}
continue;
- }
+ }*/
PlanNode accessNode = NodeEditor.findNodePreOrder(node, NodeConstants.Types.ACCESS);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -63,7 +63,6 @@
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Function;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
@@ -421,17 +420,15 @@
// Convert expressions from correlated subquery references;
// currently only for SELECT or PROJECT nodes
- List refs = (List)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ SymbolMap refs = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
if (refs != null){
- Iterator refIter = refs.iterator();
- while (refIter.hasNext()) {
- Reference ref = (Reference)refIter.next();
- Expression expr = ref.getExpression();
+ for (Map.Entry<ElementSymbol, Expression> ref : refs.asUpdatableMap().entrySet()) {
+ Expression expr = ref.getValue();
Expression mappedExpr = exprMap.get(expr);
if (mappedExpr != null) {
- ref.setExpression(mappedExpr);
+ ref.setValue(mappedExpr);
} else {
- ExpressionMappingVisitor.mapExpressions(ref.getExpression(), exprMap);
+ ExpressionMappingVisitor.mapExpressions(ref.getValue(), exprMap);
}
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,11 +22,9 @@
package com.metamatrix.query.optimizer.relational.rules;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -47,23 +45,16 @@
import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
import com.metamatrix.query.resolver.util.AccessPattern;
-import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.util.ValueIteratorProvider;
import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
@@ -102,22 +93,22 @@
if (isPhantom || isCopied || isPushed || deadNodes.contains(critNode)) {
continue;
}
- pushTowardOriginatingNode(critNode, metadata, capFinder);
+ PlanNode sourceNode = findOriginatingNode(metadata, capFinder, critNode);
+
+ if(sourceNode == null) {
+ deadNodes.add(critNode);
+ continue;
+ }
+ pushTowardOriginatingNode(sourceNode, critNode, metadata, capFinder);
+
boolean moved = false;
- if(critNode.getGroups().isEmpty()) {
+ if((critNode.getGroups().isEmpty() && !FrameUtil.hasSubquery(critNode)) || !atBoundary(critNode, sourceNode)) {
deadNodes.add(critNode);
continue;
}
-
- PlanNode sourceNode = FrameUtil.findOriginatingNode(critNode, critNode.getGroups());
- if (sourceNode == null || !atBoundary(critNode, sourceNode)) {
- deadNodes.add(critNode);
- continue;
- }
-
switch (sourceNode.getType()) {
case NodeConstants.Types.SOURCE:
{
@@ -141,6 +132,24 @@
return plan;
}
+
+ private PlanNode findOriginatingNode(QueryMetadataInterface metadata,
+ CapabilitiesFinder capFinder, PlanNode critNode)
+ throws MetaMatrixComponentException, QueryMetadataException {
+ if (critNode.getGroups().isEmpty() && FrameUtil.hasSubquery(critNode)) {
+ Object modelId = RuleRaiseAccess.isEligibleSubquery(critNode, null, metadata, capFinder);
+ if (modelId != null) {
+ for (PlanNode node : NodeEditor.findAllNodes(critNode, NodeConstants.Types.SOURCE)) {
+ GroupSymbol group = node.getGroups().iterator().next();
+ Object srcModelID = metadata.getModelID(group.getMetadataID());
+ if(CapabilitiesUtil.isSameConnector(srcModelID, modelId, metadata, capFinder)) {
+ return node;
+ }
+ }
+ }
+ }
+ return FrameUtil.findOriginatingNode(critNode, critNode.getGroups());
+ }
/**
* Handles multi-group criteria originating at the given joinNode
@@ -205,35 +214,9 @@
* @throws QueryMetadataException
* @throws MetaMatrixComponentException
*/
- void pushTowardOriginatingNode(PlanNode critNode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
+ void pushTowardOriginatingNode(PlanNode sourceNode, PlanNode critNode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
- PlanNode sourceNode = null;
-
- Set<GroupSymbol> groups = critNode.getGroups();
-
- //check for an uncorrelated subquery
- if(groups.isEmpty() && FrameUtil.hasSubquery(critNode)) {
- Object modelID = getUniqueModel(critNode, metadata);
- if(modelID != null) {
- // Find source node for this model - if multiple, pick first
- for (PlanNode node : NodeEditor.findAllNodes(critNode, NodeConstants.Types.SOURCE, NodeConstants.Types.SOURCE)) {
- GroupSymbol group = node.getGroups().iterator().next();
- Object srcModelID = metadata.getModelID(group.getMetadataID());
- if(srcModelID != null && srcModelID.equals(modelID)) {
- sourceNode = node;
- break;
- }
- }
- }
- } else {
- sourceNode = FrameUtil.findOriginatingNode(critNode, groups);
- }
-
- if(sourceNode == null) {
- return;
- }
-
//to keep a stable criteria ordering, move the sourceNode to the top of the criteria chain
while (sourceNode.getParent().getType() == NodeConstants.Types.SELECT) {
sourceNode = sourceNode.getParent();
@@ -248,53 +231,6 @@
destination.addAsParent(critNode);
}
- private Object getUniqueModel(PlanNode critNode, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
-
- Object modelID = null;
- List plans = (List) critNode.getProperty(NodeConstants.Info.SUBQUERY_PLANS);
- if(plans == null) {
- return null;
- }
-
- Iterator planIter = plans.iterator();
- while(planIter.hasNext()) {
- Object plan = planIter.next();
- if(plan instanceof RelationalPlan) {
- RelationalPlan subPlan = (RelationalPlan) plan;
-
- LinkedList nodes = new LinkedList();
- nodes.add(subPlan.getRootNode());
-
- while(nodes.size() > 0) {
- RelationalNode node = (RelationalNode) nodes.removeFirst();
- if(node instanceof AccessNode) {
- Command command = ((AccessNode)node).getCommand();
- Collection groups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(command, true);
- if(groups.size() > 0) {
- GroupSymbol group = (GroupSymbol) groups.iterator().next();
- if(modelID == null) {
- modelID = metadata.getModelID(group.getMetadataID());
- } else if(! modelID.equals(metadata.getModelID(group.getMetadataID()))){
- // Mismatch - bail out
- return null;
- }
- }
- } else {
- RelationalNode[] children = node.getChildren();
- for(int i=0; i<children.length; i++) {
- if(children[i] != null) {
- nodes.add(children[i]);
- }
- }
- }
- }
- }
- }
-
- return modelID;
- }
-
/**
* Examine the path from crit node to source node to determine how far down a node
* can be pushed.
@@ -509,18 +445,9 @@
Criteria copyCrit = (Criteria) crit.clone();
copyNode.setProperty(NodeConstants.Info.SELECT_CRITERIA, copyCrit);
copyNode.addGroups(critNode.getGroups());
- // Copy subquery properties
- List<RelationalPlan> subqueryPlans = (List<RelationalPlan>)critNode.getProperty(NodeConstants.Info.SUBQUERY_PLANS);
- if(subqueryPlans != null) {
- copyNode.setProperty(NodeConstants.Info.SUBQUERY_PLANS, new ArrayList<RelationalPlan>(subqueryPlans));
- }
- List<ValueIteratorProvider> subqueryValueProviders = (List<ValueIteratorProvider>)critNode.getProperty(NodeConstants.Info.SUBQUERY_VALUE_PROVIDERS);
- if(subqueryValueProviders != null) {
- copyNode.setProperty(NodeConstants.Info.SUBQUERY_VALUE_PROVIDERS, new ArrayList<ValueIteratorProvider>(subqueryValueProviders));
- }
- List<Reference> correlatedReferences = (List<Reference>)critNode.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ SymbolMap correlatedReferences = (SymbolMap)critNode.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
if(correlatedReferences != null) {
- copyNode.setProperty(NodeConstants.Info.CORRELATED_REFERENCES, new ArrayList<Reference>(correlatedReferences));
+ copyNode.setProperty(NodeConstants.Info.CORRELATED_REFERENCES, new SymbolMap(correlatedReferences));
}
if(critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)) {
copyNode.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -50,13 +50,13 @@
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.EvaluateExpressionVisitor;
@@ -318,8 +318,7 @@
Criteria crit = (Criteria) parentNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- boolean hasSubquery = FrameUtil.hasSubquery(parentNode);
- if(hasSubquery && !isEligibleSubquery(parentNode, metadata, capFinder)){
+ if(isEligibleSubquery(parentNode, modelID, metadata, capFinder) == null){
return false;
}
@@ -343,16 +342,12 @@
/**
* Check whether the subquery in the node is eligible to be pushed.
*/
- static boolean isEligibleSubquery(PlanNode critNode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws MetaMatrixComponentException {
- List plans = (List) critNode.getProperty(NodeConstants.Info.SUBQUERY_PLANS);
- if(plans == null) {
- return false;
- }
- Iterator planIter = plans.iterator();
- while(planIter.hasNext()) {
- ProcessorPlan plan = (ProcessorPlan) planIter.next();
+ static Object isEligibleSubquery(PlanNode critNode, Object critNodeModelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws MetaMatrixComponentException {
+ List<SubqueryContainer> plans = critNode.getSubqueryContainers();
+ for (SubqueryContainer subqueryContainer : plans) {
+ ProcessorPlan plan = subqueryContainer.getCommand().getProcessorPlan();
if(!(plan instanceof RelationalPlan)) {
- return false;
+ return null;
}
RelationalPlan rplan = (RelationalPlan) plan;
@@ -360,72 +355,53 @@
// Check that the plan is just an access node
RelationalNode accessNode = rplan.getRootNode();
if(accessNode == null || ! (accessNode instanceof AccessNode) || accessNode.getChildren()[0] != null) {
- return false;
+ return null;
}
// Check that command in access node is a query
Command command = ((AccessNode)accessNode).getCommand();
if(command == null || !(command instanceof Query) || ((Query)command).getIsXML()) {
- return false;
+ return null;
}
// Check that query in access node is for the same model as current node
- Object critNodeModelID = null;
- try {
- PlanNode source = FrameUtil.findJoinSourceNode(critNode);
- if (source.getType() != NodeConstants.Types.ACCESS) {
- return false;
- }
- critNodeModelID = RuleRaiseAccess.getModelIDFromAccess(source, metadata);
-
- if (critNodeModelID == null) {
- return false;
- }
-
+ try {
Collection subQueryGroups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(command, false);
if(subQueryGroups.size() == 0) {
// No FROM?
- return false;
+ return null;
}
GroupSymbol subQueryGroup = (GroupSymbol)subQueryGroups.iterator().next();
-
+
Object modelID = metadata.getModelID(subQueryGroup.getMetadataID());
- if(!CapabilitiesUtil.isSameConnector(critNodeModelID, modelID, metadata, capFinder)) {
- return false;
+ if (critNodeModelID == null) {
+ critNodeModelID = modelID;
+ } else if(!CapabilitiesUtil.isSameConnector(critNodeModelID, modelID, metadata, capFinder)) {
+ return null;
}
} catch(QueryMetadataException e) {
throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("RulePushSelectCriteria.Error_getting_modelID")); //$NON-NLS-1$
}
// Check whether source supports correlated subqueries and if not, whether criteria has them
- Collection refs = (Collection) critNode.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
+ SymbolMap refs = (SymbolMap) critNode.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
try {
- if(refs != null && !refs.isEmpty()) {
+ if(refs != null && !refs.asMap().isEmpty()) {
if(! CapabilitiesUtil.supportsCorrelatedSubquery(critNodeModelID, metadata, capFinder)) {
- return false;
+ return null;
}
- for (Iterator i = refs.iterator(); i.hasNext();) {
- ((Reference)i.next()).setCorrelated(true);
- }
-
if (!CriteriaCapabilityValidatorVisitor.canPushLanguageObject(command, critNodeModelID, metadata, capFinder)) {
- return false;
+ return null;
}
}
} catch(QueryMetadataException e) {
throw new MetaMatrixComponentException(e, e.getMessage());
- } finally {
- if (refs != null) {
- for (Iterator i = refs.iterator(); i.hasNext();) {
- ((Reference)i.next()).setCorrelated(false);
- }
- }
}
}
// Found no reason why this node is not eligible
- return true;
+ return critNodeModelID;
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -33,12 +33,14 @@
import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.common.buffer.BufferManager.TupleSourceStatus;
+import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.util.CommandContext;
+import com.metamatrix.query.util.TypeRetrievalUtil;
/**
* TODO: combine overlapping responsibilities with RequestWorkItem
@@ -53,6 +55,7 @@
void batchProduced(TupleBatch batch) throws MetaMatrixCoreException;
}
+ private TupleSourceID resultsID;
private CommandContext context;
private ProcessorDataManager dataMgr;
private BufferManager bufferMgr;
@@ -72,8 +75,9 @@
* @param context The context that this plan is being processed in
* @param bufferMgr The buffer manager that provides access to tuple sources
* @param dataMgr The data manager that provides access to get data
+ * @throws MetaMatrixComponentException
*/
- public QueryProcessor(ProcessorPlan plan, CommandContext context, BufferManager bufferMgr, ProcessorDataManager dataMgr) {
+ public QueryProcessor(ProcessorPlan plan, CommandContext context, BufferManager bufferMgr, ProcessorDataManager dataMgr) throws MetaMatrixComponentException {
this.context = context;
this.dataMgr = dataMgr;
this.bufferMgr = bufferMgr;
@@ -81,16 +85,21 @@
// Add data manager to all nodes in tree
this.processPlan.initialize(context, this.dataMgr, bufferMgr);
+ this.resultsID = bufferMgr.createTupleSource(processPlan.getOutputElements(), TypeRetrievalUtil.getTypeNames(processPlan.getOutputElements()), context.getConnectionID(), TupleSourceType.PROCESSOR);
+ }
+
+ public CommandContext getContext() {
+ return context;
}
-
+
public Object getProcessID() {
return this.context.getProcessorID();
}
+
+ public TupleSourceID getResultsID() {
+ return resultsID;
+ }
- public TupleSourceID getResultsID() {
- return this.context.getTupleSourceID();
- }
-
public ProcessorPlan getProcessorPlan() {
return this.processPlan;
}
@@ -181,7 +190,7 @@
*/
private void flushBatch(TupleBatch batch) throws MetaMatrixCoreException {
if(batch.getRowCount() > 0) {
- this.bufferMgr.addTupleBatch(this.context.getTupleSourceID(), batch);
+ this.bufferMgr.addTupleBatch(this.resultsID, batch);
this.highestRow = batch.getEndRow();
}
if (this.batchHandler != null && (batch.getRowCount() > 0 || batch.getTerminationFlag())) {
@@ -207,7 +216,7 @@
processPlan.close();
} finally {
// Mark tuple source FULL
- this.bufferMgr.setStatus(this.context.getTupleSourceID(), TupleSourceStatus.FULL);
+ this.bufferMgr.setStatus(this.resultsID, TupleSourceStatus.FULL);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/batch/PreparedBatchUpdatePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/batch/PreparedBatchUpdatePlan.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/batch/PreparedBatchUpdatePlan.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -95,7 +95,7 @@
*/
public void open() throws MetaMatrixComponentException, MetaMatrixProcessingException{
if (!isPlanOpened) { // Open the plan only once
- PreparedStatementRequest.resolveParameterValues(parameterReferences, (List)parameterValuesList.get(planIndex));
+ PreparedStatementRequest.resolveParameterValues(parameterReferences, (List)parameterValuesList.get(planIndex), this.getContext());
updatePlans[planIndex].open();
isPlanOpened = true;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -94,7 +94,7 @@
// check to see if we have XML results
if (src.getSchema().size() > 0) {
- xml = ((SingleElementSymbol)src.getSchema().get(0)).getType().equals(DataTypeManager.DefaultDataClasses.XML);
+ xml = src.getSchema().get(0).getType().equals(DataTypeManager.DefaultDataClasses.XML);
}
if (xml) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,11 +31,9 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.program.ProgramEnvironment;
-import com.metamatrix.query.processor.xml.ProcessorInstruction;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.util.VariableContext;
@@ -61,11 +58,10 @@
* <p> Updates the current variable context with a value for the Variable
* defined using a DeclareInstruction, the variable value is obtained by either processing
* a expression or a command(stored as a processplan). The Processing of the command is
- * expected to result in 1 column, 1 row tuple, if more than a row is retuned an exception
+ * expected to result in 1 column, 1 row tuple, if more than a row is returned an exception
* is thrown. Also updates the program counter.</p>
* @throws BlockedException
* @throws MetaMatrixComponentException if error processing command or expression on this instruction
- * @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public void process(ProgramEnvironment env) throws BlockedException,
MetaMatrixComponentException, MetaMatrixProcessingException {
@@ -76,14 +72,9 @@
Object value = null;
if (this.getExpression() != null || this.getProcessorPlan() != null) {
- // get the current set of references and set their values
- setReferenceValues(varContext);
-
if (this.expression != null) {
//Evaluated the given expression - may throw BlockedException!
- value = new Evaluator(Collections.emptyMap(), procEnv
- .getDataManager(), procEnv.getContext()).evaluate(
- this.expression, Collections.EMPTY_LIST);
+ value = procEnv.evaluateExpression(this.expression);
} else if (processPlan != null) {
String rsName = "ASSIGNMENT_INSTRUCTION"; //$NON-NLS-1$
procEnv.executePlan(processPlan, rsName);
@@ -119,10 +110,6 @@
if (processPlan != null) {
clone.setProcessPlan((ProcessorPlan)getProcessPlan().clone());
}
- if (this.getReferences() != null) {
- List copyReferences = cloneReferences();
- clone.setReferences(copyReferences);
- }
}
public Map getDescriptionProperties() {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CommandInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CommandInstruction.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CommandInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,17 +22,7 @@
package com.metamatrix.query.processor.proc;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.util.VariableContext;
/**
@@ -44,51 +34,4 @@
*/
public abstract class CommandInstruction extends ProgramInstruction {
- private Collection references;
-
- protected Collection getReferences() {
- return this.references;
- }
-
- public void setReferences(Collection references) {
- this.references = references;
- }
-
- /**
- * <p> Set the value the <code>Reference</code> objects evaluate to by looking up the
- * variable context for the value of the <code>ElementSymbol</code> contained in the reference.
- * @param references List containing References whose values are to be set.
- * @param varContext The variableContext to be looked up for the value
- * @throws MetaMatrixComponentException if the value for the refwerence could not be found.
- */
- void setReferenceValues(VariableContext varContext) throws MetaMatrixComponentException {
- setReferenceValues(varContext, references);
- }
-
- static void setReferenceValues(VariableContext varContext, Collection references)
- throws MetaMatrixComponentException {
-
- Iterator refIter = references.iterator();
- while(refIter.hasNext()) {
- Reference ref = (Reference) refIter.next();
- Expression expr = ref.getExpression();
- if(expr instanceof ElementSymbol) {
- ElementSymbol elmnt = (ElementSymbol) expr;
- if(varContext.containsVariable(elmnt)) {
- ref.setValue(varContext.getValue(elmnt));
- }
- }
- }
- }
-
- protected List cloneReferences() {
- List copyReferences = new ArrayList(references.size());
- Iterator iter = references.iterator();
- while(iter.hasNext()) {
- Reference ref = (Reference) iter.next();
- copyReferences.add(ref.clone());
- }
- return copyReferences;
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -35,7 +35,6 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.program.ProgramEnvironment;
-import com.metamatrix.query.sql.util.VariableContext;
/**
*/
@@ -43,10 +42,9 @@
protected String rsName;
protected ProcessorPlan plan;
- public CreateCursorResultSetInstruction(String rsName, ProcessorPlan plan, Collection atomicCommandReferences){
+ public CreateCursorResultSetInstruction(String rsName, ProcessorPlan plan){
this.rsName = rsName;
this.plan = plan;
- setReferences(atomicCommandReferences);
}
/**
@@ -66,11 +64,7 @@
if(procEnv.resultSetExists(rsName)) {
procEnv.removeResults(rsName);
}
- //LogManager.logTrace(LogConstants.CTX_XML_PLAN, new Object[]{"SQL: Result set DOESN'T exist:",rsName});
- VariableContext varContext = procEnv.getCurrentVariableContext();
- setReferenceValues(varContext);
-
procEnv.executePlan(plan, rsName);
}
@@ -79,8 +73,7 @@
*/
public Object clone(){
ProcessorPlan clonedPlan = (ProcessorPlan) this.plan.clone();
- List copyRefs = cloneReferences();
- return new CreateCursorResultSetInstruction(this.rsName, clonedPlan, copyRefs);
+ return new CreateCursorResultSetInstruction(this.rsName, clonedPlan);
}
public String toString(){
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -32,7 +32,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.api.exception.query.QueryProcessingException;
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.common.buffer.BlockedException;
@@ -40,7 +39,6 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.id.IDGenerator;
import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataAdapter;
@@ -52,7 +50,6 @@
import com.metamatrix.query.processor.program.Program;
import com.metamatrix.query.processor.program.ProgramEnvironment;
import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.processor.xml.ProcessorInstruction;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.resolver.util.ResolveVirtualGroupCriteriaVisitor;
import com.metamatrix.query.resolver.util.ResolverUtil;
@@ -127,15 +124,13 @@
public ExecDynamicSqlInstruction(
CreateUpdateProcedureCommand parentProcCommand,
- DynamicCommand command, List references,
- QueryMetadataInterface metadata, IDGenerator idGenerator,
- CapabilitiesFinder capFinder) {
+ DynamicCommand command, QueryMetadataInterface metadata,
+ IDGenerator idGenerator, CapabilitiesFinder capFinder) {
this.parentProcCommand = parentProcCommand;
this.dynamicCommand = command;
this.metadata = metadata;
this.capFinder = capFinder;
this.idGenerator = idGenerator;
- setReferences(references);
}
/**
@@ -144,14 +139,13 @@
* the CommandStatement of the update procedure language. Executing this
* plan does not effect the values of any of the variables defined as part
* of the update procedure and hence the results of the ProcessPlan
- * execution need not be stored for furthur processing. The results are
+ * execution need not be stored for further processing. The results are
* removed from the buffer manager immediately after execution. The program
* counter is incremented after execution of the plan.
* </p>
*
* @throws BlockedException
- * if this processing the plan thows a currentVarContext
- * @see ProcessorInstruction#process(ProcessorEnvironment)
+ * if this processing the plan throws a currentVarContext
*/
public void process(ProgramEnvironment env) throws BlockedException,
MetaMatrixComponentException, MetaMatrixProcessingException {
@@ -165,13 +159,8 @@
VariableContext localContext = procEnv.getCurrentVariableContext();
- // get the current set of references and set their values
- setReferenceValues(localContext);
-
try {
- Object value = new Evaluator(Collections.emptyMap(), procEnv.getDataManager(),
- procEnv.getContext()).evaluate(dynamicCommand
- .getSql(), Collections.emptyList());
+ Object value = procEnv.evaluateExpression(dynamicCommand.getSql());
if (value == null) {
throw new QueryProcessingException(QueryExecPlugin.Util
@@ -229,10 +218,8 @@
.createNonRecordingRecord(), procEnv
.getContext());
- List references = ReferenceCollectorVisitor.getReferences(command);
-
ExecSqlInstruction inst = new ExecSqlInstruction(commandPlan,
- references, dynamicCommand.getIntoGroup());
+ dynamicCommand.getIntoGroup());
dynamicProgram = new Program();
dynamicProgram.addInstruction(inst);
@@ -256,17 +243,15 @@
* @param procEnv
* @param localContext
* @throws MetaMatrixComponentException
- * @throws ExpressionEvaluationException
* @throws MetaMatrixComponentException
+ * @throws MetaMatrixProcessingException
*/
private void updateContextWithUsingValues(ProcedureEnvironment procEnv,
- VariableContext localContext) throws ExpressionEvaluationException,
- MetaMatrixComponentException {
+ VariableContext localContext) throws MetaMatrixComponentException, MetaMatrixProcessingException {
if (dynamicCommand.getUsing() != null
&& !dynamicCommand.getUsing().isEmpty()) {
for (SetClause setClause : dynamicCommand.getUsing().getClauses()) {
- Object assignment = new Evaluator(Collections.emptyMap(), procEnv.getDataManager(),
- procEnv.getContext()).evaluate(setClause.getValue(), Collections.emptyList());
+ Object assignment = procEnv.evaluateExpression(setClause.getValue());
LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER,
new Object[] { this, " The using variable ", //$NON-NLS-1$
@@ -496,10 +481,8 @@
* Returns a deep clone
*/
public Object clone() {
- List copyReferences = cloneReferences();
-
ExecDynamicSqlInstruction clone = new ExecDynamicSqlInstruction(
- parentProcCommand, dynamicCommand, copyReferences, metadata, idGenerator, capFinder);
+ parentProcCommand, dynamicCommand, metadata, idGenerator, capFinder);
return clone;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecSqlInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -34,9 +34,7 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.program.ProgramEnvironment;
-import com.metamatrix.query.processor.xml.ProcessorInstruction;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.util.LogConstants;
/**
@@ -57,24 +55,20 @@
* Constructor for ExecSqlInstruction.
* @param command Object (such as a ProcessorPlan) that is executed when this instruction
* is processed.
- * @param references List of lists of reference objects, these references
- * would be updated to the values they evaluate to.
*/
- public ExecSqlInstruction(ProcessorPlan commandPlan, List references, GroupSymbol intoGroup) {
+ public ExecSqlInstruction(ProcessorPlan commandPlan, GroupSymbol intoGroup) {
this.commandPlan = commandPlan;
this.intoGroup = intoGroup;
- setReferences(references);
}
/**
* <p>Processing this instruction executes the ProcessorPlan for the command on the
* CommandStatement of the update procedure language. Executing this plan does not effect
* the values of any of the variables defined as part of the update procedure and hence
- * the results of the ProcessPlan execution need not be stored for furthur processing. The
+ * the results of the ProcessPlan execution need not be stored for further processing. The
* results are removed from the buffer manager immediately after execution. The program
* counter is incremented after execution of the plan.</p>
- * @throws BlockedException if this processing the plan thows a currentVarContext
- * @see ProcessorInstruction#process(ProcessorEnvironment)
+ * @throws BlockedException if this processing the plan throws a currentVarContext
*/
public void process(ProgramEnvironment env)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
@@ -82,11 +76,7 @@
LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, new Object[]{"Processing ExecSqlInstruction as part of processing the update procedure"}); //$NON-NLS-1$
ProcedureEnvironment procEnv = (ProcedureEnvironment) env;
- VariableContext varContext = procEnv.getCurrentVariableContext();
- // get the current set of references and set their values
- setReferenceValues(varContext);
-
if(intoGroup != null && intoGroup.isTempGroupSymbol()){
procEnv.executePlan(commandPlan, intoGroup.getName());
}else{
@@ -107,14 +97,12 @@
* Returns a deep clone
*/
public Object clone(){
- List copyReferences = cloneReferences();
-
GroupSymbol clonedIntoGroup = null;
if(this.intoGroup != null){
clonedIntoGroup = (GroupSymbol)intoGroup.clone();
}
- ExecSqlInstruction clone = new ExecSqlInstruction((ProcessorPlan)commandPlan.clone(), copyReferences, clonedIntoGroup);
+ ExecSqlInstruction clone = new ExecSqlInstruction((ProcessorPlan)commandPlan.clone(), clonedIntoGroup);
return clone;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -24,23 +24,18 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.processor.program.Program;
import com.metamatrix.query.processor.program.ProgramEnvironment;
import com.metamatrix.query.processor.program.ProgramInstruction;
import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
import com.metamatrix.query.util.LogConstants;
/**
@@ -85,44 +80,22 @@
this(condition, ifProgram, null);
}
- /**
- * <p> Evaluate the criteria that determines which block will be executed. This method uses the
- * CriteriaEvaluator used in the processor framework, variables and their values from the
- * variable context are used to construct a map of variable -> Index and a list of the values,
- * this is the format expected by the CriteriaEvaluator.</p>
- * @param condition The <code>Criteria</code> to evaluate.
- * @return boolean indicating what the criteria evaluated to
- * @throws MetaMatrixComponentException if there is an error trying to evaluate the criteria.
- */
- static boolean evaluateCriteria(Criteria condition, ProcedureEnvironment env) throws BlockedException, MetaMatrixComponentException {
- try {
- return new Evaluator(Collections.emptyMap(), env.getDataManager(), env.getContext()).evaluate(condition, Collections.EMPTY_LIST);
- } catch(CriteriaEvaluationException e) {
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0020));
- }
- }
-
/**
* This instruction will evaluate it's criteria, if it evaluates
* to true, it will push the corresponding sub Program on to the top of the
* program stack, and break from the loop. Regardless if whether any criteria
* evaluate to true, this instruction will increment the program counter of the
* current program.
+ * @throws MetaMatrixProcessingException
* @see ProgramInstruction#process(ProgramEnvironment)
*/
public void process(ProgramEnvironment env)
- throws BlockedException, MetaMatrixComponentException {
+ throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
ProcedureEnvironment procEnv = (ProcedureEnvironment) env;
- // create a new variable context and set the current
- // context to be the parent context
- procEnv.getCurrentVariableContext();
+ boolean evalValue = procEnv.evaluateCriteria(condition);
- // get the current variable context
- CommandInstruction.setReferenceValues(procEnv.getCurrentVariableContext(), ReferenceCollectorVisitor.getReferences(condition));
- boolean evalValue = evaluateCriteria(condition, procEnv);
-
if(evalValue) {
LogManager.logTrace(LogConstants.CTX_QUERY_PLANNER, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
" The criteria on the if block evaluated to true, processing the if block"}); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -49,8 +49,8 @@
//cursor columns
private List elements;
- public LoopInstruction(Program loopProgram, String rsName, ProcessorPlan plan, Collection atomicCommandReferences) {
- super(rsName, plan, atomicCommandReferences);
+ public LoopInstruction(Program loopProgram, String rsName, ProcessorPlan plan) {
+ super(rsName, plan);
this.loopProgram = loopProgram;
}
@@ -83,8 +83,7 @@
*/
public Object clone(){
ProcessorPlan clonedPlan = (ProcessorPlan) this.plan.clone();
- List copyRefs = cloneReferences();
- return new LoopInstruction((Program)this.loopProgram.clone(), this.rsName, clonedPlan, copyRefs);
+ return new LoopInstruction((Program)this.loopProgram.clone(), this.rsName, clonedPlan);
}
public String toString() {
@@ -113,10 +112,6 @@
* @see com.metamatrix.query.processor.proc.RepeatedInstruction#testCondition(com.metamatrix.query.processor.proc.ProcedureEnvironment)
*/
public boolean testCondition(ProcedureEnvironment procEnv) throws MetaMatrixComponentException, MetaMatrixProcessingException {
-
- VariableContext varContext = procEnv.getCurrentVariableContext();
- setReferenceValues(varContext);
-
if(!procEnv.resultSetExists(rsName)) {
procEnv.executePlan(plan, rsName);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedureEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedureEnvironment.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedureEnvironment.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -23,6 +23,7 @@
package com.metamatrix.query.processor.proc;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -33,8 +34,10 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.buffer.TupleSourceID;
+import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.processor.NullTupleSource;
import com.metamatrix.query.processor.ProcessorDataManager;
@@ -43,7 +46,9 @@
import com.metamatrix.query.processor.program.ProgramEnvironment;
import com.metamatrix.query.processor.program.ProgramInstruction;
import com.metamatrix.query.sql.ProcedureReservedWords;
+import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.tempdata.TempTableStore;
import com.metamatrix.query.util.CommandContext;
@@ -83,7 +88,7 @@
*/
public ProcedureEnvironment() {
super();
- this.currentVarContext = new VariableContext();
+ this.currentVarContext = new VariableContext(true);
this.currentVarContext.setValue(ROWS_UPDATED, new Integer(NO_ROWS_UPDATED));
}
@@ -117,7 +122,7 @@
return this.currentVarContext;
}
- public void executePlan(Object command, String rsName)
+ public void executePlan(ProcessorPlan command, String rsName)
throws MetaMatrixComponentException, MetaMatrixProcessingException {
boolean isExecSQLInstruction = rsName.equals(ExecSqlInstruction.RS_NAME);
// Defect 14544: Close all non-final ExecSqlInstruction tuple sources before creating a new source.
@@ -126,7 +131,7 @@
removeResults(ExecSqlInstruction.RS_NAME);
}
- TupleSourceID tsID = this.plan.registerRequest(command);
+ TupleSourceID tsID = this.plan.registerRequest(command, this.currentVarContext);
TupleSource source = this.plan.getResults(tsID);
tupleSourceIDMap.put(rsName.toUpperCase(), tsID);
tupleSourceMap.put(rsName.toUpperCase(), source);
@@ -143,6 +148,9 @@
*/
public void pop() throws MetaMatrixComponentException {
super.pop();
+ if (this.currentVarContext.getParentContext() != null) {
+ this.currentVarContext = this.currentVarContext.getParentContext();
+ }
Set current = getTempContext();
Set tempTables = getLocalTempTables();
@@ -161,6 +169,10 @@
*/
public void push(Program program) {
super.push(program);
+ VariableContext context = new VariableContext(true);
+ context.setParentContext(this.currentVarContext);
+ this.currentVarContext = context;
+
Set current = getTempContext();
Set tempTables = getLocalTempTables();
@@ -272,10 +284,11 @@
}
public CommandContext getContext() {
- return this.plan.getContext();
+ CommandContext context = this.plan.getContext();
+ context.setVariableContext(currentVarContext);
+ return context;
}
-
/**
* @return
*/
@@ -338,4 +351,13 @@
public void setTempTableStore(TempTableStore tempTableStore) {
this.tempTableStore = tempTableStore;
}
+
+ boolean evaluateCriteria(Criteria condition) throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
+ return new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(condition, Collections.emptyList());
+ }
+
+ Object evaluateExpression(Expression expression) throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
+ return new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(expression, Collections.emptyList());
+ }
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -38,10 +38,8 @@
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -63,7 +61,6 @@
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
import com.metamatrix.query.util.LogConstants;
-import com.metamatrix.query.util.TypeRetrievalUtil;
/**
*/
public class ProcedurePlan extends BaseProcessorPlan {
@@ -141,30 +138,22 @@
* @param command Command to execute from node
* @return The <code>TupleSourceID</code> for the results
*/
- TupleSourceID registerRequest(Object command)
+ TupleSourceID registerRequest(ProcessorPlan subPlan, VariableContext currentVariableContext)
throws MetaMatrixComponentException {
- Assertion.assertTrue((command instanceof ProcessorPlan), QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0050, command.getClass()));
-
if(this.internalProcessor != null){
return this.internalResultID;
}
- // this is typically a query or an insert being executed from within the
- // procedure and is mostly a relational plan
- ProcessorPlan subPlan = (ProcessorPlan) command;
-
//this may not be the first time the plan is being run
subPlan.reset();
// Run query processor on command
- List schema = subPlan.getOutputElements();
CommandContext subContext = (CommandContext) getContext().clone();
+ subContext.setVariableContext(currentVariableContext);
subContext.setTempTableStore(env.getTempTableStore());
- this.internalResultID = this.bufferMgr.createTupleSource(schema, TypeRetrievalUtil.getTypeNames(schema), subContext.getConnectionID(), TupleSourceType.PROCESSOR);
- subContext.setTupleSourceID(internalResultID);
internalProcessor = new QueryProcessor(subPlan, subContext, this.bufferMgr, this.dataMgr);
-
+ this.internalResultID = this.internalProcessor.getResultsID();
return this.internalResultID;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -29,11 +29,11 @@
import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.query.processor.program.Program;
import com.metamatrix.query.processor.program.ProgramEnvironment;
import com.metamatrix.query.processor.program.ProgramInstruction;
import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
/**
*/
@@ -84,16 +84,12 @@
return this.whileProgram.getChildPlans();
}
-
/**
+ * @throws MetaMatrixProcessingException
* @see com.metamatrix.query.processor.proc.RepeatedInstruction#testCondition(com.metamatrix.query.processor.proc.ProcedureEnvironment)
*/
- public boolean testCondition(ProcedureEnvironment procEnv) throws MetaMatrixComponentException {
- // get the current variable context
- CommandInstruction.setReferenceValues(procEnv.getCurrentVariableContext(), ReferenceCollectorVisitor.getReferences(condition));
- boolean evalValue = IfInstruction.evaluateCriteria(condition, procEnv);
-
- return evalValue;
+ public boolean testCondition(ProcedureEnvironment procEnv) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ return procEnv.evaluateCriteria(condition);
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramEnvironment.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramEnvironment.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -25,7 +25,6 @@
import java.util.Stack;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.query.processor.ProcessorPlan;
/**
@@ -78,16 +77,6 @@
}
/**
- * <p>Execute a ProcessorPlan and return the tupelSourceID for the results.
- * The TupleSourceID could be used by differrent {@link ProgramInstruction}s that
- * use this environment to access results. The
- * @param command The command to execute which is a ProcessPlan
- * @param rsName The name of the result set, which can be used later to obtain the tuple source.
- */
- public abstract void executePlan(Object command, String rsName)
- throws MetaMatrixComponentException, MetaMatrixProcessingException;
-
- /**
* Remove the a data source from the environment.
* @param rsName The name of the result set.
* @throws MetaMatrixComponentException
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -154,8 +154,8 @@
}
if(isUpdate && !returnedRows) {
- List tuple = new ArrayList(1);
- tuple.add(new Integer(0));
+ List<Integer> tuple = new ArrayList<Integer>(1);
+ tuple.add(Integer.valueOf(0));
// Add tuple to current batch
addBatchRow(tuple);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -31,6 +31,8 @@
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.util.VariableContext;
+import com.metamatrix.query.util.CommandContext;
public class DependentProcedureAccessNode extends AccessNode {
@@ -87,6 +89,16 @@
criteriaProcessor.close();
}
}
+
+ @Override
+ public void open() throws MetaMatrixComponentException,
+ MetaMatrixProcessingException {
+ CommandContext context = (CommandContext)getContext().clone();
+ context.pushVariableContext(new VariableContext());
+ this.setContext(context);
+ DependentProcedureExecutionNode.shareVariableContext(this, context);
+ super.open();
+ }
/**
* @see com.metamatrix.query.processor.relational.AccessNode#prepareNextCommand(com.metamatrix.query.sql.lang.Command)
@@ -97,7 +109,11 @@
this.criteriaProcessor = new DependentProcedureCriteriaProcessor(this, (Criteria)inputCriteria.clone(), inputReferences, inputDefaults, new Evaluator(null, null, getContext()));
}
- return criteriaProcessor.prepareNextCommand();
+ if (criteriaProcessor.prepareNextCommand(this.getContext().getVariableContext())) {
+ return super.prepareNextCommand(atomicCommand);
+ }
+
+ return false;
}
@Override
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -35,9 +35,11 @@
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.IsNullCriteria;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.util.ValueIterator;
+import com.metamatrix.query.sql.util.VariableContext;
public class DependentProcedureCriteriaProcessor extends DependentCriteriaProcessor {
@@ -66,18 +68,18 @@
* @throws TupleSourceNotFoundException
* @see com.metamatrix.query.processor.relational.PlanExecutionNode#prepareNextCommand()
*/
- protected boolean prepareNextCommand() throws BlockedException,
+ protected boolean prepareNextCommand(VariableContext context) throws BlockedException,
MetaMatrixComponentException, MetaMatrixProcessingException {
if (this.critInProgress == null) {
critInProgress = prepareCriteria();
}
-
+
for (int j = 0; j < inputReferences.size(); j++) {
Reference ref = (Reference)inputReferences.get(j);
- ref.setData(null, null);
+ context.remove(ref.getExpression());
}
boolean validRow = true;
@@ -116,16 +118,17 @@
break;
}
- if (parameter.getTuple() != null) {
- Object existingValue = parameter.getTuple().get(0);
-
- if ((value != null && !value.equals(existingValue)) || (value == null && existingValue != null)) {
- validRow = false;
- break;
- }
+ ElementSymbol parameterSymbol = parameter.getExpression();
+ if (context.containsVariable(parameterSymbol)) {
+ Object existingValue = context.getValue(parameterSymbol);
+
+ if ((value != null && !value.equals(existingValue)) || (value == null && existingValue != null)) {
+ validRow = false;
+ break;
+ }
}
- parameter.setValue(value);
+ context.setValue(parameterSymbol, value);
}
critInProgress = null;
@@ -140,11 +143,9 @@
Reference ref = (Reference)inputReferences.get(j);
- if (defaultValue != null && ref.getTuple() == null) {
- ref.setValue(defaultValue);
+ if (defaultValue != null && !context.containsVariable(ref.getExpression())) {
+ context.setValue(ref.getExpression(), defaultValue);
}
-
- Assertion.isNotNull(ref.getTuple());
}
return true;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureExecutionNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureExecutionNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,7 +22,6 @@
package com.metamatrix.query.processor.relational;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -32,6 +31,7 @@
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.util.CommandContext;
public class DependentProcedureExecutionNode extends PlanExecutionNode {
@@ -67,8 +67,8 @@
*/
public Object clone() {
DependentProcedureExecutionNode copy = new DependentProcedureExecutionNode(getID(), (Criteria)inputCriteria.clone(),
- new ArrayList(inputReferences),
- new ArrayList(inputDefaults));
+ inputReferences,
+ inputDefaults);
copy(this, copy);
return copy;
}
@@ -100,7 +100,7 @@
this.criteriaProcessor = new DependentProcedureCriteriaProcessor(this, (Criteria)inputCriteria.clone(), inputReferences, inputDefaults, new Evaluator(null, null, getContext()));
}
- return criteriaProcessor.prepareNextCommand();
+ return criteriaProcessor.prepareNextCommand(this.getProcessorPlan().getContext().getVariableContext());
}
/**
@@ -116,5 +116,25 @@
public Criteria getInputCriteria() {
return this.inputCriteria;
}
+
+ @Override
+ public void open() throws MetaMatrixComponentException,
+ MetaMatrixProcessingException {
+ super.open();
+ shareVariableContext(this, this.getProcessorPlan().getContext());
+ }
+ public static void shareVariableContext(RelationalNode node, CommandContext context) {
+ // we need to look up through our parents and share this context
+ RelationalNode parent = node.getParent();
+ int projectCount = 0;
+ while (parent != null && projectCount < 2) {
+ parent.setContext(context);
+ if (parent instanceof ProjectNode) {
+ projectCount++;
+ }
+ parent = parent.getParent();
+ }
+ }
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProjectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProjectNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProjectNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,14 +22,13 @@
package com.metamatrix.query.processor.relational;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
/**
@@ -41,27 +40,16 @@
public class DependentProjectNode extends ProjectNode {
private SubqueryProcessorUtility subqueryProcessor;
+ private SymbolMap correlatedReferences;
/**
* @param nodeID
*/
- public DependentProjectNode(int nodeID) {
+ public DependentProjectNode(int nodeID, SymbolMap correlatedReferences) {
super(nodeID);
- this.subqueryProcessor = new SubqueryProcessorUtility();
+ this.correlatedReferences = correlatedReferences;
}
- public void setPlansAndValueProviders(List subqueryProcessorPlans, List valueIteratorProviders) {
- subqueryProcessor.setPlansAndValueProviders(subqueryProcessorPlans, valueIteratorProviders);
- }
-
- /**
- * Set List of References needing to be updated with each outer tuple
- * @param correlatedReferences List<Reference> correlated reference to outer query
- */
- public void setCorrelatedReferences(List correlatedReferences){
- subqueryProcessor.setCorrelatedReferences(correlatedReferences);
- }
-
public void reset() {
super.reset();
this.subqueryProcessor.reset();
@@ -74,8 +62,15 @@
throws MetaMatrixComponentException, MetaMatrixProcessingException {
super.open();
- this.subqueryProcessor.open(this.getContext(), this.getBatchSize(), this.getDataManager(), this.getBufferManager());
+ this.subqueryProcessor.open(this);
}
+
+ @Override
+ public void setSelectSymbols(List symbols) {
+ super.setSelectSymbols(symbols);
+ List valueList = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(this.getSelectSymbols());
+ this.subqueryProcessor = new SubqueryProcessorUtility(valueList, this.correlatedReferences);
+ }
/**
* Closes the subquery processor (which removes the temporary tuple
@@ -103,7 +98,7 @@
protected void prepareToProcessTuple(Map elementMap, List currentTuple)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
- this.subqueryProcessor.process(elementMap, currentTuple, this.getBufferManager(), this.getConnectionID());
+ this.subqueryProcessor.process(this, elementMap, currentTuple);
}
/**
@@ -112,27 +107,9 @@
* @see java.lang.Object#clone()
*/
public Object clone(){
- DependentProjectNode clonedNode = new DependentProjectNode(super.getID());
+ DependentProjectNode clonedNode = new DependentProjectNode(super.getID(), this.correlatedReferences);
super.copy(this, clonedNode);
- List processorPlans = this.subqueryProcessor.getSubqueryPlans();
-
- List clonedValueIteratorProviders = new ArrayList(processorPlans.size());
- ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(clonedNode.getSelectSymbols(), clonedValueIteratorProviders);
- List clonedProcessorPlans = new ArrayList(clonedValueIteratorProviders.size());
- for (int i=0; i<clonedValueIteratorProviders.size(); i++){
- ProcessorPlan aPlan = (ProcessorPlan)processorPlans.get(i);
- clonedProcessorPlans.add(aPlan.clone());
- }
- clonedNode.setPlansAndValueProviders(clonedProcessorPlans, clonedValueIteratorProviders);
-
- //Since Reference.clone() returns itself and not a true clone, this shallow clone is sufficient
- //to clone the Collection of References
- if (this.subqueryProcessor.getCorrelatedReferences() != null){
- List clonedReferences = new ArrayList(this.subqueryProcessor.getCorrelatedReferences());
- clonedNode.setCorrelatedReferences(clonedReferences);
- }
-
return clonedNode;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSelectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSelectNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentSelectNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,14 +22,14 @@
package com.metamatrix.query.processor.relational;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
/**
@@ -43,14 +43,15 @@
public class DependentSelectNode extends SelectNode {
private SubqueryProcessorUtility subqueryProcessor;
+ private SymbolMap correlatedReferences;
/**
* Constructor for DependentSelectNode.
* @param nodeID
*/
- public DependentSelectNode(int nodeID) {
+ public DependentSelectNode(int nodeID, SymbolMap correlatedReferences) {
super(nodeID);
- this.subqueryProcessor = new SubqueryProcessorUtility();
+ this.correlatedReferences = correlatedReferences;
}
/** for unit testing */
@@ -58,28 +59,6 @@
return this.subqueryProcessor;
}
- /**
- * Set the two Lists that map subquery ProcessorPlans to SubqueryContainer criteria
- * which hold the Commands represented by the ProcessorPlans. The objects at
- * each index of both lists are essentially "mapped" to each other, one to one.
- * At a given index, the ProcessorPlan in the one List will be processed and
- * "fill" the SubqueryContainer criteria (of the other List) so the SubqueryContainer criteria
- * can be evalutated later.
- * @param subqueryProcessorPlans List of ProcessorPlans
- * @param subqueryContainerCriteria List of SubqueryContainer criteria
- */
- public void setPlansAndCriteriaMapping(List subqueryProcessorPlans, List subqueryContainerCriteria) {
- subqueryProcessor.setPlansAndValueProviders(subqueryProcessorPlans, subqueryContainerCriteria);
- }
-
- /**
- * Set List of References needing to be updated with each outer tuple
- * @param correlatedReferences List<Reference> correlated reference to outer query
- */
- public void setCorrelatedReferences(List correlatedReferences){
- subqueryProcessor.setCorrelatedReferences(correlatedReferences);
- }
-
public void reset() {
super.reset();
this.subqueryProcessor.reset();
@@ -92,8 +71,15 @@
throws MetaMatrixComponentException, MetaMatrixProcessingException {
super.open();
- this.subqueryProcessor.open(this.getContext(), this.getBatchSize(), this.getDataManager(), this.getBufferManager());
+ this.subqueryProcessor.open(this);
}
+
+ @Override
+ public void setCriteria(Criteria criteria) {
+ super.setCriteria(criteria);
+ List valueList = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(this.getCriteria());
+ this.subqueryProcessor = new SubqueryProcessorUtility(valueList, this.correlatedReferences);
+ }
/**
* Closes the subquery processor (which removes the temporary tuple
@@ -121,7 +107,7 @@
protected void prepareToProcessTuple(Map elementMap, List currentTuple)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
- this.subqueryProcessor.process(elementMap, currentTuple, this.getBufferManager(), this.getConnectionID());
+ this.subqueryProcessor.process(this, elementMap, currentTuple);
}
/**
@@ -130,27 +116,8 @@
* @see java.lang.Object#clone()
*/
public Object clone(){
- DependentSelectNode clonedNode = new DependentSelectNode(super.getID());
+ DependentSelectNode clonedNode = new DependentSelectNode(super.getID(), this.correlatedReferences);
super.copy(this, clonedNode);
-
- List processorPlans = this.subqueryProcessor.getSubqueryPlans();
-
- List clonedValueIteratorProviders = new ArrayList(processorPlans.size());
- ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(clonedNode.getCriteria(), clonedValueIteratorProviders);
- List clonedProcessorPlans = new ArrayList(clonedValueIteratorProviders.size());
- for (int i=0; i<clonedValueIteratorProviders.size(); i++){
- ProcessorPlan aPlan = (ProcessorPlan)processorPlans.get(i);
- clonedProcessorPlans.add(aPlan.clone());
- }
- clonedNode.setPlansAndCriteriaMapping(clonedProcessorPlans, clonedValueIteratorProviders);
-
- //Since Reference.clone() returns itself and not a true clone, this shallow clone is sufficient
- //to clone the Collection of References
- if (this.subqueryProcessor.getCorrelatedReferences() != null){
- List clonedReferences = new ArrayList(this.subqueryProcessor.getCorrelatedReferences());
- clonedNode.setCorrelatedReferences(clonedReferences);
- }
-
return clonedNode;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -31,6 +31,7 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.util.CommandContext;
public class PlanExecutionNode extends RelationalNode {
@@ -65,8 +66,7 @@
// Initialize plan for execution
CommandContext subContext = (CommandContext) getContext().clone();
- subContext.setOutputBatchSize(getBatchSize());
-
+ subContext.pushVariableContext(new VariableContext());
plan.initialize(subContext, getDataManager(), this.getBufferManager());
if (prepareNextCommand()) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -36,6 +36,7 @@
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -288,7 +289,11 @@
protected void copy(ProjectNode source, ProjectNode target){
super.copy(source, target);
if(selectSymbols != null){
- target.selectSymbols = new ArrayList(source.selectSymbols);
+ List clonedSymbols = new ArrayList(source.selectSymbols.size());
+ for (LanguageObject obj : (List<LanguageObject>)this.selectSymbols) {
+ clonedSymbols.add(obj.clone());
+ }
+ target.setSelectSymbols(clonedSymbols);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -81,6 +81,10 @@
public RelationalNode(int nodeID) {
this.nodeID = nodeID;
}
+
+ public void setContext(CommandContext context) {
+ this.context = context;
+ }
public void initialize(CommandContext context, BufferManager bufferManager, ProcessorDataManager dataMgr) {
this.context = context;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -171,7 +171,7 @@
protected void copy(SelectNode source, SelectNode target){
super.copy(source, target);
if(criteria != null){
- target.criteria = (Criteria)source.criteria.clone();
+ target.setCriteria((Criteria)source.criteria.clone());
}
if(elementMap != null){
target.elementMap = new HashMap(source.elementMap);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryProcessorUtility.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryProcessorUtility.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryProcessorUtility.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -23,7 +23,6 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -32,20 +31,20 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceStatus;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.symbol.Reference;
+import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.sql.lang.SubqueryContainer;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.util.ValueIterator;
import com.metamatrix.query.sql.util.ValueIteratorProvider;
+import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
-import com.metamatrix.query.util.TypeRetrievalUtil;
/**
* <p>This utility handles the work of processing a subquery; certain types
@@ -68,69 +67,48 @@
* and provides the ValueIteratorProvider instance with a ValueIterator
* instance, which iterates over the subquery results.</p>
*/
-class SubqueryProcessorUtility {
-
+public class SubqueryProcessorUtility {
+
/**
* List of ProcessorPlans for each subquery. Contents match
* 1-for-1 with the contents of {@link #valueIteratorProviders} List
* see {@link #setPlansAndValueProviders}
*/
- private List processorPlans;
+ private List<ProcessorPlan> processorPlans = new ArrayList<ProcessorPlan>();
+ private List<QueryProcessor> processors = new ArrayList<QueryProcessor>();
/**
* List of ValueIteratorProvider for each subquery. Contents match
* 1-for-1 with the contents of {@link #processorPlans} List
* see {@link #setPlansAndValueProviders}
*/
- private List valueIteratorProviders;
+ private List<ValueIteratorProvider> valueIteratorProviders;
- /**
- * List<Reference> to set data on
- */
- private List correlatedReferences;
+ private SymbolMap correlatedReferences;
// "Placeholder" state, for resuming processing after
// a BlockedException - not cloned
private int currentIndex = 0;
- private ProcessorPlan currentPlan;
- private TupleSourceID currentID;
+ private QueryProcessor currentProcessor;
// List <TupleSourceID> - same index-matchup as other two Lists
// Need to clean up on close()
- private List tupleSources = new ArrayList();
+ private List<TupleSourceID> tupleSources = new ArrayList<TupleSourceID>();
+
+ private VariableContext currentContext;
- /**
- * Constructor
- */
- SubqueryProcessorUtility() {
+ public SubqueryProcessorUtility(List<ValueIteratorProvider> valList, SymbolMap references) {
+ for (ValueIteratorProvider val : valList) {
+ SubqueryContainer sc = (SubqueryContainer)val;
+ this.processorPlans.add((ProcessorPlan)sc.getCommand().getProcessorPlan().clone());
+ }
+ this.valueIteratorProviders = valList;
+ if (references != null && !references.asMap().isEmpty()) {
+ this.correlatedReferences = references;
+ }
}
- /**
- * Set the two Lists that map subquery ProcessorPlans to ValueIteratorProviders
- * which hold the Commands represented by the ProcessorPlans. The objects at
- * each index of both lists are essentially "mapped" to each other, one to one.
- * At a given index, the ProcessorPlan in the one List will be processed and
- * "fill" the ValueIteratorProvider (of the other List) so the ValueIteratorProvider
- * can be evalutated later.
- * @param subqueryProcessorPlans List of ProcessorPlans
- * @param valueIteratorProviders List of ValueIteratorProviders
- */
- void setPlansAndValueProviders(List subqueryProcessorPlans, List valueIteratorProviders) {
- this.processorPlans = subqueryProcessorPlans;
- this.valueIteratorProviders = valueIteratorProviders;
- }
-
- /**
- * Set List of References needing to be updated with each outer tuple
- * @param correlatedReferences List<Reference> correlated reference to outer query
- */
- void setCorrelatedReferences(List correlatedReferences){
- if (correlatedReferences != null && correlatedReferences.size() > 0) {
- this.correlatedReferences = correlatedReferences;
- }
- }
-
- List getSubqueryPlans(){
+ List<ProcessorPlan> getSubqueryPlans(){
return this.processorPlans;
}
@@ -138,36 +116,27 @@
return this.valueIteratorProviders;
}
- List getCorrelatedReferences(){
- return this.correlatedReferences;
- }
-
void reset() {
this.currentIndex = 0;
- currentPlan = null;
- currentID = null;
-
+ currentProcessor = null;
// Reset internal plans
for(int i=0; i<processorPlans.size(); i++) {
- ProcessorPlan plan = (ProcessorPlan) processorPlans.get(i);
+ ProcessorPlan plan = processorPlans.get(i);
plan.reset();
}
}
/**
* initializes each subquery ProcessorPlan
+ * @throws MetaMatrixComponentException
*/
- void open(CommandContext processorContext,
- int batchSize,
- ProcessorDataManager dataManager,
- BufferManager bufferManager) {
+ void open(RelationalNode parent) throws MetaMatrixComponentException {
// Open subquery processor plans
- Iterator plans = this.processorPlans.iterator();
- while (plans.hasNext()) {
- ProcessorPlan plan = (ProcessorPlan) plans.next();
- CommandContext subContext = (CommandContext) processorContext.clone();
- subContext.setOutputBatchSize(batchSize);
- plan.initialize(subContext, dataManager, bufferManager);
+ for (ProcessorPlan plan : this.processorPlans) {
+ CommandContext subContext = (CommandContext) parent.getContext().clone();
+ QueryProcessor processor = new QueryProcessor(plan, subContext, parent.getBufferManager(), parent.getDataManager());
+ this.processors.add(processor);
+ this.tupleSources.add(processor.getResultsID());
}
}
@@ -177,17 +146,22 @@
void close(BufferManager bufferManager)
throws MetaMatrixComponentException {
- Iterator i = this.tupleSources.iterator();
- while (i.hasNext()){
- TupleSourceID tsID = (TupleSourceID)i.next();
+ for (QueryProcessor processor : this.processors) {
try {
+ processor.closeProcessing();
+ } catch (TupleSourceNotFoundException e) {
+ }
+ }
+ this.processors.clear();
+
+ for (TupleSourceID tsID : this.tupleSources) {
+ try {
bufferManager.removeTupleSource(tsID);
} catch (TupleSourceNotFoundException e) {
//ignore
}
}
- //Clear this list, just in case this obj is ever closed and then re-opened
this.tupleSources.clear();
}
@@ -213,64 +187,50 @@
* @throws MetaMatrixComponentException for unexpected exception
* @throws MetaMatrixProcessingException for exception due to user input or modeling
*/
- void process(Map elementMap, List currentTuple, BufferManager bufferManager, String groupName)
+ void process(RelationalNode parent, Map elementMap, List currentTuple)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
// This IF block is only intended to be run when the outer query tuple has changed,
// so it should not be run when this instance is resuming processing after a BlockedException
- if (this.currentPlan == null && this.correlatedReferences != null){
+ if (this.currentContext == null && this.currentProcessor == null && this.correlatedReferences != null){
// Close old tuple sources
- this.close(bufferManager);
- Iterator refs = this.correlatedReferences.iterator();
- while (refs.hasNext()) {
- Reference ref = (Reference)refs.next();
- ref.setData(elementMap, currentTuple);
- }
+ this.close(parent.getBufferManager());
+ this.open(parent);
+ this.currentContext = new VariableContext();
+ for (Map.Entry<ElementSymbol, Expression> entry : this.correlatedReferences.asMap().entrySet()) {
+ this.currentContext.setValue(entry.getKey(), new Evaluator(elementMap, parent.getDataManager(), parent.getContext()).evaluate(entry.getValue(), currentTuple));
+ }
}
-
- while (this.currentPlan != null || this.currentIndex < this.processorPlans.size()){
+
+ while (this.currentProcessor != null || this.currentIndex < this.processorPlans.size()){
//Initialize current ProcessorPlan tuple source, if necessary
- if (this.currentPlan == null){
- this.currentPlan = (ProcessorPlan)this.processorPlans.get(this.currentIndex);
-
- // Run query processor on command
- List schema = this.currentPlan.getOutputElements();
- this.currentID = bufferManager.createTupleSource(schema, TypeRetrievalUtil.getTypeNames(schema), groupName, TupleSourceType.PROCESSOR);
- this.tupleSources.add(this.currentID);
-
- // Open plan
- this.currentPlan.open();
+ if (this.currentProcessor == null){
+ this.currentProcessor = this.processors.get(currentIndex);
+ if (this.currentContext != null) {
+ this.currentProcessor.getContext().pushVariableContext(this.currentContext);
+ }
}
// Process the results
IndexedTupleSource subqueryResults = null;
- while(true) {
-
- TupleBatch batch = this.currentPlan.nextBatch(); // Might throw BlockedException.
- flushBatch(bufferManager, batch, this.currentID);
-
- // Check if this was the last batch
- if(batch.getTerminationFlag() == true) {
- this.currentPlan.close();
- this.currentPlan.reset();
- try {
- bufferManager.setStatus(this.currentID, TupleSourceStatus.FULL);
- subqueryResults = bufferManager.getTupleSource(this.currentID);
- } catch (TupleSourceNotFoundException e) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0029, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0029, this.currentID));
- }
-
- break;
- }
+ try {
+ this.currentProcessor.process(Integer.MAX_VALUE);
+ subqueryResults = parent.getBufferManager().getTupleSource(this.currentProcessor.getResultsID());
+ this.currentProcessor.getProcessorPlan().reset();
+ } catch (MetaMatrixProcessingException e) {
+ throw e;
+ } catch (MetaMatrixComponentException e) {
+ throw e;
+ } catch (MetaMatrixCoreException e) {
+ throw new MetaMatrixComponentException(e);
}
// Set the results on the ValueIteratorProviders
- ValueIteratorProvider vip = (ValueIteratorProvider)this.valueIteratorProviders.get(this.currentIndex);
+ ValueIteratorProvider vip = this.valueIteratorProviders.get(this.currentIndex);
ValueIterator iterator = new TupleSourceValueIterator(subqueryResults, 0);
vip.setValueIterator(iterator);
- this.currentID = null;
- this.currentPlan = null;
+ this.currentProcessor = null;
this.currentIndex++;
}
@@ -279,26 +239,8 @@
// If we've made it this far, then the next time
// this method is called, it should be for a new outer tuple
currentIndex = 0;
- }
+ }
+ this.currentContext = null;
}
-
-
- // ========================================================================
- // PRIVATE UTILITY
- // ========================================================================
-
- /**
- * Flush the batch by giving it to the buffer manager.
- */
- private static void flushBatch(BufferManager bufferManager, TupleBatch batch, TupleSourceID tsID)
- throws MetaMatrixComponentException{
- if(batch != null && batch.getRowCount() > 0) {
- try {
- bufferManager.addTupleBatch(tsID, batch);
- } catch (TupleSourceNotFoundException e) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0029, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0029, tsID));
- }
- }
- }
-
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,8 +22,6 @@
package com.metamatrix.query.processor.xml;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -33,9 +31,7 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.query.execution.QueryExecPlugin;
@@ -44,12 +40,11 @@
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.QueryProcessor;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Reference;
+import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
import com.metamatrix.query.util.LogConstants;
-import com.metamatrix.query.util.TypeRetrievalUtil;
/**
@@ -61,7 +56,6 @@
class RelationalPlanExecutor implements PlanExecutor {
QueryProcessor internalProcessor;
- TupleSourceID internalResultID;
// information about the result set.
ResultSetInfo resultInfo;
@@ -82,12 +76,8 @@
this.bufferMgr = bufferMgr;
ProcessorPlan plan = (ProcessorPlan)resultInfo.getPlan();
- List schema = plan.getOutputElements();
CommandContext subContext = (CommandContext)context.clone();
-
- this.internalResultID = bufferMgr.createTupleSource(schema, TypeRetrievalUtil.getTypeNames(schema), subContext.getConnectionID(), TupleSourceType.PROCESSOR);
- subContext.setTupleSourceID(internalResultID);
- subContext.setProcessorID(subContext.getProcessorID());
+ subContext.pushVariableContext(new VariableContext());
this.internalProcessor = new QueryProcessor(plan, subContext, bufferMgr, dataMgr);
}
@@ -123,28 +113,15 @@
if (this.resultInfo.hasReferences() && (referencesValues != null && !referencesValues.isEmpty()) ) {
for (final Iterator i = this.resultInfo.getReferences().iterator(); i.hasNext();) {
Reference ref = (Reference)i.next();
- Expression expr = ref.getExpression();
- if(expr instanceof ElementSymbol) {
- ElementSymbol element = (ElementSymbol) expr;
- if(referencesValues.containsKey(element)) {
- setReferenceValue(referencesValues.get(element), element, ref);
- }
- else {
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("unmapped_reference", element.getName())); //$NON-NLS-1$
- }
+ ElementSymbol expr = ref.getExpression();
+ if(!referencesValues.containsKey(expr)) {
+ throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("unmapped_reference", expr.getName())); //$NON-NLS-1$
}
+ this.internalProcessor.getContext().getVariableContext().setValue(expr, referencesValues.get(expr));
}
}
}
- static void setReferenceValue(Object value, ElementSymbol element, Reference ref) {
- Map elmntMap = new HashMap();
- elmntMap.put(element, new Integer(0));
- List tuple = new ArrayList(1);
- tuple.add(value);
- ref.setData(elmntMap, tuple);
- }
-
/**
* Get the next row from the result set
* @return
@@ -153,7 +130,7 @@
public List nextRow() throws MetaMatrixComponentException, MetaMatrixProcessingException {
if (this.tupleSource == null) {
try {
- this.tupleSource = this.bufferMgr.getTupleSource(this.internalResultID);
+ this.tupleSource = this.bufferMgr.getTupleSource(this.internalProcessor.getResultsID());
} catch (TupleSourceNotFoundException e) {
throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("tuple_not_found", this.resultInfo.getResultSetName())); //$NON-NLS-1$
}
@@ -199,22 +176,12 @@
* Close the executor and release all the resources.
*/
public void close() throws MetaMatrixComponentException {
- removeTupleSource(this.resultInfo.getResultSetName(), this.internalResultID);
- }
-
- /**
- * Remove a tuple source when it is done with it.
- */
- void removeTupleSource(String rsName, TupleSourceID tupleSourceID)
- throws MetaMatrixComponentException {
try {
- this.bufferMgr.removeTupleSource(tupleSourceID);
+ this.bufferMgr.removeTupleSource(this.internalProcessor.getResultsID());
} catch (TupleSourceNotFoundException e) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0021, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0021, rsName));
- } catch (MetaMatrixComponentException e) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0022, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0022, rsName));
- }
- LogManager.logTrace(LogConstants.CTX_XML_PLAN, new Object[]{"removed tuple source", tupleSourceID, "for result set", rsName}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+ LogManager.logTrace(LogConstants.CTX_XML_PLAN, new Object[]{"removed tuple source", this.internalProcessor.getResultsID(), "for result set", this.internalProcessor.getResultsID()}); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -289,14 +289,8 @@
ResolverVisitor.resolveLanguageObject(expr, null, externalGroups, metadata);
Class paramType = param.getClassType();
- //if it is reference, set type for it
- if(expr instanceof Reference){
- Reference ref = (Reference)expr;
- if (ref.getExpression() == null){
- ref.setExpression(new Constant(null, paramType));
- }
- continue;
- }
+ ResolverUtil.setTypeIfReference(expr, paramType, storedProcedureCommand);
+
// Compare type of parameter expression against parameter type
// and add implicit conversion if necessary
Class exprType = expr.getType();
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -55,7 +55,6 @@
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.util.ErrorMessageKeys;
/**
@@ -165,6 +164,10 @@
// Walk through both elements and expressions, which should match up
Expression expression = (Expression) valueIter.next();
ElementSymbol element = (ElementSymbol) varIter.next();
+
+ if (!usingQuery) {
+ ResolverUtil.setTypeIfReference(expression, element.getType(), insert);
+ }
if(element.getType() != null && expression.getType() != null) {
String elementTypeName = DataTypeManager.getDataTypeName(element.getType());
@@ -176,11 +179,6 @@
//TODO: a special case here is a projected literal
throw new QueryResolverException(QueryPlugin.Util.getString("InsertResolver.cant_convert_query_type", new Object[] {expression, expression.getType().getName(), element, element.getType().getName()})); //$NON-NLS-1$
}
- } else if(element.getType() != null && expression.getType() == null && expression instanceof Reference){
- Reference ref = (Reference)expression;
- //set the type of reference to be the same as variable
- ref.setExpression(new Constant(null, element.getType()));
- newValues.add(ref);
} else if (element.getType() == null && expression.getType() != null && !usingQuery) {
element.setType(expression.getType());
newValues.add(expression);
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -92,7 +92,7 @@
private static final String ALL_IN_GROUP_SUFFIX = ".*"; //$NON-NLS-1$
private static Command resolveVirtualGroup(GroupSymbol virtualGroup, Command parentCommand, QueryMetadataInterface metadata, AnalysisRecord analysis)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException, QueryParserException {
QueryNode qnode = null;
Object metadataID = virtualGroup.getMetadataID();
@@ -253,7 +253,7 @@
}
private static Command convertToSubquery(QueryNode qnode, boolean nocache, QueryMetadataInterface metadata)
- throws QueryResolverException, MetaMatrixComponentException {
+ throws QueryResolverException, MetaMatrixComponentException, QueryParserException {
// Parse this node's command
Command command = qnode.getCommand();
@@ -545,7 +545,7 @@
SPParameter clonedParam = (SPParameter)metadataParameter.clone();
if (clonedParam.getParameterType()==ParameterInfo.IN || metadataParameter.getParameterType()==ParameterInfo.INOUT) {
ElementSymbol paramSymbol = clonedParam.getParameterSymbol();
- Reference ref = new Reference(0, paramSymbol);
+ Reference ref = new Reference(paramSymbol);
clonedParam.setExpression(ref);
clonedParam.setIndex(paramIndex++);
storedProcedureCommand.setParameter(clonedParam);
@@ -605,7 +605,9 @@
throw new MetaMatrixRuntimeException(e);
} catch(MetaMatrixComponentException e) {
throw new MetaMatrixRuntimeException(e);
- }
+ } catch (QueryParserException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
}
public void visit(OrderBy obj) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -65,7 +65,7 @@
Update update = (Update) command;
// Resolve elements and functions
- Set groups = new HashSet();
+ Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
groups.add(update.getGroup());
ResolverVisitor.resolveLanguageObject(update, groups, update.getExternalGroupContexts(), metadata);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -148,19 +148,18 @@
// Parse and resolve ref
Expression expr = QueryParser.getQueryParser().parseExpression(binding);
- if(expr instanceof ElementSymbol) {
- ElementSymbol element = (ElementSymbol) expr;
-
- GroupSymbol groupSymbol = new GroupSymbol(metadata.getGroupName(element.getName()));
- ResolverVisitorUtil.resolveGroup(groupSymbol, metadata);
-
- ResolverVisitor.resolveLanguageObject(element, Arrays.asList(groupSymbol), metadata);
-
- } else if(expr instanceof Function) {
+ if(!(expr instanceof ElementSymbol)) {
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0025, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0025, expr));
}
+
+ ElementSymbol element = (ElementSymbol) expr;
- reference.setExpression(expr);
+ GroupSymbol groupSymbol = new GroupSymbol(metadata.getGroupName(element.getName()));
+ ResolverVisitorUtil.resolveGroup(groupSymbol, metadata);
+
+ ResolverVisitor.resolveLanguageObject(element, Arrays.asList(groupSymbol), metadata);
+
+ reference.setExpression(element);
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -230,13 +230,12 @@
* @param targetType the target type, if the expression's type is null.
* @throws QueryResolverException if unable to set the reference type to the target type.
*/
- public static void setTypeIfReference(Expression expression, Class targetType, LanguageObject surroundingExpression) throws QueryResolverException {
- if ((expression instanceof Reference) && expression.getType() == null) {
+ public static void setTypeIfReference(Expression expression, Class<?> targetType, LanguageObject surroundingExpression) throws QueryResolverException {
+ if ((expression instanceof Reference) && ((Reference)expression).isPositional()) {
if (targetType == null) {
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0026, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0026, surroundingExpression));
}
- Constant dummy = new Constant(null, targetType);
- ((Reference)expression).setExpression(dummy);
+ ((Reference)expression).setType(targetType);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -477,7 +477,7 @@
*/
private static void rewriteSubqueryContainer(SubqueryContainer container, Command procCommand,
CommandContext context, QueryMetadataInterface metadata) throws QueryValidatorException {
- if (container.getCommand() != null && metadata != null) {
+ if (container.getCommand() != null && container.getCommand().getProcessorPlan() == null && metadata != null) {
container.setCommand(rewriteCommand(container.getCommand(), procCommand, metadata, context));
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -23,7 +23,6 @@
package com.metamatrix.query.sql.lang;
import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.ValueIterator;
import com.metamatrix.query.sql.util.ValueIteratorProvider;
/**
@@ -79,33 +78,7 @@
negated = negationFlag;
}
- /**
- * <p>Returns a ValueIterator over the Collection of values that the
- * Criteria tests the Expression for inclusion in. This
- * method allows implementors leeway in how the Collection
- * of values of this Criteria are stored.</p>
- * <p>Subclasses must take care that a ValueIterator returned from
- * this method is always {@link ValueIterator#reset reset} to the
- * beginning of the iteration.</p>
- * <p>Also note that no guarantee is made as to whether or not the
- * same ValueIterator instance is returned by multiple calls to
- * this method, or if a new ValueIterator instance is returned.
- * Clients must be aware that the same instance might be returned
- * multiple times, and modifying the state of one will affect anything
- * else using that reference.</p>
- * @return ValueIterator over the Collection of values that the
- * left Expression is tested for inclusion in
- */
- public abstract ValueIterator getValueIterator();
-
/**
- * Sets the ValueIterator instance on this object. Subclasses may
- * choose to implement with a no-op method.
- * @see com.metamatrix.query.sql.util.ValueIteratorProvider#setValueIterator(com.metamatrix.query.sql.util.ValueIterator)
- */
- public abstract void setValueIterator(ValueIterator valueIterator);
-
- /**
* Deep copy of object
* @return Deep copy of object
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -27,6 +27,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.GroupSymbol;
@@ -123,6 +124,8 @@
/** The option clause */
private Option option;
+
+ private ProcessorPlan plan;
/**
* Return type of command to make it easier to build switch statements by command type.
@@ -218,6 +221,7 @@
}
copy.setIsResolved(this.isResolved());
+ copy.plan = this.plan;
}
/**
@@ -351,6 +355,14 @@
this.variableValues = parameters;
}
+ public ProcessorPlan getProcessorPlan() {
+ return this.plan;
+ }
+
+ public void setProcessorPlan(ProcessorPlan plan) {
+ this.plan = plan;
+ }
+
/**
* Returns a string representation of an instance of this class.
* @return String representation of object
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/StoredProcedure.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/StoredProcedure.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/StoredProcedure.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -35,9 +35,7 @@
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
import com.metamatrix.query.util.ErrorMessageKeys;
@@ -221,9 +219,9 @@
}
copy.callableName = callableName;
- List params = getParameters();
+ List<SPParameter> params = getParameters();
for(int i=0; i<params.size(); i++) {
- copy.setParameter((SPParameter)params.get(i));
+ copy.setParameter((SPParameter)params.get(i).clone());
}
copy.resultSetParameterKey = resultSetParameterKey;
this.copyMetadataState(copy);
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,38 +22,27 @@
package com.metamatrix.query.sql.symbol;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.eval.LookupEvaluator;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.util.CommandContext;
/**
- * This class represents a reference within a SQL statement to some other
- * source of data. This reference may resolve to many different values
+ * This class represents a reference (positional from the user query, or
+ * to an element from another scope). This reference may resolve to many different values
* during evaluation. For any particular bound value, it is treated as a constant.
*/
public class Reference implements Expression {
- private int refIndex;
- private Expression expression;
- //set true for correlated references only when determining if the subquery can be pushed down
- private boolean correlated;
private boolean positional;
- transient private Map elements; // Elements needed for evaluation, may be null
- transient private List tuple; // Current data values for elements
+ private int refIndex;
+ private Class<?> type;
+
+ private ElementSymbol expression;
/**
- * Constructor for Reference.
+ * Constructor for a positional Reference.
*/
public Reference(int refIndex) {
this.refIndex = refIndex;
@@ -61,62 +50,44 @@
}
/**
- * Constructor for Reference.
+ * Constructor for an element Reference.
*/
- public Reference(int refIndex, Expression expression) {
- this.refIndex = refIndex;
+ public Reference(ElementSymbol expression) {
this.expression = expression;
this.positional = false;
- }
+ }
+
+ private Reference(Reference ref) {
+ this.refIndex = ref.refIndex;
+ this.positional = ref.positional;
+ this.type = ref.type;
+ if (ref.expression != null) {
+ this.expression = (ElementSymbol)ref.expression.clone();
+ }
+ }
public boolean isResolved() {
- return (expression != null);
+ return (expression != null || this.type != null);
}
public int getIndex() {
return this.refIndex;
}
- public void setExpression(Expression expression) {
- this.expression = expression;
- }
-
- public Expression getExpression() {
+ public ElementSymbol getExpression() {
+ if (this.isPositional() && this.expression == null) {
+ return new ElementSymbol("$param.pos" + this.refIndex); //$NON-NLS-1$
+ }
return this.expression;
}
- public Class getType() {
- if(expression == null) {
- return null;
- }
- return expression.getType();
+ public Class<?> getType() {
+ if (this.isPositional()) {
+ return type;
+ }
+ return expression.getType();
}
- /**
- * Set value provider for this reference
- * @param provider Provider of values for this reference
- */
- public void setData(Map elements, List tuple) {
- this.elements = elements;
- this.tuple = tuple;
- }
-
- public Map getDataElements() {
- return this.elements;
- }
-
- public List getTuple() {
- return this.tuple;
- }
-
- public Object getValue(LookupEvaluator dataMgr, CommandContext context) throws ExpressionEvaluationException, MetaMatrixComponentException {
- if ( elements == null ) {
- elements = Collections.EMPTY_MAP;
- }
-
- return new Evaluator(elements, dataMgr, context).evaluate(expression, tuple);
- }
-
public void acceptVisitor(LanguageVisitor visitor) {
visitor.visit(this);
}
@@ -125,7 +96,7 @@
* @see java.lang.Object#clone()
*/
public Object clone() {
- return this;
+ return new Reference(this);
}
/**
@@ -155,12 +126,20 @@
return this.expression.equals(other.expression);
}
+ public void setType(Class<?> type) {
+ Assertion.assertTrue(this.positional);
+ this.type = type;
+ }
+
/**
* Define hash code to be that of the underlying object to make it stable.
* @return Hash code, based on value
*/
public int hashCode() {
- return getIndex();
+ if (this.isPositional()) {
+ return getIndex();
+ }
+ return this.expression.hashCode();
}
/**
@@ -172,32 +151,27 @@
}
public boolean isCorrelated() {
- return this.correlated;
+ if (this.isPositional()) {
+ return false;
+ }
+ //metadata hack
+ if (!(this.expression.getMetadataID() instanceof TempMetadataID)) {
+ return true;
+ }
+ TempMetadataID tid = (TempMetadataID)this.expression.getMetadataID();
+ return !tid.isScalarGroup();
}
-
- public void setCorrelated(boolean correlated) {
- this.correlated = correlated;
- }
- public void setValue(Object value) {
- HashMap symbolMap = new HashMap(1);
- symbolMap.put(this.getExpression(), new Integer(0));
-
- if (value instanceof Constant) {
- value = ((Constant)value).getValue();
- }
-
- this.setData(symbolMap, Arrays.asList(new Object[] {
- value
- }));
- }
-
public boolean isPositional() {
return this.positional;
}
+
+ /**
+ * Should never be called - used for an xml hack
+ * @param expression
+ */
+ public void setExpression(ElementSymbol expression) {
+ this.expression = expression;
+ }
- public void setPositional(boolean positional) {
- this.positional = positional;
- }
}
-
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -44,6 +44,21 @@
private LinkedHashMap<ElementSymbol, Expression> map = new LinkedHashMap<ElementSymbol, Expression>();
private Map<ElementSymbol, Expression> unmodifiableMap = Collections.unmodifiableMap(map);
+ public SymbolMap() {
+ }
+
+ public SymbolMap(SymbolMap other) {
+ //todo clone;
+ this.map.putAll(other.map);
+ }
+
+ public SymbolMap merge(SymbolMap other) {
+ if (other != null) {
+ this.map.putAll(other.map);
+ }
+ return this;
+ }
+
/**
* @return true if the map did not already contained the given symbol
*/
@@ -71,6 +86,10 @@
public Expression getMappedExpression(ElementSymbol symbol) {
return map.get(symbol);
}
+
+ public Map<ElementSymbol, Expression> asUpdatableMap() {
+ return this.map;
+ }
public Map<ElementSymbol, Expression> asMap() {
return unmodifiableMap;
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorProvider.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorProvider.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorProvider.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,6 +22,8 @@
package com.metamatrix.query.sql.util;
+import com.metamatrix.query.sql.LanguageObject;
+
/**
* <p>Language Object Implementors of this interface will provide a
* {@link ValueIterator} over one or potentially more values
@@ -31,7 +33,7 @@
* have their value iterators given to them by some external
* entity, so there is a setter method in this interface.</p>
*/
-public interface ValueIteratorProvider {
+public interface ValueIteratorProvider extends LanguageObject {
/**
* Get the {@link ValueIterator} from this ValueIterator provider
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -25,19 +25,8 @@
import java.util.HashMap;
import java.util.Map;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
-/**
- * <p>This class holds a map of variables to their values, these variables and
- * their values are held in the context of a {@link Block} in the procedure language,
- * differrent {@link Statement}s populate the map by declaring variables and
- * assigning values. This class holds reference to a parent <code>VariableContext</code>
- * that holds variable info for parent {@link Block}. The variable declared at
- * the parent level is available to its immediate child context and any children,
- * down the heirarchy.</p>
- */
public class VariableContext {
// map between variables and their values
@@ -45,22 +34,18 @@
// reference to the parent variable context
private VariableContext parentContext;
+ private boolean delegateSets;
/**
* Constructor for VariableContext.
*/
public VariableContext() {
- this.variableMap = new HashMap();
+ this(false);
}
-
- /**
- * Constructor for VariableContext.
- */
- public VariableContext(Map variableMap) {
- if(variableMap == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0019));
- }
- this.variableMap = variableMap;
+
+ public VariableContext(boolean delegateSets) {
+ this.delegateSets = delegateSets;
+ this.variableMap = new HashMap();
}
/**
@@ -70,7 +55,11 @@
* @param value The value to be set for the given variable.
*/
public void setValue(ElementSymbol variable, Object value) {
- variableMap.put(variable, value);
+ if (delegateSets && parentContext != null && parentContext.containsVariable(variable)) {
+ parentContext.setValue(variable, value);
+ } else {
+ variableMap.put(variable, value);
+ }
}
/**
@@ -149,4 +138,15 @@
}
return false;
}
+
+ public Object remove(ElementSymbol symbol) {
+ if (!this.variableMap.containsKey(symbol)) {
+ if (this.parentContext != null) {
+ return this.parentContext.remove(symbol);
+ }
+ return null;
+ }
+ return this.variableMap.remove(symbol);
+ }
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CorrelatedVariableSubstitutionVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CorrelatedVariableSubstitutionVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CorrelatedVariableSubstitutionVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -54,7 +54,7 @@
ElementSymbol variable = (ElementSymbol)expression;
if (variable.isExternalReference()) {
- return new Reference(0, variable);
+ return new Reference(variable);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -25,8 +25,6 @@
*/
package com.metamatrix.query.sql.visitor;
-import java.util.Iterator;
-
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.function.metadata.FunctionMethod;
import com.metamatrix.query.metadata.TempMetadataID;
@@ -63,9 +61,12 @@
public class EvaluatableVisitor extends LanguageVisitor {
protected boolean evaluationPossible = true;
+
+ //TODO: there aren't really 16 states here, this should be minimized
private boolean duringPlanning = false;
private boolean fullyEvaluatable = false;
private boolean deterministic = false;
+ private boolean pushdown = false;
public EvaluatableVisitor(boolean duringPlanning, boolean fullyEvaluatable) {
this.duringPlanning = duringPlanning;
@@ -117,19 +118,10 @@
}
public void visit(Reference obj) {
- if (duringPlanning) {
+ if (duringPlanning || fullyEvaluatable) {
evaluationNotPossible();
- } else if (fullyEvaluatable) {
- if (obj.getExpression() != null) {
- for (Iterator i = ReferenceCollectorVisitor.getReferences(obj.getExpression()).iterator(); i.hasNext();) {
- PreOrderNavigator.doVisit((Reference)i.next(), this); //follow reference
- }
- if (!ElementCollectorVisitor.getElements(obj.getExpression(), false).isEmpty() && obj.getTuple() == null) {
- evaluationNotPossible();
- }
- }
- } else if (obj.isCorrelated()) {
- evaluationNotPossible();
+ } else if (pushdown && obj.isCorrelated()) {
+ evaluationNotPossible();
}
}
@@ -161,9 +153,10 @@
return evaluationPossible;
}
- static final boolean isEvaluatable(LanguageObject obj, boolean duringPlanning, boolean fullyEvaluatable, boolean deterministic) {
+ static final boolean isEvaluatable(LanguageObject obj, boolean duringPlanning, boolean fullyEvaluatable, boolean deterministic, boolean pushdown) {
EvaluatableVisitor visitor = new EvaluatableVisitor(duringPlanning, fullyEvaluatable);
visitor.deterministic = deterministic;
+ visitor.pushdown = pushdown;
PreOrderNavigator.doVisit(obj, visitor);
return visitor.isEvaluationPossible();
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluateExpressionVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluateExpressionVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluateExpressionVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -151,17 +151,12 @@
* @return
*/
public Expression replaceExpression(Expression expr) {
- if(expr instanceof Reference) {
- Reference ref = (Reference) expr;
- if(!EvaluatableVisitor.isEvaluatable(expr, false, true, false)) {
- return ref.getExpression();
- }
- } else if(!ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(expr).isEmpty()) {
+ if(!ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(expr).isEmpty()) {
return expr;
}
//if the expression is a constant or is not evaluatable, just return
- if (expr instanceof Constant || !EvaluatableVisitor.isEvaluatable(expr, false, true, false)) {
+ if (expr instanceof Constant || (!(expr instanceof Reference) && !EvaluatableVisitor.isEvaluatable(expr, false, true, false, false))) {
return expr;
}
@@ -169,6 +164,9 @@
try {
value = new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(expr, Collections.emptyList());
} catch (MetaMatrixException err) {
+ if (expr instanceof Reference) {
+ return expr;
+ }
throw new MetaMatrixRuntimeException(err);
}
return new Constant(value, expr.getType());
@@ -179,14 +177,18 @@
* evaluatable during planning
*/
public static final boolean willBecomeConstant(LanguageObject obj) {
- return EvaluatableVisitor.isEvaluatable(obj, false, false, true);
+ return willBecomeConstant(obj, false);
}
+ public static final boolean willBecomeConstant(LanguageObject obj, boolean pushdown) {
+ return EvaluatableVisitor.isEvaluatable(obj, false, false, true, pushdown);
+ }
+
/**
* Should be called to check if the object can fully evaluated
*/
public static final boolean isFullyEvaluatable(LanguageObject obj, boolean duringPlanning) {
- return EvaluatableVisitor.isEvaluatable(obj, duringPlanning, true, true);
+ return EvaluatableVisitor.isEvaluatable(obj, duringPlanning, true, true, false);
}
public static final void replaceExpressions(LanguageObject obj, boolean deep, LookupEvaluator dataMgr, CommandContext context)
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/GroupCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/GroupCollectorVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/GroupCollectorVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -49,13 +49,13 @@
*/
public class GroupCollectorVisitor extends LanguageVisitor {
- private Collection groups;
+ private Collection<GroupSymbol> groups;
private boolean isIntoClauseGroup;
// In some cases, set a flag to ignore groups created by a subquery from clause
private boolean ignoreInlineViewGroups = false;
- private Collection inlineViewGroups; // groups defined by a SubqueryFromClause
+ private Collection<GroupSymbol> inlineViewGroups; // groups defined by a SubqueryFromClause
/**
* Construct a new visitor with the specified collection, which should
@@ -63,7 +63,7 @@
* @param groups Collection to use for groups
* @throws IllegalArgumentException If groups is null
*/
- public GroupCollectorVisitor(Collection groups) {
+ public GroupCollectorVisitor(Collection<GroupSymbol> groups) {
if(groups == null) {
throw new IllegalArgumentException(QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0023));
}
@@ -75,11 +75,11 @@
* after the visitor has been run on the language object tree.
* @return Collection of {@link com.metamatrix.query.sql.symbol.GroupSymbol}
*/
- public Collection getGroups() {
+ public Collection<GroupSymbol> getGroups() {
return this.groups;
}
- public Collection getInlineViewGroups() {
+ public Collection<GroupSymbol> getInlineViewGroups() {
return this.inlineViewGroups;
}
@@ -121,7 +121,7 @@
public void visit(SubqueryFromClause obj) {
if(this.ignoreInlineViewGroups) {
if(this.inlineViewGroups == null) {
- this.inlineViewGroups = new ArrayList();
+ this.inlineViewGroups = new ArrayList<GroupSymbol>();
}
this.inlineViewGroups.add(obj.getGroupSymbol());
}
@@ -132,7 +132,7 @@
* @param obj Language object
* @param elements Collection to collect groups in
*/
- public static void getGroups(LanguageObject obj, Collection groups) {
+ public static void getGroups(LanguageObject obj, Collection<GroupSymbol> groups) {
GroupCollectorVisitor visitor = new GroupCollectorVisitor(groups);
PreOrderNavigator.doVisit(obj, visitor);
}
@@ -145,12 +145,12 @@
* @param removeDuplicates True to remove duplicates
* @return Collection of {@link com.metamatrix.query.sql.symbol.GroupSymbol}
*/
- public static Collection getGroups(LanguageObject obj, boolean removeDuplicates) {
- Collection groups = null;
+ public static Collection<GroupSymbol> getGroups(LanguageObject obj, boolean removeDuplicates) {
+ Collection<GroupSymbol> groups = null;
if(removeDuplicates) {
- groups = new HashSet();
+ groups = new HashSet<GroupSymbol>();
} else {
- groups = new ArrayList();
+ groups = new ArrayList<GroupSymbol>();
}
GroupCollectorVisitor visitor = new GroupCollectorVisitor(groups);
PreOrderNavigator.doVisit(obj, visitor);
@@ -162,7 +162,7 @@
* @param obj Language object
* @param elements Collection to collect groups in
*/
- public static void getGroupsIgnoreInlineViews(LanguageObject obj, Collection groups) {
+ public static void getGroupsIgnoreInlineViews(LanguageObject obj, Collection<GroupSymbol> groups) {
GroupCollectorVisitor visitor = new GroupCollectorVisitor(groups);
visitor.setIgnoreInlineViewGroups(true);
DeepPreOrderNavigator.doVisit(obj, visitor);
@@ -180,12 +180,12 @@
* @param removeDuplicates True to remove duplicates
* @return Collection of {@link com.metamatrix.query.sql.symbol.GroupSymbol}
*/
- public static Collection getGroupsIgnoreInlineViews(LanguageObject obj, boolean removeDuplicates) {
- Collection groups = null;
+ public static Collection<GroupSymbol> getGroupsIgnoreInlineViews(LanguageObject obj, boolean removeDuplicates) {
+ Collection<GroupSymbol> groups = null;
if(removeDuplicates) {
- groups = new HashSet();
+ groups = new HashSet<GroupSymbol>();
} else {
- groups = new ArrayList();
+ groups = new ArrayList<GroupSymbol>();
}
GroupCollectorVisitor visitor = new GroupCollectorVisitor(groups);
visitor.setIgnoreInlineViewGroups(true);
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/NeedsEvaluationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/NeedsEvaluationVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/NeedsEvaluationVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -57,7 +57,7 @@
*/
@Override
public void visit(Function obj) {
- if (EvaluatableVisitor.isEvaluatable(obj, false, true, false)) {
+ if (EvaluatableVisitor.isEvaluatable(obj, false, true, false, false)) {
setNeedsEvaluation();
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ValueIteratorProviderCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ValueIteratorProviderCollectorVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ValueIteratorProviderCollectorVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,13 +22,17 @@
package com.metamatrix.query.sql.visitor;
-import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.*;
+import com.metamatrix.query.sql.lang.ExistsCriteria;
+import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
+import com.metamatrix.query.sql.lang.SubquerySetCriteria;
import com.metamatrix.query.sql.navigator.PreOrderNavigator;
import com.metamatrix.query.sql.symbol.ScalarSubquery;
@@ -45,7 +49,7 @@
*/
public class ValueIteratorProviderCollectorVisitor extends LanguageVisitor {
- private Collection valueIteratorProviders;
+ private List valueIteratorProviders;
/**
* Construct a new visitor with the default collection type, which is a
@@ -60,7 +64,7 @@
* ValueIteratorProvider instances
* @param valueIteratorProviders Collection to accumulate found
*/
- public ValueIteratorProviderCollectorVisitor(Collection valueIteratorProviders) {
+ ValueIteratorProviderCollectorVisitor(List valueIteratorProviders) {
this.valueIteratorProviders = valueIteratorProviders;
}
@@ -70,7 +74,7 @@
* @return Collection of {@link com.metamatrix.sql.util.ValueIteratorProvider}
* (by default, this is a java.util.ArrayList)
*/
- public Collection getValueIteratorProviders() {
+ public List getValueIteratorProviders() {
return this.valueIteratorProviders;
}
@@ -115,28 +119,25 @@
* @param obj Language object
* @return java.util.ArrayList of found ValueIteratorProvider
*/
- public static final Collection getValueIteratorProviders(LanguageObject obj) {
+ public static final List getValueIteratorProviders(LanguageObject obj) {
ValueIteratorProviderCollectorVisitor visitor = new ValueIteratorProviderCollectorVisitor();
PreOrderNavigator.doVisit(obj, visitor);
return visitor.getValueIteratorProviders();
}
- /**
- * Helper to quickly get the ValueIteratorProvider instances from obj
- * @param obj Language object
- * @param valueIteratorProviders Collection to collect ValueIteratorProviders in
- */
- public static final void getValueIteratorProviders(LanguageObject obj, Collection valueIteratorProviders) {
+ public static final void getValueIteratorProviders(LanguageObject obj, List valueIteratorProviders) {
ValueIteratorProviderCollectorVisitor visitor = new ValueIteratorProviderCollectorVisitor(valueIteratorProviders);
PreOrderNavigator.doVisit(obj, visitor);
}
- public static final void getValueIteratorProviders(Collection languageObjects, Collection valueIteratorProviders) {
- ValueIteratorProviderCollectorVisitor visitor = new ValueIteratorProviderCollectorVisitor(valueIteratorProviders);
+ public static final List getValueIteratorProviders(Collection<? extends LanguageObject> languageObjects) {
+ List result = new LinkedList();
+ ValueIteratorProviderCollectorVisitor visitor = new ValueIteratorProviderCollectorVisitor(result);
Iterator i = languageObjects.iterator();
while (i.hasNext()) {
LanguageObject obj = (LanguageObject)i.next();
PreOrderNavigator.doVisit(obj, visitor);
}
+ return result;
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -30,13 +30,13 @@
import java.util.TimeZone;
import com.metamatrix.api.exception.query.QueryProcessingException;
-import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.query.eval.SecurityFunctionEvaluator;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.optimizer.relational.PlanToProcessConverter;
import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.sql.util.VariableContext;
/**
* Defines the context that a command is processing in. For example, this defines
@@ -52,12 +52,6 @@
/** Identify a group of related commands, which typically get cleaned up together */
private String connectionID;
- /** Identify where the results of processing this command should be placed */
- private TupleSourceID tupleSourceID;
-
- /** Identify how the final result set should be batched. */
- private int outputBatchSize = 2000;
-
private int processorBatchSize = 2000;
private int connectorBatchSize = 2000;
@@ -100,17 +94,17 @@
private QueryProcessor.ProcessorFactory queryProcessorFactory;
+ private VariableContext variableContext;
+
/**
* Construct a new context.
* @param collectNodeStatistics TODO
*/
- public CommandContext(Object processorID, String connectionID, TupleSourceID tupleSourceID,
- int outputBatchSize, String userName, Serializable trustedPayload, Serializable commandPayload, String vdbName, String vdbVersion,
- Properties envProperties, boolean processDebug, boolean collectNodeStatistics) {
+ public CommandContext(Object processorID, String connectionID, String userName,
+ Serializable trustedPayload, Serializable commandPayload, String vdbName, String vdbVersion, Properties envProperties, boolean processDebug,
+ boolean collectNodeStatistics) {
setProcessorID(processorID);
setConnectionID(connectionID);
- setTupleSourceID(tupleSourceID);
- setOutputBatchSize(outputBatchSize);
setUserName(userName);
setTrustedPayload(trustedPayload);
setCommandPayload(commandPayload);
@@ -124,24 +118,20 @@
/**
* Construct a new context.
*/
- public CommandContext(Object processorID, String connectionID, TupleSourceID tupleSourceID,
- int outputBatchSize, String userName, Serializable trustedPayLoad, String vdbName, String vdbVersion) {
+ public CommandContext(Object processorID, String connectionID, int outputBatchSize,
+ String userName, Serializable trustedPayLoad, String vdbName, String vdbVersion) {
- this(processorID, connectionID, tupleSourceID, outputBatchSize, userName,
- trustedPayLoad, null, vdbName, vdbVersion, null, false, false);
+ this(processorID, connectionID, userName, trustedPayLoad, null,
+ vdbName, vdbVersion, null, false, false);
}
protected CommandContext(CommandContext context) {
setConnectionID(context.connectionID);
- setOutputBatchSize(context.outputBatchSize);
// Reuse existing processor ID - may be overridden
setProcessorID(context.processorID);
- // Can't reuse tuple source for different context
- setTupleSourceID(null);
-
setUserName(context.userName);
setTrustedPayload(context.trustedPayload);
setCommandPayload(context.commandPayload);
@@ -160,6 +150,7 @@
this.preparedBatchUpdateValues = context.preparedBatchUpdateValues;
this.planToProcessConverter = context.planToProcessConverter;
this.queryProcessorFactory = context.queryProcessorFactory;
+ this.variableContext = context.variableContext;
}
public CommandContext() {
@@ -168,24 +159,10 @@
/**
* @return
*/
- public int getOutputBatchSize() {
- return outputBatchSize;
- }
-
- /**
- * @return
- */
public Object getProcessorID() {
return processorID;
}
- /**
- * @return
- */
- public TupleSourceID getTupleSourceID() {
- return tupleSourceID;
- }
-
public boolean getProcessDebug() {
return this.processDebug;
}
@@ -193,12 +170,6 @@
public void setProcessDebug(boolean processDebug) {
this.processDebug = processDebug;
}
- /**
- * @param i
- */
- public void setOutputBatchSize(int i) {
- outputBatchSize = i;
- }
/**
* @param object
@@ -208,13 +179,6 @@
processorID = object;
}
- /**
- * @param sourceID
- */
- public void setTupleSourceID(TupleSourceID sourceID) {
- tupleSourceID = sourceID;
- }
-
public boolean equals(Object obj) {
if(this == obj) {
return true;
@@ -473,4 +437,17 @@
public void setQueryProcessorFactory(QueryProcessor.ProcessorFactory queryProcessorFactory) {
this.queryProcessorFactory = queryProcessorFactory;
}
+
+ public VariableContext getVariableContext() {
+ return variableContext;
+ }
+
+ public void setVariableContext(VariableContext variableContext) {
+ this.variableContext = variableContext;
+ }
+
+ public void pushVariableContext(VariableContext toPush) {
+ toPush.setParentContext(this.variableContext);
+ this.variableContext = toPush;
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -836,11 +836,7 @@
if(((Constant)value).isNull() && ! getMetadata().elementSupports(elementID.getMetadataID(), SupportConstants.Element.NULL)) {
handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0060, SQLStringVisitor.getSQLString(elementID)), elementID);
}// end of if
- } else if(value instanceof Reference) {
- if(value.getType() == null){
- ((Reference)value).setExpression(new Constant(null, elementID.getType()));
- }
- } else if (!EvaluateExpressionVisitor.willBecomeConstant(value)) {
+ } else if (!EvaluateExpressionVisitor.willBecomeConstant(value)) {
// If this is an update on a virtual group, verify that no elements are in the right side
GroupSymbol group = update.getGroup();
if(getMetadata().isVirtualGroup(group.getMetadataID())) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -46,6 +46,8 @@
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Reference;
+import com.metamatrix.query.sql.util.VariableContext;
+import com.metamatrix.query.util.CommandContext;
/**
* Specific request for handling prepared statement calls.
@@ -132,7 +134,7 @@
}
}
} else {
- PreparedStatementRequest.resolveParameterValues(params, values);
+ PreparedStatementRequest.resolveParameterValues(params, values, this.context);
}
}
@@ -193,22 +195,19 @@
* @param values
* @throws QueryResolverException
*/
- public static void resolveParameterValues(List params,
- List values) throws QueryResolverException, MetaMatrixComponentException {
+ public static void resolveParameterValues(List<Reference> params,
+ List values, CommandContext context) throws QueryResolverException, MetaMatrixComponentException {
+ VariableContext result = new VariableContext();
//the size of the values must be the same as that of the parameters
if (params.size() != values.size()) {
String msg = QueryPlugin.Util.getString("QueryUtil.wrong_number_of_values", new Object[] {new Integer(values.size()), new Integer(params.size())}); //$NON-NLS-1$
throw new QueryResolverException(msg);
}
- if (params.isEmpty()) {
- return;
- }
-
//the type must be the same, or the type of the value can be implicitly converted
//to that of the reference
for (int i = 0; i < params.size(); i++) {
- Reference param = (Reference) params.get(i);
+ Reference param = params.get(i);
Object value = values.get(i);
//TODO: why is the list check in here
@@ -225,12 +224,11 @@
throw new QueryResolverException(msg);
}
}
-
- // Create with expected type if null
- Constant constant = new Constant(value, param.getType());
-
+
//bind variable
- param.setExpression(constant);
+ result.setValue(param.getExpression(), value);
}
+
+ context.setVariableContext(result);
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -51,8 +51,6 @@
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.xa.XATransactionException;
@@ -101,7 +99,6 @@
import com.metamatrix.query.tempdata.TempTableStore;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ContextProperties;
-import com.metamatrix.query.util.TypeRetrievalUtil;
import com.metamatrix.query.validator.AbstractValidationVisitor;
import com.metamatrix.query.validator.ValidationVisitor;
import com.metamatrix.query.validator.Validator;
@@ -273,15 +270,13 @@
new CommandContext(
reqID,
groupName,
- null,
- requestMsg.getFetchSize(),
- workContext.getUserName(),
- workContext.getTrustedPayload(),
- requestMsg.getExecutionPayload(),
- workContext.getVdbName(),
+ workContext.getUserName(),
+ workContext.getTrustedPayload(),
+ requestMsg.getExecutionPayload(),
+ workContext.getVdbName(),
workContext.getVdbVersion(),
- props,
- useProcDebug(command),
+ props,
+ useProcDebug(command),
collectNodeStatistics(command));
this.context.setProcessorBatchSize(bufferManager.getProcessorBatchSize());
this.context.setConnectorBatchSize(bufferManager.getConnectorBatchSize());
@@ -477,12 +472,6 @@
}
this.transactionContext = tc;
- List outputElements = processPlan.getOutputElements();
- this.context.setTupleSourceID(this.bufferManager.createTupleSource(
- outputElements,
- TypeRetrievalUtil.getTypeNames(outputElements),
- this.workContext.getConnectionID(),
- TupleSourceType.FINAL));
this.processor = new QueryProcessor(processPlan, context, bufferManager, new TempTableDataManager(processorDataManager, tempTableStore));
}
@@ -658,9 +647,6 @@
QueryRewriter.rewrite(newCommand, null, metadata, copy);
ProcessorPlan plan = QueryOptimizer.optimizePlan(newCommand, metadata, idGenerator, capabilitiesFinder, analysisRecord, copy);
-
- TupleSourceID resultsId = bufferManager.createTupleSource(newCommand.getProjectedSymbols(), TypeRetrievalUtil.getTypeNames(newCommand.getProjectedSymbols()), copy.getConnectionID(), TupleSourceType.PROCESSOR);
- copy.setTupleSourceID(resultsId);
return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -388,7 +388,7 @@
sendResultsIfNeeded(batch);
}
});
- resultsID = request.context.getTupleSourceID();
+ resultsID = processor.getResultsID();
analysisRecord = request.analysisRecord;
schemas = request.schemas;
transactionContext = request.transactionContext;
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -1106,7 +1106,7 @@
public void testPushMatchCritWithReference() {
List bindings = new ArrayList();
- bindings.add("'%'"); //$NON-NLS-1$
+ bindings.add("pm1.g2.e1"); //$NON-NLS-1$
helpPlan("select e1 FROM pm1.g1 WHERE e1 LIKE ?", example1(), bindings, null, //$NON-NLS-1$
new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 LIKE ?" }, true ); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -690,5 +690,31 @@
0 // UnionAll
});
}
+
+ @Test public void testPushMultipleCorrelatedSubquery1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_WHERE, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_OR, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_COMPARISON, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_ALL, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan("SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey ) or intkey = (SELECT MIN(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey )", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT g_0.intkey FROM bqt1.smalla AS g_0 WHERE (g_0.intkey = (SELECT MAX(g_1.intkey) FROM bqt1.smallb AS g_1 WHERE g_1.stringkey = g_0.stringkey)) OR (g_0.intkey = (SELECT MIN(g_2.IntKey) FROM bqt1.smallb AS g_2 WHERE g_2.StringKey = g_0.stringkey))" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -48,7 +48,6 @@
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.XMLType;
@@ -83,6 +82,7 @@
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Reference;
+import com.metamatrix.query.sql.util.VariableContext;
import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -233,9 +233,7 @@
try {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), null, null, TupleSourceType.FINAL);
-
- CommandContext context = new CommandContext("0", "test", tsID, 5, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("0", "test", 5, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
processor.process();
fail("Expected error during processing, but got none."); //$NON-NLS-1$
@@ -251,16 +249,16 @@
BufferManagerImpl bufferMgr = (BufferManagerImpl)BufferManagerFactory.getStandaloneBufferManager();
bufferMgr.getConfig().setProcessorBatchSize(context.getProcessorBatchSize());
bufferMgr.getConfig().setConnectorBatchSize(context.getProcessorBatchSize());
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), null, "test", TupleSourceType.FINAL); //$NON-NLS-1$
- context.setTupleSourceID(tsID);
context.getNextRand(0);
+ TupleSourceID id = null;
try {
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
+ id = processor.getResultsID();
processor.process();
assertEquals(0, bufferMgr.getPinnedCount());
- examineResults(expectedResults, bufferMgr, tsID);
+ examineResults(expectedResults, bufferMgr, processor.getResultsID());
} finally {
- bufferMgr.removeTupleSource(tsID);
+ bufferMgr.removeTupleSource(id);
}
}
@@ -314,7 +312,7 @@
Properties props = new Properties();
props.setProperty("soap_host", "my.host.com"); //$NON-NLS-1$ //$NON-NLS-2$
props.setProperty("soap_port", "12345"); //$NON-NLS-1$ //$NON-NLS-2$
- CommandContext context = new CommandContext("0", "test", null, 5, "user", null, null, "myvdb", "1", props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ CommandContext context = new CommandContext("0", "test", "user", null, null, "myvdb", "1", props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
context.setProcessorBatchSize(2000);
context.setConnectorBatchSize(2000);
return context;
@@ -1387,27 +1385,6 @@
helpProcess(plan, dataManager, expected);
}
- public void testParameterized1() {
- // Create query
- String sql = "SELECT e1, e2, e3, e4 FROM pm1.g1 WHERE e2 = ?"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached(), new String[] { "1" }); //$NON-NLS-1$
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
/** SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1 */
public void testRightOuterJoin1() {
// Create query
@@ -5501,11 +5478,12 @@
// Collect reference, set value
Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
- Constant constant = new Constant("a ", String.class); //$NON-NLS-1$
- ref.setExpression(constant);
-
+ VariableContext vc = new VariableContext();
+ vc.setValue(ref.getExpression() , "a "); //$NON-NLS-1$
+ CommandContext context = createCommandContext();
+ context.setVariableContext(vc);
// Run query
- helpProcess(plan, dataManager, expected);
+ helpProcess(plan, context, dataManager, expected);
}
@@ -5542,11 +5520,13 @@
// Collect reference, set value
Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
- Constant constant = new Constant("a", String.class); //$NON-NLS-1$
- ref.setExpression(constant);
+ VariableContext vc = new VariableContext();
+ vc.setValue(ref.getExpression() , "a"); //$NON-NLS-1$
+ CommandContext context = createCommandContext();
+ context.setVariableContext(vc);
// Run query
- helpProcess(plan, dataManager, expected);
+ helpProcess(plan, context, dataManager, expected);
}
@@ -7889,8 +7869,10 @@
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
- Constant constant = new Constant("a"); //$NON-NLS-1$
- ref.setExpression(constant);
+ VariableContext vc = new VariableContext();
+ vc.setValue(ref.getExpression(), "a"); //$NON-NLS-1$
+ CommandContext context = createCommandContext();
+ context.setVariableContext(vc);
List[] expected = new List[] {
Arrays.asList("a", "b"), //$NON-NLS-1$ //$NON-NLS-2$
@@ -7900,7 +7882,7 @@
HardcodedDataManager manager = new HardcodedDataManager();
manager.addData("SELECT 'a', pm1.g1.e1 FROM pm1.g1", expected); //$NON-NLS-1$
- helpProcess(plan, manager, expected);
+ helpProcess(plan, context, manager, expected);
}
public void testCase6486() {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
@@ -35,12 +34,8 @@
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.util.CommandContext;
/**
@@ -57,17 +52,9 @@
public void helpTestProcessor(FakeProcessorPlan plan, long timeslice, List[] expectedResults) throws MetaMatrixCoreException {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- List schema = plan.getSchema();
- ArrayList typeNames = new ArrayList();
- for(Iterator s = schema.iterator(); s.hasNext();) {
- SingleElementSymbol es = (SingleElementSymbol)s.next();
- typeNames.add(DataTypeManager.getDataTypeName(es.getType()));
- }
- String[] types = (String[])typeNames.toArray(new String[typeNames.size()]);
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getSchema(), types, "group", TupleSourceType.FINAL); //$NON-NLS-1$
FakeDataManager dataManager = new FakeDataManager();
- CommandContext context = new CommandContext("pid", "group", tsID, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "group", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
while(true) {
@@ -81,10 +68,10 @@
}
// Compare # of rows in actual and expected
- assertEquals("Did not get expected # of rows", expectedResults.length, bufferMgr.getFinalRowCount(tsID)); //$NON-NLS-1$
+ assertEquals("Did not get expected # of rows", expectedResults.length, bufferMgr.getFinalRowCount(processor.getResultsID())); //$NON-NLS-1$
// Compare actual with expected results
- TupleSource actual = bufferMgr.getTupleSource(tsID);
+ TupleSource actual = bufferMgr.getTupleSource(processor.getResultsID());
if(expectedResults.length > 0) {
for(int i=0; i<expectedResults.length; i++) {
List actRecord = actual.nextTuple();
@@ -182,17 +169,9 @@
final FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- List schema = plan.getOutputElements();
- ArrayList typeNames = new ArrayList();
- for(Iterator s = schema.iterator(); s.hasNext();) {
- SingleElementSymbol es = (SingleElementSymbol)s.next();
- typeNames.add(DataTypeManager.getDataTypeName(es.getType()));
- }
- String[] types = (String[])typeNames.toArray(new String[typeNames.size()]);
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getSchema(), types, "group", TupleSourceType.FINAL); //$NON-NLS-1$
FakeDataManager dataManager = new FakeDataManager();
- CommandContext context = new CommandContext("pid", "group", tsID, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "group", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
final QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
processor.setBatchHandler(new QueryProcessor.BatchHandler() {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -24,7 +24,6 @@
import java.math.BigDecimal;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
@@ -38,9 +37,7 @@
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerPropertyNames;
-import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
import com.metamatrix.common.buffer.storage.memory.MemoryStorageManager;
import com.metamatrix.common.types.DataTypeManager;
@@ -50,7 +47,6 @@
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.unittest.FakeMetadataObject;
@@ -481,19 +477,10 @@
// Run query
BufferManager bufferMgr = createCustomBufferMgr(2);
- List schema = plan.getOutputElements();
- ArrayList typeNames = new ArrayList();
- for(Iterator s = schema.iterator(); s.hasNext();) {
- SingleElementSymbol es = (SingleElementSymbol)s.next();
- typeNames.add(DataTypeManager.getDataTypeName(es.getType()));
- }
- String[] types = (String[])typeNames.toArray(new String[typeNames.size()]);
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), types, "test", TupleSourceType.FINAL); //$NON-NLS-1$
- context.setTupleSourceID(tsID);
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
processor.process();
- TestProcessor.examineResults((List[])expected.toArray(new List[expected.size()]), bufferMgr, tsID);
+ TestProcessor.examineResults((List[])expected.toArray(new List[expected.size()]), bufferMgr, processor.getResultsID());
}
private BufferManager createCustomBufferMgr(int batchSize) throws MetaMatrixComponentException {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -22,13 +22,9 @@
package com.metamatrix.query.processor.dynamic;
-import java.util.List;
-
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.core.id.IDGenerator;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -42,7 +38,6 @@
import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.TypeRetrievalUtil;
public class SimpleQueryProcessorFactory implements QueryProcessor.ProcessorFactory {
@@ -73,13 +68,7 @@
idGenerator, finder, AnalysisRecord.createNonRecordingRecord(),
commandContext);
- List elements = plan.getOutputElements();
CommandContext copy = (CommandContext) commandContext.clone();
- TupleSourceID resultsId = bufferMgr.createTupleSource(elements,
- TypeRetrievalUtil.getTypeNames(elements), commandContext
- .getConnectionID(), TupleSourceType.PROCESSOR);
- copy.setTupleSourceID(resultsId);
-
return new QueryProcessor(plan, copy, bufferMgr, dataMgr);
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -37,7 +36,6 @@
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.eval.Evaluator;
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionLibraryManager;
@@ -45,17 +43,13 @@
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.CollectionValueIterator;
-import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.StoredProcedure;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.CaseExpression;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.ScalarSubquery;
import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
@@ -316,7 +310,7 @@
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
- CommandContext context = new CommandContext(new Long(1), null, null, -1, null, null, null, null);
+ CommandContext context = new CommandContext(new Long(1), null, -1, null, null, null, null);
context.setUserName("logon"); //$NON-NLS-1$
assertEquals(context.getUserName(), new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList()) );
}
@@ -337,7 +331,7 @@
Properties props = new Properties();
props.setProperty("http_host", "testHostName"); //$NON-NLS-1$ //$NON-NLS-2$
props.setProperty("http_port", "8000"); //$NON-NLS-1$ //$NON-NLS-2$
- CommandContext context = new CommandContext(new Long(1), null, null, -1, null, null, null, null, null, props, false, false);
+ CommandContext context = new CommandContext(new Long(1), null, null, null, null, null, null, props, false, false);
func.setArgs(new Expression[] {new Constant("http_host")}); //$NON-NLS-1$
assertEquals("testHostName", new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList())); //$NON-NLS-1$
@@ -359,7 +353,7 @@
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
- CommandContext context = new CommandContext(new Long(-1), null, null, 500, "user", null, payload, "vdb", "1", null, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ CommandContext context = new CommandContext(new Long(-1), null, "user", null, payload, "vdb", "1", null, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if(property != null) {
func.setArgs(new Expression[] {new Constant(property)});
@@ -410,50 +404,6 @@
}
}
- public void testEvaluateExpressionVisitorDefect24026() throws Exception {
-
- Function func = new Function("concat", new Expression[] { new Constant("a"), new Constant("b") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
- func.setFunctionDescriptor(desc);
- func.setType(DataTypeManager.DefaultDataClasses.STRING);
- Reference ref = new Reference(0, func);
-
- CompareCriteria criteria = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, ref); //$NON-NLS-1$
-
- EvaluateExpressionVisitor.replaceExpressions(criteria, true, null, null);
-
- assertEquals("e1 = 'ab'", criteria.toString()); //$NON-NLS-1$
- }
-
- public void testEvaluateExpressionVisitorWithExpression() throws Exception {
-
- Function func = new Function("concat", new Expression[] { new ElementSymbol("e2"), new Constant("b") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
- func.setFunctionDescriptor(desc);
- func.setType(DataTypeManager.DefaultDataClasses.STRING);
- Reference ref = new Reference(0, func);
- HashMap symbolMap = new HashMap(1);
- symbolMap.put(new ElementSymbol("e2"), new Integer(0)); //$NON-NLS-1$
- ref.setData(symbolMap, Arrays.asList(new Object[] {"a"})); //$NON-NLS-1$
-
- CompareCriteria criteria = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, ref); //$NON-NLS-1$
-
- EvaluateExpressionVisitor.replaceExpressions(criteria, true, null, null);
-
- assertEquals("e1 = 'ab'", criteria.toString()); //$NON-NLS-1$
- }
-
- public void testExecParam() throws Exception {
- SPParameter param = new SPParameter(1, new Reference(1, new Constant(1)));
- StoredProcedure sp = new StoredProcedure();
- sp.setParameter(param);
-
- EvaluateExpressionVisitor.replaceExpressions(sp, true, null, null);
-
- //ensure that the reference is replaced with its value
- assertEquals(new Constant(1), ((SPParameter)sp.getParameters().get(0)).getExpression());
- }
-
//tests that the visitor is safe to use against a null expression in the aggregate symbol
public void testCountStar() throws Exception {
ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -44,7 +44,6 @@
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.XMLType;
import com.metamatrix.core.MetaMatrixCoreException;
@@ -116,12 +115,12 @@
// Process twice, testing reset and clone method of Processor plan
for (int i=1; i<=2; i++) {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- TupleSourceID tsID = bufferMgr.createTupleSource(procPlan.getOutputElements(), null, null, TupleSourceType.FINAL);
- CommandContext context = new CommandContext("pID", null, tsID, 10, null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pID", null, 10, null, null, null, null); //$NON-NLS-1$
context.getNextRand(0);
context.setOptimisticTransaction(optimistic);
context.setProcessDebug(DEBUG);
QueryProcessor processor = new QueryProcessor(procPlan, context, bufferMgr, dataMgr);
+ TupleSourceID tsID = processor.getResultsID();
processor.process();
// Create QueryResults from TupleSource
@@ -2578,7 +2577,7 @@
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userQuery, metadata);
- List[] expected = new List[] {Arrays.asList(new Object[] {new Integer(3)})}; //$NON-NLS-1$
+ List[] expected = new List[] {Arrays.asList(new Object[] {new Integer(3)})};
helpTestProcess(plan, expected, dataMgr);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentSelectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentSelectNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentSelectNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -122,17 +122,16 @@
*/
public void testClone(){
int id = 1;
- DependentSelectNode node = new DependentSelectNode(id);
Command subCommand = helpMakeCommand();
+ subCommand.setProcessorPlan(new DoNothingProcessorPlan());
Criteria subCrit = new SubquerySetCriteria(new Constant("3"), subCommand); //$NON-NLS-1$
Command subCommand2 = helpMakeCommand2();
+ subCommand2.setProcessorPlan(new DoNothingProcessorPlan());
Criteria subCrit2 = new SubquerySetCriteria(new ElementSymbol("f"), subCommand2); //$NON-NLS-1$
- //Set up DependentSelectNode data
- List plans = helpMakeFakeProcessorPlans(2);
List crits = new ArrayList(2);
crits.add(subCrit);
crits.add(subCrit2);
- node.setPlansAndCriteriaMapping(plans, crits);
+ DependentSelectNode node = new DependentSelectNode(id, null);
//Set up criteria
CompoundCriteria crit = new CompoundCriteria();
crit.addCriteria(subCrit);
@@ -145,7 +144,7 @@
//Test clone
DependentSelectNode cloned = (DependentSelectNode)node.clone();
- List originalProcessorPlans = node.getSubqueryProcessorUtility().getSubqueryPlans();
+ List<ProcessorPlan> originalProcessorPlans = node.getSubqueryProcessorUtility().getSubqueryPlans();
List clonedProcessorPlans = cloned.getSubqueryProcessorUtility().getSubqueryPlans();
List clonedCrits = cloned.getSubqueryProcessorUtility().getValueIteratorProviders();
List checkClonedCrits = new ArrayList(clonedCrits.size());
@@ -156,10 +155,10 @@
assertEquals(clonedCrits.size(), clonedProcessorPlans.size());
for (int i=0; i<originalProcessorPlans.size(); i++){
//Check ProcessorPlans
- Object originalPlan = originalProcessorPlans.get(i);
+ ProcessorPlan originalPlan = originalProcessorPlans.get(i);
DoNothingProcessorPlan clonedPlan = (DoNothingProcessorPlan)clonedProcessorPlans.get(i);
assertNotNull(clonedPlan.original);
- assertSame(originalPlan, clonedPlan.original);
+ assertSame(((DoNothingProcessorPlan)originalPlan).original, clonedPlan.original);
//Check SubquerySetCriteria
assertNotNull(clonedCrits.get(i));
@@ -173,20 +172,21 @@
*/
public void testClone2(){
int id = 1;
- DependentSelectNode node = new DependentSelectNode(id);
-
Command subCommand = helpMakeCommand();
+ subCommand.setProcessorPlan(new DoNothingProcessorPlan());
Criteria subCrit = new SubqueryCompareCriteria(new ElementSymbol("f"), subCommand, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ANY); //$NON-NLS-1$
Command subCommand2 = helpMakeCommand2();
+ subCommand2.setProcessorPlan(new DoNothingProcessorPlan());
Criteria subCrit2 = new ExistsCriteria(subCommand2);
//Set up DependentSelectNode data
- List plans = helpMakeFakeProcessorPlans(2);
List crits = new ArrayList(2);
crits.add(subCrit);
crits.add(subCrit2);
- node.setPlansAndCriteriaMapping(plans, crits);
+
+ DependentSelectNode node = new DependentSelectNode(id, null);
+
//Set up criteria
CompoundCriteria crit = new CompoundCriteria();
crit.addCriteria(subCrit);
@@ -213,7 +213,7 @@
Object originalPlan = originalProcessorPlans.get(i);
DoNothingProcessorPlan clonedPlan = (DoNothingProcessorPlan)clonedProcessorPlans.get(i);
assertNotNull(clonedPlan.original);
- assertSame(originalPlan, clonedPlan.original);
+ assertSame(((DoNothingProcessorPlan)originalPlan).original, clonedPlan.original);
//Check SubquerySetCriteria
assertNotNull(clonedCrits.get(i));
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -158,7 +158,7 @@
List groupingElements = new ArrayList();
groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
node.initialize(context, mgr, null);
List[] expected = new List[] {
@@ -192,7 +192,7 @@
List groupingElements = new ArrayList();
groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
node.initialize(context, mgr, null);
List[] expected = new List[] {
@@ -228,7 +228,7 @@
List groupingElements = new ArrayList();
groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
node.initialize(context, mgr, null);
List[] expected = new List[] {
@@ -260,7 +260,7 @@
// Set grouping elements to null
node.setGroupingElements(null);
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
node.initialize(context, mgr, null);
List[] data = new List[] {
@@ -301,7 +301,7 @@
List groupingElements = new ArrayList();
groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
node.initialize(context, mgr, null);
List[] data = new List[] {
@@ -350,7 +350,7 @@
List groupingElements = new ArrayList();
groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
FakeDataManager dataMgr = new FakeDataManager();
dataMgr.setThrowBlocked(true);
@@ -399,7 +399,7 @@
groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
}
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
node.initialize(context, mgr, null);
List[] data = new List[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -227,7 +227,7 @@
public void helpTestJoinDirect(List[] expectedResults, boolean swapExpected) throws MetaMatrixComponentException, MetaMatrixProcessingException {
helpCreateJoin();
BufferManager mgr = NodeTestUtil.getTestBufferManager(1, getProcessorBatchSize());
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
join.addChild(leftNode);
join.addChild(rightNode);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -63,7 +63,7 @@
public ProjectNode helpSetupProject(List elements, List[] data, List childElements, ProcessorDataManager dataMgr) throws MetaMatrixComponentException {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
FakeRelationalNode dataNode = new FakeRelationalNode(2, data);
dataNode.setElements(childElements);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -116,7 +116,7 @@
FakeRelationalNode fakeNode = new FakeRelationalNode(1, data, 100);
fakeNode.setElements(elements);
- CommandContext context = new CommandContext("pid", "group", null, 100, null, null, null, null, null, null, false, true); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "group", null, null, null, null, null, null, false, true); //$NON-NLS-1$ //$NON-NLS-2$
fakeNode.initialize(context, BufferManagerFactory.getStandaloneBufferManager(), null);
return fakeNode;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -67,7 +67,7 @@
public void helpTestSelect(List elements, Criteria criteria, List childElements, ProcessorDataManager dataMgr, List[] expected, RelationalNode child) throws MetaMatrixComponentException, MetaMatrixProcessingException {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
child.setElements(childElements);
child.initialize(context, mgr, dataMgr);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -63,7 +63,7 @@
impl.getConfig().setTotalAvailableMemory(bytesInMemory);
impl.getConfig().setGroupUsePercentage(100);
impl.getConfig().setManagementInterval(0);
- CommandContext context = new CommandContext ("pid", "test", null, BATCH_SIZE, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext ("pid", "test", BATCH_SIZE, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
FakeRelationalNode dataNode = new FakeRelationalNode(2, data);
dataNode.setElements(elements);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -51,7 +51,7 @@
public void helpTestUnion(RelationalNode[] children, RelationalNode union, List[] expected) throws MetaMatrixComponentException, MetaMatrixProcessingException {
BufferManager mgr = NodeTestUtil.getTestBufferManager(1, 2);
- CommandContext context = new CommandContext("pid", "test", null, 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("pid", "test", 100, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
for(int i=0; i<children.length; i++) {
union.addChild(children[i]);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -348,7 +348,7 @@
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
XMLPlan temp = new XMLPlan(env);
- CommandContext context = new CommandContext("pid", null, null, 100, null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pid", null, 100, null, null, null, null); //$NON-NLS-1$
temp.initialize(context,null,bufferMgr);
List schema = new ArrayList();
@@ -404,7 +404,7 @@
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
XMLPlan temp = new XMLPlan(env);
- CommandContext context = new CommandContext("pid", null, null, 100, null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pid", null, 100, null, null, null, null); //$NON-NLS-1$
temp.initialize(context,null,bufferMgr);
env.addData(resultSetName, command.getProjectedSymbols(), new List[] {
Arrays.asList( new Object[] { "001", "Lamp", new Integer(5) } ), //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -27,7 +27,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -44,8 +43,6 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.XMLType;
import com.metamatrix.core.util.UnitTestUtil;
@@ -79,7 +76,6 @@
import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.unittest.FakeMetadataObject;
@@ -2969,18 +2965,8 @@
// Process twice, to test reset and clone methods
for (int i=1; i<=2; i++) {
- BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
-
- List schema = plan.getOutputElements();
- ArrayList typeNames = new ArrayList();
- for(Iterator s = schema.iterator(); s.hasNext();) {
- SingleElementSymbol es = (SingleElementSymbol)s.next();
- typeNames.add(DataTypeManager.getDataTypeName(es.getType()));
- }
- String[] types = (String[])typeNames.toArray(new String[typeNames.size()]);
-
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), types, "TestConn", TupleSourceType.FINAL); //$NON-NLS-1$
- CommandContext context = new CommandContext("pID", "TestConn", tsID, 10, "testUser", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
+ CommandContext context = new CommandContext("pID", "TestConn", 10, "testUser", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
context.setProcessDebug(DEBUG);
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
@@ -2996,7 +2982,7 @@
//int count = bufferMgr.getFinalRowCount(tsID);
//assertEquals("Incorrect number of records: ", 1, count); //$NON-NLS-1$
- TupleSource ts = bufferMgr.getTupleSource(tsID);
+ TupleSource ts = bufferMgr.getTupleSource(processor.getResultsID());
List row = ts.nextTuple();
assertEquals("Incorrect number of columns: ", 1, row.size()); //$NON-NLS-1$
@@ -3004,7 +2990,7 @@
XMLType result = (XMLType)row.get(0);
String actualDoc = result.getString();
- bufferMgr.removeTupleSource(tsID);
+ bufferMgr.removeTupleSource(processor.getResultsID());
if(DEBUG) {
System.out.println("expectedDoc = \n" + expectedDoc); //$NON-NLS-1$
@@ -3026,15 +3012,7 @@
XMLPlan plan = (XMLPlan)QueryOptimizer.optimizePlan(command, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- List schema = plan.getOutputElements();
- ArrayList typeNames = new ArrayList();
- for(Iterator s = schema.iterator(); s.hasNext();) {
- SingleElementSymbol es = (SingleElementSymbol)s.next();
- typeNames.add(DataTypeManager.getDataTypeName(es.getType()));
- }
- String[] types = (String[])typeNames.toArray(new String[typeNames.size()]);
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), types, null, TupleSourceType.FINAL);
- CommandContext context = new CommandContext("pID", null, tsID, 10, null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pID", null, 10, null, null, null, null); //$NON-NLS-1$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
processor.process();
} catch (Exception e){
@@ -3077,25 +3055,15 @@
System.out.println(analysisRecord.getDebugLog());
}
-//System.out.println("Plan w/ criteria\n" + plan);
-
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- List schema = plan.getOutputElements();
- ArrayList typeNames = new ArrayList();
- for(Iterator s = schema.iterator(); s.hasNext();) {
- SingleElementSymbol es = (SingleElementSymbol)s.next();
- typeNames.add(DataTypeManager.getDataTypeName(es.getType()));
- }
- String[] types = (String[])typeNames.toArray(new String[typeNames.size()]);
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), types, null, TupleSourceType.FINAL);
- CommandContext context = new CommandContext("pID", null, tsID, 10, null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pID", null, 10, null, null, null, null); //$NON-NLS-1$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
processor.process();
- int count = bufferMgr.getFinalRowCount(tsID);
+ int count = bufferMgr.getFinalRowCount(processor.getResultsID());
assertEquals("Incorrect number of records: ", expectedDocs.length, count); //$NON-NLS-1$
- TupleSource ts = bufferMgr.getTupleSource(tsID);
+ TupleSource ts = bufferMgr.getTupleSource(processor.getResultsID());
for (int i=0; i<expectedDocs.length; i++){
List row = ts.nextTuple();
if(row.isEmpty()){
@@ -3108,7 +3076,7 @@
//assertEquals("XML doc result # " + i +" mismatch: ", expectedDocs[i], actualDoc); //$NON-NLS-1$ //$NON-NLS-2$
compareDocuments(expectedDocs[i], actualDoc);
}
- bufferMgr.removeTupleSource(tsID);
+ bufferMgr.removeTupleSource(processor.getResultsID());
}
// =============================================================================================
@@ -6095,16 +6063,7 @@
XMLPlan plan = TestXMLPlanner.preparePlan(command, metadata, new DefaultCapabilitiesFinder(), null);
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- List schema = plan.getOutputElements();
- ArrayList typeNames = new ArrayList();
- for(Iterator s = schema.iterator(); s.hasNext();) {
- SingleElementSymbol es = (SingleElementSymbol)s.next();
- typeNames.add(DataTypeManager.getDataTypeName(es.getType()));
- }
- String[] types = (String[])typeNames.toArray(new String[typeNames.size()]);
-
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), types, null, TupleSourceType.FINAL);
- CommandContext context = new CommandContext("pID", null, tsID, 10, null, null, null, null); //$NON-NLS-1$
+ CommandContext context = new CommandContext("pID", null, 10, null, null, null, null); //$NON-NLS-1$
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
MetaMatrixComponentException failOnDefaultException = null;
Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -905,8 +905,8 @@
public void testResolveParameters() {
List bindings = new ArrayList();
- bindings.add("0"); //$NON-NLS-1$
- bindings.add("'abc'"); //$NON-NLS-1$
+ bindings.add("pm1.g2.e1"); //$NON-NLS-1$
+ bindings.add("pm1.g2.e2"); //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.e1, ? FROM pm1.g1 WHERE pm1.g1.e1 = ?", bindings); //$NON-NLS-1$
@@ -920,14 +920,14 @@
public void testResolveParametersInsert() {
List bindings = new ArrayList();
- bindings.add("'abc'"); //$NON-NLS-1$
+ bindings.add("pm1.g2.e1"); //$NON-NLS-1$
helpResolve("INSERT INTO pm1.g1 (e1) VALUES (?)", bindings); //$NON-NLS-1$
}
public void testResolveParametersExec() {
List bindings = new ArrayList();
- bindings.add("'abc'"); //$NON-NLS-1$
+ bindings.add("pm1.g2.e1"); //$NON-NLS-1$
Query resolvedQuery = (Query)helpResolve("SELECT * FROM (exec pm1.sq2(?)) as a", bindings); //$NON-NLS-1$
//verify the type of the reference is resolved
Deleted: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestEvaluation.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestEvaluation.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestEvaluation.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -1,100 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.sql.visitor;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-
-import junit.framework.TestCase;
-
-public class TestEvaluation extends TestCase {
-
- private Reference getNestedReferences() {
- ElementSymbol foo = new ElementSymbol("foo");//$NON-NLS-1$
- foo.setType(DataTypeManager.DefaultDataClasses.INTEGER);
-
- Reference reference = new Reference(0, foo);
-
- Reference wrapper = new Reference(1, reference);
- return wrapper;
- }
-
- public void testNestedReferences() {
- Reference wrapper = getNestedReferences();
-
- //references are never considered evaluatable during planning
- assertFalse(EvaluateExpressionVisitor.isFullyEvaluatable(wrapper, true));
-
- //lacks data
- assertFalse(EvaluateExpressionVisitor.isFullyEvaluatable(wrapper, false));
-
- //should have data at runtime
- assertTrue(EvaluateExpressionVisitor.willBecomeConstant(wrapper));
-
- //should have data at runtime
- assertTrue(EvaluateExpressionVisitor.willBecomeConstant(wrapper));
- }
-
- public void testNestedReferences1() {
- Reference wrapper = getNestedReferences();
-
- ((Reference)wrapper.getExpression()).setData(Collections.EMPTY_MAP, Collections.EMPTY_LIST);
-
- //references are never considered evaluatable during planning
- assertFalse(EvaluateExpressionVisitor.isFullyEvaluatable(wrapper, true));
-
- //still lacks data
- assertTrue(EvaluateExpressionVisitor.isFullyEvaluatable(wrapper, false));
-
- //should have data at runtime
- assertTrue(EvaluateExpressionVisitor.willBecomeConstant(wrapper));
-
- //should have data at runtime
- assertTrue(EvaluateExpressionVisitor.willBecomeConstant(wrapper));
- }
-
- public void testNestedReferencesEvaluation() throws Exception {
- Reference wrapper = getNestedReferences();
-
- HashMap index = new HashMap();
- index.put(new ElementSymbol("foo"), new Integer(0)); //$NON-NLS-1$
- List data = new ArrayList();
- data.add(new Integer(1));
-
- ((Reference)wrapper.getExpression()).setData(index, data);
-
- CompareCriteria crit = new CompareCriteria(new ElementSymbol("bar"), CompareCriteria.EQ, wrapper); //$NON-NLS-1$
-
- EvaluateExpressionVisitor.replaceExpressions(crit, true, null, null);
-
- assertEquals("bar = 1", crit.toString()); //$NON-NLS-1$
-
- }
-}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -56,6 +56,8 @@
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -99,7 +101,8 @@
// this has two result set columns and 1 out parameter
int total_columns = 3;
- Command command = helpGetCommand("{call pm2.spTest8(?)}", EXAMPLE_BQT); //$NON-NLS-1$
+ StoredProcedure command = (StoredProcedure)helpGetCommand("{call pm2.spTest8(?)}", EXAMPLE_BQT); //$NON-NLS-1$
+ command.getInputParameters().get(0).setExpression(new Constant(1));
IProcedure proc = (IProcedure) new LanguageBridgeFactory(EXAMPLE_BQT)
.translate(command);
@@ -118,7 +121,7 @@
fail("Expected exception from resultset mismatch"); //$NON-NLS-1$
} catch (ConnectorException err) {
assertEquals(
- "Could not process stored procedure results for EXEC spTest8(, ?). Expected 2 result set columns, but was 1. Please update your models to allow for stored procedure results batching.", err.getMessage()); //$NON-NLS-1$
+ "Could not process stored procedure results for EXEC spTest8(, 1). Expected 2 result set columns, but was 1. Please update your models to allow for stored procedure results batching.", err.getMessage()); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -38,8 +38,8 @@
*/
public class TestCodeTableCache extends TestCase {
- private static CommandContext TEST_CONTEXT = new CommandContext("pid", "1", null, 5, null, null, "test", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static CommandContext TEST_CONTEXT_1 = new CommandContext("pid", "1", null, 5, null, null, "test", "2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static CommandContext TEST_CONTEXT = new CommandContext("pid", "1", 5, null, null, "test", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static CommandContext TEST_CONTEXT_1 = new CommandContext("pid", "1", 5, null, null, "test", "2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
public TestCodeTableCache(String name) {
super(name);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -29,12 +29,6 @@
import java.util.Map;
import java.util.Properties;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.process.DataTierManagerImpl;
-import org.teiid.dqp.internal.process.DataTierTupleSource;
-import org.teiid.dqp.internal.process.RequestWorkItem;
-
import junit.framework.TestCase;
import com.metamatrix.api.exception.ComponentNotFoundException;
@@ -46,7 +40,6 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
@@ -133,7 +126,6 @@
context = new CommandContext();
context.setProcessorID(requestID);
- context.setTupleSourceID(new TupleSourceID("fakeid")); //$NON-NLS-1$
context.setVdbName("test"); //$NON-NLS-1$
context.setVdbVersion("1"); //$NON-NLS-1$
context.setQueryProcessorFactory(new SimpleQueryProcessorFactory(bs.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
@@ -327,7 +319,7 @@
public void close() throws MetaMatrixComponentException {}
public List getAndClearWarnings() {return null;}
public CommandContext getContext() {return null;}
- public List getOutputElements() {return null;}
+ public List getOutputElements() {return Collections.EMPTY_LIST;}
public void initialize(CommandContext context,ProcessorDataManager dataMgr,BufferManager bufferMgr) {}
public TupleBatch nextBatch() throws BlockedException,MetaMatrixComponentException {
ArrayList one = new ArrayList(); one.add("1");
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -94,10 +94,10 @@
static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement) throws Exception {
TestablePreparedPlanCache prepPlan = new TestablePreparedPlanCache();
//Create plan
- ProcessorPlan plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, SESSION_ID, callableStatement, false);
+ PreparedStatementRequest plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, SESSION_ID, callableStatement, false);
// Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
+ TestProcessor.helpProcess(plan.processPlan, plan.context, dataManager, expected);
//test cached plan
plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, SESSION_ID, callableStatement, false);
@@ -106,7 +106,7 @@
assertEquals("should reuse the plan", 1, prepPlan.hitCount); //$NON-NLS-1$
// Run query again
- TestProcessor.helpProcess(plan, dataManager, expected);
+ TestProcessor.helpProcess(plan.processPlan, plan.context, dataManager, expected);
//get the plan again with a new connection
assertNotNull(TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, 7, callableStatement, false));
@@ -159,19 +159,19 @@
List values = new ArrayList();
values.add(new Integer(0));
- ProcessorPlan plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new PreparedPlanCache(), SESSION_ID, false, false);
+ PreparedStatementRequest plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new PreparedPlanCache(), SESSION_ID, false, false);
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ TestOptimizer.checkNodeTypes(plan.processPlan, TestOptimizer.FULL_PUSHDOWN);
}
- private ProcessorPlan helpGetProcessorPlan(String preparedSql, List values, PreparedPlanCache prepPlanCache)
+ private PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values, PreparedPlanCache prepPlanCache)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
QueryPlannerException {
return helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), prepPlanCache, SESSION_ID, false, false);
}
- private ProcessorPlan helpGetProcessorPlan(String preparedSql, List values,
+ private PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
PreparedPlanCache prepPlanCache, int conn)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
@@ -181,7 +181,7 @@
.example1Cached(), prepPlanCache, conn, false, false);
}
- static ProcessorPlan helpGetProcessorPlan(String preparedSql, List values,
+ static PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
CapabilitiesFinder capFinder, QueryMetadataInterface metadata, PreparedPlanCache prepPlanCache, int conn, boolean callableStatement, boolean limitResults)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
@@ -212,9 +212,8 @@
serverRequest.setMetadata(capFinder, metadata, null);
serverRequest.processRequest();
- ProcessorPlan plan = serverRequest.processPlan;
- assertNotNull(plan);
- return plan;
+ assertNotNull(serverRequest.processPlan);
+ return serverRequest;
}
public void testValidateCorrectValues() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -120,7 +120,7 @@
idGenerator.setDefaultFactory(new IntegerIDFactory());
Properties props = new Properties();
- CommandContext context = new CommandContext("0", "test", null, 5, "user", null, null, vdbName, vdbVersion, props, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ CommandContext context = new CommandContext("0", "test", "user", null, null, vdbName, vdbVersion, props, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
context.setPlanToProcessConverter(new MultiSourcePlanToProcessConverter(metadata, idGenerator, analysis, finder, multiSourceModels, vdbName, vdbService, vdbVersion));
ProcessorPlan plan = QueryOptimizer.optimizePlan(command, wrapper, idGenerator, finder, analysis, context);
Modified: trunk/test-integration/src/test/java/com/metamatrix/server/integration/BaseQueryTest.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/server/integration/BaseQueryTest.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/test-integration/src/test/java/com/metamatrix/server/integration/BaseQueryTest.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -69,7 +69,7 @@
AnalysisRecord analysisRecord = new AnalysisRecord(false, debug, debug);
ProcessorPlan plan = null;
try {
- plan = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, createCommandContext(null, command));
+ plan = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, createCommandContext());
} finally {
if(debug) {
System.out.println(analysisRecord.getDebugLog());
@@ -81,11 +81,10 @@
protected void doProcess(ProcessorPlan plan, ProcessorDataManager dataManager, List[] expectedResults, boolean debug) throws Exception {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), null, "test", BufferManager.TupleSourceType.FINAL); //$NON-NLS-1$
-
- CommandContext context = createCommandContext(tsID, null);
+ CommandContext context = createCommandContext();
context.setProcessDebug(debug);
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
+ TupleSourceID tsID = processor.getResultsID();
processor.process();
// Create QueryResults from TupleSource
@@ -121,10 +120,9 @@
protected void doProcessNoResultsCheck(ProcessorPlan plan, ProcessorDataManager dataManager, int expectedRowCount, boolean debug) throws Exception {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- TupleSourceID tsID = bufferMgr.createTupleSource(plan.getOutputElements(), null, "test", BufferManager.TupleSourceType.FINAL); //$NON-NLS-1$
-
- CommandContext context = createCommandContext(tsID, null);
+ CommandContext context = createCommandContext();
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
+ TupleSourceID tsID = processor.getResultsID();
processor.process();
// Create QueryResults from TupleSource
@@ -151,10 +149,10 @@
bufferMgr.removeTupleSource(tsID);
}
- protected CommandContext createCommandContext(TupleSourceID tsID, Command command) {
+ protected CommandContext createCommandContext() {
Properties props = new Properties();
//props.setProperty(ContextProperties.SOAP_HOST, "my.host.com"); //$NON-NLS-1$
- CommandContext context = new CommandContext("0", "test", tsID, 5, "user", null, null, "myvdb", "1", props, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ CommandContext context = new CommandContext("0", "test", "user", null, null, "myvdb", "1", props, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
return context;
}
Modified: trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -61,13 +61,13 @@
public IProcedure getProcedure(String procName, int inputArgs, TranslationUtility transUtil) throws Exception {
StringBuffer sql = new StringBuffer("EXEC " + procName + "("); //$NON-NLS-1$ //$NON-NLS-2$
if(inputArgs > 0) {
- sql.append("?"); //$NON-NLS-1$
+ sql.append("null"); //$NON-NLS-1$
for(int i=1; i<inputArgs; i++) {
- sql.append(", ?"); //$NON-NLS-1$
+ sql.append(", null"); //$NON-NLS-1$
}
}
sql.append(")"); //$NON-NLS-1$
- IProcedure proc = (IProcedure) transUtil.parseCommand(sql.toString()); //$NON-NLS-1$
+ IProcedure proc = (IProcedure) transUtil.parseCommand(sql.toString());
return proc;
}
@@ -114,62 +114,62 @@
assertEquals(4, params.size());
checkParameter((IParameter)params.get(0),
- "in1",
- "sptest.proc1.in1",
+ "in1", //$NON-NLS-1$
+ "sptest.proc1.in1", //$NON-NLS-1$
1,
Direction.IN,
null,
- "sample default",
+ "sample default", //$NON-NLS-1$
TypeModel.NOT_NULLABLE,
String.class,
20,
10,
5,
CONNECTOR_METADATA_UTILITY,
- "http://www.w3.org/2001/XMLSchema#string",
- "http://www.w3.org/2001/XMLSchema#anySimpleType",
- "http://www.w3.org/2001/XMLSchema#string");
+ "http://www.w3.org/2001/XMLSchema#string", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#anySimpleType", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#string"); //$NON-NLS-1$
checkParameter((IParameter)params.get(1),
- "in2",
- "sptest.proc1.in2",
+ "in2", //$NON-NLS-1$
+ "sptest.proc1.in2", //$NON-NLS-1$
2,
Direction.IN,
null,
- "15",
+ "15", //$NON-NLS-1$
TypeModel.NULLABLE,
Integer.class,
0,
10,
0,
CONNECTOR_METADATA_UTILITY,
- "http://www.w3.org/2001/XMLSchema#int",
- "http://www.w3.org/2001/XMLSchema#long",
- "http://www.w3.org/2001/XMLSchema#decimal");
+ "http://www.w3.org/2001/XMLSchema#int", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#long", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#decimal"); //$NON-NLS-1$
checkParameter((IParameter)params.get(2),
- "in3",
- "sptest.proc1.in3",
+ "in3", //$NON-NLS-1$
+ "sptest.proc1.in3", //$NON-NLS-1$
3,
Direction.IN,
null,
- "2003-04-23 09:30:00",
+ "2003-04-23 09:30:00", //$NON-NLS-1$
TypeModel.NULLABLE_UNKNOWN,
Timestamp.class,
22,
10,
0,
CONNECTOR_METADATA_UTILITY,
- "http://www.metamatrix.com/metamodels/SimpleDatatypes-instance#timestamp",
- "http://www.w3.org/2001/XMLSchema#dateTime",
- "http://www.w3.org/2001/XMLSchema#dateTime");
+ "http://www.metamatrix.com/metamodels/SimpleDatatypes-instance#timestamp", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#dateTime", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#dateTime"); //$NON-NLS-1$
checkParameter((IParameter)params.get(3),
- "inOptional",
- "sptest.proc1.inOptional",
+ "inOptional", //$NON-NLS-1$
+ "sptest.proc1.inOptional", //$NON-NLS-1$
4,
Direction.IN,
- "optionalName",
+ "optionalName", //$NON-NLS-1$
null,
TypeModel.NULLABLE,
String.class,
@@ -177,9 +177,9 @@
0,
0,
CONNECTOR_METADATA_UTILITY,
- "http://www.w3.org/2001/XMLSchema#string",
- "http://www.w3.org/2001/XMLSchema#anySimpleType",
- "http://www.w3.org/2001/XMLSchema#string");
+ "http://www.w3.org/2001/XMLSchema#string", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#anySimpleType", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#string"); //$NON-NLS-1$
}
Modified: trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java 2009-04-15 19:36:14 UTC (rev 779)
+++ trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java 2009-04-15 20:21:58 UTC (rev 780)
@@ -60,13 +60,13 @@
public Procedure getProcedure(String procName, int inputArgs, TranslationUtility transUtil) throws Exception {
StringBuffer sql = new StringBuffer("EXEC " + procName + "("); //$NON-NLS-1$ //$NON-NLS-2$
if(inputArgs > 0) {
- sql.append("?"); //$NON-NLS-1$
+ sql.append("null"); //$NON-NLS-1$
for(int i=1; i<inputArgs; i++) {
- sql.append(", ?"); //$NON-NLS-1$
+ sql.append(", null"); //$NON-NLS-1$
}
}
sql.append(")"); //$NON-NLS-1$
- IProcedure proc = (IProcedure) transUtil.parseCommand(sql.toString()); //$NON-NLS-1$
+ IProcedure proc = (IProcedure) transUtil.parseCommand(sql.toString());
return proc.getMetadataObject();
}
@@ -122,7 +122,7 @@
Element elemID2 = rsCols.get(1);
assertEquals("RSCol2", elemID2.getName()); //$NON-NLS-1$
assertEquals("ConnectorMetadata.TestProc2.RSParam.RSCol2", elemID2.getFullName()); //$NON-NLS-1$
- assertEquals(null, elemID2.getNameInSource()); //$NON-NLS-1$
+ assertEquals(null, elemID2.getNameInSource());
assertEquals(String.class, elemID2.getJavaType());
assertEquals(1, elemID2.getPosition());
Properties props = new Properties();
15 years, 4 months
teiid SVN: r779 - in branches/remove_psc/common-internal/src: main/java/com/metamatrix/common/config/xml and 2 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-15 15:36:14 -0400 (Wed, 15 Apr 2009)
New Revision: 779
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicDeployedComponent.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java
branches/remove_psc/common-internal/src/test/resources/config-original.xml
Log:
Teiid 323 - the import/export of the configuration needed to add the properties for the deployed service so that is supports the enabled option in the console
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicDeployedComponent.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicDeployedComponent.java 2009-04-15 17:35:54 UTC (rev 778)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicDeployedComponent.java 2009-04-15 19:36:14 UTC (rev 779)
@@ -51,6 +51,8 @@
*/
public class BasicDeployedComponent extends BasicComponentObject implements DeployedComponent, Serializable {
+ private static final String ENABLED="component.enabled";
+
private ConfigurationID configurationID;
/**
@@ -72,8 +74,6 @@
* @clientCardinality 1
*/
private VMComponentDefnID vmComponentID;
-
- private boolean isEnabled;
/**
* Constructor takes a <code>ComponentID, HostID, </code> and <code> Collection </code> of system components to declare a component as being deployed.
@@ -107,14 +107,22 @@
if (deployedComponent.getServiceComponentDefnID() != null) {
this.componentID = deployedComponent.getServiceComponentDefnID();
}
+ this.addProperties(deployedComponent.getEditableProperties());
}
+
+
public boolean isEnabled() {
- return this.isEnabled;
+ String enabled = this.getProperty(ENABLED);
+ if (enabled == null || enabled.trim().length() == 0) {
+ return true;
+ }
+ return (new Boolean(enabled).booleanValue());
+
}
public void setIsEnabled(boolean enable) {
- this.isEnabled = enable;
+ this.addProperty(ENABLED, new Boolean(enable).toString());
}
/**
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java 2009-04-15 17:35:54 UTC (rev 778)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java 2009-04-15 19:36:14 UTC (rev 779)
@@ -302,179 +302,84 @@
}
-
- /**
- * This is the class that represents the ConfigurationInfo Element which contains
- * all of the XML elements that represent a ConfigurationInfo object.
- */
- public static class ConfigurationInfo {
-
- /**
- * This is the name of the ServiceComponentDefnID Element.
- */
- public static final String ELEMENT = "ConfigurationInfo"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String LAST_CHANGED_DATE = "LastChangedDate"; //$NON-NLS-1$
- public static final String CREATION_DATE = "CreationDate"; //$NON-NLS-1$
- }
- }
/**
* This is the class that represents the LogConfiguration Element which contains
* all of the XML elements that represent a LogConfiguration object.
*/
- public static class LogConfiguration {
-
- /**
- * This is the name of the LogConfiguration Element.
- */
- public static final String ELEMENT = "LogConfiguration"; //$NON-NLS-1$
-
- }
+// public static class LogConfiguration {
+//
+// /**
+// * This is the name of the LogConfiguration Element.
+// */
+// public static final String ELEMENT = "LogConfiguration"; //$NON-NLS-1$
+//
+// }
/**
* This is the class that represents the VMComponentDefns Element which contains
* all of the XML elements that represent a VMComponentDefns object.
*/
- public static class VMComponentDefns {
-
- /**
- * This is the name of the VMComponentDefns Element.
- */
- public static final String ELEMENT = Configuration.ELEMENT + DELIMITER +"VMComponentDefns"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the VMComponentDefn Element which contains
- * all of the XML elements that represent a VMComponentDefn object.
- */
- public static class VMComponentDefn {
-
- /**
- * This is the name of the VMComponentDefn Element.
- */
- public static final String ELEMENT = "VMComponentDefn"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- }
- }
- }
+// public static class VMComponentDefns {
+//
+// /**
+// * This is the name of the VMComponentDefns Element.
+// */
+// public static final String ELEMENT = Configuration.ELEMENT + DELIMITER +"VMComponentDefns"; //$NON-NLS-1$
+//
+// /**
+// * This is the class that represents the VMComponentDefn Element which contains
+// * all of the XML elements that represent a VMComponentDefn object.
+// */
+// public static class VMComponentDefn {
+//
+// /**
+// * This is the name of the VMComponentDefn Element.
+// */
+// public static final String ELEMENT = "VMComponentDefn"; //$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ComponentObject.Attributes{
+// }
+// }
+// }
- /**
- * This is the class that represents the ProductServiceConfigID Element which contains
- * all of the XML elements that represent a ProductServiceConfigID object.
- */
- // public static final class ProductServiceConfigID{
- //
- // /**
- // * This is the name of the ProductServiceConfigID Element.
- // */
- // public static final String ELEMENT = "ProductServiceConfigID"; //$NON-NLS-1$
- //
- // /**
- // * This class defines the Attributes of the Element class that
- // * contains it. Note that this class just inherits its attributes
- // * from its configuration object superclass.
- // */
- // public static class Attributes extends ID.Attributes {
- // }
- // }
/**
* This is the class that represents the VMComponentDefnID Element which contains
* all of the XML elements that represent a VMComponentDefnID object.
*/
- public static final class VMComponentDefnID{
-
- /**
- * This is the name of the VMComponentDefnID Element.
- */
- public static final String ELEMENT = "VMComponentDefnID"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
+// public static final class VMComponentDefnID{
+//
+// /**
+// * This is the name of the VMComponentDefnID Element.
+// */
+// public static final String ELEMENT = "VMComponentDefnID"; //$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
- /**
- * This is the class that represents the VMComponentDefnID Element which contains
- * all of the XML elements that represent a VMComponentDefnID object.
- */
-// public static final class ServiceComponentDefnID{
-//
-// /**
-// * This is the name of the ServiceComponentDefnID Element.
-// */
-// public static final String ELEMENT = "ServiceComponentDefnID"; //$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ID.Attributes {
-// }
-// }
/**
- * This is the class that represents the DeployedComponents Element which contains
- * all of the XML elements that represent a DeployedComponents object.
- */
-// public static class DeployedComponents {
-//
-// /**
-// * This is the name of the DeployedComponents Element.
-// */
-// public static final String ELEMENT = Configuration.ELEMENT + DELIMITER + "DeployedComponents"; //$NON-NLS-1$
-//
-// /**
-// * This is the class that represents the DeployedComponent Element which contains
-// * all of the XML elements that represent a DeployedComponent object.
-// */
-// public static class DeployedComponent {
-//
-// /**
-// * This is the name of the DeployedComponent Element.
-// */
-// public static final String ELEMENT = "DeployedComponent"; //$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ComponentObject.Attributes{
-// public static final String HOST_ID = "HostID"; //$NON-NLS-1$
-// // public static final String PRODUCT_SERVICE_CONFIG_ID = "ProductServiceConfigID"; //$NON-NLS-1$
-// public static final String SERVICE_COMPONENT_DEFN_ID = "ServiceComponentDefnID"; //$NON-NLS-1$
-// public static final String VM_COMPONENT_DEFN_ID = "VMComponentDefnID"; //$NON-NLS-1$
-// }
-// }
-// }
-
- /**
- * This is the class that represents the DeployedComponentID Element which contains
- * all of the XML elements that represent a DeployedComponentID object.
+ * This is the class that represents the HostID Element which contains
+ * all of the XML elements that represent a HostID object.
*/
-// public static final class DeployedComponentID{
+// public static final class HostID {
//
// /**
-// * This is the name of the DeployedComponentID Element.
+// * This is the name of the HostID Element.
// */
-// public static final String ELEMENT = "DeployedComponentID"; //$NON-NLS-1$
+// public static final String ELEMENT = "HostID"; //$NON-NLS-1$
//
// /**
// * This class defines the Attributes of the Element class that
@@ -485,26 +390,6 @@
// }
// }
- /**
- * This is the class that represents the HostID Element which contains
- * all of the XML elements that represent a HostID object.
- */
- public static final class HostID {
-
- /**
- * This is the name of the HostID Element.
- */
- public static final String ELEMENT = "HostID"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
-
public static class DeployedService {
/**
@@ -539,33 +424,8 @@
public static class Attributes extends ComponentObject.Attributes{
}
- }
-
- /**
- * This is the class that represents the DeployedComponent Element which contains
- * all of the XML elements that represent a DeployedComponent object.
- */
- public static class xDeployedComponent {
-
- /**
- * This is the name of the DeployedComponent Element.
- */
- public static final String ELEMENT = "DeployedService"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- public static final String HOST_ID = "HostID"; //$NON-NLS-1$
- // public static final String PRODUCT_SERVICE_CONFIG_ID = "ProductServiceConfigID"; //$NON-NLS-1$
- public static final String SERVICE_COMPONENT_DEFN_ID = "ServiceComponentDefnID"; //$NON-NLS-1$
- public static final String VM_COMPONENT_DEFN_ID = "VMComponentDefnID"; //$NON-NLS-1$
- }
- }
+ }
-
}
@@ -574,22 +434,22 @@
* This is the class that represents the ComponentTypeID Element which contains
* all of the XML elements that represent a ComponentTypeID object.
*/
- public static class ComponentTypeID {
-
- /**
- * This is the name of the ComponentTypeID Element.
- */
- public static final String ELEMENT = "ComponentTypeID"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
-
- }
+// public static class ComponentTypeID {
+//
+// /**
+// * This is the name of the ComponentTypeID Element.
+// */
+// public static final String ELEMENT = "ComponentTypeID"; //$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+//
+// }
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java 2009-04-15 17:35:54 UTC (rev 778)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java 2009-04-15 19:36:14 UTC (rev 779)
@@ -512,12 +512,12 @@
return hostElement;
}
- public Element createDeployedVMElementx(DeployedComponent vm) {
- Assertion.isNotNull(vm);
-
- Element hostElement = createComponentObjectElement(XMLConfig_ElementNames.Configuration.Host.ELEMENT, vm, true);
- return hostElement;
- }
+// public Element createDeployedVMElementx(DeployedComponent vm) {
+// Assertion.isNotNull(vm);
+//
+// Element hostElement = createComponentObjectElement(XMLConfig_ElementNames.Configuration.Host.ELEMENT, vm, true);
+// return hostElement;
+// }
// public final boolean is42ConfigurationCompatible(Element root) throws InvalidConfigurationElementException{
// Element headerElement = root.getChild(XMLConfig_ElementNames.Header.ELEMENT);
@@ -1049,7 +1049,11 @@
// this will add the changed history information
if (componentObject instanceof DeployedComponent) {
- // don't write the properties for the deployed component
+ Properties props = componentObject.getProperties();
+ if (props != null && ! props.isEmpty()) {
+ Element properties = createPropertiesElement( props);
+ componentObjectElement.addContent(properties);
+ }
} else {
Element properties = createPropertiesElement( componentObject.getProperties());
componentObjectElement.addContent(properties);
@@ -1871,7 +1875,8 @@
}
ServiceComponentDefnID svcid = null;
- if (type.getComponentTypeCode() == ComponentType.CONNECTOR_COMPONENT_TYPE_CODE) {
+ if (type.isOfTypeConnector()) {
+ // type.getComponentTypeCode() == ComponentType.CONNECTOR_COMPONENT_TYPE_CODE) {
svcid = new ConnectorBindingID(configID, name);
@@ -1883,8 +1888,8 @@
}
component = editor.createDeployedServiceComponent(name, configID, hostID,vmID, svcid, (ComponentTypeID) type.getID());
+ component = (DeployedComponent)addProperties(element, component, editor);
-
component = (DeployedComponent) setDateHistory(component, element, editor);
@@ -2291,7 +2296,9 @@
if (!propertiesElement.getName().equals(XMLConfig_ElementNames.Properties.ELEMENT)) {
propertiesElement = propertiesElement.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
- }
+ }
+
+
Properties props = null;
if (propertiesElement == null) {
Modified: branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java
===================================================================
--- branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java 2009-04-15 17:35:54 UTC (rev 778)
+++ branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java 2009-04-15 19:36:14 UTC (rev 779)
@@ -27,6 +27,7 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Collection;
+import java.util.Iterator;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -39,10 +40,12 @@
import com.metamatrix.common.config.api.ConnectorArchive;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.config.api.ConnectorBindingType;
+import com.metamatrix.common.config.api.DeployedComponent;
import com.metamatrix.common.config.api.ExtensionModule;
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
import com.metamatrix.common.config.model.BasicConnectorArchive;
+import com.metamatrix.common.config.model.BasicDeployedComponent;
import com.metamatrix.common.config.model.BasicExtensionModule;
import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
import com.metamatrix.common.config.util.ConfigurationImportExportUtility;
@@ -403,6 +406,22 @@
fail("Didnt find 6 deployed services for VM " + vm.getName());
}
+ boolean isenabled = false;
+ for (Iterator<DeployedComponent> it=depsvcs.iterator(); it.hasNext();) {
+ DeployedComponent dc = it.next();
+ if (!dc.isEnabled()) {
+ if (dc.getName().equalsIgnoreCase("QueryService")) {
+ isenabled = true;
+ BasicDeployedComponent bdc = (BasicDeployedComponent) dc;
+ bdc.setIsEnabled(true);
+ }
+
+ }
+ }
+ if (! isenabled) {
+ fail("Did not find the QueryService deployed service that wase enabled");
+ }
+
String fileToExport = UnitTestUtil.getTestScratchPath() + ("/exported_config.xml");
cma.writeConfigurationModel(fileToExport, configModel, "TestCase");
@@ -411,7 +430,23 @@
// try reloading what was written to confirm
configModel = cma.readConfigurationModel(fileToExport, Configuration.NEXT_STARTUP_ID);
+ depsvcs = configModel.getConfiguration().getDeployedServicesForVM(vm);
+ if (depsvcs == null || depsvcs.size() != 6) {
+ fail("Didnt find 6 deployed services for VM " + vm.getName());
+ }
+
+ isenabled = false;
+ for (Iterator<DeployedComponent> it=depsvcs.iterator(); it.hasNext();) {
+ DeployedComponent dc = it.next();
+ if ( dc.getName().equalsIgnoreCase("QueryService")) {
+ if (!dc.isEnabled()) {
+ fail("Update to change enabled status to true did not work");
+ }
+ }
+
+ }
+
}
}
Modified: branches/remove_psc/common-internal/src/test/resources/config-original.xml
===================================================================
--- branches/remove_psc/common-internal/src/test/resources/config-original.xml 2009-04-15 17:35:54 UTC (rev 778)
+++ branches/remove_psc/common-internal/src/test/resources/config-original.xml 2009-04-15 19:36:14 UTC (rev 779)
@@ -77,9 +77,17 @@
</Properties>
<DeployedService Name="MembershipService" ComponentType="MembershipService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
<DeployedService Name="SessionService" ComponentType="SessionService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
- <DeployedService Name="AuthorizationService" ComponentType="AuthorizationService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
+ <DeployedService Name="AuthorizationService" ComponentType="AuthorizationService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" >
+ <Properties>
+ <Property Name="component.enabled">true</Property>
+ </Properties>
+ </DeployedService>
<DeployedService Name="ConfigurationService" ComponentType="ConfigurationService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
- <DeployedService Name="QueryService" ComponentType="QueryService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
+ <DeployedService Name="QueryService" ComponentType="QueryService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" >
+ <Properties>
+ <Property Name="component.enabled">false</Property>
+ </Properties>
+ </DeployedService>
<DeployedService Name="RuntimeMetadataService" ComponentType="RuntimeMetadataService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
</Process>
</Host>
@@ -172,8 +180,10 @@
</ComponentType>
<ComponentType Name="Host" ComponentTypeCode="7" Deployable="true" Deprecated="false" Monitorable="false" ParentComponentType="Configuration" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.950-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.950-06:00">
</ComponentType>
- <ComponentType Name="DeployedComponent" ComponentTypeCode="8" Deployable="false" Deprecated="false" Monitorable="false" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.970-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.970-06:00" />
- <ComponentType Name="VM" ComponentTypeCode="5" Deployable="true" Deprecated="false" Monitorable="false" ParentComponentType="Host" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.944-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.944-06:00">
+ <ComponentType Name="DeployedComponent" ComponentTypeCode="8" Deployable="false" Deprecated="false" Monitorable="false" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.970-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.970-06:00" >
+ <PropertyDefinition Name="component.enabled" DisplayName="Enabled Flag" ShortDescription="The enabled flag allows for disabling of the service or connector from starting without have to remove it from deployment." DefaultValue="true" Multiplicity="1" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="VM" ComponentTypeCode="5" Deployable="true" Deprecated="false" Monitorable="false" ParentComponentType="Host" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.944-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.944-06:00">
<PropertyDefinition Name="vm.starter.cmd.java_opts" DisplayName="Java Options" ShortDescription="These are the java options passed in before the main class" DefaultValue="-server -Djava.io.tmpdir=${metamatrix.host.dir}/data/tmp -ms${vm.starter.minHeapSize}m -mx${vm.starter.maxHeapSize}m" />
<PropertyDefinition Name="vm.enabled" DisplayName="Start Enabled Flag" ShortDescription="The enabled flag allows for disabling the VM from starting without have to remove it from deployment." DefaultValue="true" Multiplicity="1" PropertyType="Boolean" />
<PropertyDefinition Name="vm.timetolive" DisplayName="Socket Worker Thread Time-To-Live (ms)" ShortDescription="Time-to-live (in milliseconds) for threads used to do work on client requests." DefaultValue="30000" />
15 years, 4 months
teiid SVN: r778 - trunk/common-internal/src/test/java/com/metamatrix/common/queue.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-15 13:35:54 -0400 (Wed, 15 Apr 2009)
New Revision: 778
Modified:
trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java
Log:
increasing the test tolerance for execution variablity
Modified: trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java 2009-04-15 14:21:25 UTC (rev 777)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java 2009-04-15 17:35:54 UTC (rev 778)
@@ -132,7 +132,7 @@
}
/**
- * Here each execution exceeds the period, so only half the number of executions are expected.
+ * Here each execution exceeds the period
*/
@Test public void testScheduleRepeated() throws Exception {
final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5, 120000); //$NON-NLS-1$
@@ -142,15 +142,15 @@
public void run() {
result.add("hello"); //$NON-NLS-1$
try {
- Thread.sleep(7);
+ Thread.sleep(75);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
- }, 0, 5, TimeUnit.MILLISECONDS);
- Thread.sleep(99);
+ }, 0, 10, TimeUnit.MILLISECONDS);
+ Thread.sleep(100);
future.cancel(true);
- assertTrue(result.size() > 8 && result.size() < 12);
+ assertEquals(2, result.size());
}
@Test public void testFailingWork() throws Exception {
15 years, 4 months
teiid SVN: r777 - in trunk: connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-15 10:21:25 -0400 (Wed, 15 Apr 2009)
New Revision: 777
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/MMJDBCSQLTypeInfo.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/TranslatedCommand.java
Log:
TEIID-489 SQLXML should be a bound value
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/MMJDBCSQLTypeInfo.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/MMJDBCSQLTypeInfo.java 2009-04-15 13:08:51 UTC (rev 776)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/MMJDBCSQLTypeInfo.java 2009-04-15 14:21:25 UTC (rev 777)
@@ -22,6 +22,9 @@
package com.metamatrix.common.types;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.SQLXML;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
@@ -59,28 +62,28 @@
public static final String XML = DataTypeManager.DefaultDataTypes.XML;
public static final String NULL = DataTypeManager.DefaultDataTypes.NULL;
- private static Map NAME_TO_TYPE_MAP = new HashMap();
+ private static Map<String, Integer> NAME_TO_TYPE_MAP = new HashMap<String, Integer>();
static {
- NAME_TO_TYPE_MAP.put(STRING, new Integer(Types.VARCHAR));
- NAME_TO_TYPE_MAP.put(BOOLEAN, new Integer(Types.BIT));
- NAME_TO_TYPE_MAP.put(TIME, new Integer(Types.TIME));
- NAME_TO_TYPE_MAP.put(DATE, new Integer(Types.DATE));
- NAME_TO_TYPE_MAP.put(TIMESTAMP, new Integer(Types.TIMESTAMP));
- NAME_TO_TYPE_MAP.put(INTEGER, new Integer(Types.INTEGER));
- NAME_TO_TYPE_MAP.put(FLOAT, new Integer(Types.REAL));
- NAME_TO_TYPE_MAP.put(DOUBLE, new Integer(Types.DOUBLE));
- NAME_TO_TYPE_MAP.put(BIGDECIMAL, new Integer(Types.NUMERIC));
- NAME_TO_TYPE_MAP.put(BIGINTEGER, new Integer(Types.NUMERIC));
- NAME_TO_TYPE_MAP.put(BYTE, new Integer(Types.TINYINT));
- NAME_TO_TYPE_MAP.put(SHORT, new Integer(Types.SMALLINT));
- NAME_TO_TYPE_MAP.put(LONG, new Integer(Types.BIGINT));
- NAME_TO_TYPE_MAP.put(CHAR, new Integer(Types.CHAR));
- NAME_TO_TYPE_MAP.put(OBJECT, new Integer(Types.JAVA_OBJECT));
- NAME_TO_TYPE_MAP.put(CLOB, new Integer(Types.CLOB));
- NAME_TO_TYPE_MAP.put(BLOB, new Integer(Types.BLOB));
- NAME_TO_TYPE_MAP.put(XML, new Integer(Types.JAVA_OBJECT));
- NAME_TO_TYPE_MAP.put(NULL, new Integer(Types.NULL));
+ NAME_TO_TYPE_MAP.put(STRING, Integer.valueOf(Types.VARCHAR));
+ NAME_TO_TYPE_MAP.put(BOOLEAN, Integer.valueOf(Types.BIT));
+ NAME_TO_TYPE_MAP.put(TIME, Integer.valueOf(Types.TIME));
+ NAME_TO_TYPE_MAP.put(DATE, Integer.valueOf(Types.DATE));
+ NAME_TO_TYPE_MAP.put(TIMESTAMP, Integer.valueOf(Types.TIMESTAMP));
+ NAME_TO_TYPE_MAP.put(INTEGER, Integer.valueOf(Types.INTEGER));
+ NAME_TO_TYPE_MAP.put(FLOAT, Integer.valueOf(Types.REAL));
+ NAME_TO_TYPE_MAP.put(DOUBLE, Integer.valueOf(Types.DOUBLE));
+ NAME_TO_TYPE_MAP.put(BIGDECIMAL, Integer.valueOf(Types.NUMERIC));
+ NAME_TO_TYPE_MAP.put(BIGINTEGER, Integer.valueOf(Types.NUMERIC));
+ NAME_TO_TYPE_MAP.put(BYTE, Integer.valueOf(Types.TINYINT));
+ NAME_TO_TYPE_MAP.put(SHORT, Integer.valueOf(Types.SMALLINT));
+ NAME_TO_TYPE_MAP.put(LONG, Integer.valueOf(Types.BIGINT));
+ NAME_TO_TYPE_MAP.put(CHAR, Integer.valueOf(Types.CHAR));
+ NAME_TO_TYPE_MAP.put(OBJECT, Integer.valueOf(Types.JAVA_OBJECT));
+ NAME_TO_TYPE_MAP.put(CLOB, Integer.valueOf(Types.CLOB));
+ NAME_TO_TYPE_MAP.put(BLOB, Integer.valueOf(Types.BLOB));
+ NAME_TO_TYPE_MAP.put(XML, Integer.valueOf(Types.JAVA_OBJECT));
+ NAME_TO_TYPE_MAP.put(NULL, Integer.valueOf(Types.NULL));
}
//java class names
@@ -99,31 +102,31 @@
public static final String CHAR_CLASS = DataTypeManager.DefaultDataClasses.CHAR.getName();
public static final String BIGINTEGER_CLASS = DataTypeManager.DefaultDataClasses.BIG_INTEGER.getName();
public static final String OBJECT_CLASS = DataTypeManager.DefaultDataClasses.OBJECT.getName();
- public static final String CLOB_CLASS = "java.sql.Clob"; //$NON-NLS-1$
- public static final String BLOB_CLASS = "java.sql.Blob"; //$NON-NLS-1$
- public static final String XML_CLASS = "com.metamatrix.core.jdbc.SQLXML"; //$NON-NLS-1$
+ public static final String CLOB_CLASS = Clob.class.getName();
+ public static final String BLOB_CLASS = Blob.class.getName();
+ public static final String XML_CLASS = SQLXML.class.getName();
- private static Map CLASSNAME_TO_TYPE_MAP = new HashMap();
+ private static Map<String, Integer> CLASSNAME_TO_TYPE_MAP = new HashMap<String, Integer>();
static {
- CLASSNAME_TO_TYPE_MAP.put(STRING_CLASS.toLowerCase(), new Integer(Types.VARCHAR));
- CLASSNAME_TO_TYPE_MAP.put(BOOLEAN_CLASS.toLowerCase(), new Integer(Types.BIT));
- CLASSNAME_TO_TYPE_MAP.put(TIME_CLASS.toLowerCase(), new Integer(Types.TIME));
- CLASSNAME_TO_TYPE_MAP.put(DATE_CLASS.toLowerCase(), new Integer(Types.DATE));
- CLASSNAME_TO_TYPE_MAP.put(TIMESTAMP_CLASS.toLowerCase(), new Integer(Types.TIMESTAMP));
- CLASSNAME_TO_TYPE_MAP.put(INTEGER_CLASS.toLowerCase(), new Integer(Types.INTEGER));
- CLASSNAME_TO_TYPE_MAP.put(FLOAT_CLASS.toLowerCase(), new Integer(Types.REAL));
- CLASSNAME_TO_TYPE_MAP.put(DOUBLE_CLASS.toLowerCase(), new Integer(Types.DOUBLE));
- CLASSNAME_TO_TYPE_MAP.put(BIGDECIMAL_CLASS.toLowerCase(), new Integer(Types.NUMERIC));
- CLASSNAME_TO_TYPE_MAP.put(BIGINTEGER_CLASS.toLowerCase(), new Integer(Types.NUMERIC));
- CLASSNAME_TO_TYPE_MAP.put(BYTE_CLASS.toLowerCase(), new Integer(Types.TINYINT));
- CLASSNAME_TO_TYPE_MAP.put(SHORT_CLASS.toLowerCase(), new Integer(Types.SMALLINT));
- CLASSNAME_TO_TYPE_MAP.put(LONG_CLASS.toLowerCase(), new Integer(Types.BIGINT));
- CLASSNAME_TO_TYPE_MAP.put(CHAR_CLASS.toLowerCase(), new Integer(Types.CHAR));
- CLASSNAME_TO_TYPE_MAP.put(OBJECT_CLASS.toLowerCase(), new Integer(Types.JAVA_OBJECT));
- CLASSNAME_TO_TYPE_MAP.put(CLOB_CLASS.toLowerCase(), new Integer(Types.CLOB));
- CLASSNAME_TO_TYPE_MAP.put(BLOB_CLASS.toLowerCase(), new Integer(Types.BLOB));
- CLASSNAME_TO_TYPE_MAP.put(XML_CLASS.toLowerCase(), new Integer(Types.JAVA_OBJECT));
+ CLASSNAME_TO_TYPE_MAP.put(STRING_CLASS.toLowerCase(), Integer.valueOf(Types.VARCHAR));
+ CLASSNAME_TO_TYPE_MAP.put(BOOLEAN_CLASS.toLowerCase(), Integer.valueOf(Types.BIT));
+ CLASSNAME_TO_TYPE_MAP.put(TIME_CLASS.toLowerCase(), Integer.valueOf(Types.TIME));
+ CLASSNAME_TO_TYPE_MAP.put(DATE_CLASS.toLowerCase(), Integer.valueOf(Types.DATE));
+ CLASSNAME_TO_TYPE_MAP.put(TIMESTAMP_CLASS.toLowerCase(), Integer.valueOf(Types.TIMESTAMP));
+ CLASSNAME_TO_TYPE_MAP.put(INTEGER_CLASS.toLowerCase(), Integer.valueOf(Types.INTEGER));
+ CLASSNAME_TO_TYPE_MAP.put(FLOAT_CLASS.toLowerCase(), Integer.valueOf(Types.REAL));
+ CLASSNAME_TO_TYPE_MAP.put(DOUBLE_CLASS.toLowerCase(), Integer.valueOf(Types.DOUBLE));
+ CLASSNAME_TO_TYPE_MAP.put(BIGDECIMAL_CLASS.toLowerCase(), Integer.valueOf(Types.NUMERIC));
+ CLASSNAME_TO_TYPE_MAP.put(BIGINTEGER_CLASS.toLowerCase(), Integer.valueOf(Types.NUMERIC));
+ CLASSNAME_TO_TYPE_MAP.put(BYTE_CLASS.toLowerCase(), Integer.valueOf(Types.TINYINT));
+ CLASSNAME_TO_TYPE_MAP.put(SHORT_CLASS.toLowerCase(), Integer.valueOf(Types.SMALLINT));
+ CLASSNAME_TO_TYPE_MAP.put(LONG_CLASS.toLowerCase(), Integer.valueOf(Types.BIGINT));
+ CLASSNAME_TO_TYPE_MAP.put(CHAR_CLASS.toLowerCase(), Integer.valueOf(Types.CHAR));
+ CLASSNAME_TO_TYPE_MAP.put(OBJECT_CLASS.toLowerCase(), Integer.valueOf(Types.JAVA_OBJECT));
+ CLASSNAME_TO_TYPE_MAP.put(CLOB_CLASS.toLowerCase(), Integer.valueOf(Types.CLOB));
+ CLASSNAME_TO_TYPE_MAP.put(BLOB_CLASS.toLowerCase(), Integer.valueOf(Types.BLOB));
+ CLASSNAME_TO_TYPE_MAP.put(XML_CLASS.toLowerCase(), Integer.valueOf(Types.SQLXML));
}
/**
@@ -138,7 +141,7 @@
return Types.NULL;
}
- Integer sqlType = (Integer)NAME_TO_TYPE_MAP.get(typeName.toLowerCase());
+ Integer sqlType = NAME_TO_TYPE_MAP.get(typeName.toLowerCase());
if (sqlType == null) {
return Types.JAVA_OBJECT;
@@ -159,7 +162,7 @@
return Types.NULL;
}
- Integer sqlType = (Integer)CLASSNAME_TO_TYPE_MAP.get(typeName.toLowerCase());
+ Integer sqlType = CLASSNAME_TO_TYPE_MAP.get(typeName.toLowerCase());
if (sqlType == null) {
return Types.JAVA_OBJECT;
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/TranslatedCommand.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/TranslatedCommand.java 2009-04-15 13:08:51 UTC (rev 776)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/TranslatedCommand.java 2009-04-15 14:21:25 UTC (rev 777)
@@ -112,13 +112,11 @@
* @return
*/
static boolean isBindEligible(ILiteral l) {
- if (TypeFacility.RUNTIME_TYPES.CLOB.equals(l.getType())
- || TypeFacility.RUNTIME_TYPES.BLOB.equals(l.getType())
- || TypeFacility.RUNTIME_TYPES.OBJECT.equals(l.getType())) {
- return true;
- }
- return false;
- }
+ return TypeFacility.RUNTIME_TYPES.XML.equals(l.getType())
+ || TypeFacility.RUNTIME_TYPES.CLOB.equals(l.getType())
+ || TypeFacility.RUNTIME_TYPES.BLOB.equals(l.getType())
+ || TypeFacility.RUNTIME_TYPES.OBJECT.equals(l.getType());
+ }
/**
* Return List of values to set on a prepared statement, if
15 years, 4 months
teiid SVN: r776 - branches/remove_psc/common-core/src/main/java/com/metamatrix/core/util.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-15 09:08:51 -0400 (Wed, 15 Apr 2009)
New Revision: 776
Modified:
branches/remove_psc/common-core/src/main/java/com/metamatrix/core/util/MetaMatrixProductVersion.java
Log:
Teiid 323 - refactured, removing unused Config API classes: ProductType, ProductTypeID and ConfigurationLock
Modified: branches/remove_psc/common-core/src/main/java/com/metamatrix/core/util/MetaMatrixProductVersion.java
===================================================================
--- branches/remove_psc/common-core/src/main/java/com/metamatrix/core/util/MetaMatrixProductVersion.java 2009-04-15 13:07:22 UTC (rev 775)
+++ branches/remove_psc/common-core/src/main/java/com/metamatrix/core/util/MetaMatrixProductVersion.java 2009-04-15 13:08:51 UTC (rev 776)
@@ -38,12 +38,5 @@
* If the product is in a patch version (i.e., 4.2.1) release, that will not be indicated.
*/
public static final String VERSION_NUMBER = ApplicationInfo.getInstance().getMajorReleaseNumber();
-
- // Changing any of these will force a change to config.xml and data_mmproducts_insert.sql
- // (see build.kits.server.common.config and build.kits.server.common.config.sql repectively)
- public static final String PLATFORM_TYPE_NAME = "Platform"; //$NON-NLS-1$
- public static final String METAMATRIX_SERVER_TYPE_NAME = "Integration Server"; //$NON-NLS-1$
- public static final String CONNECTOR_PRODUCT_TYPE_NAME = "Connectors"; //$NON-NLS-1$
- public static final String MODELER_PRODUCT_TYPE_NAME = "Modeler"; //$NON-NLS-1$
}
15 years, 4 months
teiid SVN: r775 - branches/remove_psc/console/src/main/java/com/metamatrix/console/ui/layout.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-15 09:07:22 -0400 (Wed, 15 Apr 2009)
New Revision: 775
Modified:
branches/remove_psc/console/src/main/java/com/metamatrix/console/ui/layout/PanelsTreeModel.java
Log:
Teiid 323 - removing product related tree nodes
Modified: branches/remove_psc/console/src/main/java/com/metamatrix/console/ui/layout/PanelsTreeModel.java
===================================================================
--- branches/remove_psc/console/src/main/java/com/metamatrix/console/ui/layout/PanelsTreeModel.java 2009-04-14 22:07:44 UTC (rev 774)
+++ branches/remove_psc/console/src/main/java/com/metamatrix/console/ui/layout/PanelsTreeModel.java 2009-04-15 13:07:22 UTC (rev 775)
@@ -50,7 +50,7 @@
public static final String SYS_LOG = "Log Viewer"; //$NON-NLS-1$
public static final Class SYSTEM_LOG_PANEL_CLASS =
com.metamatrix.console.ui.views.syslog.SysLogPanel.class;
- public static final String MM_SERVER = MetaMatrixProductVersion.METAMATRIX_SERVER_TYPE_NAME;
+// public static final String MM_SERVER = MetaMatrixProductVersion.METAMATRIX_SERVER_TYPE_NAME;
public static final String QUERIES = "Queries"; //$NON-NLS-1$
public static final Class QUERIES_PANEL_CLASS =
com.metamatrix.console.ui.views.queries.QueryPanel.class;
@@ -99,11 +99,10 @@
public static final Class SYSTEMLOGSETUP_PANEL_CLASS =
com.metamatrix.console.ui.views.logsetup.SystemLogSetUpPanel.class;
- public static final Object[] BLOCKED_ITEMS = new Object[] {RUNTIME,
- MM_SERVER, CONFIGURATION, AUTHORIZATION};
+ public static final Object[] BLOCKED_ITEMS = new Object[] {RUNTIME, CONFIGURATION, AUTHORIZATION};
private static final String MM_SERV_TIP =
- "The " + MM_SERVER + " product provides integrated information " + //$NON-NLS-1$ //$NON-NLS-2$
+ "The Data Services Platform product provides integrated information " + //$NON-NLS-1$ //$NON-NLS-2$
"access to disparate data sources"; //$NON-NLS-1$
// private static final String MB_SERV_TIP =
// "The " + MB_SERVER + " product manages enterprise metadata"; //$NON-NLS-1$
@@ -206,19 +205,13 @@
log.setToolTipText(tipText);
runtime.add(log);
- // MetaMatrixServer header node
- PanelsTreeNode runtimeMMServer = new PanelsTreeNode(MM_SERVER, null,
- connection, false);
- runtimeMMServer.setToolTipText(MM_SERV_TIP);
- runtime.add(runtimeMMServer);
-
// queries panel node
PanelsTreeNode queries = new PanelsTreeNode(QUERIES,
QUERIES_PANEL_CLASS, connection, false);
tipText = ConsolePlugin.Util.getString("PanelsTreeModel.queryPanel.tooltip"); //$NON-NLS-1$
queries.setToolTipText(tipText);
- runtimeMMServer.add(queries);
+ runtime.add(queries);
// transactions panel node
PanelsTreeNode transactions = new PanelsTreeNode(TRANSACTIONS,
@@ -226,7 +219,7 @@
transactions.setToolTipText(
"View and manage transactions that are currently being executed "
+ "in the MetaMatrix Server");
- runtimeMMServer.add(transactions);
+ runtime.add(transactions);
// --------------------------------------------------------------------------------
// setup Configuration header node
@@ -274,32 +267,26 @@
systeLogSetup.setToolTipText(tipText);
configuration.add(systeLogSetup);
- // MetaMatrixServer header node
- PanelsTreeNode configMMServer = new PanelsTreeNode(MM_SERVER, null,
- connection, false);
- configMMServer.setToolTipText(MM_SERV_TIP);
- configuration.add(configMMServer);
-
// VDB panel node
PanelsTreeNode vdb = new PanelsTreeNode(VDB, VDB_PANEL_CLASS,
connection, false);
tipText = ConsolePlugin.Util.getString("PanelsTreeModel.vdbPanel.tooltip"); //$NON-NLS-1$
vdb.setToolTipText(tipText);
- configMMServer.add(vdb);
+ configuration.add(vdb);
// connector bindings panel node
PanelsTreeNode bindings = new PanelsTreeNode(CONNECTOR_BINDINGS,
CONNECTOR_BINDINGS_PANEL_CLASS, connection, false);
tipText = ConsolePlugin.Util.getString("PanelsTreeModel.bindingsPanel.tooltip"); //$NON-NLS-1$
bindings.setToolTipText(tipText);
- configMMServer.add(bindings);
+ configuration.add(bindings);
// connectors panel node
PanelsTreeNode connectors = new PanelsTreeNode(CONNECTORS,
CONNECTOR_DEFINITIONS_PANEL_CLASS, connection, false);
tipText = ConsolePlugin.Util.getString("PanelsTreeModel.connectorsPanel.tooltip"); //$NON-NLS-1$
connectors.setToolTipText(tipText);
- configMMServer.add(connectors);
+ configuration.add(connectors);
// --------------------------------------------------------------------------------
// Security Tree Node
15 years, 4 months
teiid SVN: r774 - trunk/client-jdbc/src/main/java/com/metamatrix/jdbc.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-14 18:07:44 -0400 (Tue, 14 Apr 2009)
New Revision: 774
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
Log:
TEIID-479: providing a way to use non-delegating class loader if need. This will be used by the Designer until the dependency issues are resolved in Designer.
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-04-14 18:00:23 UTC (rev 773)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-04-14 22:07:44 UTC (rev 774)
@@ -375,7 +375,13 @@
}
URL[] dqpClassPath = runtimeClasspath.toArray(new URL[runtimeClasspath.size()]);
- this.classLoader = new URLClassLoader(dqpClassPath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());
+ boolean useNondelegation = Boolean.parseBoolean(info.getProperty("dqp.useNonDelegateClassloader", "false")); //$NON-NLS-1$ //$NON-NLS-2$
+ if (useNondelegation) {
+ this.classLoader = new NonDelegatingClassLoader(dqpClassPath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());
+ }
+ else {
+ this.classLoader = new URLClassLoader(dqpClassPath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());
+ }
String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
DriverManager.println(logMsg);
for (int i = 0; i < dqpClassPath.length; i++) {
15 years, 5 months
teiid SVN: r773 - branches/remove_psc/server/src/main/java/com/metamatrix/platform/admin/api/runtime.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-14 14:00:23 -0400 (Tue, 14 Apr 2009)
New Revision: 773
Modified:
branches/remove_psc/server/src/main/java/com/metamatrix/platform/admin/api/runtime/SystemStateBuilder.java
Log:
Teiid 323 - fixed serialization issued to due to removing PSCData
Modified: branches/remove_psc/server/src/main/java/com/metamatrix/platform/admin/api/runtime/SystemStateBuilder.java
===================================================================
--- branches/remove_psc/server/src/main/java/com/metamatrix/platform/admin/api/runtime/SystemStateBuilder.java 2009-04-14 17:59:24 UTC (rev 772)
+++ branches/remove_psc/server/src/main/java/com/metamatrix/platform/admin/api/runtime/SystemStateBuilder.java 2009-04-14 18:00:23 UTC (rev 773)
@@ -24,24 +24,26 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.ComponentDefnID;
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.DeployedComponent;
import com.metamatrix.common.config.api.HostID;
+import com.metamatrix.common.config.api.ServiceComponentDefnID;
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.VMComponentDefnID;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.registry.HostControllerRegistryBinding;
-import com.metamatrix.platform.registry.ServiceRegistryBinding;
import com.metamatrix.platform.registry.ProcessRegistryBinding;
+import com.metamatrix.platform.registry.ServiceRegistryBinding;
import com.metamatrix.platform.service.api.ServiceID;
import com.metamatrix.platform.service.api.ServiceState;
import com.metamatrix.platform.service.controller.ServicePropertyNames;
@@ -177,7 +179,7 @@
vmBinding.getProcessName(),
String.valueOf(vmBinding.getPort()),
null, // deployed component id
- new ArrayList(),
+ Collections.EMPTY_LIST,
false, // not deployed
true); // registered
}
@@ -185,9 +187,8 @@
// ServiceBindings for vm
List bindings = this.registry.getServiceBindings(vmBinding.getHostName(), vmBinding.getProcessName());
- // Map of pscIDs -> List of services
- Map svcMap = new HashMap();
- // List list = new ArrayList();
+ Set<ServiceComponentDefnID> serviceKeys = new HashSet<ServiceComponentDefnID>(bindings.size());
+ Set<ServiceData> serviceDatas = new HashSet<ServiceData>(bindings.size());
// get all running services from registry.
// for each create ServiceData object and add to the appropriate list
@@ -195,23 +196,11 @@
while (iter.hasNext()) {
ServiceRegistryBinding svcBinding = (ServiceRegistryBinding) iter.next();
- // get the pscID for service
-// ProductServiceConfigID id = svcBinding.getPscID();
-// if (id == null) {
-// id = new ProductServiceConfigID("Default PSC"); //$NON-NLS-1$
-// }
-// // get list for psc, if does not exist then create one.
-// List list = (List) pscMap.get(id);
-// if (list == null) {
-// list = new ArrayList();
-// pscMap.put(id, list);
-// }
-
// create a ServiceData object and add to list
// Note: createServiceData removes svc from global deployedServicesList.
- svcMap.put(svcBinding.getDeployedComponent().getServiceComponentDefnID(), createServiceData(svcBinding));
- // list.add(createServiceData(svcBinding));
- }
+ serviceKeys.add(svcBinding.getDeployedComponent().getServiceComponentDefnID());
+ serviceDatas.add(createServiceData(svcBinding));
+ }
// now get all deployed services for this vm that are not running.
List cmpList = new ArrayList(deployedComponents);
@@ -225,45 +214,30 @@
// check to see if this component belongs to this vm
if (vmBinding.getDeployedComponent().getID().equals(dCmp.getVMComponentDefnID()) &&
dCmp.getServiceComponentDefnID() != null &&
- ! svcMap.containsKey(dCmp.getServiceComponentDefnID() ) ){
+ ! serviceKeys.contains(dCmp.getServiceComponentDefnID() ) ){
- // ProductServiceConfigID id = dCmp.getProductServiceConfigID();
-// if (id == null) {
-// id = new ProductServiceConfigID("Default PSC"); //$NON-NLS-1$
-// }
-// List list = (List) pscMap.get(id);
-// if (list == null) {
-// list = new ArrayList();
-// pscMap.put(id, list);
-// }
String essentialStr = dCmp.getProperty(ServicePropertyNames.SERVICE_ESSENTIAL);
boolean essential = false;
if (essentialStr != null && essentialStr.trim().length() != 0) {
essential = Boolean.valueOf(essentialStr).booleanValue();
}
+
+ serviceKeys.add(dCmp.getServiceComponentDefnID());
+ serviceDatas.add(new ServiceData(null, dCmp.getComponentTypeID().getFullName(),
+ null, dCmp.getServiceComponentDefnID(),
+ dCmp.getName(), null,
+ ServiceState.STATE_NOT_REGISTERED, new Date(), essential, true, false, null));
+
- svcMap.put(dCmp.getServiceComponentDefnID(), new ServiceData(null, dCmp.getComponentTypeID().getFullName(),
- null, dCmp.getServiceComponentDefnID(),
- dCmp, null,
- ServiceState.STATE_NOT_REGISTERED, new Date(), essential, true, false, null)); // deployed, not registered.
+// svcMap.put(dCmp.getServiceComponentDefnID(), new ServiceData(null, dCmp.getComponentTypeID().getFullName(),
+// null, dCmp.getServiceComponentDefnID(),
+// dCmp.getName(), null,
+// ServiceState.STATE_NOT_REGISTERED, new Date(), essential, true, false, null)); // deployed, not registered.
deployedComponents.remove(dCmp);
}
}
}
-
- // ok we now have a map of Service ID's -> list of ServiceData objects
-
- // List pscList = new ArrayList();
- // Iterator pscIter = svcMap.keySet().iterator();
-// String processName = vmBinding.getProcessName();
-//
-// while (pscIter.hasNext()) {
-// ProductServiceConfigID pId = (ProductServiceConfigID) pscIter.next();
-// List sList = (List) pscMap.get(pId);
-// pscList.add(createPSCData(pId, sList, processName));
-// }
-
// determine if process/vm is deployed
VMComponentDefn dc = vmBinding.getDeployedComponent();
boolean deployed = deployedComponents.contains(dc);
@@ -272,11 +246,12 @@
deployedComponents.remove(dc);
}
+
return new ProcessData( vmBinding.getHostName(),
vmBinding.getProcessName(),
vmBinding.getPort(),
(VMComponentDefnID) vmBinding.getDeployedComponent().getID(),
- svcMap.values(),
+ serviceDatas,
deployed, true);
}
@@ -316,7 +291,7 @@
}
svcList.add(new ServiceData(null, dCmp.getComponentTypeID().getName(),
null, dCmp.getServiceComponentDefnID(),
- dCmp, null,
+ dCmp.getName(), null,
ServiceState.STATE_NOT_REGISTERED, new Date(), essential, true, false, null)); // deployed, not registered
}
@@ -372,7 +347,7 @@
deployedComponents.remove(deployedComponent);
}
- return new ServiceData(id,serviceName,instanceName,defnID,deployedComponent,queues,state,stateDate,essential, deployed, true, serviceBinding.getInitException()); // registered
+ return new ServiceData(id,serviceName,instanceName,defnID,deployedComponent.getName(),queues,state,stateDate,essential, deployed, true, serviceBinding.getInitException()); // registered
}
}
15 years, 5 months
teiid SVN: r772 - in branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform: service/api and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-14 13:59:24 -0400 (Tue, 14 Apr 2009)
New Revision: 772
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ComponentData.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/HostData.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ProcessData.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ServiceData.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/SystemState.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/service/api/ServiceID.java
Log:
Teiid 323 - added serializedid to impacted classes due to removing PSCData
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ComponentData.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ComponentData.java 2009-04-14 17:58:10 UTC (rev 771)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ComponentData.java 2009-04-14 17:59:24 UTC (rev 772)
@@ -30,7 +30,12 @@
*/
public class ComponentData implements Serializable {
- // Name that this object represents.
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1276023440163989298L;
+
+ // Name that this object represents.
private String name;
/** indicates if component is in operational configuration */
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/HostData.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/HostData.java 2009-04-14 17:58:10 UTC (rev 771)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/HostData.java 2009-04-14 17:59:24 UTC (rev 772)
@@ -30,8 +30,12 @@
*/
public class HostData extends ComponentData {
- // Collection of ProcessData objects
- private Collection processes;
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7192156515568357069L;
+ // Collection of ProcessData objects
+ private Collection<ProcessData> processes;
private Properties properties;
@@ -40,7 +44,7 @@
*
* @param hostName Name of host
*/
- public HostData(String hostName, Collection processes, boolean deployed, boolean registered, Properties props) {
+ public HostData(String hostName, Collection<ProcessData> processes, boolean deployed, boolean registered, Properties props) {
super(hostName, deployed, registered);
this.processes = processes;
this.properties = props;
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ProcessData.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ProcessData.java 2009-04-14 17:58:10 UTC (rev 771)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ProcessData.java 2009-04-14 17:59:24 UTC (rev 772)
@@ -23,7 +23,6 @@
package com.metamatrix.platform.admin.api.runtime;
import java.util.Collection;
-import java.util.Iterator;
import com.metamatrix.common.config.api.ComponentDefnID;
import com.metamatrix.core.util.HashCodeUtil;
@@ -34,9 +33,15 @@
*/
public class ProcessData extends ComponentData {
- /** Collection of serviceData objects */
- private Collection services;
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4648970293578256936L;
+
+ /** Collection of serviceData objects */
+ private Collection<ServiceData> services;
+
/** defines vm in configuration */
private ComponentDefnID defnID;
@@ -52,7 +57,7 @@
* @param vmController VMController implementation
* @param hostName Name of host VM is running on
*/
- public ProcessData(String hostName, String processName, String port, ComponentDefnID defnID, Collection services, boolean deployed, boolean registered) {
+ public ProcessData(String hostName, String processName, String port, ComponentDefnID defnID, Collection<ServiceData> services, boolean deployed, boolean registered) {
super(processName, deployed, registered);
this.hostName = hostName;
this.defnID = defnID;
@@ -67,7 +72,7 @@
*
* @return List of ServiceData objects
*/
- public Collection getServices() {
+ public Collection<ServiceData> getServices() {
return services;
}
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ServiceData.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ServiceData.java 2009-04-14 17:58:10 UTC (rev 771)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ServiceData.java 2009-04-14 17:59:24 UTC (rev 772)
@@ -26,14 +26,16 @@
import java.util.Date;
import com.metamatrix.common.config.api.ComponentDefnID;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.config.model.BasicServiceComponentDefn;
-
import com.metamatrix.platform.service.api.ServiceID;
public class ServiceData extends ComponentData {
- /** Identifies service for purpose of looking up in registry */
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2408872419190347292L;
+
+ /** Identifies service for purpose of looking up in registry */
private ServiceID serviceID;
/**
@@ -47,9 +49,7 @@
/** indicates if service is an essential service */
private boolean essential;
-
- private DeployedComponent deployedComponent;
-
+
/** defines service in configuration */
private ComponentDefnID defnID;
@@ -77,16 +77,16 @@
* @throws RegistryException if an an error occurs creating remote instance of service.
*/
public ServiceData(ServiceID serviceID, String serviceName, String instanceName,
- ComponentDefnID defnID, DeployedComponent deployedComponent,
+ ComponentDefnID defnID, String deployedComponentName,
Collection queueNames,
int state, Date time, boolean essential, boolean deployed,
boolean registered, Throwable initError) {
// super(serviceName, deployed, registered);
- super(BasicServiceComponentDefn.getDisplayableName(deployedComponent.getName()), deployed, registered);
+ super(deployedComponentName, deployed, registered);
this.serviceID = serviceID;
+
this.defnID = defnID;
- this.deployedComponent = deployedComponent;
this.queueNames = queueNames;
this.currentState = state;
this.stateChangeTime = time;
@@ -126,11 +126,7 @@
public ComponentDefnID getComponentDefnID() {
return this.defnID;
}
-
- public DeployedComponent getDeployedComponent() {
- return this.deployedComponent;
- }
-
+
public Throwable getInitError() {
return this.initError;
}
@@ -160,7 +156,10 @@
if ( obj instanceof ServiceData ) {
ServiceData that = (ServiceData) obj;
- return deployedComponent.equals(that.getDeployedComponent());
+ return (this.serviceID.getHostName().equals(that.getServiceID().getHostName()) &&
+ this.serviceID.getProcessName().equals(that.serviceID.getProcessName()) &&
+ this.getComponentDefnID().equals(that.getComponentDefnID()));
+//eployedComponent.equals(that.getDeployedComponent());
// return defnID.equals(that.getComponentDefnID());
}
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/SystemState.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/SystemState.java 2009-04-14 17:58:10 UTC (rev 771)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/SystemState.java 2009-04-14 17:59:24 UTC (rev 772)
@@ -36,7 +36,11 @@
*/
public class SystemState implements Serializable {
- private Collection hosts;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8316522636781619120L;
+ private Collection<HostData> hosts;
/**
* Create a new instance of VMRegistryBinding.
@@ -78,7 +82,7 @@
List services = new ArrayList();
- // loop thru all hosts/processes/psc and
+ // loop thru all hosts/processes and
// get serviceData objects.
Iterator hosts = this.hosts.iterator();
while (hosts.hasNext()) {
Modified: branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/service/api/ServiceID.java
===================================================================
--- branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/service/api/ServiceID.java 2009-04-14 17:58:10 UTC (rev 771)
+++ branches/remove_psc/common-internal/src/main/java/com/metamatrix/platform/service/api/ServiceID.java 2009-04-14 17:59:24 UTC (rev 772)
@@ -26,7 +26,11 @@
public class ServiceID implements Serializable {
- private long id;
+/**
+ *
+ */
+ private static final long serialVersionUID = 1776393684657738553L;
+ private long id;
private String hostName;
private String processName;
15 years, 5 months