Author: shawkins
Date: 2009-10-26 21:16:42 -0400 (Mon, 26 Oct 2009)
New Revision: 1542
Added:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java
Removed:
trunk/engine/src/main/java/com/metamatrix/query/util/TypeRetrievalUtil.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities/
Modified:
trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMetadataReader.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/DefaultCapabilitiesFinder.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.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/RulePushSelectCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchCollector.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
Log:
TEIID-203 correctly implementing the check for supportsSelectExpression. also merging
Connector and Shared capabilities finders, and removing TypeRetrievalUtil
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java 2009-10-25
02:09:27 UTC (rev 1541)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -100,13 +100,13 @@
* Creates a tuple source based on a schema and properties describing
* hints about the source
* @param elements Elements of the tuple source
- * @param groupName Tuple source group name
- * @param tupleSourceType Type of tuple source
+ * @param groupName Tuple source group name
+ * @param tupleSourceType Type of tuple source
* @return Identifier for tuple source
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- TupleSourceID createTupleSource(List elements, String[] types, String groupName,
TupleSourceType tupleSourceType)
+ TupleSourceID createTupleSource(List elements, String groupName, TupleSourceType
tupleSourceType)
throws MetaMatrixComponentException;
/**
Modified:
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -29,6 +29,7 @@
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -48,12 +49,14 @@
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.common.lob.LobChunk;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.Streamable;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.sql.symbol.Expression;
/**
* <p>Default implementation of BufferManager. This buffer manager implementation
@@ -242,18 +245,18 @@
/**
* Register a new tuple source and return a unique ID for it.
- * @param schema List of ElementSymbol
* @param groupName Group name
* @param tupleSourceType Type of tuple source as defined in BufferManager constants
+ * @param schema List of ElementSymbol
* @return New unique ID for this tuple source
* @throws MetaMatrixComponentException If internal server error occurs
*/
- public TupleSourceID createTupleSource(List schema, String[] types, String groupName,
TupleSourceType tupleSourceType)
+ public TupleSourceID createTupleSource(List schema, String groupName, TupleSourceType
tupleSourceType)
throws MetaMatrixComponentException {
TupleSourceID newID = new
TupleSourceID(String.valueOf(this.currentTuple.getAndIncrement()), this.lookup);
TupleGroupInfo tupleGroupInfo = getGroupInfo(groupName);
- TupleSourceInfo info = new TupleSourceInfo(newID, schema, types, tupleGroupInfo,
tupleSourceType);
+ TupleSourceInfo info = new TupleSourceInfo(newID, schema, getTypeNames(schema),
tupleGroupInfo, tupleSourceType);
tupleGroupInfo.getTupleSourceIDs().add(newID);
tupleSourceMap.put(newID, info);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR,
MessageLevel.DETAIL)) {
@@ -262,6 +265,21 @@
return newID;
}
+
+ /**
+ * Gets the data type names for each of the input expressions, in order.
+ * @param expressions List of Expressions
+ * @return
+ * @since 4.2
+ */
+ public static String[] getTypeNames(List expressions) {
+ String[] types = new String[expressions.size()];
+ for (ListIterator i = expressions.listIterator(); i.hasNext();) {
+ Expression expr = (Expression)i.next();
+ types[i.previousIndex()] = DataTypeManager.getDataTypeName(expr.getType());
+ }
+ return types;
+ }
/**
* Remove a tuple source based on ID
Modified:
trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMetadataReader.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMetadataReader.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMetadataReader.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -106,9 +106,7 @@
}
return methods;
} catch (JDOMException e) {
- IOException ex = new IOException();
- ex.initCause(e);
- throw ex;
+ throw new IOException(e);
}
}
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/DefaultCapabilitiesFinder.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/DefaultCapabilitiesFinder.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/DefaultCapabilitiesFinder.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -28,17 +28,23 @@
*/
public class DefaultCapabilitiesFinder implements CapabilitiesFinder {
+ private SourceCapabilities capabilities;
/**
*
*/
public DefaultCapabilitiesFinder() {
+ this.capabilities = new BasicSourceCapabilities();
}
+
+ public DefaultCapabilitiesFinder(SourceCapabilities capabilities) {
+ this.capabilities = capabilities;
+ }
/* (non-Javadoc)
* @see
com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder#findCapabilities(java.lang.Object)
*/
public SourceCapabilities findCapabilities(String modelName) throws
MetaMatrixComponentException {
- return new BasicSourceCapabilities();
+ return capabilities;
}
}
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -222,7 +222,7 @@
return supports(Capability.QUERY_SELECT_DISTINCT, modelID, metadata, capFinder);
}
- public static boolean supportsSelectLiterals(Object modelID, QueryMetadataInterface
metadata, CapabilitiesFinder capFinder)
+ public static boolean supportsSelectExpression(Object modelID, QueryMetadataInterface
metadata, CapabilitiesFinder capFinder)
throws QueryMetadataException, MetaMatrixComponentException {
return supports(Capability.QUERY_SELECT_EXPRESSION, modelID, metadata, capFinder);
}
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-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -183,7 +183,7 @@
}
public void visit(DependentSetCriteria obj) {
- if (checkForInput(obj.getExpression())) {
+ if (!obj.isNegated() && checkForInput(obj.getExpression()))
{
addInputNode((Reference)obj.getExpression());
}
}
@@ -197,9 +197,9 @@
return inputs.contains(ref.getExpression());
}
- boolean checkForAnyInput(LanguageObject expr) {
- for (Iterator refs =
ReferenceCollectorVisitor.getReferences(expr).iterator(); refs.hasNext();) {
- if (checkForInput((Expression)refs.next())) {
+ boolean checkForAnyInput(LanguageObject expr) {
+ for (Reference ref : ReferenceCollectorVisitor.getReferences(expr)) {
+ if (checkForInput(ref)) {
return true;
}
}
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-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -450,14 +450,11 @@
* @param elements
* @return
*/
- static boolean satisfyAccessPatterns(List aps, Collection elements) {
- for (Iterator i = aps.iterator(); i.hasNext();) {
- AccessPattern ap = (AccessPattern)i.next();
- if (ap.getCurrentElements().containsAll(elements)) {
- ap.getUnsatisfied().removeAll(elements);
- if (ap.getUnsatisfied().isEmpty()) {
- return true;
- }
+ static boolean satisfyAccessPatterns(List<AccessPattern> aps, Collection
elements) {
+ for (AccessPattern ap : aps) {
+ ap.getUnsatisfied().removeAll(elements);
+ if (ap.getUnsatisfied().isEmpty()) {
+ return true;
}
}
return false;
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-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -49,13 +49,11 @@
import com.metamatrix.query.sql.lang.JoinType;
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.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
import com.metamatrix.query.util.CommandContext;
public final class RuleRaiseAccess implements OptimizerRule {
@@ -368,11 +366,9 @@
return false;
}
- if(inSelectClause && !(expr instanceof ElementSymbol)) {
- if (!CapabilitiesUtil.supportsSelectLiterals(modelID, metadata, capFinder)
- && (expr instanceof Constant ||
EvaluatableVisitor.willBecomeConstant(expr))) {
- return false;
- }
+ if(inSelectClause && !(expr instanceof ElementSymbol || expr instanceof
AggregateSymbol)
+ && !CapabilitiesUtil.supportsSelectExpression(modelID, metadata,
capFinder)) {
+ return false;
}
// By default, no reason we can't push
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -244,6 +244,9 @@
*/
static boolean useNonDistinctRows(PlanNode parent) {
while (parent != null) {
+ if (parent.hasBooleanProperty(NodeConstants.Info.IS_DUP_REMOVAL)) {
+ return false;
+ }
switch (parent.getType()) {
case NodeConstants.Types.DUP_REMOVE: {
return false;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -40,7 +40,6 @@
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
@@ -85,7 +84,7 @@
// 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);
+ this.resultsID = bufferMgr.createTupleSource(processPlan.getOutputElements(),
context.getConnectionID(), TupleSourceType.PROCESSOR);
}
public CommandContext getContext() {
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchCollector.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchCollector.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchCollector.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -31,7 +31,6 @@
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.common.buffer.BufferManager.TupleSourceStatus;
import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.query.util.TypeRetrievalUtil;
public class BatchCollector {
@@ -45,7 +44,7 @@
public BatchCollector(RelationalNode sourceNode) throws MetaMatrixComponentException
{
this.sourceNode = sourceNode;
List sourceElements = sourceNode.getElements();
- tsID = sourceNode.getBufferManager().createTupleSource(sourceElements,
TypeRetrievalUtil.getTypeNames(sourceElements), sourceNode.getConnectionID(),
TupleSourceType.PROCESSOR);
+ tsID = sourceNode.getBufferManager().createTupleSource(sourceElements,
sourceNode.getConnectionID(), TupleSourceType.PROCESSOR);
}
public TupleSourceID collectTuples() throws MetaMatrixComponentException,
MetaMatrixProcessingException {
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -37,7 +37,6 @@
import com.metamatrix.query.function.aggregate.AggregateFunction;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.TypeRetrievalUtil;
/**
*/
@@ -50,7 +49,6 @@
// Derived and static - can be reused
private List elements;
- private String[] elementTypes;
private List sortTypes;
// Temporary state - should be reset
@@ -84,7 +82,6 @@
element.setType(inputType);
elements = new ArrayList();
elements.add(element);
- elementTypes = TypeRetrievalUtil.getTypeNames(elements);
sortTypes = new ArrayList();
sortTypes.add(Boolean.valueOf(OrderBy.ASC));
@@ -107,7 +104,7 @@
try {
if(collectionID == null) {
- collectionID = mgr.createTupleSource(elements, elementTypes, groupName,
TupleSourceType.PROCESSOR);
+ collectionID = mgr.createTupleSource(elements, groupName,
TupleSourceType.PROCESSOR);
this.tupleCollector = new TupleCollector(collectionID, mgr);
}
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -53,7 +53,6 @@
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.TypeRetrievalUtil;
public class GroupingNode extends RelationalNode {
@@ -148,7 +147,7 @@
// Determine expressions to build (all grouping expressions + expressions used by
aggregates)
collectExpressions();
- this.collectionID = getBufferManager().createTupleSource(collectedExpressions,
TypeRetrievalUtil.getTypeNames(collectedExpressions), getConnectionID(),
TupleSourceType.PROCESSOR);
+ this.collectionID = getBufferManager().createTupleSource(collectedExpressions,
getConnectionID(), TupleSourceType.PROCESSOR);
initializeFunctionAccumulators();
}
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -42,7 +42,6 @@
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.TypeRetrievalUtil;
/**
*/
@@ -66,7 +65,6 @@
//init state
private int batchSize;
protected List schema;
- private String[] schemaTypes;
protected int[] sortCols;
private ListNestedSortComparator comparator;
@@ -153,7 +151,7 @@
}
private TupleSourceID createTupleSource() throws MetaMatrixComponentException {
- return bufferManager.createTupleSource(this.schema, this.schemaTypes, this.groupName,
TupleSourceType.PROCESSOR);
+ return bufferManager.createTupleSource(this.schema, this.groupName,
TupleSourceType.PROCESSOR);
}
protected void initialSort() throws BlockedOnMemoryException,
TupleSourceNotFoundException, MetaMatrixComponentException {
@@ -405,7 +403,6 @@
private void initialize() throws TupleSourceNotFoundException,
MetaMatrixComponentException {
this.schema = this.bufferManager.getTupleSchema(this.sourceID);
- this.schemaTypes = TypeRetrievalUtil.getTypeNames(schema);
this.batchSize = bufferManager.getProcessorBatchSize();
int distinctIndex = sortElements != null? sortElements.size() - 1:0;
if (useAllColumns && mode != Mode.SORT) {
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -31,7 +31,6 @@
import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.buffer.TupleSourceNotFoundException;
import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.query.util.TypeRetrievalUtil;
class SourceState {
@@ -66,7 +65,7 @@
}
TupleSourceID createSourceTupleSource() throws MetaMatrixComponentException {
- return this.source.getBufferManager().createTupleSource(source.getElements(),
TypeRetrievalUtil.getTypeNames(source.getElements()), source.getConnectionID(),
TupleSourceType.PROCESSOR);
+ return this.source.getBufferManager().createTupleSource(source.getElements(),
source.getConnectionID(), TupleSourceType.PROCESSOR);
}
public List saveNext() throws MetaMatrixComponentException,
MetaMatrixProcessingException {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java 2009-10-25
02:09:27 UTC (rev 1541)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -102,7 +102,7 @@
* Creates a buffer manager's id for XML based data.
*/
public static TupleSourceID createXMLTupleSource(BufferManager bufferMgr, String
tupleGroupName) throws MetaMatrixComponentException {
- TupleSourceID sourceID = bufferMgr.createTupleSource(getOutputElements(), new
String[]{DataTypeManager.DefaultDataTypes.XML}, tupleGroupName,
TupleSourceType.PROCESSOR);
+ TupleSourceID sourceID = bufferMgr.createTupleSource(getOutputElements(),
tupleGroupName, TupleSourceType.PROCESSOR);
return sourceID;
}
Modified:
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2009-10-25
02:09:27 UTC (rev 1541)
+++
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -66,7 +66,6 @@
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.TypeRetrievalUtil;
/**
* @since 5.5
@@ -91,7 +90,7 @@
this.ts = buffer.getTupleSource(tsId);
List columns = buffer.getTupleSchema(tsId);
this.lookup = RelationalNode.createLookupMap(columns);
- this.newTs = buffer.createTupleSource(columns,
TypeRetrievalUtil.getTypeNames(columns), sessionID, TupleSourceType.PROCESSOR);
+ this.newTs = buffer.createTupleSource(columns, sessionID, TupleSourceType.PROCESSOR);
this.tc = new TupleCollector(newTs, buffer);
this.eval = new Evaluator(lookup, null, null);
this.crit = crit;
@@ -170,7 +169,7 @@
//add metadata
tempMetadataStore.addTempGroup(tempTableName, columns, false, true);
//create tuple source
- TupleSourceID tsId = buffer.createTupleSource(columns,
TypeRetrievalUtil.getTypeNames(columns), sessionID, TupleSourceType.PROCESSOR);
+ TupleSourceID tsId = buffer.createTupleSource(columns, sessionID,
TupleSourceType.PROCESSOR);
try {
buffer.setStatus(tsId, TupleSourceStatus.FULL);
}catch(TupleSourceNotFoundException e) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-10-25
02:09:27 UTC (rev 1541)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -168,7 +168,7 @@
public void setSessionFunctionEvaluated(boolean sessionFunctionEvaluated) {
if (parent != null) {
- parent.setCollectNodeStatistics(sessionFunctionEvaluated);
+ parent.setSessionFunctionEvaluated(sessionFunctionEvaluated);
} else {
this.sessionFunctionEvaluated = sessionFunctionEvaluated;
}
Deleted: trunk/engine/src/main/java/com/metamatrix/query/util/TypeRetrievalUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/TypeRetrievalUtil.java 2009-10-25
02:09:27 UTC (rev 1541)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/TypeRetrievalUtil.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -1,56 +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.util;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.symbol.Expression;
-
-
-/**
- * Utility to provide type names to pass to the BufferManager.createTupleSource()
method.
- * @since 4.2
- */
-public class TypeRetrievalUtil {
- private TypeRetrievalUtil() {} // Uninstantiable
-
- /**
- * Gets the data type names for each of the input expressions, in order.
- * @param expressions List of Expressions
- * @return
- * @since 4.2
- */
- public static String[] getTypeNames(List expressions) {
- String[] types = new String[expressions.size()];
- ListIterator i = expressions.listIterator();
- Expression expr = null;
- for (int index = 0; i.hasNext(); index++) {
- expr = (Expression)i.next();
- types[index] = DataTypeManager.getDataTypeName(expr.getType());
- }
- return types;
- }
-
-}
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-10-25
02:09:27 UTC (rev 1541)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -34,8 +34,6 @@
import javax.transaction.SystemException;
import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.dqp.internal.process.capabilities.ConnectorCapabilitiesFinder;
-import org.teiid.dqp.internal.process.capabilities.SharedCachedFinder;
import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
@@ -192,15 +190,12 @@
return;
}
// Prepare dependencies for running the optimizer
- CapabilitiesFinder baseFinder =
- new ConnectorCapabilitiesFinder(
+ this.capabilitiesFinder =
+ new SharedCachedFinder(
this.vdbService,
(DataService) this.env.findService(DQPServiceNames.DATA_SERVICE),
- requestMsg, workContext);
+ requestMsg, workContext, connectorCapabilitiesCache);
- // Wrap the finder with a cache
- this.capabilitiesFinder = new SharedCachedFinder(baseFinder,
connectorCapabilitiesCache);
-
MetadataService metadataService = (MetadataService)
this.env.findService(DQPServiceNames.METADATA_SERVICE);
if(metadataService == null){
//should not come here. Per defect 15087,
Added: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java
(rev 0)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java 2009-10-27
01:16:42 UTC (rev 1542)
@@ -0,0 +1,109 @@
+/*
+ * 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 org.teiid.dqp.internal.process;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+
+/**
+ */
+public class SharedCachedFinder implements CapabilitiesFinder {
+
+ private static BasicSourceCapabilities SYSTEM_CAPS = new BasicSourceCapabilities();
+
+ private VDBService vdbService;
+ private DataService dataService;
+ private RequestMessage requestMessage;
+ private DQPWorkContext workContext;
+
+ // Cache of SourceCapabilities by modelName
+ private Map<String, SourceCapabilities> capabilityCache; //synchronized
+ private Map<String, SourceCapabilities> userCache = new HashMap<String,
SourceCapabilities>(); //unsynchronized
+
+
+ /**
+ * Construct a CacheFinder that wraps another finder
+ * @param internalFinder Finder to wrap
+ * @param sharedCache The shared cache - map of model name to SourceCapabilities
+ */
+ public SharedCachedFinder(VDBService vdbService, DataService dataService,
RequestMessage requestMessage, DQPWorkContext workContext, Map<String,
SourceCapabilities> sharedCache) {
+ this.vdbService = vdbService;
+ this.dataService = dataService;
+ this.requestMessage = requestMessage;
+ this.workContext = workContext;
+ this.capabilityCache = sharedCache;
+ userCache.put(CoreConstants.SYSTEM_MODEL, SYSTEM_CAPS);
+ }
+
+ /**
+ * Find capabilities used the cache if possible, otherwise do the lookup.
+ */
+ public SourceCapabilities findCapabilities(String modelName) throws
MetaMatrixComponentException {
+ if (CoreConstants.SYSTEM_MODEL.equals(modelName)) {
+ return SYSTEM_CAPS;
+ }
+ SourceCapabilities caps = userCache.get(modelName);
+ if(caps != null) {
+ return caps;
+ }
+ caps = capabilityCache.get(modelName);
+ if(caps == null) {
+ // Find capabilities
+ List bindings = vdbService.getConnectorBindingNames(workContext.getVdbName(),
workContext.getVdbVersion(), modelName);
+ for(int i=0; i<bindings.size(); i++) {
+ try {
+ String connBinding = (String) bindings.get(i);
+ ConnectorID connector = dataService.selectConnector(connBinding);
+ caps = dataService.getCapabilities(requestMessage, workContext,
connector);
+ break;
+ }catch(MetaMatrixComponentException e) {
+ if(i == bindings.size()-1) {
+ throw e;
+ }
+ }
+ }
+ if(caps == null) {
+ throw new
MetaMatrixComponentException(DQPPlugin.Util.getString("SharedCacheFinder.Didnt_find_caps",
modelName)); //$NON-NLS-1$
+ }
+ }
+ if(caps.getScope() == SourceCapabilities.Scope.SCOPE_GLOBAL) {
+ capabilityCache.put(modelName, caps);
+ }
+ userCache.put(modelName, caps);
+ return caps;
+ }
+
+}
Property changes on:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain