Author: shawkins
Date: 2011-06-02 14:05:39 -0400 (Thu, 02 Jun 2011)
New Revision: 3212
Added:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLProjectionMinimizer.java
Removed:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/xml/JoinedWhileInstruction.java
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingAttribute.java
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingBaseNode.java
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingCriteriaNode.java
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingElement.java
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingNode.java
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeConstants.java
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingRecursiveElement.java
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/ResultSetInfo.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/MarkExcludeVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/NameInSourceResolverVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodePlannerVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/ValidateMappedCriteriaVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanToProcessVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLQueryPlanner.java
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/xml/XMLContext.java
branches/7.4.x/engine/src/main/java/org/teiid/query/sql/LanguageObject.java
branches/7.4.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingElement.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/xml/TestSourceNodeGenaratorVisitor.java
Log:
TEIID-1615 Adding back the project minimization feature that was left out of 5.5 and misc
xml cleanups.
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingAttribute.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingAttribute.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingAttribute.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -26,15 +26,12 @@
/**
- * A Mapping node which denotes a attribuite node.
+ * A Mapping node which denotes a attribute node.
*/
public class MappingAttribute extends MappingNode {
// Element symbol in the resultset source
ElementSymbol symbol;
- // Position of the element in the resultset source
- int position = -1;
-
// namespace of the attribute
Namespace namespace;
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingBaseNode.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingBaseNode.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingBaseNode.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -23,7 +23,6 @@
package org.teiid.query.mapping.xml;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.teiid.core.TeiidRuntimeException;
@@ -205,11 +204,11 @@
return false;
}
- public List getStagingTables() {
- return (List)getProperty(MappingNodeConstants.Properties.TEMP_GROUP_NAMES);
+ public List<String> getStagingTables() {
+ return
(List<String>)getProperty(MappingNodeConstants.Properties.TEMP_GROUP_NAMES);
}
- public void setStagingTables(List tables) {
+ public void setStagingTables(List<String> tables) {
if (tables != null) {
setProperty(MappingNodeConstants.Properties.TEMP_GROUP_NAMES, tables);
}
@@ -222,9 +221,9 @@
if (tablename == null) {
return;
}
- List tables = getStagingTables();
- if (tables == null || tables == Collections.EMPTY_LIST) {
- tables = new ArrayList();
+ List<String> tables = getStagingTables();
+ if (tables == null || tables.isEmpty()) {
+ tables = new ArrayList<String>();
}
tables.add(tablename);
setProperty(MappingNodeConstants.Properties.TEMP_GROUP_NAMES, tables);
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingCriteriaNode.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingCriteriaNode.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingCriteriaNode.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -22,8 +22,6 @@
package org.teiid.query.mapping.xml;
-import java.util.List;
-
import org.teiid.query.sql.lang.Criteria;
@@ -34,7 +32,6 @@
*/
public class MappingCriteriaNode extends MappingBaseNode{
boolean defalt;
- List criteriaGroups;
Criteria criteriaNode;
public MappingCriteriaNode(String criteria, boolean defalt) {
@@ -87,23 +84,6 @@
return this.criteriaNode;
}
- /**
- * Groups that are referenced inthe criteria string. This is set by
ValidateMappedCriteriaVisitor
- * class during the preplan.
- * @param criteriaGroups
- */
- public void setGroupsInCriteria(List criteriaGroups) {
- this.criteriaGroups = criteriaGroups;
- }
-
- /**
- * @deprecated - may not be needed
- * @return
- */
- public List getGroupsInCriteria() {
- return this.criteriaGroups;
- }
-
/**
* @see org.teiid.query.mapping.xml.MappingNode#isExcluded()
*/
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingElement.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingElement.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingElement.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -39,9 +39,6 @@
// Element symbol in the resultset source
ElementSymbol symbol;
- // Position of the element in the resultset source
- int position = -1;
-
Namespace namespace;
public MappingElement(String name) {
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingNode.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingNode.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingNode.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -52,7 +52,7 @@
private List<MappingNode> children = new LinkedList<MappingNode>();
/** node properties, as defined in NodeConstants.Properties. */
- private Map<Integer, Object> nodeProperties;
+ private Map<MappingNodeConstants.Properties, Object> nodeProperties;
/** default constructor */
public MappingNode(){
@@ -165,7 +165,7 @@
* @param propertyID Integer property key
* @return Object value
*/
- public Object getProperty(Integer propertyID) {
+ public Object getProperty(MappingNodeConstants.Properties propertyID) {
Object value = null;
if(nodeProperties != null) {
value = nodeProperties.get(propertyID);
@@ -183,11 +183,11 @@
* @param propertyID Integer property key
* @param value Object property value
*/
- void setProperty(Integer propertyID, Object value) {
+ void setProperty(MappingNodeConstants.Properties propertyID, Object value) {
if (value != null){
// Get the default for the property ...
final Object defaultValue =
MappingNodeConstants.Defaults.DEFAULT_VALUES.get(propertyID);
- final Map<Integer, Object> props = getNodeProperties(); // props
is never null
+ final Map<MappingNodeConstants.Properties, Object> props =
getNodeProperties(); // props is never null
if ( !value.equals(defaultValue) ) { // we know value is not null
// Set the value only if different than the default; note that the
'getProperty'
// method is returning the default if there isn't a value
@@ -200,7 +200,7 @@
}
}
- void removeProperty(Integer propertyID) {
+ void removeProperty(MappingNodeConstants.Properties propertyID) {
getNodeProperties().remove(propertyID);
}
@@ -212,9 +212,9 @@
* object.
* @see #getProperties
*/
- public Map<Integer, Object> getNodeProperties(){
+ public Map<MappingNodeConstants.Properties, Object> getNodeProperties(){
if(nodeProperties == null) {
- nodeProperties = new HashMap<Integer, Object>();
+ nodeProperties = new HashMap<MappingNodeConstants.Properties,
Object>();
}
return nodeProperties;
}
@@ -348,7 +348,7 @@
* {@link MappingNodeConstants#SEARCH_DOWN} or {@link
MappingNodeConstants#SEARCH_DOWN_BREADTH_FIRST}
* @return MappingNode first node found that has the indicated property and value, or
null if none found
*/
- static MappingNode findFirstNodeWithProperty(Integer propertyKey, Object value,
MappingNode node, int searchDirection) {
+ static MappingNode findFirstNodeWithProperty(MappingNodeConstants.Properties
propertyKey, Object value, MappingNode node, int searchDirection) {
return findFirstNodeWithPropertyValue(propertyKey, value, false, node,
searchDirection);
}
@@ -368,11 +368,11 @@
* {@link MappingNodeConstants#SEARCH_DOWN} or {@link
MappingNodeConstants#SEARCH_DOWN_BREADTH_FIRST}
* @return MappingNode first node found that has the indicated property and value, or
null if none found
*/
- static MappingNode findFirstNodeWithPropertyString(Integer propertyKey, String value,
MappingNode node, int searchDirection) {
+ static MappingNode findFirstNodeWithPropertyString(MappingNodeConstants.Properties
propertyKey, String value, MappingNode node, int searchDirection) {
return findFirstNodeWithPropertyValue(propertyKey, value, true, node,
searchDirection);
}
- private static MappingNode findFirstNodeWithPropertyValue(Integer propertyKey, Object
value, boolean isStringValue, MappingNode node, int searchDirection) {
+ private static MappingNode
findFirstNodeWithPropertyValue(MappingNodeConstants.Properties propertyKey, Object value,
boolean isStringValue, MappingNode node, int searchDirection) {
if (node == null || propertyKey == null){
return null;
@@ -392,7 +392,7 @@
}
}
- private static MappingNode traverseDownForFirstNodeWithPropertyString(Integer
propertyKey, Object value, boolean isStringValue, MappingNode node, boolean breadthFirst)
{
+ private static MappingNode
traverseDownForFirstNodeWithPropertyString(MappingNodeConstants.Properties propertyKey,
Object value, boolean isStringValue, MappingNode node, boolean breadthFirst) {
if (breadthFirst) {
Iterator<MappingNode> children = node.getChildren().iterator();
while (children.hasNext()){
@@ -421,7 +421,7 @@
return null;
}
- private static boolean checkThisNodeForPropertyValue(Integer propertyKey, Object
value, boolean isStringValue, MappingNode node) {
+ private static boolean checkThisNodeForPropertyValue(MappingNodeConstants.Properties
propertyKey, Object value, boolean isStringValue, MappingNode node) {
Object thisValue = node.getProperty(propertyKey);
if (thisValue != null){
if (value == null){
@@ -437,7 +437,7 @@
return false;
}
- private static MappingNode traverseUpForFirstNodeWithPropertyString(Integer
propertyKey, Object value, boolean isStringValue, MappingNode node) {
+ private static MappingNode
traverseUpForFirstNodeWithPropertyString(MappingNodeConstants.Properties propertyKey,
Object value, boolean isStringValue, MappingNode node) {
while (node != null){
if (checkThisNodeForPropertyValue(propertyKey, value, isStringValue, node)){
return node;
@@ -494,4 +494,8 @@
throw new TeiidRuntimeException(e);
}
}
+
+ public ElementSymbol getElementSymbol() {
+ return null;
+ }
}
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeConstants.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeConstants.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeConstants.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -151,18 +151,17 @@
* Property names for type-specific node properties. Values will be of
* type String unless otherwise specified.
*/
- public static final class Properties {
- private Properties() { }
+ public enum Properties {
/** The basic name of this node. Will be the element or attribute tag name. */
- public static final Integer NAME = new Integer(0);
+ NAME,
/**
* The namespace prefix, which indicates the namespace for this node.
* The namespace must be declared either at this node or an ancestor
* node; use the {@link #NAMESPACE_DECLARATIONS} property.
*/
- public static final Integer NAMESPACE_PREFIX = new Integer(1);
+ NAMESPACE_PREFIX,
/**
* <p>This property allows for one or more namespace declarations
@@ -182,42 +181,42 @@
* <pre><shipDate xsi:nil="true"/></pre>
* </p>
*/
- public static final Integer NAMESPACE_DECLARATIONS = new Integer(2);
+ NAMESPACE_DECLARATIONS,
/**
* The target node type. Can take on one of the values {@link #ATTRIBUTE}
* or {@link #ELEMENT}.
*/
- public static final Integer NODE_TYPE = new Integer(4); // Values:
ATTRIBUTE|ELEMENT
+ NODE_TYPE, // Values: ATTRIBUTE|ELEMENT
/**
* <p>The minimum number of times this node must occur in a
document.</p>
* <p>Type: <code>java.lang.Integer</code></p>
*/
- public static final Integer CARDINALITY_MIN_BOUND = new Integer(5);
+ CARDINALITY_MIN_BOUND,
/**
* <p>The maximum number of times this node may occur in a
document.</p>
* <p>Type: <code>java.lang.Integer</code></p>
*/
- public static final Integer CARDINALITY_MAX_BOUND = new Integer(6);
+ CARDINALITY_MAX_BOUND,
/**
* An optional constraint that applies for the node. If a constraint is
* defined, the input tuple to the node will be compared to the constraint.
* The node will be processed only if the constraint is satisfied.
*/
- public static final Integer CRITERIA = new Integer(7);
+ CRITERIA,
/**
* This property represents a default value for an XML node
*/
- public static final Integer DEFAULT_VALUE = new Integer(8);
+ DEFAULT_VALUE,
/**
* This property represents a fixed value for an XML node
*/
- public static final Integer FIXED_VALUE = new Integer(11);
+ FIXED_VALUE,
/**
* <p>Value will be of type Boolean. Indicates that the node is nillable,
@@ -226,11 +225,11 @@
* indicates when the element has null content.</p>
*
* <p><b>Note:</b> This property may only be set to true if
this node
- * is an element (i.e. the {@link #NODE_TYPE} property must have
+ * is an element (i.e. the {@link #NODETYPE} property must have
* a value of {@link #ELEMENT}), although this constraint is not
* enforced anywhere in the MappingNode framework.</p>
*/
- public static final Integer IS_NILLABLE = new Integer(9);
+ IS_NILLABLE,
/**
* <p>This node will be completely ignored, not output, not
@@ -238,11 +237,11 @@
* <p>Type: <code>java.lang.Boolean</code></p>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_IS_EXCLUDED}</p>
*/
- public static final Integer IS_EXCLUDED = new Integer(10);
+ IS_EXCLUDED,
/** The name of the result being returned by this node */
- public static final Integer RESULT_SET_NAME = new Integer(20);
+ RESULT_SET_NAME,
/**
* The name(s) of the temporary group(s) to be materialized at this
@@ -250,18 +249,18 @@
* <p>Type: <code>java.util.List</code> of
</code>java.lang.String</code>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_TEMP_GROUP_NAMES}</p>
*/
- public static final Integer TEMP_GROUP_NAMES = new Integer(23);
+ TEMP_GROUP_NAMES,
/** The symbol from a result set that maps to this node. */
- public static final Integer ELEMENT_NAME = new Integer(30);
+ ELEMENT_NAME,
/** The temporary property to mark whether this node should be included. */
- public static final Integer IS_INCLUDED = new Integer(15);
+ IS_INCLUDED,
/**
* The text for a comment.
*/
- public static final Integer COMMENT_TEXT = new Integer(16);
+ COMMENT_TEXT,
/**
* Indicates that the element or attribute is to be considered optional,
@@ -271,7 +270,7 @@
* <p>Type: <code>java.lang.Boolean</code>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_IS_OPTIONAL}</p>
*/
- public static final Integer IS_OPTIONAL = new Integer(22);
+ IS_OPTIONAL,
/**
* <p>Indicates the level of text normalization that will be applied
@@ -279,7 +278,7 @@
* <p>Type: <code>java.lang.String</code></p>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_NORMALIZE_TEXT}</p>
*/
- public static final Integer NORMALIZE_TEXT = new Integer(24);
+ NORMALIZE_TEXT,
/**
* Specifies the design-time base built-in type for the virtual document node.
@@ -288,7 +287,7 @@
* is used to determine special translations from the runtime value to the
expected
* XML schema output value string.
*/
- public static final Integer BUILT_IN_TYPE = new Integer(25);
+ BUILT_IN_TYPE,
// ========================================================================
// CHOICE NODE RELATED PROPERTIES
@@ -300,7 +299,7 @@
* <p>Type: <code>java.lang.Boolean</code></p>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_IS_DEFAULT_CHOICE}</p>
*/
- public static final Integer IS_DEFAULT_CHOICE = new Integer(40);
+ IS_DEFAULT_CHOICE,
/**
* <p>This property of a choice node indicates that, by
@@ -313,7 +312,7 @@
* <p>Type: <code>java.lang.Boolean</code></p>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_EXCEPTION_ON_DEFAULT}</p>
*/
- public static final Integer EXCEPTION_ON_DEFAULT = new Integer(42);
+ EXCEPTION_ON_DEFAULT,
// ========================================================================
// RECURSI0N RELATED PROPERTIES
@@ -324,7 +323,7 @@
* <p>Type: <code>java.lang.Boolean</code></p>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_IS_RECURSIVE}</p>
*/
- public static final Integer IS_RECURSIVE = new Integer(59);
+ IS_RECURSIVE,
/**
* The criteria of a node representing the root of a recursive
@@ -332,7 +331,7 @@
* recursion should terminate. i.e. "resultSetName.employeeName =
'Jones'"
* @see #RECURSION_LIMIT
*/
- public static final Integer RECURSION_CRITERIA = new Integer(50);
+ RECURSION_CRITERIA,
/**
* The recursion limit of a recursive XML fragment - if the
@@ -343,7 +342,7 @@
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_RECURSION_LIMIT}</p>
* @see #EXCEPTION_ON_RECURSION_LIMIT
*/
- public static final Integer RECURSION_LIMIT = new Integer(51);
+ RECURSION_LIMIT,
/**
* If recursion is terminated due to the safeguard {@link #RECURSION_LIMIT}
being
@@ -353,7 +352,7 @@
* @see #RECURSION_CRITERIA
* @see #RECURSION_LIMIT
*/
- public static final Integer EXCEPTION_ON_RECURSION_LIMIT = new Integer(52);
+ EXCEPTION_ON_RECURSION_LIMIT,
/**
* This property should be set on each document node at which a recursive
@@ -363,14 +362,14 @@
* document).
* <p>Type: <code>java.lang.String</code></p>
*/
- public static final Integer RECURSION_ROOT_MAPPING_CLASS = new Integer(53);
+ RECURSION_ROOT_MAPPING_CLASS,
/**
* Indicates if the node is the root of a recursive XML fragment or not.
* <p>Type: <code>java.lang.Boolean</code></p>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_IS_RECURSIVE_ROOT}</p>
*/
- public static final Integer IS_RECURSIVE_ROOT = new Integer(54);
+ IS_RECURSIVE_ROOT,
//
==================================================================================
// DOCUMENT PROPERTIES (read from root node only, applicable to document as a
whole)
@@ -381,7 +380,7 @@
* set at the root MappingNode of the document.</p>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_DOCUMENT_ENCODING}</p>
*/
- public static final Integer DOCUMENT_ENCODING = new Integer(80);
+ DOCUMENT_ENCODING,
/**
* <p>Indicates whether the document will be outputted as a compressed
@@ -391,14 +390,14 @@
* <p>Type: <code>java.lang.Boolean</code></p>
* <p>Default: {@link
MappingNodeConstants.Defaults#DEFAULT_FORMATTED_DOCUMENT}</p>
*/
- public static final Integer FORMATTED_DOCUMENT = new Integer(81);
+ FORMATTED_DOCUMENT,
/**
* A property to mark to implicity include a node which needs to be
* added to result document. The implicit nodes are such nodes which
* define the encoding information and type defination information.
*/
- public static final Integer ALWAYS_INCLUDE = new Integer(82);
+ ALWAYS_INCLUDE,
/**
* In the case of the recursive mapping element nodes, the source nodes
@@ -406,13 +405,13 @@
* (i.e. mapping class in recurive node) is alias to the source node which is
* above the recursive node.
*/
- public static final Integer ALIAS_RESULT_SET_NAME = new Integer(83);
+ ALIAS_RESULT_SET_NAME,
/**
* Result Set Info object which contains the query and the plan for
* the source node.
*/
- public static final Integer RESULT_SET_INFO = new Integer(84);
+ RESULT_SET_INFO,
}
// =========================================================================
@@ -487,11 +486,11 @@
* manner. Some tags are left out that the MappingOutputter
* handles separately.
*/
- static final List OUTPUTTER_PROPERTY_TAGS;
+ static final List<String> OUTPUTTER_PROPERTY_TAGS;
// Initialize static variables...
static {
- List temp = Arrays.asList( new String[]{
+ List<String> temp = Arrays.asList( new String[]{
MappingNodeConstants.Tags.NAME,
MappingNodeConstants.Tags.NODE_TYPE,
MappingNodeConstants.Tags.NAMESPACE_PREFIX,
@@ -535,7 +534,7 @@
* defined in {@link Properties}
* @see getPropertyString
*/
- public static final Integer getPropertyInteger(String property) {
+ public static final MappingNodeConstants.Properties getProperty(String property) {
if(property.equals(Tags.NAME)) return Properties.NAME;
else if (property.equals(Tags.NAMESPACE_PREFIX)) return
Properties.NAMESPACE_PREFIX;
else if (property.equals(Tags.NODE_TYPE)) return Properties.NODE_TYPE;
@@ -626,7 +625,7 @@
* {@link MappingNodeConstants.Properties}. The {@link MappingNode} class will
return
* these values if none are defined, for each property.
*/
- public static final Map DEFAULT_VALUES;
+ public static final Map<Properties, Object> DEFAULT_VALUES;
/** The default minimum bound of the cardinality of a node. */
public static final Integer DEFAULT_CARDINALITY_MINIMUM_BOUND = new Integer(1);
@@ -695,7 +694,7 @@
public static final Boolean DEFAULT_FORMATTED_DOCUMENT = Boolean.FALSE;
static{
- HashMap temp = new HashMap();
+ HashMap<Properties, Object> temp = new HashMap<Properties,
Object>();
temp.put(Properties.CARDINALITY_MIN_BOUND,
DEFAULT_CARDINALITY_MINIMUM_BOUND);
temp.put(Properties.CARDINALITY_MAX_BOUND,
DEFAULT_CARDINALITY_MAXIMUM_BOUND);
temp.put(Properties.NODE_TYPE, DEFAULT_NODE_TYPE);
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -129,10 +129,10 @@
* @throws XMLStreamException
*/
void addElementProperties(Map properties ) throws XMLStreamException {
- Iterator propNames =
MappingNodeConstants.Tags.OUTPUTTER_PROPERTY_TAGS.iterator();
+ Iterator<String> propNames =
MappingNodeConstants.Tags.OUTPUTTER_PROPERTY_TAGS.iterator();
while ( propNames.hasNext() ) {
- String propName = (String)propNames.next();
- Integer propKey = MappingNodeConstants.getPropertyInteger(propName);
+ String propName = propNames.next();
+ MappingNodeConstants.Properties propKey =
MappingNodeConstants.getProperty(propName);
if ( properties.containsKey(propKey) ) {
Object value = properties.get(propKey);
addElementProperty( propName, value );
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingRecursiveElement.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingRecursiveElement.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/MappingRecursiveElement.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -22,8 +22,6 @@
package org.teiid.query.mapping.xml;
-import java.util.List;
-
import org.teiid.query.sql.lang.Criteria;
@@ -34,7 +32,6 @@
* upto given depth limit.
*/
public class MappingRecursiveElement extends MappingElement {
- List criteriaGroups;
Criteria criteriaNode;
public MappingRecursiveElement(String name, String mappingClass) {
@@ -114,19 +111,6 @@
}
/**
- * Groups that are referenced inthe criteria string. This is set by
ValidateMappedCriteriaVisitor
- * class during the preplan.
- * @param criteriaGroups
- */
- public void setGroupsInCriteria(List criteriaGroups) {
- this.criteriaGroups = criteriaGroups;
- }
-
- public List getGroupsInCriteria() {
- return this.criteriaGroups;
- }
-
- /**
* This is parsed and resolved criteria node based on the criteria string. This is
set by
* ValidateMappedCriteriaVisitor class during pre planning.
* @param node
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/ResultSetInfo.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/ResultSetInfo.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/mapping/xml/ResultSetInfo.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -23,7 +23,6 @@
package org.teiid.query.mapping.xml;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.teiid.query.processor.ProcessorPlan;
@@ -45,9 +44,6 @@
// The result set command
private Command rsCommand;
- // The bound references for this result set: List<Reference>
- private List boundReferences;
-
// The processor plan output for the result set
private ProcessorPlan rsPlan;
@@ -68,8 +64,6 @@
private boolean stagedResult = false;
//joined source node state
- private boolean joinedWithParent = false;
- private boolean joinRoot = false;
private int mappingClassNumber = 0;
private ElementSymbol mappingClassSymbol;
@@ -150,13 +144,10 @@
public Object clone() {
ResultSetInfo clone = new ResultSetInfo(this.resultSetName, this.stagedResult);
clone.rsPlan = this.rsPlan;
- clone.boundReferences = this.boundReferences;
clone.userRowLimit = this.userRowLimit;
clone.exceptionOnRowLimit = this.exceptionOnRowLimit;
clone.rsCommand = (Command)this.rsCommand.clone();
clone.criteriaRaised = this.criteriaRaised;
- clone.joinedWithParent = this.joinedWithParent;
- clone.joinRoot = this.joinRoot;
clone.mappingClassNumber = this.mappingClassNumber;
clone.mappingClassSymbol = this.mappingClassSymbol;
return clone;
@@ -166,22 +157,6 @@
return resultSetName + ", resultSetObject " + rsCommand; //$NON-NLS-1$
}
- public boolean isJoinedWithParent() {
- return this.joinedWithParent;
- }
-
- public void setJoinedWithParent(boolean joinedWithParent) {
- this.joinedWithParent = joinedWithParent;
- }
-
- public boolean isJoinRoot() {
- return this.joinRoot;
- }
-
- public void setJoinRoot(boolean joinRoot) {
- this.joinRoot = joinRoot;
- }
-
public int getMappingClassNumber() {
return this.mappingClassNumber;
}
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/MarkExcludeVisitor.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/MarkExcludeVisitor.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/MarkExcludeVisitor.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -40,13 +40,13 @@
/**
- * This vistor marks all the nodes in the Mapping Document to
+ * This visitor marks all the nodes in the Mapping Document to
* "exclude".
*/
public class MarkExcludeVisitor extends MappingVisitor{
- HashSet keepNodes;
+ HashSet<String> keepNodes;
- public MarkExcludeVisitor(HashSet keppNodes) {
+ public MarkExcludeVisitor(HashSet<String> keppNodes) {
this.keepNodes = keppNodes;
}
@@ -132,7 +132,7 @@
}
}
- public static MappingDocument markExcludedNodes(MappingDocument doc, HashSet
keepNodes) {
+ public static MappingDocument markExcludedNodes(MappingDocument doc,
HashSet<String> keepNodes) {
MarkExcludeVisitor visitor = new MarkExcludeVisitor(keepNodes);
doc.acceptVisitor(new Navigator(true, visitor));
return doc;
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/NameInSourceResolverVisitor.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/NameInSourceResolverVisitor.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/NameInSourceResolverVisitor.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -61,12 +61,12 @@
Map symbols = element.getSymbolMap();
- List elements = new LinkedList();
+ List<ElementSymbol> elements = new LinkedList<ElementSymbol>();
for (Iterator i = symbols.values().iterator(); i.hasNext();) {
Object symbol = i.next();
if (symbol instanceof ElementSymbol) {
- elements.add(symbol);
+ elements.add((ElementSymbol)symbol);
}
}
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodePlannerVisitor.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodePlannerVisitor.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodePlannerVisitor.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -125,7 +125,7 @@
// root source nodes do not have any inputset criteria on them; so there is
no use in
// going through the raising the criteria.
// if the original query is not a select.. we are out of luck. we can expand
on this later
- // versions. make ure bindings are only to parent.
+ // versions. make sure bindings are only to parent.
if (parent == null || !canRaiseInputset(command, bindings) ||
!areBindingsOnlyToNode(modifiedNode, parent)) {
return;
}
@@ -418,14 +418,14 @@
*/
@Override
protected void walkChildNodes(MappingNode element) {
- List children = new ArrayList(element.getNodeChildren());
- for(Iterator i=children.iterator(); i.hasNext();) {
+ List<MappingNode> children = new
ArrayList<MappingNode>(element.getNodeChildren());
+ for(Iterator<MappingNode> i=children.iterator(); i.hasNext();)
{
if (shouldAbort()) {
break;
}
- MappingNode node = (MappingNode)i.next();
+ MappingNode node = i.next();
node.acceptVisitor(this);
}
}
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/ValidateMappedCriteriaVisitor.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/ValidateMappedCriteriaVisitor.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/ValidateMappedCriteriaVisitor.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -22,10 +22,6 @@
package org.teiid.query.optimizer.xml;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import org.teiid.api.exception.query.QueryMetadataException;
@@ -40,8 +36,6 @@
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.util.ResolverVisitor;
import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
import org.teiid.query.sql.visitor.StaticSymbolMappingVisitor;
@@ -60,9 +54,7 @@
Map symbolMap = element.getSourceNode().buildFullSymbolMap();
Criteria criteria = resolveCriteria(criteriaStr, symbolMap);
if (criteria != null) {
- List groupNames = getCriteriaGroups(criteria);
element.setCriteriaNode(criteria);
- element.setGroupsInCriteria(groupNames);
}
}
@@ -71,9 +63,7 @@
Map symbolMap = element.getSourceNode().buildFullSymbolMap();
Criteria criteria = resolveCriteria(criteriaStr, symbolMap);
if (criteria != null) {
- List groupNames = getCriteriaGroups(criteria);
element.setCriteriaNode(criteria);
- element.setGroupsInCriteria(groupNames);
}
}
@@ -91,17 +81,6 @@
return null;
}
- private static List getCriteriaGroups(Criteria criteria) {
- Collection criteriaGroups = GroupsUsedByElementsVisitor.getGroups(criteria);
- List names = new ArrayList(criteriaGroups.size());
- Iterator iter = criteriaGroups.iterator();
- while(iter.hasNext()) {
- names.add( ((GroupSymbol)iter.next()).getName().toUpperCase() );
- }
- return names;
- }
-
-
public static void validateAndCollectCriteriaElements(MappingDocument doc,
XMLPlannerEnvironment planEnv)
throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanToProcessVisitor.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanToProcessVisitor.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanToProcessVisitor.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -22,7 +22,6 @@
package org.teiid.query.optimizer.xml;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Stack;
@@ -53,7 +52,6 @@
import org.teiid.query.processor.xml.ExecStagingTableInstruction;
import org.teiid.query.processor.xml.IfInstruction;
import org.teiid.query.processor.xml.InitializeDocumentInstruction;
-import org.teiid.query.processor.xml.JoinedWhileInstruction;
import org.teiid.query.processor.xml.MoveCursorInstruction;
import org.teiid.query.processor.xml.MoveDocInstruction;
import org.teiid.query.processor.xml.ProcessorInstruction;
@@ -258,19 +256,6 @@
String source = node.getActualResultSetName();
ResultSetInfo info= node.getResultSetInfo();
- if (info.isJoinedWithParent()) {
- //create a dependent while loop
- JoinedWhileInstruction whileInst = new JoinedWhileInstruction(source, new
Integer(info.getMappingClassNumber()),
-
info.getMappingClassSymbol(), node.getResultName());
- currentProgram.addInstruction(whileInst);
-
- Program childProgram = new Program();
- whileInst.setBlockProgram(childProgram);
-
- programStack.push(childProgram);
- return;
- }
-
// Add instruction to execute relational query
ExecSqlInstruction sqlInst = new ExecSqlInstruction(source, info);
currentProgram.addInstruction(sqlInst);
@@ -306,10 +291,8 @@
String source = node.getActualResultSetName();
ResultSetInfo info= node.getResultSetInfo();
- if (!info.isJoinRoot()) {
- // move to next row.
- currentProgram.addInstruction(new MoveCursorInstruction(source));
- }
+ // move to next row.
+ currentProgram.addInstruction(new MoveCursorInstruction(source));
// Since each element with a source started a new program;
// since now we are done with children, we need to pop to current program
@@ -343,15 +326,14 @@
startRootRecursive(node, context);
}
- List stagingTables = node.getStagingTables();
- for (final Iterator i = stagingTables.iterator(); i.hasNext();) {
- final String table = (String)i.next();
+ List<String> stagingTables = node.getStagingTables();
+ for (String table : stagingTables) {
Program currentProgram = (Program)programStack.peek();
// load staging
currentProgram.addInstruction(new ExecStagingTableInstruction(table,
planEnv.getStagingTableResultsInfo(table)));
- // unload sttaging
+ // unload staging
String unloadName = planEnv.unLoadResultName(table);
cleanupProgram.addInstruction(new ExecStagingTableInstruction(unloadName,
planEnv.getStagingTableResultsInfo(unloadName)));
} // for
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -201,24 +201,28 @@
if (debug) {
debugDocumentInfo("After Exclude", planEnv); //$NON-NLS-1$
}
+
+ //Resolve all the "elements" against the result sets
+ NameInSourceResolverVisitor.resolveElements(planEnv.mappingDoc, planEnv);
+ //Validate and resolve the criteria specified on the mapping nodes.
+
ValidateMappedCriteriaVisitor.validateAndCollectCriteriaElements(planEnv.mappingDoc,
planEnv);
+
+ XMLProjectionMinimizer.minimizeProjection(planEnv);
+
+ if (debug) {
+ debugDocumentInfo("After Projection Minimization", planEnv);
//$NON-NLS-1$
+ }
+
// Autostage queries. try to auto-stage the planned queries
// removal of this step should not affect overall processing
XMLStagaingQueryPlanner.stageQueries(planEnv.mappingDoc, planEnv);
- //JoinSourceNodes.joinSourceNodes(planEnv.mappingDoc, planEnv);
-
//Plan the various relational result sets
XMLQueryPlanner.optimizeQueries(planEnv.mappingDoc, planEnv);
//Handle nillable nodes
planEnv.mappingDoc = HandleNillableVisitor.execute(planEnv.mappingDoc);
-
- //Resolve all the "elements" aginst the result sets
- NameInSourceResolverVisitor.resolveElements(planEnv.mappingDoc, planEnv);
-
- //Validate and resolve the criteria specified on the mapping nodes.
-
ValidateMappedCriteriaVisitor.validateAndCollectCriteriaElements(planEnv.mappingDoc,
planEnv);
}
static void removeExcluded(MappingNode node) {
Added:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLProjectionMinimizer.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLProjectionMinimizer.java
(rev 0)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLProjectionMinimizer.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -0,0 +1,202 @@
+/*
+ * 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.query.optimizer.xml;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingCriteriaNode;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+
+public class XMLProjectionMinimizer {
+
+ /**
+ * Implements projection minimization through two passes over the document
+ */
+ static void minimizeProjection(final XMLPlannerEnvironment planEnv) {
+ final HashMap<MappingSourceNode, LinkedHashSet<ElementSymbol>>
neededElements = new HashMap<MappingSourceNode,
LinkedHashSet<ElementSymbol>>();
+
+ //collect included elements
+ MappingVisitor visitor = new Navigator(true, new MappingVisitor() {
+ @Override
+ public void visit(MappingAttribute attribute) {
+ collectElementSymbol(attribute);
+ }
+
+ private void collectElementSymbol(MappingNode node) {
+ if (node.isExcluded() || node.getElementSymbol() == null) {
+ return;
+ }
+ MappingSourceNode msn = node.getSourceNode();
+ ElementSymbol es = node.getElementSymbol();
+ collectElementSymbol(msn, es);
+ }
+
+ private void collectElementSymbol(
+ MappingSourceNode msn, ElementSymbol es) {
+ msn = getActualSourceNode(msn);
+ LinkedHashSet<ElementSymbol> elems = neededElements.get(msn);
+ if (elems == null) {
+ elems = new LinkedHashSet<ElementSymbol>();
+ neededElements.put(msn, elems);
+ }
+ elems.add(es);
+ }
+
+ @Override
+ public void visit(MappingElement element) {
+ collectElementSymbol(element);
+ }
+
+ @Override
+ public void visit(MappingSourceNode element) {
+ try {
+ QueryNode node = QueryUtil.getQueryNode(element.getResultName(),
planEnv.getGlobalMetadata());
+
+ Collection<ElementSymbol> bindings =
QueryUtil.getBindingElements(node);
+ MappingSourceNode parent = element.getParentSourceNode();
+ parent = collectElementSymbols(element, bindings, parent);
+ } catch (TeiidException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ private MappingSourceNode collectElementSymbols(
+ MappingSourceNode element,
+ Collection<ElementSymbol> bindings, MappingSourceNode parent) {
+ for (ElementSymbol elementSymbol : bindings) {
+ if (element != null) {
+ elementSymbol = element.getMappedSymbol(elementSymbol);
+ }
+ while (parent != null) {
+ if
(parent.getActualResultSetName().equalsIgnoreCase(elementSymbol.getGroupSymbol().getNonCorrelationName()))
{
+ collectElementSymbol(parent, elementSymbol);
+ break;
+ }
+ parent = parent.getParentSourceNode();
+ }
+ }
+ return parent;
+ }
+
+ @Override
+ public void visit(MappingCriteriaNode element) {
+ Criteria crit = element.getCriteriaNode();
+ if (crit == null) {
+ return;
+ }
+ collectElementSymbols(null, ElementCollectorVisitor.getElements(crit, true),
element.getSourceNode());
+ }
+
+ @Override
+ public void visit(MappingRecursiveElement element) {
+ Criteria crit = element.getCriteriaNode();
+ if (crit == null) {
+ return;
+ }
+ collectElementSymbols(null, ElementCollectorVisitor.getElements(crit, true),
element.getSourceNode());
+ }
+
+ });
+ planEnv.mappingDoc.acceptVisitor(visitor);
+
+ visitor = new Navigator(true, new MappingVisitor() {
+ @Override
+ public void visit(MappingSourceNode element) {
+ try {
+ ResultSetInfo rsInfo = element.getResultSetInfo();
+ Query rsQuery = (Query)rsInfo.getCommand();
+ if (rsQuery.getSelect().isDistinct()) {
+ return;
+ }
+ LinkedHashSet<ElementSymbol> elements = neededElements.get(element);
+ if (elements != null) {
+ rsQuery.setSelect(new Select(LanguageObject.Util.deepClone(elements,
ElementSymbol.class)));
+ } else {
+ String alias = element.getAliasResultName();
+ if (alias == null) {
+ rsQuery.setSelect(new Select(Arrays.asList(new
ExpressionSymbol("foo", new Constant(1))))); //$NON-NLS-1$
+ } else {
+ MappingSourceNode actual = getActualSourceNode(element);
+ elements = neededElements.get(actual);
+ if (elements != null) {
+ Map reverseMap = QueryUtil.createSymbolMap(new
GroupSymbol(element.getAliasResultName()),
+ rsInfo.getResultSetName(),
+ ResolverUtil.resolveElementsInGroup(QueryUtil.createResolvedGroup(element.getAliasResultName(),
planEnv.getGlobalMetadata()), planEnv.getGlobalMetadata()));
+ Select select = new Select(new ArrayList<SelectSymbol>(elements));
+ ExpressionMappingVisitor.mapExpressions(select, reverseMap);
+ rsQuery.setSelect(select);
+ }
+ }
+ }
+ } catch (TeiidException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ });
+ planEnv.mappingDoc.acceptVisitor(visitor);
+ }
+
+ private static MappingSourceNode getActualSourceNode(MappingSourceNode element) {
+ if (element.getAliasResultName() == null) {
+ return element;
+ }
+ String actual = element.getActualResultSetName();
+ MappingSourceNode parent = element.getParentSourceNode();
+ while (parent != null) {
+ if (parent.getActualResultSetName().equalsIgnoreCase(actual) ) {
+ return parent;
+ }
+ parent = parent.getParentSourceNode();
+ }
+ return null;
+ }
+
+}
Property changes on:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLProjectionMinimizer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLQueryPlanner.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLQueryPlanner.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/xml/XMLQueryPlanner.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -71,6 +71,7 @@
import org.teiid.query.sql.lang.SubqueryFromClause;
import org.teiid.query.sql.lang.UnaryFromClause;
import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.visitor.StaticSymbolMappingVisitor;
@@ -114,10 +115,6 @@
try {
ResultSetInfo rsInfo = sourceNode.getResultSetInfo();
- if (rsInfo.isJoinedWithParent()) {
- return;
- }
-
Query command = (Query)rsInfo.getCommand();
prepareQuery(sourceNode, planEnv, command);
@@ -157,7 +154,7 @@
}
}
- static void planQueries(MappingSourceNode sourceNode, XMLPlannerEnvironment planEnv)
+ static void planQueries(final MappingSourceNode sourceNode, XMLPlannerEnvironment
planEnv)
throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
ResultSetInfo rsInfo = sourceNode.getResultSetInfo();
@@ -186,8 +183,6 @@
rsQuery.setLimit(new Limit(null, new Constant(new Integer(limit))));
}
- //prepareQuery(sourceNode, planEnv, rsQuery);
-
// this query is not eligible for staging; proceed normally.
rsInfo.setCommand(rsQuery);
}
@@ -226,14 +221,14 @@
/**
* The Criteria Source nodes are source nodes underneath the context Node.
*/
- private static boolean getResultSets(MappingSourceNode contextNode, Set
criteriaSourceNodes, LinkedHashSet allResultSets) {
+ private static boolean getResultSets(MappingSourceNode contextNode, Set
criteriaSourceNodes, LinkedHashSet<MappingSourceNode> allResultSets) {
boolean singleParentage = true;
for (Iterator i = criteriaSourceNodes.iterator(); i.hasNext();) {
MappingSourceNode node = (MappingSourceNode)i.next();
- List rsStack = getResultSetStack(contextNode, node);
+ List<MappingSourceNode> rsStack = getResultSetStack(contextNode,
node);
if (allResultSets.containsAll(rsStack)) {
continue;
@@ -268,7 +263,7 @@
// this list of all the source nodes below the context, which are directly ro
indirectly
// involved in the criteria
- LinkedHashSet resultSets = new LinkedHashSet();
+ LinkedHashSet<MappingSourceNode> resultSets = new
LinkedHashSet<MappingSourceNode>();
boolean singleParentage = getResultSets(contextNode,
rsInfo.getCriteriaResultSets(), resultSets);
@@ -377,7 +372,7 @@
GroupSymbol oldGroupSymbol = new GroupSymbol(oldGroup);
ResolverUtil.resolveGroup(oldGroupSymbol, metadata);
- HashSet projectedElements = new
HashSet(ResolverUtil.resolveElementsInGroup(oldGroupSymbol, metadata));
+ HashSet<ElementSymbol> projectedElements = new
HashSet<ElementSymbol>(ResolverUtil.resolveElementsInGroup(oldGroupSymbol,
metadata));
symbolMap.putAll(QueryUtil.createSymbolMap(oldGroupSymbol, newGroup,
projectedElements));
}
@@ -480,11 +475,11 @@
rsInfo.setCommand(cmd);
rsInfo.setPlan(plan);
- //set the carinality on the temp group.
+ //set the cardinality on the temp group.
TempMetadataID intoGroupID = (TempMetadataID)intoGroupSymbol.getMetadataID();
intoGroupID.setCardinality(cardinality);
- // add the meterialization hook for the staged table to original one.
+ // add the materialization hook for the staged table to original one.
//GroupSymbol groupSymbol = (GroupSymbol)query.getFrom().getGroups().get(0);
planEnv.addStagingTable(srcGroup.getMetadataID(), intoGroupID);
Deleted:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/xml/JoinedWhileInstruction.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/xml/JoinedWhileInstruction.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/xml/JoinedWhileInstruction.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -1,145 +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 org.teiid.query.processor.xml;
-
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.client.plan.PlanNode;
-import org.teiid.common.buffer.BlockedException;
-import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidProcessingException;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.util.VariableContext;
-
-
-/**
- * Loop instruction on the result set execute before this instruction.
- */
-public class JoinedWhileInstruction extends WhileInstruction {
-
- private Integer mappingClassNumber;
- private ElementSymbol mappingClassSymbol;
- private String originalResultSet;
-
- /**
- * Constructor for WhileInstruction.
- */
- public JoinedWhileInstruction(String rsName,
- Integer mappingClassNumber,
- ElementSymbol mappingClassSymbol, String
originalResultSet) {
- super(rsName);
- this.mappingClassNumber = mappingClassNumber;
- this.mappingClassSymbol = mappingClassSymbol;
- this.originalResultSet = originalResultSet;
- }
-
- /**
- * @see ProcessorInstruction#process(ProcessorEnvironment)
- */
- public XMLContext process(XMLProcessorEnvironment env,
- XMLContext context) throws BlockedException,
- TeiidComponentException,
- TeiidProcessingException {
-
- List values = context.getCurrentRow(getResultSetName());
-
- if (values == null) {
- env.incrementCurrentProgramCounter();
- return context;
- }
-
- List outputElements = context.getOutputElements(getResultSetName());
-
- int index = outputElements.indexOf(mappingClassSymbol);
-
- Object value = values.get(index);
-
- VariableContext varContext = context.getVariableContext();
-
- // move on to the next row and don't push the program
- if (value == null) {
- if (Boolean.TRUE.equals(getFirst(varContext))) {
- context.getNextRow(getResultSetName());
- }
- setFirst(varContext, Boolean.TRUE);
- env.incrementCurrentProgramCounter();
- return context;
- }
-
- boolean canConsume = true;
-
- // TODO: this is very inefficient. each root should check only its values and
pass that value through the context
- // TODO: likewise the context update below should also only involve the columns
from this context
- if (!Boolean.TRUE.equals(getFirst(varContext))) {
- Map previousValues = getPreviousValues(varContext);
-
- if (previousValues != null) {
- for (int i = 0; i < index - 1 && canConsume; i++) {
- Object previousValue = previousValues.get(outputElements.get(i));
- Object currentValue = values.get(i);
- if (previousValue != null) {
- if (!previousValue.equals(currentValue)) {
- canConsume = false;
- }
- } else if (currentValue != null) {
- canConsume = false;
- }
- }
- }
- }
-
- // consume this row only if the parent values are the same
- if (value.equals(mappingClassNumber) && canConsume) {
- //it is not necessary to push the values back into the context here
- setPreviousValues(varContext, context.getReferenceValues());
-
- pushProgram(env, context, values);
-
- setFirst(varContext, Boolean.FALSE);
- } else {
- setFirst(varContext, Boolean.TRUE);
-
- env.incrementCurrentProgramCounter();
- return context;
- }
-
- return context;
- }
-
- Boolean getFirst(VariableContext varContext) {
- return (Boolean)varContext.getValue(new ElementSymbol("$" +
getResultSetName() + "$" + originalResultSet + "$first"));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- void setFirst(VariableContext varContext, Boolean value) {
- varContext.setValue(new ElementSymbol("$" + getResultSetName() +
"$" + originalResultSet + "$first"), value); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public String toString() {
- return "JOINED " + originalResultSet + " " +
super.toString(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public PlanNode getDescriptionProperties() {
- return new PlanNode("JOINED LOOP"); //$NON-NLS-1$
- }
-}
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/xml/XMLContext.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/xml/XMLContext.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/xml/XMLContext.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -190,6 +190,9 @@
List elements = getOutputElements(resultSetName);
for (int index = 0; index < elements.size(); index++) {
+ if (!(elements.get(index) instanceof ElementSymbol)) {
+ continue;
+ }
ElementSymbol symbol = (ElementSymbol)elements.get(index);
variableContext.setValue(new ElementSymbol(resultSetName +
ElementSymbol.SEPARATOR + symbol.getShortName()), row.get(index));
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/LanguageObject.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/LanguageObject.java 2011-06-01
18:19:08 UTC (rev 3211)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/LanguageObject.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -23,7 +23,7 @@
package org.teiid.query.sql;
import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
/**
* This is the primary interface for all language objects. It extends a few
@@ -47,7 +47,7 @@
public static class Util {
- public static <S extends LanguageObject, T extends S> ArrayList<S>
deepClone(List<T> collection, Class<S> type) {
+ public static <S extends LanguageObject, T extends S> ArrayList<S>
deepClone(Collection<T> collection, Class<S> type) {
if (collection == null) {
return null;
}
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingElement.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingElement.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingElement.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -232,7 +232,7 @@
public void testAddNullStagingTable() {
MappingElement element = new MappingElement("Test"); //$NON-NLS-1$
element.addStagingTable(null);
- List stagingTables = element.getStagingTables();
+ List<String> stagingTables = element.getStagingTables();
assertTrue(stagingTables.isEmpty());
}
}
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/xml/TestSourceNodeGenaratorVisitor.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/xml/TestSourceNodeGenaratorVisitor.java 2011-06-01
18:19:08 UTC (rev 3211)
+++
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/xml/TestSourceNodeGenaratorVisitor.java 2011-06-02
18:05:39 UTC (rev 3212)
@@ -82,7 +82,7 @@
MappingSourceNode source = (MappingSourceNode)root;
assertEquals("licenseSource", source.getResultName()); //$NON-NLS-1$
- List list = source.getStagingTables();
+ List<String> list = source.getStagingTables();
assertEquals(2, list.size());
assertEquals("testTempGroup1", list.get(0)); //$NON-NLS-1$
@@ -128,7 +128,7 @@
assertTrue(node instanceof MappingElement);
MappingElement element = (MappingElement)node;
- List list = element.getStagingTables();
+ List<String> list = element.getStagingTables();
assertEquals(1, list.size());
assertEquals("testTempGroup1", list.get(0)); //$NON-NLS-1$
@@ -137,7 +137,7 @@
assertEquals(1, element.getMinOccurence());
assertEquals(1, element.getMaxOccurence());
- MappingNode node1 = (MappingNode)element.getNodeChildren().get(0);
+ MappingNode node1 = element.getNodeChildren().get(0);
assertTrue(node1 instanceof MappingSourceNode);
MappingSourceNode source = (MappingSourceNode)node1;
@@ -149,7 +149,7 @@
// make sure source's child is mapping element and mapping element's
source
// is above source
- node1 = (MappingNode)source.getNodeChildren().get(0);
+ node1 = source.getNodeChildren().get(0);
assertTrue(node instanceof MappingElement);
element = (MappingElement)node1;
assertEquals("childNode", element.getName()); //$NON-NLS-1$
@@ -194,14 +194,14 @@
MappingSourceNode source = (MappingSourceNode)node;
assertEquals("parentNodeSource", source.getSource()); //$NON-NLS-1$
- node = (MappingNode)source.getNodeChildren().get(0);
+ node = source.getNodeChildren().get(0);
assertTrue(node instanceof MappingElement);
MappingElement element = (MappingElement)node;
assertEquals("parentNode", element.getName()); //$NON-NLS-1$
assertTrue(element.isRootRecursiveNode());
assertFalse(element.isRecursive());
- node = (MappingNode)element.getNodeChildren().get(0);
+ node = element.getNodeChildren().get(0);
assertTrue(node instanceof MappingElement);
element = (MappingElement)node;
assertEquals("childNode", element.getName()); //$NON-NLS-1$
@@ -213,7 +213,7 @@
assertEquals("ddd", attribute.getDefaultValue()); //$NON-NLS-1$
assertEquals("fff", attribute.getValue()); //$NON-NLS-1$
- node = (MappingNode)element.getNodeChildren().get(0);
+ node = element.getNodeChildren().get(0);
assertTrue(node instanceof MappingRecursiveElement);
MappingRecursiveElement recursive = (MappingRecursiveElement)node;
assertEquals("recursivenodename", recursive.getName()); //$NON-NLS-1$
@@ -254,7 +254,7 @@
assertEquals("parentSource", source.getSource()); //$NON-NLS-1$
// parent element
- node = (MappingNode)source.getNodeChildren().get(0);
+ node = source.getNodeChildren().get(0);
assertTrue(node instanceof MappingElement);
MappingElement element = (MappingElement)node;
assertEquals("parentNode", element.getName()); //$NON-NLS-1$
@@ -262,12 +262,12 @@
assertFalse(element.isRecursive());
// recursive source
- node = (MappingNode)element.getNodeChildren().get(0);
+ node = element.getNodeChildren().get(0);
source = (MappingSourceNode)node;
assertEquals("childSource", source.getSource()); //$NON-NLS-1$
assertEquals("parentSource", source.getAliasResultName());
//$NON-NLS-1$
- node = (MappingNode)source.getNodeChildren().get(0);
+ node = source.getNodeChildren().get(0);
assertTrue(node instanceof MappingRecursiveElement);
MappingRecursiveElement relement = (MappingRecursiveElement)node;