teiid SVN: r3021 - trunk/documentation/client-developers-guide/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-22 22:01:33 -0400 (Tue, 22 Mar 2011)
New Revision: 3021
Modified:
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/using-hibernate.xml
Log:
TEIID-1525 update about id generation
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/using-hibernate.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/using-hibernate.xml 2011-03-23 00:19:04 UTC (rev 3020)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/using-hibernate.xml 2011-03-23 02:01:33 UTC (rev 3021)
@@ -7,10 +7,19 @@
<title>Using Teiid with Hibernate</title>
<section>
<title>Limitations</title>
- <para>Many Hibernate use cases assume a data source has the ability (with proper user permissions)
+ <itemizedlist>
+ <listitem>
+ <para>Many Hibernate use cases assume a data source has the ability (with proper user permissions)
to process Data Definition Language (DDL) statements like CREATE TABLE and DROP TABLE
as well as Data Manipulation Language (DML) statements like SELECT, UPDATE, INSERT and DELETE.
- Teiid can handle a broad range of DML, but does not support DDL.</para>
+ Teiid can handle a broad range of DML, but does not support directly support DDL against a particular source.</para>
+ </listitem>
+ <listitem>
+ <para>Sequence and Identity generation are not supported.
+ Identifier generation based upon table values, such as the hilo generator, require that the identifier table(s) be exposed through Teiid.
+ The GUID identifier generation strategy is directly supported.</para>
+ </listitem>
+ </itemizedlist>
</section>
<section>
13 years, 9 months
teiid SVN: r3020 - in trunk: engine/src/main/java/org/teiid/dqp/internal/process/multisource and 12 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-22 20:19:04 -0400 (Tue, 22 Mar 2011)
New Revision: 3020
Removed:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java
Modified:
trunk/api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElement.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/DynamicCommandResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
Log:
TEIID-1520 further reducing calls that construct strings and adjusting querymetadatainterface methods
Modified: trunk/api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -23,6 +23,7 @@
package org.teiid.metadata;
import java.io.Serializable;
+import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -45,6 +46,7 @@
private String uuid; //globally unique id
private String name; //contextually unique name
+ private WeakReference<String> fullNameRef;
private String canonicalName;
private String nameInSource;
@@ -76,9 +78,18 @@
* is not SQL safe - it may need quoted/escaped
*/
public String getFullName() {
+ if (this.fullNameRef != null) {
+ String fullName = this.fullNameRef.get();
+ if (fullName != null) {
+ return fullName;
+ }
+ this.fullNameRef = null;
+ }
AbstractMetadataRecord parent = getParent();
if (parent != null) {
- return parent.getFullName() + NAME_DELIM_CHAR + getName();
+ String result = parent.getFullName() + NAME_DELIM_CHAR + getName();
+ this.fullNameRef = new WeakReference<String>(result);
+ return result;
}
return name;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElement.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElement.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElement.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -37,12 +37,12 @@
}
public boolean equals(Object obj) {
- if(obj == null || !(obj instanceof MultiSourceElement)) {
- return false;
- } else if(obj == this) {
+ if(obj == this) {
return true;
}
-
+ if(!(obj instanceof MultiSourceElement)) {
+ return false;
+ }
return groupID.equals(((MultiSourceElement)obj).groupID);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -31,9 +31,11 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.StringUtil;
import org.teiid.query.metadata.BasicQueryMetadataWrapper;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
/**
@@ -42,19 +44,27 @@
*/
public class MultiSourceMetadataWrapper extends BasicQueryMetadataWrapper {
- private Set<String> multiSourceModels;
+ private static final String SUFFIX = SingleElementSymbol.SEPARATOR + MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME;
+ private Set<String> multiSourceModels;
public MultiSourceMetadataWrapper(QueryMetadataInterface actualMetadata, Set<String> multiSourceModels){
super(actualMetadata);
this.multiSourceModels = multiSourceModels;
}
+ public static String getGroupName(final String fullElementName) {
+ int index = fullElementName.lastIndexOf('.');
+ if(index >= 0) {
+ return fullElementName.substring(0, index);
+ }
+ return null;
+ }
+
/**
* @see org.teiid.query.metadata.QueryMetadataInterface#getElementID(java.lang.String)
*/
public Object getElementID(String elementName) throws TeiidComponentException, QueryMetadataException {
- String shortName = getShortElementName(elementName);
- if(shortName.equalsIgnoreCase(MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME)) {
+ if(StringUtil.endsWithIgnoreCase(elementName, SUFFIX)) {
try {
String groupName = getGroupName(elementName);
Object groupID = getGroupID(groupName);
@@ -97,6 +107,15 @@
}
return actualMetadata.getFullName(metadataID);
}
+
+ @Override
+ public String getName(Object metadataID) throws TeiidComponentException,
+ QueryMetadataException {
+ if(metadataID instanceof MultiSourceElement) {
+ return MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME;
+ }
+ return actualMetadata.getName(metadataID);
+ }
/**
* @see org.teiid.query.metadata.QueryMetadataInterface#getElementIDsInGroupID(java.lang.Object)
@@ -346,7 +365,7 @@
Object modelID = this.getModelID(gid);
String modelName = this.getFullName(modelID);
if(multiSourceModels.contains(modelName)) {
- String shortName = getShortElementName(getFullName(elementId));
+ String shortName = getName(elementId);
return shortName.equalsIgnoreCase(MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -625,7 +625,7 @@
int endVal = Math.min(startVal+lengthVal, string.length());
- return string.substring(startVal, endVal);
+ return new String(string.substring(startVal, endVal));
}
public static Object substring(String string, Integer start) {
@@ -644,7 +644,7 @@
if(string.length() < countValue) {
return string;
}
- return string.substring(0, countValue);
+ return new String(string.substring(0, countValue));
}
// ================== Function = right =====================
@@ -657,7 +657,7 @@
} else if(string.length() < countValue) {
return string;
} else {
- return string.substring(string.length() - countValue);
+ return new String(string.substring(string.length() - countValue));
}
}
@@ -702,7 +702,7 @@
for(int i=0; i<string.length(); i++) {
if(string.charAt(i) != SPACE) {
// end of trim, return what's left
- return string.substring(i);
+ return new String(string.substring(i));
}
}
@@ -716,7 +716,7 @@
for(int i=string.length()-1; i>=0; i--) {
if(string.charAt(i) != SPACE) {
// end of trim, return what's left
- return string.substring(0, i+1);
+ return new String(string.substring(0, i+1));
}
}
@@ -739,7 +739,7 @@
int newIndex = string.indexOf(subString, index);
if(newIndex < 0) {
// No more replacement sections, grab from old index to end of string
- result.append( string.substring(index) );
+ result.append( string.substring(index));
// Break out of loop
break;
@@ -748,7 +748,7 @@
// Matched the substring at newIndex
// First append section from old index to new
- result.append( string.substring( index, newIndex) );
+ result.append( string.substring( index, newIndex));
// Then append replacement section for sub
result.append( replaceString );
@@ -858,7 +858,7 @@
throw new FunctionExecutionException("ERR.015.001.0025", QueryPlugin.Util.getString("ERR.015.001.0025")); //$NON-NLS-1$ //$NON-NLS-2$
}
if(length < str.length()) {
- return str.substring(0, length);
+ return new String(str.substring(0, length));
}
if(length > DataTypeManager.MAX_STRING_LENGTH) {
length = DataTypeManager.MAX_STRING_LENGTH;
@@ -877,9 +877,9 @@
}
}
if (left) {
- return outStr.substring(outStr.length() - length);
+ return new String(outStr.substring(outStr.length() - length));
}
- return outStr.substring(0, length);
+ return new String(outStr.substring(0, length));
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -90,32 +90,6 @@
}
/**
- * @see QueryMetadataInterface#getFullElementName(String, String)
- */
- public String getFullElementName(
- String fullGroupName,
- String shortElementName)
- throws TeiidComponentException, QueryMetadataException {
- return null;
- }
-
- /**
- * @see QueryMetadataInterface#getShortElementName(String)
- */
- public String getShortElementName(String fullElementName)
- throws TeiidComponentException, QueryMetadataException {
- return null;
- }
-
- /**
- * @see QueryMetadataInterface#getGroupName(String)
- */
- public String getGroupName(String fullElementName)
- throws TeiidComponentException, QueryMetadataException {
- return null;
- }
-
- /**
* @see QueryMetadataInterface#getElementIDsInGroupID(Object)
*/
public List getElementIDsInGroupID(Object groupID)
@@ -528,5 +502,11 @@
public boolean hasProcedure(String name) throws TeiidComponentException {
return false;
}
+
+ @Override
+ public String getName(Object metadataID) throws TeiidComponentException,
+ QueryMetadataException {
+ return null;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -126,13 +126,6 @@
return actualMetadata.getForeignKeysInGroup(groupID);
}
- public String getFullElementName(String fullGroupName,
- String shortElementName) throws TeiidComponentException,
- QueryMetadataException {
- return actualMetadata.getFullElementName(fullGroupName,
- shortElementName);
- }
-
public String getFullName(Object metadataID)
throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getFullName(metadataID);
@@ -148,11 +141,6 @@
return actualMetadata.getGroupIDForElementID(elementID);
}
- public String getGroupName(String fullElementName)
- throws TeiidComponentException, QueryMetadataException {
- return actualMetadata.getGroupName(fullElementName);
- }
-
public Collection getGroupsForPartialName(String partialGroupName)
throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getGroupsForPartialName(partialGroupName);
@@ -262,11 +250,6 @@
return actualMetadata.getScale(elementID);
}
- public String getShortElementName(String fullElementName)
- throws TeiidComponentException, QueryMetadataException {
- return actualMetadata.getShortElementName(fullElementName);
- }
-
public StoredProcedureInfo getStoredProcedureInfoForProcedure(
String fullyQualifiedProcedureName)
throws TeiidComponentException, QueryMetadataException {
@@ -393,5 +376,11 @@
public boolean hasProcedure(String name) throws TeiidComponentException {
return actualMetadata.hasProcedure(name);
}
+
+ @Override
+ public String getName(Object metadataID) throws TeiidComponentException,
+ QueryMetadataException {
+ return actualMetadata.getName(metadataID);
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -96,39 +96,18 @@
* @throws TeiidComponentException Unexpected internal system problem during request
*/
String getFullName(Object metadataID)
- throws TeiidComponentException, QueryMetadataException;
-
- /**
- * Get the fully qualified (unique) element name given the full group name and the short element name.
- * @param fullGroupName Fully qualified group name
- * @param shortElementName Short element name
- * @return Unique element name for the specified group and element name
- * @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws TeiidComponentException Unexpected internal system problem during request
- */
- String getFullElementName(String fullGroupName, String shortElementName)
throws TeiidComponentException, QueryMetadataException;
/**
- * Get the short (unique only to group) name of an element, given a fully qualified element name.
- * @param fullElementName Fully qualified element name
- * @return Short (unique only to group) name of element
+ * Get the name of the metadata identifier specified. This metadata
+ * identifier was previously returned by some other method.
+ * @param metadataID Metadata identifier
+ * @return Metadata identifier for this model
* @throws QueryMetadataException Metadata implementation detected a problem during the request
* @throws TeiidComponentException Unexpected internal system problem during request
*/
- String getShortElementName(String fullElementName)
- throws TeiidComponentException, QueryMetadataException;
+ String getName(Object metadataID) throws TeiidComponentException, QueryMetadataException;
- /**
- * Get the group name from a fully qualified element name.
- * @param fullElementName Fully qualified element name
- * @return Group name
- * @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws TeiidComponentException Unexpected internal system problem during request
- */
- String getGroupName(String fullElementName)
- throws TeiidComponentException, QueryMetadataException;
-
/**
* Get list of metadata element IDs for a group ID
* @param groupID Group ID
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -163,7 +163,17 @@
return ((TempMetadataID)metadataID).getID();
}
return this.actualMetadata.getFullName(metadataID);
- }
+ }
+
+ @Override
+ public String getName(Object metadataID) throws TeiidComponentException,
+ QueryMetadataException {
+ if(metadataID instanceof TempMetadataID) {
+ TempMetadataID tid = (TempMetadataID)metadataID;
+ return tid.getName();
+ }
+ return this.actualMetadata.getName(metadataID);
+ }
// SPECIAL: Override for temp groups
public List getElementIDsInGroupID(Object groupID)
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -31,6 +31,7 @@
import org.teiid.core.util.LRUCache;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.sql.lang.CacheHint;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
/**
@@ -68,6 +69,7 @@
}
private String ID; // never null, upper cased fully-qualified string
+ private String name;
private Type metadataType = Type.VIRTUAL;
private Object originalMetadataID;
@@ -103,6 +105,7 @@
for (TempMetadataID tempMetadataID : elements) {
tempMetadataID.setPosition(pos++);
}
+ this.name = ID;
this.metadataType = type;
}
@@ -363,5 +366,12 @@
public boolean isUpdatable() {
return updatable;
}
+
+ public String getName() {
+ if (this.name == null) {
+ this.name = SingleElementSymbol.getShortName(this.ID);
+ }
+ return this.name;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -237,46 +237,15 @@
AbstractMetadataRecord metadataRecord = (AbstractMetadataRecord) metadataID;
return metadataRecord.getFullName();
}
-
- public String getFullElementName(final String fullGroupName, final String shortElementName)
- throws TeiidComponentException, QueryMetadataException {
- ArgCheck.isNotEmpty(fullGroupName);
- ArgCheck.isNotEmpty(shortElementName);
-
- return fullGroupName + DELIMITER_CHAR + shortElementName;
+
+ @Override
+ public String getName(Object metadataID) throws TeiidComponentException,
+ QueryMetadataException {
+ ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
+ AbstractMetadataRecord metadataRecord = (AbstractMetadataRecord) metadataID;
+ return metadataRecord.getName();
}
- public String getShortElementName(final String fullElementName) throws TeiidComponentException, QueryMetadataException {
- ArgCheck.isNotEmpty(fullElementName);
- int index = fullElementName.lastIndexOf(DELIMITER_CHAR);
- if(index >= 0) {
- return fullElementName.substring(index+1);
- }
- return fullElementName;
- }
-
- /**
- * Return the text portion of the fullElementName representing a group.
- * That means that this should only return text that is part of the
- * fullElementName and not look up new IDs or do much of anything fancy.
- * This method is used by the resolver to decide which portion of a fully-
- * qualified element name is the group name. It will compare whatever comes
- * back with the actual group names and aliases in the query, which is
- * why it is important not to introduce new metadata here. Also, returning
- * null indicates that no portion of the fullElementName is a
- * group name - that is ok as it will be resolved as an ambiguous element.
- * @see org.teiid.query.metadata.QueryMetadataInterface#getGroupName(java.lang.String)
- */
- public String getGroupName(final String fullElementName) throws TeiidComponentException, QueryMetadataException {
- ArgCheck.isNotEmpty(fullElementName);
-
- int index = fullElementName.lastIndexOf(DELIMITER_CHAR);
- if(index >= 0) {
- return fullElementName.substring(0, index);
- }
- return null;
- }
-
public List getElementIDsInGroupID(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
return ((Table)groupID).getColumns();
@@ -285,13 +254,12 @@
public Object getGroupIDForElementID(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
Column columnRecord = (Column) elementID;
- return this.getGroupID(getGroupName(columnRecord.getFullName()));
- } else if(elementID instanceof ProcedureParameter){
- ProcedureParameter columnRecord = (ProcedureParameter) elementID;
- return this.getGroupID(getGroupName(columnRecord.getFullName()));
- } else {
- throw createInvalidRecordTypeException(elementID);
- }
+ AbstractMetadataRecord parent = columnRecord.getParent();
+ if (parent instanceof Table) {
+ return parent;
+ }
+ }
+ throw createInvalidRecordTypeException(elementID);
}
public boolean hasProcedure(String name) throws TeiidComponentException {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -38,7 +38,6 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.Assertion;
import org.teiid.query.QueryPlugin;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -320,27 +319,16 @@
public static Map<ElementSymbol, Expression> buildSymbolMap(GroupSymbol oldGroup, GroupSymbol newGroup, QueryMetadataInterface metadata)
throws QueryMetadataException, TeiidComponentException {
- String newGroupName = null;
- if (newGroup != null) {
- newGroupName = newGroup.getName();
- }
- Map map = new HashMap();
+ Map<ElementSymbol, Expression> map = new HashMap<ElementSymbol, Expression>();
// Get elements of old group
- List elements = ResolverUtil.resolveElementsInGroup(oldGroup, metadata);
+ List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(oldGroup, metadata);
- Iterator iter = elements.iterator();
- while(iter.hasNext()) {
- ElementSymbol oldElementSymbol = (ElementSymbol)iter.next();
-
+ for (ElementSymbol oldElementSymbol : elements) {
Expression symbol = null;
if (newGroup != null) {
- String newFullName = metadata.getFullElementName(newGroupName, oldElementSymbol.getShortName());
- ElementSymbol newElementSymbol = new ElementSymbol(newFullName);
+ ElementSymbol newElementSymbol = oldElementSymbol.clone();
newElementSymbol.setGroupSymbol(newGroup);
- newElementSymbol.setMetadataID(oldElementSymbol.getMetadataID());
- String elementType = metadata.getElementType(newElementSymbol.getMetadataID());
- newElementSymbol.setType(DataTypeManager.getDataTypeClass(elementType));
symbol = newElementSymbol;
} else {
symbol = new Constant(null, oldElementSymbol.getType());
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -428,7 +428,7 @@
ArrayList<String> result = new ArrayList<String>();
int beginIndex = 0;
for (TextColumn col : table.getColumns()) {
- String val = line.substring(beginIndex, beginIndex + col.getWidth());
+ String val = new String(line.substring(beginIndex, beginIndex + col.getWidth()));
addValue(result, false, val);
beginIndex += col.getWidth();
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -287,7 +287,7 @@
StoredProcedureInfo info = metadata.getStoredProcedureInfoForProcedure(container.getCanonicalName());
// Create temporary metadata that defines a group based on either the stored proc
// name or the stored query name - this will be used later during planning
- String procName = metadata.getFullName(info.getProcedureID());
+ String procName = info.getProcedureCallableName();
// Look through parameters to find input elements - these become child metadata
List<ElementSymbol> tempElements = new ArrayList<ElementSymbol>(info.getParameters().size());
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -149,7 +149,8 @@
ResolverUtil.resolveGroup(container, metadata);
switch (type) {
case Command.TYPE_QUERY:
- QueryNode queryNode = metadata.getVirtualPlan(metadata.getGroupID(container.getCanonicalName()));
+ ResolverUtil.resolveGroup(container, metadata);
+ QueryNode queryNode = metadata.getVirtualPlan(container.getMetadataID());
return resolveWithBindingMetadata(currentCommand, metadata, queryNode, false);
case Command.TYPE_INSERT:
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/DynamicCommandResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/DynamicCommandResolver.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/DynamicCommandResolver.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -43,7 +43,6 @@
import org.teiid.query.sql.lang.SetClause;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
public class DynamicCommandResolver implements CommandResolver {
@@ -68,8 +67,8 @@
}
} else if (dynamicCmd.getIntoGroup().isTempGroupSymbol()) {
while (columns.hasNext()) {
- ElementSymbol column = (ElementSymbol)columns.next();
- column.setName(dynamicCmd.getIntoGroup().getCanonicalName() + SingleElementSymbol.SEPARATOR + column.getShortName());
+ ElementSymbol column = (ElementSymbol)columns.next();
+ column.setGroupSymbol(new GroupSymbol(dynamicCmd.getIntoGroup().getCanonicalName()));
}
}
@@ -85,7 +84,6 @@
if (dynamicCmd.getUsing() != null && !dynamicCmd.getUsing().isEmpty()) {
for (SetClause clause : dynamicCmd.getUsing().getClauses()) {
ElementSymbol id = clause.getSymbol();
- id.setName(ProcedureReservedWords.DVARS + SingleElementSymbol.SEPARATOR + id.getShortName());
id.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.DVARS));
id.setType(clause.getValue().getType());
id.setMetadataID(new TempMetadataID(id.getCanonicalName(), id.getType()));
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -180,9 +180,7 @@
continue;
}
if (namedParameters) {
- String nameKey = param.getName();
- nameKey = metadata.getShortElementName(nameKey);
- nameKey = nameKey.toUpperCase();
+ String nameKey = param.getParameterSymbol().getShortCanonicalName();
Expression expr = inputExpressions.remove(nameKey);
// With named parameters, have to check on optional params and default values
if (expr == null && param.getParameterType() != ParameterInfo.OUT) {
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -347,17 +347,13 @@
private void collectDeclareVariable(DeclareStatement obj, GroupSymbol variables, TempMetadataAdapter metadata, GroupContext externalGroups) throws QueryResolverException, TeiidComponentException {
ElementSymbol variable = obj.getVariable();
String typeName = obj.getVariableType();
- String varName = variable.getName();
- int sepIndex = varName.indexOf(ElementSymbol.SEPARATOR);
- if(sepIndex < 0) {
- String outputName = varName;
- varName = ProcedureReservedWords.VARIABLES + ElementSymbol.SEPARATOR+ varName;
- variable.setName(varName);
+ GroupSymbol gs = variable.getGroupSymbol();
+ if(gs == null) {
+ String outputName = variable.getShortName();
+ variable.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.VARIABLES));
variable.setOutputName(outputName);
} else {
- sepIndex = varName.lastIndexOf(ElementSymbol.SEPARATOR);
- String groupName = varName.substring(0, sepIndex);
- if(!groupName.equals(ProcedureReservedWords.VARIABLES)) {
+ if (gs.getSchema() != null || !gs.getShortCanonicalName().equals(ProcedureReservedWords.VARIABLES)) {
handleUnresolvableDeclaration(variable, QueryPlugin.Util.getString("ERR.015.010.0031", new Object[]{ProcedureReservedWords.VARIABLES, variable})); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -363,7 +363,10 @@
SingleElementSymbol sortKey = orderBy.getVariable(i);
if (sortKey instanceof ElementSymbol) {
ElementSymbol symbol = (ElementSymbol)sortKey;
- String groupPart = metadata.getGroupName(symbol.getName());
+ String groupPart = null;
+ if (symbol.getGroupSymbol() != null) {
+ groupPart = symbol.getGroupSymbol().getName();
+ }
String symbolName = symbol.getName();
String shortName = symbol.getShortName();
if (groupPart == null) {
@@ -502,19 +505,9 @@
List elementIDs = metadata.getElementIDsInGroupID(group.getMetadataID());
LinkedHashMap<Object, ElementSymbol> symbols = new LinkedHashMap<Object, ElementSymbol>(elementIDs.size());
-
- String groupFullName = metadata.getFullName(group.getMetadataID());
- boolean isXml = metadata.isXMLGroup(group.getMetadataID());
for (Object elementID : elementIDs) {
- String elementName = metadata.getFullName(elementID);
- if (isXml) {
- elementName = elementName.substring(groupFullName.length() + 1);
- } else {
- //the logic about should work in either case,
- //but there is a lot of metadata to correct
- elementName = metadata.getShortElementName(elementName);
- }
+ String elementName = metadata.getName(elementID);
// Form an element symbol from the ID
ElementSymbol element = new ElementSymbol(elementName, DataTypeManager.getCanonicalString(StringUtil.toUpperCase(elementName)), group);
element.setMetadataID(elementID);
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -145,14 +145,14 @@
return;
}
- // determine the "metadataID" part of the symbol to look up
- String potentialID = elementSymbol.getName();
-
// look up group and element parts of the potentialID
- String groupContext = metadata.getGroupName(potentialID);
+ String groupContext = null;
+ if (elementSymbol.getGroupSymbol() != null) {
+ groupContext = elementSymbol.getGroupSymbol().getName();
+ }
String elementShortName = elementSymbol.getShortCanonicalName();
if (groupContext != null) {
- groupContext = groupContext.toUpperCase();
+ groupContext = elementSymbol.getGroupSymbol().getCanonicalName();
try {
if (findShortName && internalResolveElementSymbol(elementSymbol, null, elementShortName, groupContext)) {
elementSymbol.setDisplayMode(DisplayMode.SHORT_OUTPUT_NAME);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -180,15 +180,15 @@
this.groupSymbol = symbol;
}
- public void setName(String name) {
+ protected void setName(String name) {
int index = name.lastIndexOf('.');
if (index > 0) {
if (this.groupSymbol != null) {
throw new AssertionError("Attempt to set an invalid name"); //$NON-NLS-1$
}
- GroupSymbol gs = new GroupSymbol(name.substring(0, index));
+ GroupSymbol gs = new GroupSymbol(new String(name.substring(0, index)));
this.setGroupSymbol(gs);
- name = name.substring(index + 1);
+ name = new String(name.substring(index + 1));
} else {
this.groupSymbol = null;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -304,8 +304,8 @@
public void setName(String name) {
int index = name.indexOf('.');
if (index > 0) {
- this.schema = name.substring(0, index);
- name = name.substring(index + 1);
+ this.schema = new String(name.substring(0, index));
+ name = new String(name.substring(index + 1));
} else {
this.schema = null;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -185,7 +185,7 @@
}
public void setOutputName(String outputName) {
- this.outputName =outputName;
+ this.outputName = DataTypeManager.getCanonicalString(outputName);
}
/**
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -26,13 +26,14 @@
import java.util.List;
import java.util.Properties;
+import junit.framework.TestCase;
+
import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.unittest.FakeMetadataFactory;
-import junit.framework.TestCase;
-
/**
* @since 4.2
*/
@@ -68,7 +69,7 @@
assertEquals(0, wrapper.getPrecision(instanceElementID));
assertEquals(0, wrapper.getScale(instanceElementID));
assertEquals(0, wrapper.getRadix(instanceElementID));
- assertEquals(MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME, wrapper.getShortElementName(fullName));
- assertEquals(fullName, wrapper.getFullElementName(wrapper.getFullName(groupID), MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME));
+ assertEquals(MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME, SingleElementSymbol.getShortName(fullName));
+ assertEquals(fullName, wrapper.getFullName(groupID) + SingleElementSymbol.SEPARATOR + MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME);
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -35,7 +35,6 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.optimizer.TestOptimizer;
-import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.proc.CreateCursorResultSetInstruction;
import org.teiid.query.processor.proc.ProcedurePlan;
import org.teiid.query.processor.proc.TestProcedureProcessor;
@@ -296,7 +295,7 @@
String userQuery = "select e1 from pm1.vsp26 where param1=1 and param2='a'"; //$NON-NLS-1$
String inputCriteria = "(pm1.vsp26.param1 = 1) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
- String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
+ String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= PM1.VSP26.param1) AND (g_0.e1 = PM1.VSP26.param2)"; //$NON-NLS-1$
helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
}
@@ -305,7 +304,7 @@
@Test public void testCase3403() {
String userQuery = "select e1 from pm1.vsp26 where param1=2 and param2='a' and 'x'='x'"; //$NON-NLS-1$
String inputCriteria = "(pm1.vsp26.param1 = 2) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
- String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
+ String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= PM1.VSP26.param1) AND (g_0.e1 = PM1.VSP26.param2)"; //$NON-NLS-1$
helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
}
@@ -313,7 +312,7 @@
@Test public void testCase3448() {
String userQuery = "select e1 from pm1.vsp26 where (param1=1 and e2=2) and param2='a'"; //$NON-NLS-1$
String inputCriteria = "(pm1.vsp26.param1 = 1) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
- String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
+ String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= PM1.VSP26.param1) AND (g_0.e1 = PM1.VSP26.param2)"; //$NON-NLS-1$
helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
}
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -48,6 +48,7 @@
import org.teiid.query.metadata.SupportConstants;
import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
public class FakeMetadataFacade extends BasicQueryMetadata {
@@ -153,6 +154,28 @@
ArgCheck.isInstanceOf(FakeMetadataObject.class, metadataID);
return ((FakeMetadataObject)metadataID).getName();
}
+
+ @Override
+ public String getName(Object metadataID) throws TeiidComponentException,
+ QueryMetadataException {
+ String name = getFullName(metadataID);
+ Object groupID = getGroupIDForElementID(metadataID);
+ boolean isXml = false;
+ String groupFullName = null;
+ if (groupID != null) {
+ isXml = isXMLGroup(groupID);
+ groupFullName = getFullName(groupID);
+ }
+
+ if (isXml) {
+ name = name.substring(groupFullName.length() + 1);
+ } else {
+ //the logic about should work in either case,
+ //but there is a lot of metadata to correct
+ name = SingleElementSymbol.getShortName(name);
+ }
+ return name;
+ }
public List getElementIDsInGroupID(Object groupID)
throws TeiidComponentException, QueryMetadataException {
@@ -295,40 +318,6 @@
return maxSetSize.intValue();
}
- public String getFullElementName(String fullGroupName, String shortElementName)
- throws TeiidComponentException, QueryMetadataException {
-
- Assertion.isNotNull(fullGroupName);
- Assertion.isNotNull(shortElementName);
-
- return fullGroupName + "." + shortElementName; //$NON-NLS-1$
- }
-
- public String getShortElementName(String fullElementName)
- throws TeiidComponentException, QueryMetadataException {
-
- Assertion.isNotNull(fullElementName);
-
- int index = fullElementName.lastIndexOf("."); //$NON-NLS-1$
- if(index >= 0) {
- return fullElementName.substring(index+1);
- }
- return fullElementName;
- }
-
- public String getGroupName(String fullElementName)
- throws TeiidComponentException, QueryMetadataException {
-
- Assertion.isNotNull(fullElementName);
-
- int index = fullElementName.lastIndexOf("."); //$NON-NLS-1$
- if(index >= 0) {
- return fullElementName.substring(0, index);
- }
- return null;
- }
-
-
public StoredProcedureInfo getStoredProcedureInfoForProcedure(String fullyQualifiedProcedureName)
throws TeiidComponentException, QueryMetadataException {
Deleted: trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java 2011-03-22 22:09:54 UTC (rev 3019)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java 2011-03-23 00:19:04 UTC (rev 3020)
@@ -1,20 +0,0 @@
-package org.teiid.jdbc;
-
-import org.teiid.core.util.UnitTestUtil;
-
-public class MetadataSizeExperiment {
-
- static FakeServer server = new FakeServer();
-
- public static void main(String[] args) throws Exception {
- server.deployVDB("test", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
- server.deployVDB("QT_Ora9DS", UnitTestUtil.getTestDataPath()+"/QT_Ora9DS_1.vdb");
- server.deployVDB("x", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
- server.deployVDB("x1", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
-
- Thread.sleep(10000000);
-
- System.out.println(server);
- }
-
-}
13 years, 9 months
teiid SVN: r3019 - trunk/metadata/src/main/java/org/teiid/metadata/index.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-22 18:09:54 -0400 (Tue, 22 Mar 2011)
New Revision: 3019
Modified:
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
Log:
TEIID-1524 fixing the metadata to not reference index record lines
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2011-03-22 17:09:46 UTC (rev 3018)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2011-03-22 22:09:54 UTC (rev 3019)
@@ -149,18 +149,17 @@
for (IEntryResult iEntryResult : properties) {
final String str = new String(iEntryResult.getWord());
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = RecordFactory.getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
- // The tokens are the standard header values
- int tokenIndex = 2;
-
- String uuid = (String)tokens.get(1);
+ String uuid = tokens.get(1);
LinkedHashMap<String, String> result = this.extensionCache.get(uuid);
if (result == null) {
result = new LinkedHashMap<String, String>();
this.extensionCache.put(uuid, result);
}
- result.put( (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+ // The tokens are the standard header values
+ int tokenIndex = 2;
+ result.put( tokens.get(tokenIndex++), tokens.get(tokenIndex++));
}
}
@@ -169,14 +168,12 @@
for (IEntryResult iEntryResult : results) {
final String str = new String(iEntryResult.getWord());
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = RecordFactory.getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
// Extract the index version information from the record
int indexVersion = recordFactory.getIndexVersion(iEntryResult.getWord());
-
+ String uuid = tokens.get(2);
- String uuid = (String)tokens.get(2);
-
// The tokens are the standard header values
int tokenIndex = 6;
@@ -186,7 +183,7 @@
}
// The next token is the description
- this.annotationCache.put(uuid, (String)tokens.get(tokenIndex++));
+ this.annotationCache.put(uuid, tokens.get(tokenIndex++));
}
}
@@ -275,7 +272,7 @@
columnRecordImpl.setParent(tableRecord);
String fullName = columnRecordImpl.getName();
if (fullName.startsWith(tableRecord.getName() + '.')) {
- columnRecordImpl.setName(fullName.substring(tableRecord.getName().length() + 1));
+ columnRecordImpl.setName(new String(fullName.substring(tableRecord.getName().length() + 1)));
}
}
Collections.sort(columns);
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2011-03-22 17:09:46 UTC (rev 3018)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2011-03-22 22:09:54 UTC (rev 3019)
@@ -288,7 +288,7 @@
}
}
Assertion.assertTrue(beginIndex < endIndex);
- return baseStr.substring(beginIndex,endIndex);
+ return new String(baseStr.substring(beginIndex,endIndex));
}
// ==================================================================================
@@ -300,26 +300,26 @@
*/
public Schema createModelRecord(final char[] record) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final Schema model = new Schema();
// The tokens are the standard header values
int tokenIndex = 0;
- setRecordHeaderValues(model, (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++));
+ setRecordHeaderValues(model, tokens.get(tokenIndex++), tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++));
// The next token is the max set size
tokenIndex++;
// The next token is the model type
- model.setPhysical(Integer.parseInt((String)tokens.get(tokenIndex++)) == 0);
+ model.setPhysical(Integer.parseInt(tokens.get(tokenIndex++)) == 0);
// The next token is the primary metamodel Uri
- model.setPrimaryMetamodelUri(getObjectValue((String)tokens.get(tokenIndex++)));
+ model.setPrimaryMetamodelUri(getObjectValue(tokens.get(tokenIndex++)));
// The next token are the supports flags
- char[] supportFlags = ((String)tokens.get(tokenIndex++)).toCharArray();
+ char[] supportFlags = (tokens.get(tokenIndex++)).toCharArray();
model.setVisible(getBooleanValue(supportFlags[0]));
// The next tokens are footer values - the footer will contain the version number for the index record
@@ -333,7 +333,7 @@
*/
public TransformationRecordImpl createTransformationRecord(final char[] record) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final TransformationRecordImpl transform = new TransformationRecordImpl();
// Extract the index version information from the record
@@ -343,22 +343,22 @@
int tokenIndex = 2;
// The next token is the UUID of the transformed object
- getObjectValue((String)tokens.get(tokenIndex++));
+ getObjectValue(tokens.get(tokenIndex++));
// The next token is the UUID of the transformation object
if(includeTransformationUUID(indexVersion)) {
- transform.setUUID(getObjectValue(((String)tokens.get(tokenIndex++))));
+ transform.setUUID(getObjectValue((tokens.get(tokenIndex++))));
}
// The next token is the transformation definition
- transform.setTransformation(getObjectValue((String)tokens.get(tokenIndex++)));
+ transform.setTransformation(getObjectValue(tokens.get(tokenIndex++)));
// The next token are the list of bindings
- List bindings = getStrings((String)tokens.get(tokenIndex++), indexVersion);
+ List bindings = getStrings(tokens.get(tokenIndex++), getListDelimiter(indexVersion));
transform.setBindings(bindings);
// The next token are the list of schemaPaths
- List schemaPaths = getStrings((String)tokens.get(tokenIndex++), indexVersion);
+ List schemaPaths = getStrings(tokens.get(tokenIndex++), getListDelimiter(indexVersion));
transform.setSchemaPaths(schemaPaths);
// The next tokens are footer values
@@ -385,7 +385,7 @@
*/
public Table createTableRecord(final char[] record) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final Table table = new Table();
// Extract the index version information from the record
@@ -393,18 +393,18 @@
// The tokens are the standard header values
int tokenIndex = 0;
- setRecordHeaderValues(table, (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+ setRecordHeaderValues(table, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++));
// The next token is the cardinality
- table.setCardinality( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ table.setCardinality( Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the tableType
- table.setTableType(Table.Type.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
+ table.setTableType(Table.Type.values()[Integer.parseInt(tokens.get(tokenIndex++))]);
// The next token are the supports flags
- char[] supportFlags = ((String)tokens.get(tokenIndex++)).toCharArray();
+ char[] supportFlags = (tokens.get(tokenIndex++)).toCharArray();
table.setVirtual(getBooleanValue(supportFlags[0]));
table.setSystem(getBooleanValue(supportFlags[1]));
table.setSupportsUpdate(getBooleanValue(supportFlags[2]));
@@ -416,7 +416,7 @@
tokenIndex++;
// The next token is the UUID of the primary key
- String id = getObjectValue((String)tokens.get(tokenIndex++));
+ String id = getObjectValue(tokens.get(tokenIndex++));
if (id != null) {
KeyRecord pk = new KeyRecord(KeyRecord.Type.Primary);
pk.setUUID(id);
@@ -428,11 +428,11 @@
if(includeMaterializationFlag(indexVersion)) {
// The next token are the UUIDs for the materialized table ID
Table matTable = new Table();
- matTable.setUUID((String)tokens.get(tokenIndex++));
+ matTable.setUUID(tokens.get(tokenIndex++));
table.setMaterializedTable(matTable);
// The next token are the UUID for the materialized stage table ID
matTable = new Table();
- matTable.setUUID((String)tokens.get(tokenIndex++));
+ matTable.setUUID(tokens.get(tokenIndex++));
table.setMaterializedStageTable(matTable);
}
@@ -457,7 +457,7 @@
*/
public Column createColumnRecord(final char[] record) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final Column column = new Column();
// Extract the index version information from the record
@@ -465,12 +465,12 @@
// The tokens are the standard header values
int tokenIndex = 0;
- setRecordHeaderValues(column, (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+ setRecordHeaderValues(column, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++));
// The next token are the supports flags
- char[] supportFlags = ((String)tokens.get(tokenIndex++)).toCharArray();
+ char[] supportFlags = (tokens.get(tokenIndex++)).toCharArray();
column.setSelectable(getBooleanValue(supportFlags[0]));
column.setUpdatable(getBooleanValue(supportFlags[1]));
column.setAutoIncremented(getBooleanValue(supportFlags[2]));
@@ -480,58 +480,58 @@
column.setFixedLength(getBooleanValue(supportFlags[6]));
// The next token is the search type
- column.setNullType(NullType.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
+ column.setNullType(NullType.values()[Integer.parseInt(tokens.get(tokenIndex++))]);
// The next token is the search type
- column.setSearchType(SearchType.values()[3 - Integer.parseInt((String)tokens.get(tokenIndex++))]);
+ column.setSearchType(SearchType.values()[3 - Integer.parseInt(tokens.get(tokenIndex++))]);
// The next token is the length
- column.setLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ column.setLength( Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the scale
- column.setScale( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ column.setScale( Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the precision
- column.setPrecision( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ column.setPrecision( Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the precision
- column.setPosition( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ column.setPosition( Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the charOctetLength
- column.setCharOctetLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ column.setCharOctetLength( Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the radix
- column.setRadix( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ column.setRadix( Integer.parseInt(tokens.get(tokenIndex++)) );
if (includeColumnNullDistinctValues(indexVersion)) {
// The next token is the distinct value
- column.setDistinctValues(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ column.setDistinctValues(Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the null value
- column.setNullValues(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ column.setNullValues(Integer.parseInt(tokens.get(tokenIndex++)) );
}
// The next token is the min value
- column.setMinimumValue( getObjectValue((String)tokens.get(tokenIndex++)) );
+ column.setMinimumValue( getObjectValue(tokens.get(tokenIndex++)) );
// The next token is the max value
- column.setMaximumValue( getObjectValue((String)tokens.get(tokenIndex++)) );
+ column.setMaximumValue( getObjectValue(tokens.get(tokenIndex++)) );
// The next token is the format value
- column.setFormat( getObjectValue((String)tokens.get(tokenIndex++)) );
+ column.setFormat( getObjectValue(tokens.get(tokenIndex++)) );
// The next token is the runtime type
- column.setRuntimeType( getObjectValue((String)tokens.get(tokenIndex++)) );
+ column.setRuntimeType( getObjectValue(tokens.get(tokenIndex++)) );
if(includeColumnNativeType(indexVersion)) {
// The next token is the native type
- column.setNativeType( getObjectValue((String)tokens.get(tokenIndex++)) );
+ column.setNativeType( getObjectValue(tokens.get(tokenIndex++)) );
}
// The next token is the datatype ObjectID
- column.setDatatypeUUID( getObjectValue((String)tokens.get(tokenIndex++)) );
+ column.setDatatypeUUID( getObjectValue(tokens.get(tokenIndex++)) );
// The next token is the default value
- column.setDefaultValue( getObjectValue((String)tokens.get(tokenIndex++)) );
+ column.setDefaultValue( getObjectValue(tokens.get(tokenIndex++)) );
// The next tokens are footer values
setRecordFooterValues(column, tokens, tokenIndex);
@@ -544,24 +544,24 @@
*/
public ColumnSet createColumnSetRecord(final char[] record, ColumnSet columnSet) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
// Extract the index version information from the record
int indexVersion = getIndexVersion(record);
// The tokens are the standard header values
int tokenIndex = 0;
- setRecordHeaderValues(columnSet, (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+ setRecordHeaderValues(columnSet, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++));
// The next token are the UUIDs for the column references
- List uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ List<String> uuids = getStrings(tokens.get(tokenIndex++), getListDelimiter(indexVersion));
columnSet.setColumns(createColumns(uuids));
if (record[0] == MetadataConstants.RECORD_TYPE.UNIQUE_KEY || record[0] == MetadataConstants.RECORD_TYPE.PRIMARY_KEY) {
//read the values from the index to update the tokenindex, but we don't actually use them.
- getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ tokenIndex++;
}
// The next tokens are footer values
setRecordFooterValues(columnSet, tokens, tokenIndex);
@@ -574,7 +574,7 @@
*/
public ForeignKey createForeignKeyRecord(final char[] record) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final ForeignKey fkRecord = new ForeignKey();
// Extract the index version information from the record
@@ -582,16 +582,16 @@
// The tokens are the standard header values
int tokenIndex = 0;
- setRecordHeaderValues(fkRecord, (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+ setRecordHeaderValues(fkRecord, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++));
// The next token are the UUIDs for the column references
- List uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ List<String> uuids = getStrings(tokens.get(tokenIndex++), getListDelimiter(indexVersion));
fkRecord.setColumns(createColumns(uuids));
// The next token is the UUID of the unique key
- fkRecord.setUniqueKeyID(getObjectValue((String)tokens.get(tokenIndex++)));
+ fkRecord.setUniqueKeyID(getObjectValue(tokens.get(tokenIndex++)));
// The next tokens are footer values
setRecordFooterValues(fkRecord, tokens, tokenIndex);
@@ -604,7 +604,7 @@
*/
public Datatype createDatatypeRecord(final char[] record) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final Datatype dt = new Datatype();
// Extract the index version information from the record
@@ -617,63 +617,63 @@
tokenIndex++;
// Set the datatype and basetype identifiers
- dt.setDatatypeID(getObjectValue((String)tokens.get(tokenIndex++)));
- dt.setBasetypeID(getObjectValue((String)tokens.get(tokenIndex++)));
+ dt.setDatatypeID(getObjectValue(tokens.get(tokenIndex++)));
+ dt.setBasetypeID(getObjectValue(tokens.get(tokenIndex++)));
// Set the fullName/objectID/nameInSource
- String fullName = (String)tokens.get(tokenIndex++);
+ String fullName = tokens.get(tokenIndex++);
int indx = fullName.lastIndexOf(Datatype.URI_REFERENCE_DELIMITER);
if (indx > -1) {
- fullName = fullName.substring(indx+1);
+ fullName = new String(fullName.substring(indx+1));
} else {
indx = fullName.lastIndexOf(AbstractMetadataRecord.NAME_DELIM_CHAR);
if (indx > -1) {
- fullName = fullName.substring(indx+1);
+ fullName = new String(fullName.substring(indx+1));
}
}
dt.setName(fullName);
- dt.setUUID(getObjectValue((String)tokens.get(tokenIndex++)));
- dt.setNameInSource(getObjectValue((String)tokens.get(tokenIndex++)));
+ dt.setUUID(getObjectValue(tokens.get(tokenIndex++)));
+ dt.setNameInSource(getObjectValue(tokens.get(tokenIndex++)));
// Set the variety type and its properties
- dt.setVarietyType(Variety.values()[Short.parseShort((String)tokens.get(tokenIndex++))]);
- getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ dt.setVarietyType(Variety.values()[Short.parseShort(tokens.get(tokenIndex++))]);
+ tokenIndex++;
// Set the runtime and java class names
- dt.setRuntimeTypeName(getObjectValue((String)tokens.get(tokenIndex++)));
- dt.setJavaClassName(getObjectValue((String)tokens.get(tokenIndex++)));
+ dt.setRuntimeTypeName(getObjectValue(tokens.get(tokenIndex++)));
+ dt.setJavaClassName(getObjectValue(tokens.get(tokenIndex++)));
// Set the datatype type
- dt.setType(Datatype.Type.values()[Short.parseShort((String)tokens.get(tokenIndex++))]);
+ dt.setType(Datatype.Type.values()[Short.parseShort(tokens.get(tokenIndex++))]);
// Set the search type
- dt.setSearchType(SearchType.values()[3 - Integer.parseInt((String)tokens.get(tokenIndex++))]);
+ dt.setSearchType(SearchType.values()[3 - Integer.parseInt(tokens.get(tokenIndex++))]);
// Set the null type
- dt.setNullType(NullType.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
+ dt.setNullType(NullType.values()[Integer.parseInt(tokens.get(tokenIndex++))]);
// Set the boolean flags
- char[] booleanValues = ((String)tokens.get(tokenIndex++)).toCharArray();
+ char[] booleanValues = (tokens.get(tokenIndex++)).toCharArray();
dt.setSigned(getBooleanValue(booleanValues[0]));
dt.setAutoIncrement(getBooleanValue(booleanValues[1]));
dt.setCaseSensitive(getBooleanValue(booleanValues[2]));
// Append the length
- dt.setLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ dt.setLength( Integer.parseInt(tokens.get(tokenIndex++)) );
// Append the precision length
- dt.setPrecisionLength( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ dt.setPrecisionLength( Integer.parseInt(tokens.get(tokenIndex++)) );
// Append the scale
- dt.setScale( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ dt.setScale( Integer.parseInt(tokens.get(tokenIndex++)) );
// Append the radix
- dt.setRadix( Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ dt.setRadix( Integer.parseInt(tokens.get(tokenIndex++)) );
// Set the primitive type identifier
if (includePrimitiveTypeIdValue(indexVersion)) {
// The next token is the primitive type identifier
- dt.setPrimitiveTypeID(getObjectValue((String)tokens.get(tokenIndex++)));
+ dt.setPrimitiveTypeID(getObjectValue(tokens.get(tokenIndex++)));
}
// The next tokens are footer values
@@ -688,7 +688,7 @@
public Procedure createProcedureRecord(final char[] record) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final Procedure procRd = new Procedure();
// Extract the index version information from the record
@@ -698,19 +698,19 @@
int tokenIndex = 0;
// Set the record type
- setRecordHeaderValues(procRd, (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+ setRecordHeaderValues(procRd, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++));
// Set the boolean flags
- char[] booleanValues = ((String)tokens.get(tokenIndex++)).toCharArray();
+ char[] booleanValues = (tokens.get(tokenIndex++)).toCharArray();
// flag indicating if the procedure is a function
procRd.setFunction(getBooleanValue(booleanValues[0]));
// flag indicating if the procedure is virtual
procRd.setVirtual(getBooleanValue(booleanValues[1]));
// The next token are the UUIDs for the param references
- List<String> uuids = getIDs((String)tokens.get(tokenIndex++), indexVersion);
+ List<String> uuids = getStrings(tokens.get(tokenIndex++), getListDelimiter(indexVersion));
List<ProcedureParameter> columns = new ArrayList<ProcedureParameter>(uuids.size());
for (String uuid : uuids) {
ProcedureParameter column = new ProcedureParameter();
@@ -720,7 +720,7 @@
procRd.setParameters(columns);
// The next token is the UUID of the resultSet object
- String rsId = getObjectValue((String)tokens.get(tokenIndex++));
+ String rsId = getObjectValue(tokens.get(tokenIndex++));
if (rsId != null) {
ColumnSet cs = new ColumnSet();
cs.setUUID(rsId);
@@ -728,7 +728,7 @@
}
if (includeProcedureUpdateCount(indexVersion)) {
- procRd.setUpdateCount(Integer.parseInt((String)tokens.get(tokenIndex++)));
+ procRd.setUpdateCount(Integer.parseInt(tokens.get(tokenIndex++)));
}
// The next tokens are footer values
@@ -744,47 +744,47 @@
public ProcedureParameter createProcedureParameterRecord(final char[] record) {
final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+ final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final ProcedureParameter paramRd = new ProcedureParameter();
// The tokens are the standard header values
int tokenIndex = 0;
// Set the record type
- setRecordHeaderValues(paramRd, (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++),
- (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+ setRecordHeaderValues(paramRd, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++),
+ tokens.get(tokenIndex++), tokens.get(tokenIndex++));
// The next token is the default value of the parameter
- paramRd.setDefaultValue(getObjectValue((String)tokens.get(tokenIndex++)) );
+ paramRd.setDefaultValue(getObjectValue(tokens.get(tokenIndex++)) );
// The next token is the runtime type
- paramRd.setRuntimeType(getObjectValue((String)tokens.get(tokenIndex++)) );
+ paramRd.setRuntimeType(getObjectValue(tokens.get(tokenIndex++)) );
// The next token is the uuid
- paramRd.setDatatypeUUID(getObjectValue((String)tokens.get(tokenIndex++)) );
+ paramRd.setDatatypeUUID(getObjectValue(tokens.get(tokenIndex++)) );
// The next token is the length
- paramRd.setLength(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ paramRd.setLength(Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the radix
- paramRd.setRadix(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ paramRd.setRadix(Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the scale
- paramRd.setScale(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ paramRd.setScale(Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the null type
- paramRd.setNullType(NullType.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
+ paramRd.setNullType(NullType.values()[Integer.parseInt(tokens.get(tokenIndex++))]);
// The next token is the precision
- paramRd.setPrecision(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ paramRd.setPrecision(Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the position
- paramRd.setPosition(Integer.parseInt((String)tokens.get(tokenIndex++)) );
+ paramRd.setPosition(Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is parameter type
ProcedureParameter.Type type = null;
- switch (Short.parseShort((String)tokens.get(tokenIndex++))) {
+ switch (Short.parseShort(tokens.get(tokenIndex++))) {
case MetadataConstants.PARAMETER_TYPES.IN_PARM:
type = ProcedureParameter.Type.In;
break;
@@ -801,7 +801,7 @@
paramRd.setType(type);
// The next token is flag for parameter optional prop
- char[] flags = ((String)tokens.get(tokenIndex++)).toCharArray();
+ char[] flags = (tokens.get(tokenIndex++)).toCharArray();
paramRd.setOptional(getBooleanValue(flags[0]));
// The next tokens are footer values
@@ -848,39 +848,19 @@
return false;
}
- public List<String> getIDs(final String values, final int indexVersionNumber) {
+ public static List<String> getStrings(final String values, final char listDelimiter) {
if (StringUtil.isEmpty(values)) {
- return Collections.EMPTY_LIST;
- }
- if (values.length() == 1 && values.charAt(0) == IndexConstants.RECORD_STRING.SPACE) {
- return Collections.EMPTY_LIST;
- }
- final char listDelimiter = getListDelimiter(indexVersionNumber);
- final List tokens = StringUtil.split(values,String.valueOf(listDelimiter));
- final List result = new ArrayList(tokens.size());
- for (Iterator iter = tokens.iterator(); iter.hasNext();) {
- String token = getObjectValue((String)iter.next());
- if (token != null) {
- result.add(token);
- }
- }
- return result;
- }
-
- public List<String> getStrings(final String values, final int indexVersionNumber) {
- if (StringUtil.isEmpty(values)) {
return Collections.emptyList();
}
if (values.length() == 1 && values.charAt(0) == IndexConstants.RECORD_STRING.SPACE) {
return Collections.emptyList();
}
- final char listDelimiter = getListDelimiter(indexVersionNumber);
- final List tokens = StringUtil.split(values,String.valueOf(listDelimiter));
+ final List<String> tokens = StringUtil.split(values,String.valueOf(listDelimiter));
final List<String> result = new ArrayList<String>(tokens.size());
for (Iterator iter = tokens.iterator(); iter.hasNext();) {
String token = (String)iter.next();
if (token != null) {
- result.add(token);
+ result.add(new String(token));
}
}
return result;
@@ -977,7 +957,7 @@
} else { //remove model name
int index = fullName.indexOf(IndexConstants.NAME_DELIM_CHAR);
if (index > 0) {
- name = fullName.substring(index + 1);
+ name = new String(fullName.substring(index + 1));
}
}
record.setName(name);
@@ -988,7 +968,7 @@
static String getShortName(String fullName) {
int index = fullName.lastIndexOf(IndexConstants.NAME_DELIM_CHAR);
if (index > 0) {
- fullName = fullName.substring(index + 1);
+ fullName = new String(fullName.substring(index + 1));
}
return fullName;
}
@@ -1000,7 +980,7 @@
* The order of the fields in the index file header must also
* be the order of the arguments in method signature.
*/
- private void setRecordFooterValues(final AbstractMetadataRecord record, final List tokens, int tokenIndex) {
+ private void setRecordFooterValues(final AbstractMetadataRecord record, final List<String> tokens, int tokenIndex) {
if (record instanceof TransformationRecordImpl) {
((TransformationRecordImpl)record).setResourcePath(getOptionalToken(tokens, tokenIndex));
}
@@ -1012,9 +992,9 @@
getOptionalToken(tokens, tokenIndex++);
}
- public String getOptionalToken( final List tokens, int tokenIndex) {
+ public String getOptionalToken( final List<String> tokens, int tokenIndex) {
if(tokens.size() > tokenIndex) {
- return (String) tokens.get(tokenIndex);
+ return tokens.get(tokenIndex);
}
return null;
}
13 years, 9 months
teiid SVN: r3018 - in trunk/engine/src: main/java/org/teiid/query/optimizer and 12 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-22 13:09:46 -0400 (Tue, 22 Mar 2011)
New Revision: 3018
Modified:
trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java
trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/VariableResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
Log:
TEIID-1520 TEIID-1523 reducing calls that construct strings and correcting null handling in dynamic sql
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -30,7 +30,6 @@
import java.util.List;
import java.util.Map;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -49,7 +48,7 @@
this.symbolList = Collections.unmodifiableList(new ArrayList(symbols.values()));
this.shortNameToSymbolMap = new HashMap<String, ElementSymbol>(symbolList.size());
for (ElementSymbol symbol : symbolList) {
- shortNameToSymbolMap.put(DataTypeManager.getCanonicalString(symbol.getShortCanonicalName()), symbol);
+ shortNameToSymbolMap.put(symbol.getShortCanonicalName(), symbol);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -93,15 +93,17 @@
throw new AssertionError();
}
- for (Map.Entry<String, Expression> entry : QueryResolver.getVariableValues(userCommand, false, metadata).entrySet()) {
- if (entry.getKey().startsWith(ProcedureReservedWords.INPUTS)) {
+ for (Map.Entry<ElementSymbol, Expression> entry : QueryResolver.getVariableValues(userCommand, false, metadata).entrySet()) {
+ if (entry.getKey().getGroupSymbol().getShortName().equalsIgnoreCase(ProcedureReservedWords.INPUTS)) {
Expression value = entry.getValue() instanceof SingleElementSymbol ? entry.getValue() : new ExpressionSymbol("x", entry.getValue()); //$NON-NLS-1$
- params.put(new ElementSymbol(SQLConstants.Reserved.NEW + ElementSymbol.SEPARATOR + SingleElementSymbol.getShortName(entry.getKey())), value);
+ ElementSymbol newElementSymbol = entry.getKey().clone();
+ newElementSymbol.getGroupSymbol().setName(SQLConstants.Reserved.NEW);
+ params.put(newElementSymbol, value);
if (userCommand instanceof Update) {
((Query)query).getSelect().addSymbol((SelectSymbol) value);
}
} else {
- params.put(new ElementSymbol(entry.getKey()), entry.getValue());
+ params.put(entry.getKey(), entry.getValue());
}
}
ForEachRowPlan result = new ForEachRowPlan();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -61,6 +61,7 @@
import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.VariableContext;
@@ -167,7 +168,7 @@
validateDynamicCommand(procEnv, command);
// create a new set of variables including vars
- Map nameValueMap = createVariableValuesMap(localContext);
+ Map<ElementSymbol, Expression> nameValueMap = createVariableValuesMap(localContext);
nameValueMap.putAll(QueryResolver.getVariableValues(parentProcCommand.getUserCommand(), false, metadata));
ValidationVisitor visitor = new ValidationVisitor();
visitor.setUpdateProc(parentProcCommand);
@@ -236,7 +237,9 @@
new Object[] { this, " The using variable ", //$NON-NLS-1$
setClause.getSymbol(), " has value :", assignment }); //$NON-NLS-1$
localContext.setValue(setClause.getSymbol(), assignment);
- localContext.setValue(new ElementSymbol(Reserved.USING + ElementSymbol.SEPARATOR + setClause.getSymbol().getShortName()), assignment);
+ ElementSymbol es = setClause.getSymbol().clone();
+ es.getGroupSymbol().setShortName(Reserved.USING);
+ localContext.setValue(es, assignment);
}
}
}
@@ -245,17 +248,13 @@
* @param localContext
* @return
*/
- private Map createVariableValuesMap(VariableContext localContext) {
- Map variableMap = new HashMap();
+ private Map<ElementSymbol, Expression> createVariableValuesMap(VariableContext localContext) {
+ Map<ElementSymbol, Object> variableMap = new HashMap<ElementSymbol, Object>();
localContext.getFlattenedContextMap(variableMap);
- Map nameValueMap = new HashMap(variableMap.size());
- Iterator entries = variableMap.entrySet().iterator();
- while (entries.hasNext()) {
- Map.Entry entry = (Map.Entry) entries.next();
- nameValueMap.put(((ElementSymbol) entry.getKey())
- .getCanonicalName(), new Constant(entry.getValue()));
+ Map<ElementSymbol, Expression> nameValueMap = new HashMap<ElementSymbol, Expression>(variableMap.size());
+ for (Map.Entry<ElementSymbol, Object> entry : variableMap.entrySet()) {
+ nameValueMap.put(entry.getKey(), new Constant(entry.getValue(), entry.getKey().getType()));
}
-
return nameValueMap;
}
@@ -303,7 +302,7 @@
// conversion between the
// two
Object[] params = new Object[] { sourceTypeName,
- dynamicSymbol.getShortCanonicalName(),
+ dynamicSymbol.getShortName(),
dynamicTypeName };
throw new QueryProcessingException(QueryPlugin.Util
.getString("ExecDynamicSqlInstruction.6", params)); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -109,6 +109,11 @@
static ElementSymbol ROWCOUNT =
new ElementSymbol(ProcedureReservedWords.VARIABLES+"."+ProcedureReservedWords.ROWCOUNT); //$NON-NLS-1$
+
+ static {
+ ROWS_UPDATED.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ ROWCOUNT.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ }
private VariableContext currentVarContext;
private boolean isUpdateProcedure = true;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -399,7 +399,7 @@
subCommand.setExternalGroupContexts(parentContext);
}
- public static Map<String, Expression> getVariableValues(Command command, boolean changingOnly, QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, TeiidComponentException {
+ public static Map<ElementSymbol, Expression> getVariableValues(Command command, boolean changingOnly, QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, TeiidComponentException {
CommandResolver resolver = chooseResolver(command, metadata);
@@ -407,7 +407,7 @@
return ((VariableResolver)resolver).getVariableValues(command, changingOnly, metadata);
}
- return Collections.EMPTY_MAP;
+ return Collections.emptyMap();
}
public static void resolveSubqueries(Command command,
@@ -452,7 +452,9 @@
//ensure that null types match the view
List<ElementSymbol> symbols = ResolverUtil.resolveElementsInGroup(virtualGroup, qmi);
List<SingleElementSymbol> projectedSymbols = result.getProjectedSymbols();
- Assertion.assertTrue(symbols.size() == projectedSymbols.size(), "View " + virtualGroup + " does not have the correct number of projected symbols"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (symbols.size() != projectedSymbols.size()) {
+ Assertion.failed("View " + virtualGroup + " does not have the correct number of projected symbols"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
for (int i = 0; i < projectedSymbols.size(); i++) {
SingleElementSymbol projectedSymbol = projectedSymbols.get(i);
if (projectedSymbol.getType() != DataTypeManager.DefaultDataClasses.NULL) {
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/VariableResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/VariableResolver.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/VariableResolver.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -29,11 +29,12 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
public interface VariableResolver {
- Map<String, Expression> getVariableValues(Command command, boolean changingOnly, QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, TeiidComponentException;
+ Map<ElementSymbol, Expression> getVariableValues(Command command, boolean changingOnly, QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, TeiidComponentException;
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -241,15 +241,15 @@
* @throws QueryMetadataException
* @see org.teiid.query.resolver.CommandResolver#getVariableValues(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.QueryMetadataInterface)
*/
- public Map<String, Expression> getVariableValues(Command command, boolean changingOnly,
+ public Map<ElementSymbol, Expression> getVariableValues(Command command, boolean changingOnly,
QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, TeiidComponentException {
Insert insert = (Insert) command;
- Map<String, Expression> result = new HashMap<String, Expression>();
+ Map<ElementSymbol, Expression> result = new HashMap<ElementSymbol, Expression>();
// iterate over the variables and values they should be the same number
- Iterator varIter = insert.getVariables().iterator();
+ Iterator<ElementSymbol> varIter = insert.getVariables().iterator();
Iterator valIter = null;
if (insert.getQueryExpression() != null) {
valIter = insert.getQueryExpression().getProjectedSymbols().iterator();
@@ -257,34 +257,32 @@
valIter = insert.getValues().iterator();
}
while (varIter.hasNext()) {
- ElementSymbol varSymbol = (ElementSymbol) varIter.next();
+ ElementSymbol varSymbol = varIter.next().clone();
- String varName = varSymbol.getShortCanonicalName();
- String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
- String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
- result.put(changingKey, new Constant(Boolean.TRUE));
+ varSymbol.getGroupSymbol().setName(ProcedureReservedWords.CHANGING);
+ result.put(varSymbol, new Constant(Boolean.TRUE));
if (!changingOnly) {
- Object value = valIter.next();
- result.put(inputsKey, (Expression)value);
+ varSymbol = varSymbol.clone();
+ varSymbol.getGroupSymbol().setName(ProcedureReservedWords.INPUTS);
+ result.put(varSymbol, (Expression)valIter.next());
}
}
- Collection insertElmnts = ResolverUtil.resolveElementsInGroup(insert.getGroup(), metadata);
+ Collection<ElementSymbol> insertElmnts = ResolverUtil.resolveElementsInGroup(insert.getGroup(), metadata);
insertElmnts.removeAll(insert.getVariables());
- Iterator defaultIter = insertElmnts.iterator();
+ Iterator<ElementSymbol> defaultIter = insertElmnts.iterator();
while(defaultIter.hasNext()) {
- ElementSymbol varSymbol = (ElementSymbol) defaultIter.next();
-
- Expression value = ResolverUtil.getDefault(varSymbol, metadata);
+ ElementSymbol varSymbol = defaultIter.next().clone();
+ varSymbol.getGroupSymbol().setName(ProcedureReservedWords.CHANGING);
+ result.put(varSymbol, new Constant(Boolean.FALSE));
- String varName = varSymbol.getShortCanonicalName();
- String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
- String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
- result.put(changingKey, new Constant(Boolean.FALSE));
if (!changingOnly) {
- result.put(inputsKey, value);
+ Expression value = ResolverUtil.getDefault(varSymbol, metadata);
+ varSymbol = varSymbol.clone();
+ varSymbol.getGroupSymbol().setName(ProcedureReservedWords.INPUTS);
+ result.put(varSymbol, value);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateResolver.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateResolver.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -26,8 +26,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -92,40 +90,35 @@
/**
* @see org.teiid.query.resolver.VariableResolver#getVariableValues(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.QueryMetadataInterface)
*/
- public Map<String, Expression> getVariableValues(Command command, boolean changingOnly,
+ public Map<ElementSymbol, Expression> getVariableValues(Command command, boolean changingOnly,
QueryMetadataInterface metadata) throws QueryMetadataException,
TeiidComponentException {
- Map result = new HashMap();
+ Map<ElementSymbol, Expression> result = new HashMap<ElementSymbol, Expression>();
Update update = (Update) command;
- List updateVars = new LinkedList();
+ Map<ElementSymbol, Expression> changing = update.getChangeList().getClauseMap();
- for (Entry<ElementSymbol, Expression> entry : update.getChangeList().getClauseMap().entrySet()) {
- ElementSymbol leftSymbol = entry.getKey();
-
- String varName = leftSymbol.getShortCanonicalName();
- String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
- String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
- result.put(changingKey, new Constant(Boolean.TRUE));
+ for (Entry<ElementSymbol, Expression> entry : changing.entrySet()) {
+ ElementSymbol leftSymbol = entry.getKey().clone();
+ leftSymbol.getGroupSymbol().setName(ProcedureReservedWords.CHANGING);
+ result.put(leftSymbol, new Constant(Boolean.TRUE));
if (!changingOnly) {
- result.put(inputsKey, entry.getValue());
+ leftSymbol = leftSymbol.clone();
+ leftSymbol.getGroupSymbol().setName(ProcedureReservedWords.INPUTS);
+ result.put(leftSymbol, entry.getValue());
}
- updateVars.add(leftSymbol);
}
- Collection insertElmnts = ResolverUtil.resolveElementsInGroup(update.getGroup(), metadata);
+ Collection<ElementSymbol> insertElmnts = ResolverUtil.resolveElementsInGroup(update.getGroup(), metadata);
- insertElmnts.removeAll(updateVars);
+ insertElmnts.removeAll(changing.keySet());
- Iterator defaultIter = insertElmnts.iterator();
+ Iterator<ElementSymbol> defaultIter = insertElmnts.iterator();
while(defaultIter.hasNext()) {
- ElementSymbol varSymbol = (ElementSymbol) defaultIter.next();
-
- String varName = varSymbol.getShortCanonicalName();
- String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
-
- result.put(changingKey, new Constant(Boolean.FALSE));
+ ElementSymbol varSymbol = defaultIter.next().clone();
+ varSymbol.getGroupSymbol().setName(ProcedureReservedWords.CHANGING);
+ result.put(varSymbol, new Constant(Boolean.FALSE));
}
return result;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -447,13 +447,12 @@
public static Expression getDefault(ElementSymbol symbol, QueryMetadataInterface metadata) throws TeiidComponentException, QueryMetadataException, QueryResolverException {
//Check if there is a default value, if so use it
Object mid = symbol.getMetadataID();
- Class type = symbol.getType();
- String name = symbol.getCanonicalName();
+ Class<?> type = symbol.getType();
Object defaultValue = metadata.getDefaultValue(mid);
if (defaultValue == null && !metadata.elementSupports(mid, SupportConstants.Element.NULL)) {
- throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.required_param", name)); //$NON-NLS-1$
+ throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.required_param", symbol.getOutputName())); //$NON-NLS-1$
}
return getProperlyTypedConstant(defaultValue, type);
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -201,7 +201,7 @@
private boolean rewriteSubcommands;
private boolean processing;
private Evaluator evaluator;
- private Map variables; //constant propagation
+ private Map<ElementSymbol, Expression> variables; //constant propagation
private int commandType;
private QueryRewriter(QueryMetadataInterface metadata,
@@ -220,7 +220,7 @@
return queryRewriter.rewriteCommand(command, false);
}
- public static Command rewrite(Command command, CreateUpdateProcedureCommand procCommand, QueryMetadataInterface metadata, CommandContext context, Map variableValues, int commandType) throws TeiidComponentException, TeiidProcessingException{
+ public static Command rewrite(Command command, CreateUpdateProcedureCommand procCommand, QueryMetadataInterface metadata, CommandContext context, Map<ElementSymbol, Expression> variableValues, int commandType) throws TeiidComponentException, TeiidProcessingException{
QueryRewriter rewriter = new QueryRewriter(metadata, context, procCommand);
rewriter.rewriteSubcommands = true;
rewriter.variables = variableValues;
@@ -307,7 +307,7 @@
private Command rewriteUpdateProcedure(CreateUpdateProcedureCommand command)
throws TeiidComponentException, TeiidProcessingException{
- Map oldVariables = variables;
+ Map<ElementSymbol, Expression> oldVariables = variables;
if (command.getUserCommand() != null) {
variables = QueryResolver.getVariableValues(command.getUserCommand(), false, metadata);
commandType = command.getUserCommand().getType();
@@ -2271,21 +2271,21 @@
ElementSymbol es = (ElementSymbol)expression;
Class<?> type = es.getType();
if (!processing && es.isExternalReference()) {
- String grpName = es.getGroupSymbol().getCanonicalName();
-
if (variables == null) {
return new Reference(es);
}
-
- Expression value = (Expression)variables.get(es.getCanonicalName());
+ Expression value = variables.get(es);
if (value == null) {
- if (grpName.equals(ProcedureReservedWords.INPUTS)) {
- return new Constant(null, es.getType());
- }
- if (grpName.equals(ProcedureReservedWords.CHANGING)) {
- Assertion.failed("Changing value should not be null"); //$NON-NLS-1$
- }
+ if (es.getGroupSymbol().getSchema() == null) {
+ String grpName = es.getGroupSymbol().getShortCanonicalName();
+ if (grpName.equals(ProcedureReservedWords.INPUTS)) {
+ return new Constant(null, es.getType());
+ }
+ if (grpName.equals(ProcedureReservedWords.CHANGING)) {
+ Assertion.failed("Changing value should not be null"); //$NON-NLS-1$
+ }
+ }
} else if (value instanceof Constant) {
if (value.getType() == type) {
return value;
@@ -3014,12 +3014,12 @@
private boolean checkInputVariables(Expression expr) throws TeiidComponentException, TeiidProcessingException{
Boolean result = null;
for (ElementSymbol var : ElementCollectorVisitor.getElements(expr, false)) {
- String grpName = var.getGroupSymbol().getName();
- if (var.isExternalReference() && grpName.equalsIgnoreCase(ProcedureReservedWords.INPUTS)) {
+ if (var.isExternalReference() && var.getGroupSymbol().getSchema() == null && var.getGroupSymbol().getShortName().equalsIgnoreCase(ProcedureReservedWords.INPUTS)) {
- String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + var.getShortCanonicalName();
+ var = var.clone();
+ var.getGroupSymbol().setShortName(ProcedureReservedWords.CHANGING);
- Boolean changingValue = (Boolean)((Constant)variables.get(changingKey)).getValue();
+ Boolean changingValue = (Boolean)((Constant)variables.get(var)).getValue();
if (result == null) {
result = changingValue;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -88,8 +88,8 @@
stmt.setCommand(null);
stmt.setExpression(null);
String fullName = ProcedureReservedWords.VARIABLES+ElementSymbol.SEPARATOR+ProcedureReservedWords.ROWCOUNT;
- if (stmt.getVariable().getCanonicalName().equals(ProcedureReservedWords.ROWCOUNT)
- || stmt.getVariable().getCanonicalName().equals(fullName)) {
+ if (stmt.getVariable().getShortName().equalsIgnoreCase(ProcedureReservedWords.ROWCOUNT)
+ && stmt.getVariable().getCanonicalName().equals(fullName)) {
return;
}
stmt.setExpression(new ElementSymbol(fullName));
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -252,7 +252,7 @@
* Return a deep copy of this object.
* @return Deep copy of this object
*/
- public Object clone() {
+ public ElementSymbol clone() {
ElementSymbol copy = new ElementSymbol(getShortName(), getCanonical());
if(getGroupSymbol() != null) {
copy.setGroupSymbol(getGroupSymbol().clone());
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -319,4 +319,8 @@
}
return canonicalSchema;
}
+
+ public String getSchema() {
+ return schema;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -481,16 +481,6 @@
}
public void visit(DeclareStatement obj) {
- ElementSymbol variable = obj.getVariable();
- String elementname = variable.getShortCanonicalName();
-
- // varible cannot be one of the special variables
- if(elementname.equals(ProcedureReservedWords.ROWS_UPDATED)) {
- handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0017", new Object[] {ProcedureReservedWords.ROWS_UPDATED}), obj); //$NON-NLS-1$
- } else if(elementname.equals(ProcedureReservedWords.ROWCOUNT)) {
- handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0017", new Object[] {ProcedureReservedWords.ROWCOUNT}), obj); //$NON-NLS-1$
- }
-
validateAssignment(obj, obj.getVariable());
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -44,7 +44,7 @@
TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, new HardcodedDataManager(), FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
fail();
} catch (QueryResolverException e) {
- assertEquals("Required parameter 'PM4.SPTEST9.INKEY' has no value was set or is an invalid parameter.", e.getMessage()); //$NON-NLS-1$
+ assertEquals("Required parameter 'pm4.spTest9.inkey' has no value was set or is an invalid parameter.", e.getMessage()); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -246,6 +246,16 @@
helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
}
+ @Test public void testSingleReplacementInDynamicCommandNullValue() throws Exception {
+ final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
+ final String userSql = "exec Virt.sq1(null)"; //$NON-NLS-1$
+ final String multiModel = "MultiModel"; //$NON-NLS-1$
+ final int sources = 3;
+ final List[] expected = new List[0];
+ final ProcessorDataManager dataMgr = new MultiSourceDataManager();
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
+ }
+
@Test public void testMultiUpdateAll() throws Exception {
final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
final String userSql = "update MultiModel.Phys set a = '1' where b = 'z'"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -1599,7 +1599,7 @@
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE 'select e1 from pm1.g1'\" with the SQL statement \"'select e1 from pm1.g1'\" due to: The datatype 'string' for element 'E1' in the dynamic SQL cannot be implicitly converted to 'integer'.", metadata); //$NON-NLS-1$
+ helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE 'select e1 from pm1.g1'\" with the SQL statement \"'select e1 from pm1.g1'\" due to: The datatype 'string' for element 'e1' in the dynamic SQL cannot be implicitly converted to 'integer'.", metadata); //$NON-NLS-1$
}
@Test public void testDynamicCommandWithTwoDynamicStatements() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2011-03-22 14:51:13 UTC (rev 3017)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2011-03-22 17:09:46 UTC (rev 3018)
@@ -2322,6 +2322,7 @@
FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("Virt.rs1", virtModel, new String[] { "a", "b" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
+ rs2p2.putProperty(FakeMetadataObject.Props.NULL, Boolean.TRUE);
QueryNode sq2n1 = new QueryNode("pm1.sq1", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "execute string 'SELECT a, b FROM MultiModel.Phys where SOURCE_NAME = Virt.sq1.in'; END"); //$NON-NLS-1$
FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("Virt.sq1", virtModel, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1); //$NON-NLS-1$
13 years, 9 months
teiid SVN: r3017 - trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-22 10:51:13 -0400 (Tue, 22 Mar 2011)
New Revision: 3017
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
Log:
TEIID-1522 a better costing value for constant expressions
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2011-03-22 14:43:07 UTC (rev 3016)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2011-03-22 14:51:13 UTC (rev 3017)
@@ -608,7 +608,7 @@
static float getStat(Stat stat, Collection<? extends Expression> elems, PlanNode node,
float cardinality, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
- float result = 0;
+ float result = 1;
int branch = 0;
boolean branchFound = false;
for (Expression expression : elems) {
13 years, 9 months
teiid SVN: r3016 - in trunk: test-integration/common/src/test/java/org/teiid/jdbc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-22 10:43:07 -0400 (Tue, 22 Mar 2011)
New Revision: 3016
Added:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java
Modified:
trunk/api/src/main/java/org/teiid/metadata/ProcedureParameter.java
Log:
TEIID-1521 fix for procedure import error
Modified: trunk/api/src/main/java/org/teiid/metadata/ProcedureParameter.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/ProcedureParameter.java 2011-03-22 13:40:07 UTC (rev 3015)
+++ trunk/api/src/main/java/org/teiid/metadata/ProcedureParameter.java 2011-03-22 14:43:07 UTC (rev 3016)
@@ -33,6 +33,7 @@
Unknown,
In,
InOut,
+ Result,
Out,
ReturnValue
}
Added: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java 2011-03-22 14:43:07 UTC (rev 3016)
@@ -0,0 +1,74 @@
+/*
+ * 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.jdbc;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.jdbc.teiid.TeiidExecutionFactory;
+
+
+/**
+ */
+@SuppressWarnings("nls")
+public class TestDymamicImportedMetaData {
+
+ Connection conn;
+
+ ////////////////////Query Related Methods///////////////////////////
+
+ @Before public void setUp() throws Exception {
+ FakeServer server = new FakeServer();
+ server.deployVDB("test", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
+ conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
+ }
+
+ private MetadataFactory getMetadata(Properties importProperties)
+ throws TranslatorException {
+ VDBRepository vdbRepository = new VDBRepository();
+ vdbRepository.setSystemStore(VDBMetadataFactory.getSystem());
+
+ TeiidExecutionFactory tef = new TeiidExecutionFactory();
+ MetadataFactory mf = new MetadataFactory("test", vdbRepository.getBuiltinDatatypes(), importProperties);
+ tef.getMetadata(mf, conn);
+ return mf;
+ }
+
+ @Test public void testProcImport() throws Exception {
+ Properties importProperties = new Properties();
+ importProperties.setProperty("importer.importProcedures", Boolean.TRUE.toString());
+ MetadataFactory mf = getMetadata(importProperties);
+ Procedure p = mf.getMetadataStore().getSchemas().get("TEST").getProcedures().get("GETXMLSCHEMAS");
+ assertEquals(1, p.getResultSet().getColumns().size());
+ }
+}
Property changes on: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years, 9 months
teiid SVN: r3015 - in trunk/engine/src/test/java/org/teiid/query: sql/symbol and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-22 09:40:07 -0400 (Tue, 22 Mar 2011)
New Revision: 3015
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java
Log:
TEIID-1520 better string storage on group/element symbols
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2011-03-22 13:00:05 UTC (rev 3014)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2011-03-22 13:40:07 UTC (rev 3015)
@@ -186,8 +186,8 @@
@Test public void testUnionPushDownWithJoin1() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select * from (SELECT IntKey FROM BQT1.SmallA where intkey in (1, 2) UNION ALL SELECT intkey FROM BQT2.SmallA where intkey in (3, 4)) A inner join (SELECT intkey FROM BQT1.SmallB where intkey in (1, 2) UNION ALL SELECT intkey FROM BQT2.SmallB where intkey in (3, 4)) B on a.intkey = b.intkey where a.intkey in (1, 4)", FakeMetadataFactory.exampleBQTCached(), null, TestOptimizer.getGenericFinder(),//$NON-NLS-1$
- new String[] { "SELECT g_1.intkey, g_0.intkey FROM BQT2.SmallA AS g_0, BQT2.SmallB AS g_1 WHERE (g_0.intkey = g_1.intkey) AND (g_0.intkey IN (4)) AND (g_0.intkey = 4) AND (g_1.intkey IN (4)) AND (g_1.intkey = 4)",
- "SELECT g_1.intkey, g_0.IntKey FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1 WHERE (g_0.IntKey = g_1.intkey) AND (g_0.intkey IN (1)) AND (g_0.IntKey = 1) AND (g_1.intkey = 1)" }, ComparisonMode.EXACT_COMMAND_STRING);
+ new String[] { "SELECT g_1.intkey, g_0.IntKey FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1 WHERE (g_0.IntKey = g_1.intkey) AND (g_0.intkey IN (1)) AND (g_0.IntKey = 1) AND (g_1.intkey = 1)",
+ "SELECT g_1.intkey, g_0.intkey FROM BQT2.SmallA AS g_0, BQT2.SmallB AS g_1 WHERE (g_0.intkey = g_1.intkey) AND (g_0.intkey IN (4)) AND (g_0.intkey = 4) AND (g_1.intkey = 4)" }, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java 2011-03-22 13:00:05 UTC (rev 3014)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java 2011-03-22 13:40:07 UTC (rev 3015)
@@ -254,7 +254,6 @@
// Change original, clone shouldn't change
String originalName = e1.getName();
- e1.setName("a"); //$NON-NLS-1$
assertTrue("Cloned value changed but should not have: ", copy.getName().equals(originalName)); //$NON-NLS-1$
GroupSymbol originalGroup = e1.getGroupSymbol();
13 years, 9 months
teiid SVN: r3014 - in trunk/engine/src: main/java/org/teiid/query/optimizer/relational/plantree and 23 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-22 09:00:05 -0400 (Tue, 22 Mar 2011)
New Revision: 3014
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCopyCriteria.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/XMLQueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/From.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllInGroupSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/SingleElementSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/AbstractSymbolMappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestElementImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestXMLResolver.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestGroupSymbol.java
trunk/engine/src/test/java/org/teiid/query/sql/util/TestElementSymbolOptimizer.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1520 better string storage on group/element symbols
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -93,7 +93,6 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.EvaluatableVisitor;
import org.teiid.query.sql.visitor.GroupCollectorVisitor;
@@ -474,7 +473,7 @@
String groupName = node.getGroups().iterator().next().getName();
tt.getGroupSymbol().setName(groupName);
for (ElementSymbol symbol : tt.getProjectedSymbols()) {
- symbol.setName(groupName + SingleElementSymbol.SEPARATOR + symbol.getShortName());
+ symbol.setGroupSymbol(new GroupSymbol(groupName));
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -26,9 +26,10 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -67,7 +68,7 @@
// --------------------- Planning Info --------------------------
/** The set of groups that this node deals with. */
- private Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
+ private Set<GroupSymbol> groups = new LinkedHashSet<GroupSymbol>();
// =========================================================================
// C O N S T R U C T O R S
@@ -172,7 +173,7 @@
public Object setProperty(NodeConstants.Info propertyID, Object value) {
if(nodeProperties == null) {
- nodeProperties = new HashMap<NodeConstants.Info, Object>();
+ nodeProperties = new LinkedHashMap<NodeConstants.Info, Object>();
}
return nodeProperties.put(propertyID, value);
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCopyCriteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCopyCriteria.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCopyCriteria.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -25,8 +25,8 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -190,7 +190,7 @@
List<Criteria> joinCrits = (List<Criteria>) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
Set<Criteria> combinedCriteria = null;
if (joinCrits != null) {
- combinedCriteria = new HashSet<Criteria>(joinCrits);
+ combinedCriteria = new LinkedHashSet<Criteria>(joinCrits);
combinedCriteria.addAll(leftChildCriteria[1]);
combinedCriteria.addAll(rightChildCriteria[1]);
}
@@ -262,8 +262,8 @@
case NodeConstants.Types.PROJECT:
{
if (criteriaInfo[0] == null) {
- criteriaInfo[0] = new HashSet<Criteria>();
- criteriaInfo[1] = new HashSet<Criteria>();
+ criteriaInfo[0] = new LinkedHashSet<Criteria>();
+ criteriaInfo[1] = new LinkedHashSet<Criteria>();
} else {
criteriaInfo[0].clear();
criteriaInfo[1].clear();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -485,7 +485,7 @@
private void updateSymbolName(List<SingleElementSymbol> projectCols, int i,
ElementSymbol virtualElem, SingleElementSymbol projectedSymbol) {
if (projectedSymbol instanceof AliasSymbol) {
- ((AliasSymbol)projectedSymbol).setName(virtualElem.getShortCanonicalName());
+ ((AliasSymbol)projectedSymbol).setShortName(virtualElem.getShortCanonicalName());
} else {
projectCols.set(i, new AliasSymbol(virtualElem.getShortCanonicalName(), projectedSymbol));
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -190,7 +190,7 @@
if (!positional) {
symbolMap.put(new ElementSymbol(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + name), (ElementSymbol)elementSymbol.clone());
symbolMap.put(new ElementSymbol(ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + name), (ElementSymbol)elementSymbol.clone());
- elementSymbol.setName(name);
+ elementSymbol.setShortName(name);
}
elements.add(elementSymbol);
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -216,7 +216,7 @@
discoveredMetadata.addTempGroup(procName, tempElements, isVirtual);
// Resolve tempElements against new metadata
- GroupSymbol procGroup = new GroupSymbol(procName);
+ GroupSymbol procGroup = new GroupSymbol(storedProcedureInfo.getProcedureCallableName());
procGroup.setProcedure(true);
TempMetadataID tid = discoveredMetadata.getTempGroupID(procName);
tid.setOriginalMetadataID(storedProcedureCommand.getProcedureID());
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/XMLQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/XMLQueryResolver.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/XMLQueryResolver.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -309,7 +309,7 @@
// Get exact matching name
String critElemName = elem.getName();
- String critElemNameSuffix = "." + critElemName.toUpperCase(); //$NON-NLS-1$
+ String critElemNameSuffix = "." + elem.getCanonicalName(); //$NON-NLS-1$
// Prepare results
ElementSymbol exactMatch = null;
@@ -375,13 +375,14 @@
}
if(exactMatch != null) {
- String name = elem.getName();
+ String name = elem.getOutputName();
// Resolve based on exact match
- elem.setName(exactMatch.getName());
- elem.setOutputName(name);
+ elem.setShortName(exactMatch.getShortName());
+ elem.setShortCanonicalName(exactMatch.getShortCanonicalName());
elem.setMetadataID(exactMatch.getMetadataID());
elem.setType(exactMatch.getType());
elem.setGroupSymbol(exactMatch.getGroupSymbol());
+ elem.setOutputName(name);
} else if(partialMatches.size() == 0 && attributeMatches.size() == 0){
try {
ResolverVisitor.resolveLanguageObject(elem, Collections.EMPTY_LIST, externalGroups, metadata);
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -43,6 +43,7 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.TransformationException;
import org.teiid.core.types.DataTypeManager.DefaultDataTypes;
+import org.teiid.core.util.StringUtil;
import org.teiid.query.QueryPlugin;
import org.teiid.query.function.FunctionDescriptor;
import org.teiid.query.function.FunctionLibrary;
@@ -503,21 +504,20 @@
LinkedHashMap<Object, ElementSymbol> symbols = new LinkedHashMap<Object, ElementSymbol>(elementIDs.size());
- boolean groupIsAliased = group.getDefinition() != null;
+ String groupFullName = metadata.getFullName(group.getMetadataID());
+ boolean isXml = metadata.isXMLGroup(group.getMetadataID());
for (Object elementID : elementIDs) {
- String elementName = metadata.getFullName(elementID);
- String fullName = elementName;
- // This is only really needed if the group is an ALIAS. Doing the check outside the loop
- // and NOT doing unnecessary work if Aliased group.
- if(groupIsAliased) {
- String shortName = metadata.getShortElementName(elementName);
- fullName = metadata.getFullElementName(group.getName(), shortName);
- }
-
+ String elementName = metadata.getFullName(elementID);
+ if (isXml) {
+ elementName = elementName.substring(groupFullName.length() + 1);
+ } else {
+ //the logic about should work in either case,
+ //but there is a lot of metadata to correct
+ elementName = metadata.getShortElementName(elementName);
+ }
// Form an element symbol from the ID
- ElementSymbol element = new ElementSymbol(fullName);
- element.setGroupSymbol(group);
+ ElementSymbol element = new ElementSymbol(elementName, DataTypeManager.getCanonicalString(StringUtil.toUpperCase(elementName)), group);
element.setMetadataID(elementID);
element.setType( DataTypeManager.getDataTypeClass(metadata.getElementType(element.getMetadataID())) );
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -35,7 +35,6 @@
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.api.exception.query.UnresolvedSymbolDescription;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
import org.teiid.query.QueryPlugin;
@@ -151,7 +150,7 @@
// look up group and element parts of the potentialID
String groupContext = metadata.getGroupName(potentialID);
- String elementShortName = metadata.getShortElementName(potentialID);
+ String elementShortName = elementSymbol.getShortCanonicalName();
if (groupContext != null) {
groupContext = groupContext.toUpperCase();
try {
@@ -170,7 +169,7 @@
}
private boolean internalResolveElementSymbol(ElementSymbol elementSymbol,
- String groupContext, String elementShortName, String expectedGroupContext)
+ String groupContext, String shortCanonicalName, String expectedGroupContext)
throws TeiidComponentException, QueryResolverException {
boolean isExternal = false;
boolean groupMatched = false;
@@ -205,7 +204,6 @@
}
LinkedList<ElementMatch> matches = new LinkedList<ElementMatch>();
- String shortCanonicalName = elementShortName.toUpperCase();
while (root != null) {
Collection<GroupSymbol> matchedGroups = ResolverUtil.findMatchingGroups(groupContext, root.getGroups(), metadata);
if (matchedGroups != null && !matchedGroups.isEmpty()) {
@@ -252,22 +250,18 @@
}
if (isExternal //convert input to inputs
&& isScalar(resolvedSymbol, ProcedureReservedWords.INPUT)) {
- resolvedSymbol = new ElementSymbol(ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + elementShortName);
+ resolvedSymbol = new ElementSymbol(shortCanonicalName);
+ resolvedSymbol.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.INPUTS));
resolveElementSymbol(resolvedSymbol);
oldName = resolvedSymbol.getOutputName();
- resolvedGroup = new GroupSymbol(ProcedureReservedWords.INPUTS);
- try {
- ResolverUtil.resolveGroup(resolvedGroup, metadata);
- } catch (QueryResolverException e) {
- throw new TeiidRuntimeException(e);
- }
+ resolvedGroup = resolvedSymbol.getGroupSymbol();
}
elementSymbol.setIsExternalReference(isExternal);
elementSymbol.setType(resolvedSymbol.getType());
elementSymbol.setMetadataID(resolvedSymbol.getMetadataID());
elementSymbol.setGroupSymbol(resolvedGroup);
- elementSymbol.setName(resolvedSymbol.getName());
- elementSymbol.setCanonicalName(resolvedSymbol.getCanonicalName());
+ elementSymbol.setShortName(resolvedSymbol.getShortName());
+ elementSymbol.setShortCanonicalName(resolvedSymbol.getShortCanonicalName());
elementSymbol.setOutputName(oldName);
return true;
}
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -2784,7 +2784,7 @@
SingleElementSymbol actual = iter.next();
if (!ses.getShortCanonicalName().equals(actual.getShortCanonicalName())) {
if (ses instanceof AliasSymbol) {
- ((AliasSymbol)ses).setName(actual.getShortName());
+ ((AliasSymbol)ses).setShortName(actual.getShortName());
} else {
ses = new AliasSymbol(actual.getShortName(), ses);
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/From.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/From.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/From.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -22,13 +22,16 @@
package org.teiid.query.sql.lang;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
-import org.teiid.query.sql.*;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.visitor.*;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
/**
@@ -38,22 +41,21 @@
*/
public class From implements LanguageObject {
- // List of <FromClause>
- private List clauses;
+ private List<FromClause> clauses;
/**
* Constructs a default instance of this class.
*/
public From() {
- clauses = new ArrayList();
+ clauses = new ArrayList<FromClause>();
}
/**
* Constructs an instance of this class from an ordered set of from clauses
* @param parameters The ordered list of from clauses
*/
- public From( List parameters ) {
- clauses = new ArrayList( parameters );
+ public From( List<? extends FromClause> parameters ) {
+ clauses = new ArrayList<FromClause>( parameters );
}
// =========================================================================
@@ -72,15 +74,15 @@
* Add clauses to the FROM
* @param clauses Collection of {@link FromClause}s
*/
- public void addClauses(Collection clauses) {
- this.clauses.addAll(clauses);
+ public void addClauses(Collection<? extends FromClause> toAdd) {
+ this.clauses.addAll(toAdd);
}
/**
* Get all the clauses in FROM
* @return List of {@link FromClause}
*/
- public List getClauses() {
+ public List<FromClause> getClauses() {
return this.clauses;
}
@@ -88,7 +90,7 @@
* Set all the clauses
* @param clauses List of {@link FromClause}
*/
- public void setClauses(List clauses) {
+ public void setClauses(List<FromClause> clauses) {
this.clauses = clauses;
}
@@ -123,7 +125,7 @@
List<GroupSymbol> groups = new ArrayList<GroupSymbol>();
if(clauses != null) {
for(int i=0; i<clauses.size(); i++) {
- FromClause clause = (FromClause) clauses.get(i);
+ FromClause clause = clauses.get(i);
clause.collectGroups(groups);
}
}
@@ -152,16 +154,7 @@
* Return copy of this From clause.
*/
public Object clone() {
- List copyClauses = new ArrayList(clauses.size());
- if(clauses.size() > 0) {
- Iterator iter = clauses.iterator();
- while(iter.hasNext()) {
- FromClause c = (FromClause) iter.next();
- copyClauses.add(c.clone());
- }
- }
-
- return new From(copyClauses);
+ return new From(LanguageObject.Util.deepClone(clauses, FromClause.class));
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -237,7 +237,7 @@
for (int j = 0; j < iSize; j++) {
ElementSymbol symbol = (ElementSymbol)variables.get( j ).clone();
- symbol.setName(ProcedureReservedWords.INPUTS + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
+ symbol.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.INPUTS));
map.put(symbol, values.get( j ) );
} // for
return map;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -116,7 +116,7 @@
return this.procedureName;
}
public String getProcedureCallableName(){
- return this.callableName;
+ return this.callableName != null?this.callableName:this.procedureName;
}
public void setProcedureCallableName(String callableName){
this.callableName = callableName;
@@ -265,11 +265,11 @@
for (SPParameter parameter : mapOfParameters.values()) {
if(parameter.getParameterType() == ParameterInfo.RETURN_VALUE){
ElementSymbol symbol = parameter.getParameterSymbol();
- symbol.setGroupSymbol(getGroup());
+ symbol.setGroupSymbol(this.getGroup());
result.add(0, symbol);
} else if(parameter.getParameterType() == ParameterInfo.INOUT || parameter.getParameterType() == ParameterInfo.OUT){
ElementSymbol symbol = parameter.getParameterSymbol();
- symbol.setGroupSymbol(getGroup());
+ symbol.setGroupSymbol(this.getGroup());
result.add(symbol);
}
}
@@ -320,7 +320,7 @@
public GroupSymbol getGroup() {
if(group == null) {
- return new GroupSymbol(this.getProcedureName());
+ return new GroupSymbol(this.getProcedureCallableName());
}
return group;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -98,8 +98,12 @@
UnaryFromClause other = (UnaryFromClause)obj;
- return EquivalenceUtil.areEqual(getGroup(), other.getGroup()) &&
- other.isOptional() == this.isOptional();
+ if( (this.getGroup().getDefinition() == null && other.getGroup().getDefinition() == null) ||
+ (this.getGroup().getDefinition() != null && other.getGroup().getDefinition() != null) ) {
+ return EquivalenceUtil.areEqual(getGroup(), other.getGroup()) &&
+ other.isOptional() == this.isOptional();
+ }
+ return false;
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -33,7 +33,6 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -265,7 +264,7 @@
for (Iterator iter = getChangeList().getClauses().iterator(); iter.hasNext();) {
SetClause setClause = (SetClause)iter.next();
ElementSymbol symbol = (ElementSymbol)(setClause.getSymbol()).clone();
- symbol.setName(ProcedureReservedWords.INPUTS + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
+ symbol.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.INPUTS));
map.put( symbol, setClause.getValue() );
} // for
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllInGroupSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllInGroupSymbol.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllInGroupSymbol.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -22,9 +22,10 @@
package org.teiid.query.sql.symbol;
-import java.util.*;
+import java.util.List;
-import org.teiid.query.sql.*;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
/**
* <p>This is a subclass of Symbol representing <group>.*, which contains all of
@@ -61,15 +62,9 @@
public Object clone() {
AllInGroupSymbol copy = new AllInGroupSymbol(getName(), getCanonical());
- List elements = getElementSymbols();
+ List<ElementSymbol> elements = getElementSymbols();
if(elements != null && elements.size() > 0) {
- ArrayList copyElements = new ArrayList(elements.size());
- Iterator iter = elements.iterator();
- while(iter.hasNext()) {
- ElementSymbol element = (ElementSymbol) iter.next();
- copyElements.add( element.clone() );
- }
- copy.setElementSymbols(copyElements);
+ copy.setElementSymbols(LanguageObject.Util.deepClone(elements, ElementSymbol.class));
}
return copy;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllSymbol.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllSymbol.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -22,9 +22,10 @@
package org.teiid.query.sql.symbol;
-import java.util.*;
+import java.util.List;
-import org.teiid.query.sql.*;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
/**
* <p>This is a subclass of Symbol representing *, which contains all of
@@ -63,15 +64,9 @@
public Object clone() {
AllSymbol copy = new AllSymbol(ALL_SYMBOL_NAME, ALL_SYMBOL_NAME);
- List elements = getElementSymbols();
+ List<ElementSymbol> elements = getElementSymbols();
if(elements != null && elements.size() > 0) {
- ArrayList copyElements = new ArrayList(elements.size());
- Iterator iter = elements.iterator();
- while(iter.hasNext()) {
- ElementSymbol element = (ElementSymbol) iter.next();
- copyElements.add( element.clone() );
- }
- copy.setElementSymbols(copyElements);
+ copy.setElementSymbols(LanguageObject.Util.deepClone(elements, ElementSymbol.class));
}
return copy;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -22,7 +22,8 @@
package org.teiid.query.sql.symbol;
-import org.teiid.query.sql.*;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
/**
* <p>This is a subclass of Symbol representing a single element. An ElementSymbol
@@ -67,6 +68,11 @@
super(name);
}
+ public ElementSymbol(String shortName, String shortCanonical, GroupSymbol group) {
+ super(shortName, shortCanonical);
+ this.groupSymbol = group;
+ }
+
/**
* Constructor taking a name and a flag whether to display fully qualified.
* @param name Name of the symbol
@@ -77,6 +83,48 @@
setDisplayFullyQualified(displayFullyQualified);
}
+ @Override
+ public String getName() {
+ if (this.groupSymbol != null) {
+ return this.groupSymbol.getName() + SingleElementSymbol.SEPARATOR + this.getShortName();
+ }
+ return super.getName();
+ }
+
+ @Override
+ public String getCanonicalName() {
+ if (this.groupSymbol != null) {
+ return this.groupSymbol.getCanonicalName() + SingleElementSymbol.SEPARATOR + this.getShortCanonicalName();
+ }
+ return super.getCanonicalName();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this.groupSymbol == null) {
+ return super.equals(obj);
+ }
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof ElementSymbol)) {
+ return false;
+ }
+ ElementSymbol other = (ElementSymbol)obj;
+ if (other.groupSymbol == null) {
+ return super.equals(obj);
+ }
+ return this.groupSymbol.equals(other.groupSymbol) && this.getShortCanonicalName().equals(other.getShortCanonicalName());
+ }
+
+ @Override
+ public int hashCode() {
+ if (this.groupSymbol != null) {
+ return HashCodeUtil.hashCode(this.groupSymbol.hashCode(), this.getShortCanonicalName().hashCode());
+ }
+ return super.hashCode();
+ }
+
public void setDisplayMode(DisplayMode displayMode) {
if (displayMode == null) {
this.displayMode = DisplayMode.OUTPUT_NAME;
@@ -131,7 +179,22 @@
public void setGroupSymbol(GroupSymbol symbol) {
this.groupSymbol = symbol;
}
-
+
+ public void setName(String name) {
+ int index = name.lastIndexOf('.');
+ if (index > 0) {
+ if (this.groupSymbol != null) {
+ throw new AssertionError("Attempt to set an invalid name"); //$NON-NLS-1$
+ }
+ GroupSymbol gs = new GroupSymbol(name.substring(0, index));
+ this.setGroupSymbol(gs);
+ name = name.substring(index + 1);
+ } else {
+ this.groupSymbol = null;
+ }
+ super.setShortName(name);
+ }
+
/**
* Get the group symbol referred to by this element symbol, may be null before resolution
* @return Group symbol referred to by this element, may be null
@@ -190,14 +253,14 @@
* @return Deep copy of this object
*/
public Object clone() {
- ElementSymbol copy = new ElementSymbol(getName(), getCanonical());
+ ElementSymbol copy = new ElementSymbol(getShortName(), getCanonical());
if(getGroupSymbol() != null) {
copy.setGroupSymbol(getGroupSymbol().clone());
}
copy.setMetadataID(getMetadataID());
copy.setType(getType());
copy.setIsExternalReference(isExternalReference());
- copy.setOutputName(this.getOutputName());
+ copy.outputName = this.outputName;
copy.setDisplayMode(this.getDisplayMode());
return copy;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -22,6 +22,10 @@
package org.teiid.query.sql.symbol;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.core.util.StringUtil;
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.LanguageVisitor;
@@ -54,6 +58,8 @@
private Object modelMetadataId;
private String outputDefinition;
+ private String schema;
+ private String canonicalSchema;
/**
* Cloning constructor
@@ -188,14 +194,16 @@
* @return Deep copy of the object
*/
public GroupSymbol clone() {
- GroupSymbol copy = new GroupSymbol(getName(), getCanonical(), getDefinition());
+ GroupSymbol copy = new GroupSymbol(getShortName(), getCanonical(), getDefinition());
+ copy.schema = this.schema;
+ copy.canonicalSchema = this.canonicalSchema;
if(getMetadataID() != null) {
copy.setMetadataID(getMetadataID());
}
copy.setIsTempTable(isTempTable);
copy.setProcedure(isProcedure);
copy.setOutputDefinition(this.getOutputDefinition());
- copy.setOutputName(this.getOutputName());
+ copy.outputName = this.outputName;
copy.isGlobalTable = isGlobalTable;
copy.modelMetadataId = modelMetadataId;
return copy;
@@ -216,16 +224,10 @@
}
GroupSymbol other = (GroupSymbol) obj;
- // Two group symbols will be equal only if both use aliases or both
- // don't use aliases. In either case, comparing canonical names is
- // enough.
- if( (this.getDefinition() == null && other.getDefinition() == null) ||
- (this.getDefinition() != null && other.getDefinition() != null) ) {
-
+ if (this.schema == null || other.schema == null) {
return this.getCanonicalName().equals(other.getCanonicalName());
-
}
- return false;
+ return EquivalenceUtil.areEqual(this.getCanonicalSchema(), other.getCanonicalSchema()) && this.getShortCanonicalName().equals(other.getShortCanonicalName());
}
public boolean hasAlias() {
@@ -274,4 +276,47 @@
public void setGlobalTable(boolean isGlobalTable) {
this.isGlobalTable = isGlobalTable;
}
+
+ @Override
+ public String getName() {
+ if (this.schema != null) {
+ return this.schema + SingleElementSymbol.SEPARATOR + this.getShortName();
+ }
+ return super.getName();
+ }
+
+ @Override
+ public String getCanonicalName() {
+ if (this.schema != null) {
+ return this.getCanonicalSchema() + SingleElementSymbol.SEPARATOR + this.getShortCanonicalName();
+ }
+ return super.getCanonicalName();
+ }
+
+ @Override
+ public int hashCode() {
+ if (this.schema != null) {
+ return HashCodeUtil.hashCode(this.getCanonicalSchema().hashCode(), this.getShortCanonicalName().hashCode());
+ }
+ return super.hashCode();
+ }
+
+ public void setName(String name) {
+ int index = name.indexOf('.');
+ if (index > 0) {
+ this.schema = name.substring(0, index);
+ name = name.substring(index + 1);
+ } else {
+ this.schema = null;
+ }
+ this.canonicalSchema = null;
+ super.setShortName(name);
+ }
+
+ private String getCanonicalSchema() {
+ if (this.canonicalSchema == null && this.schema != null) {
+ this.canonicalSchema = DataTypeManager.getCanonicalString(StringUtil.toUpperCase(this.schema));
+ }
+ return canonicalSchema;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/SingleElementSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/SingleElementSymbol.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/SingleElementSymbol.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -53,15 +53,6 @@
super(name);
}
- /**
- * Get the short name of the element
- * @return Short name of the symbol (un-dotted)
- */
- public String getShortName() {
- String name = getName();
- return getShortName(name);
- }
-
public static String getShortName(String name) {
int index = name.lastIndexOf(SEPARATOR);
if(index >= 0) {
@@ -69,13 +60,5 @@
}
return name;
}
-
- /**
- * Get the short name of the element
- * @return Short name of the symbol (un-dotted)
- */
- public String getShortCanonicalName() {
- String name = getCanonicalName();
- return getShortName(name);
- }
+
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -46,12 +46,12 @@
* Prior to resolving it is the name as entered in the query,
* after resolving it is the fully qualified name.
*/
- private String name;
+ private String shortName;
/**
* upper case of name
*/
- private String canonicalName;
+ private String canonicalShortName;
/**
* Prior to resolving null, after resolving it is the exact string
@@ -59,7 +59,7 @@
*
* The AliasGenerator can also set this value as necessary for the data tier.
*/
- private String outputName;
+ protected String outputName;
/**
* Constructor to be used for cloning instances. Calls to String.toUpperCase() to generate the canonical names
@@ -70,8 +70,8 @@
* @since 4.3
*/
protected Symbol(String name, String canonicalName) {
- this.name = name;
- this.canonicalName = canonicalName;
+ this.shortName = name;
+ this.canonicalShortName = canonicalName;
}
/**
@@ -80,8 +80,12 @@
* @throws IllegalArgumentException If name is null
*/
public Symbol(String name) {
- setName(name);
+ this.setName(name);
}
+
+ protected void setName(String name) {
+ setShortName(name);
+ }
/**
* Change the symbol's name. This will change the symbol's hash code
@@ -89,14 +93,14 @@
* collection, it will be lost!
* @param name New name
*/
- public void setName(String name) {
+ public void setShortName(String name) {
if(name == null) {
throw new IllegalArgumentException(QueryPlugin.Util.getString("ERR.015.010.0017")); //$NON-NLS-1$
}
- this.name = DataTypeManager.getCanonicalString(name);
+ this.shortName = DataTypeManager.getCanonicalString(name);
this.outputName = null;
// Canonical name is lazily created
- this.canonicalName = null;
+ this.canonicalShortName = null;
}
/**
@@ -104,7 +108,7 @@
* @return Name of the symbol, never null
*/
public String getName() {
- return this.name;
+ return getShortName();
}
/**
@@ -112,14 +116,11 @@
* @return Canonical name for comparisons
*/
public String getCanonicalName() {
- // PERFORMANCE1: String.toUpperCase() is an expensive call, and calls from this class are the largest component
- // of the total toUpperCase() calls, so we are lazily performing the toUpperCase and calculating the hash.
- computeCanonicalNameAndHash();
- return this.canonicalName;
+ return getShortCanonicalName();
}
- public void setCanonicalName(String canonicalName) {
- this.canonicalName = canonicalName;
+ public void setShortCanonicalName(String shortCanonicalName) {
+ this.canonicalShortName = shortCanonicalName;
}
/**
@@ -146,9 +147,7 @@
* @return Hash code
*/
public int hashCode() {
- computeCanonicalNameAndHash();
- // Return cached hash code
- return this.canonicalName.hashCode();
+ return this.getCanonicalName().hashCode();
}
/**
@@ -167,7 +166,9 @@
if(!(obj instanceof Symbol)) {
return false;
}
- return ((Symbol)obj).getCanonicalName().equals(getCanonicalName());
+ String otherFqn = ((Symbol)obj).getCanonicalName();
+ String thisFqn = getCanonicalName();
+ return thisFqn.equals(otherFqn);
}
/**
@@ -175,16 +176,10 @@
*/
public abstract Object clone();
- protected String getCanonical() {
- return canonicalName;
+ protected final String getCanonical() {
+ return canonicalShortName;
}
- private void computeCanonicalNameAndHash() {
- if (canonicalName == null) {
- canonicalName = DataTypeManager.getCanonicalString(StringUtil.toUpperCase(name));
- }
- }
-
public String getOutputName() {
return this.outputName == null ? getName() : this.outputName;
}
@@ -192,5 +187,25 @@
public void setOutputName(String outputName) {
this.outputName =outputName;
}
+
+ /**
+ * Get the short name of the element
+ * @return Short name of the symbol (un-dotted)
+ */
+ public final String getShortName() {
+ return shortName;
+ }
+ /**
+ * Get the short name of the element
+ * @return Short name of the symbol (un-dotted)
+ */
+ public final String getShortCanonicalName() {
+ if (canonicalShortName == null) {
+ canonicalShortName = DataTypeManager.getCanonicalString(StringUtil.toUpperCase(shortName));
+ }
+ return this.canonicalShortName;
+ }
+
+
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/AbstractSymbolMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/AbstractSymbolMappingVisitor.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/AbstractSymbolMappingVisitor.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -164,7 +164,7 @@
// Finally, swap name of group, which should be the name of the group
// for all of the element symbols
- obj.setName(newGroupName + ".*"); //$NON-NLS-1$
+ obj.setShortName(newGroupName + ".*"); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -164,7 +164,7 @@
if (replacement instanceof SingleElementSymbol) {
replacmentSymbol = (SingleElementSymbol)replacement;
} else {
- replacmentSymbol = new ExpressionSymbol(ses.getName(), replacement);
+ replacmentSymbol = new ExpressionSymbol(ses.getShortName(), replacement);
}
if (alias && createAliases() && !replacmentSymbol.getShortCanonicalName().equals(ses.getShortCanonicalName())) {
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -427,7 +427,8 @@
public Expression replaceExpression(Expression element) {
if (element instanceof ElementSymbol) {
ElementSymbol es = (ElementSymbol)element;
- ((ElementSymbol) element).setName(tableName + ElementSymbol.SEPARATOR + es.getShortName());
+ es.getGroupSymbol().setName(tableName);
+ es.getGroupSymbol().setDefinition(null);
}
return element;
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -405,7 +405,7 @@
UpdateMapping info = updateInfo.updatableGroups.get(groupName);
if (es.getGroupSymbol().getDefinition() != null) {
ElementSymbol clone = (ElementSymbol)es.clone();
- clone.setName(es.getGroupSymbol().getDefinition() + ElementSymbol.SEPARATOR + es.getShortName());
+ clone.setOutputName(null);
clone.getGroupSymbol().setName(clone.getGroupSymbol().getNonCorrelationName());
clone.getGroupSymbol().setDefinition(null);
es = clone;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestElementImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestElementImpl.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestElementImpl.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -82,7 +82,7 @@
public void testGetName() throws Exception {
Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$
- assertEquals("e1", example("pm1.g1", "e1", metadataID).getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("pm1.g1.e1", example("pm1.g1", "e1", metadataID).getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void testGetGroup() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -25,6 +25,8 @@
import java.util.HashSet;
import java.util.Set;
+import junit.framework.TestCase;
+
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
@@ -32,10 +34,8 @@
import org.teiid.query.sql.navigator.DeepPostOrderNavigator;
import org.teiid.query.unittest.FakeMetadataFactory;
-import junit.framework.TestCase;
-
/**
* @since 4.2
*/
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -2784,7 +2784,7 @@
@Test public void testCopyCriteriaWithOuterJoin2_defect10050(){
ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1 and pm2.g1.e2=pm2.g2.e2 where pm2.g1.e1 = 'a' and pm2.g1.e2 = 1", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0 LEFT OUTER JOIN pm2.g2 AS g_1 ON g_0.e1 = g_1.e1 AND g_0.e2 = g_1.e2 AND g_1.e2 = 1 AND g_1.e1 = 'a' WHERE (g_0.e1 = 'a') AND (g_0.e2 = 1)" }); //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0 LEFT OUTER JOIN pm2.g2 AS g_1 ON g_0.e1 = g_1.e1 AND g_0.e2 = g_1.e2 AND g_1.e1 = 'a' AND g_1.e2 = 1 WHERE (g_0.e1 = 'a') AND (g_0.e2 = 1)" }); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -186,8 +186,8 @@
@Test public void testUnionPushDownWithJoin1() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select * from (SELECT IntKey FROM BQT1.SmallA where intkey in (1, 2) UNION ALL SELECT intkey FROM BQT2.SmallA where intkey in (3, 4)) A inner join (SELECT intkey FROM BQT1.SmallB where intkey in (1, 2) UNION ALL SELECT intkey FROM BQT2.SmallB where intkey in (3, 4)) B on a.intkey = b.intkey where a.intkey in (1, 4)", FakeMetadataFactory.exampleBQTCached(), null, TestOptimizer.getGenericFinder(),//$NON-NLS-1$
- new String[] { "SELECT g_1.intkey, g_0.intkey FROM BQT2.SmallA AS g_0, BQT2.SmallB AS g_1 WHERE (g_0.intkey = g_1.intkey) AND (g_0.intkey IN (4)) AND (g_0.intkey = 4) AND (g_1.intkey = 4)",
- "SELECT g_1.intkey, g_0.IntKey FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1 WHERE (g_0.IntKey = g_1.intkey) AND (g_0.intkey IN (1)) AND (g_0.IntKey = 1) AND (g_1.intkey IN (1)) AND (g_1.intkey = 1)" }, ComparisonMode.EXACT_COMMAND_STRING);
+ new String[] { "SELECT g_1.intkey, g_0.intkey FROM BQT2.SmallA AS g_0, BQT2.SmallB AS g_1 WHERE (g_0.intkey = g_1.intkey) AND (g_0.intkey IN (4)) AND (g_0.intkey = 4) AND (g_1.intkey IN (4)) AND (g_1.intkey = 4)",
+ "SELECT g_1.intkey, g_0.IntKey FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1 WHERE (g_0.IntKey = g_1.intkey) AND (g_0.intkey IN (1)) AND (g_0.IntKey = 1) AND (g_1.intkey = 1)" }, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -60,7 +60,7 @@
Query command = (Query)QueryParser.getQueryParser().parseCommand(sql);
((ElementSymbol)command.getSelect().getSymbol(0)).setGroupSymbol(new GroupSymbol("y")); //$NON-NLS-1$
command.acceptVisitor(new AliasGenerator(true));
- assertEquals("SELECT v_0.c_0 FROM (SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 AS g_0) AS v_0", command.toString()); //$NON-NLS-1$
+ assertEquals("SELECT v_0.c_0 FROM (SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0) AS v_0", command.toString()); //$NON-NLS-1$
}
@Test public void testLongOrderByAlias() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -305,7 +305,7 @@
Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, new Function("func", new Expression[] {y})); //$NON-NLS-1$
JoinPredicate predicate = new JoinPredicate(new UnaryFromClause(a), new UnaryFromClause(b), JoinType.JOIN_INNER, Arrays.asList(new Object[] {criteria}));
- From from = new From(Arrays.asList(new Object[] {predicate}));
+ From from = new From(Arrays.asList(predicate));
predicate.getLeftClause().setMakeNotDep(true);
predicate.getRightClause().setMakeDep(true);
Select select = new Select(Arrays.asList(new Object[] {x, y}));
@@ -990,7 +990,7 @@
ElementSymbol x = new ElementSymbol("a.x", true); //$NON-NLS-1$
ElementSymbol y = new ElementSymbol("b.y", true); //$NON-NLS-1$
- From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(a), new UnaryFromClause(b)}));
+ From from = new From(Arrays.asList(new UnaryFromClause(a), new UnaryFromClause(b)));
Option option = new Option();
option.addDependentGroup("a"); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -2966,7 +2966,6 @@
Select select = new Select();
ElementSymbol symbol = new ElementSymbol("c"); //$NON-NLS-1$
- symbol.setGroupSymbol(g);
select.addSymbol(symbol);
Query query = new Query();
@@ -2998,7 +2997,6 @@
Select select = new Select();
ElementSymbol symbol = new ElementSymbol("c"); //$NON-NLS-1$
- symbol.setGroupSymbol(g);
select.addSymbol(symbol);
Query query = new Query();
@@ -3030,7 +3028,6 @@
Select select = new Select();
ElementSymbol symbol = new ElementSymbol("c"); //$NON-NLS-1$
- symbol.setGroupSymbol(g);
select.addSymbol(symbol);
Query query = new Query();
@@ -6440,7 +6437,7 @@
@Test public void testLimit() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
- From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
+ From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(null, new Constant(new Integer(100))));
@@ -6450,7 +6447,7 @@
@Test public void testLimitWithOffset() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
- From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
+ From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Constant(new Integer(50)), new Constant(new Integer(100))));
@@ -6460,7 +6457,7 @@
@Test public void testLimitWithReferences1() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
- From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
+ From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Reference(0), new Constant(new Integer(100))));
@@ -6470,7 +6467,7 @@
@Test public void testLimitWithReferences2() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
- From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
+ From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Constant(new Integer(50)), new Reference(0)));
@@ -6480,7 +6477,7 @@
@Test public void testLimitWithReferences3() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
- From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
+ From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Reference(0), new Reference(1)));
Modified: trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -282,11 +282,8 @@
if (group.getDefinition() != null){
String groupAlias = group.getCanonicalName();
ElementSymbol elementSymbol = (ElementSymbol)SymbolMap.getExpression((SingleElementSymbol)element);
- String newName = groupAlias + "." + elementSymbol.getShortName(); //$NON-NLS-1$
- ElementSymbol aliasedElement = new ElementSymbol(newName, elementSymbol.getDisplayFullyQualified());
- aliasedElement.setGroupSymbol(elementSymbol.getGroupSymbol());
- aliasedElement.setMetadataID(elementSymbol.getMetadataID());
- aliasedElement.setType(elementSymbol.getType());
+ ElementSymbol aliasedElement = (ElementSymbol)elementSymbol.clone();
+ aliasedElement.getGroupSymbol().setName(groupAlias);
lookupMap.put(aliasedElement, index);
} else {
lookupMap.put(element, index);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -698,7 +698,7 @@
FakeMetadataObject in1 = FakeMetadataFactory.createParameter("pm1.sp119.in1", 2, SPParameter.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
FakeMetadataObject rs3 = FakeMetadataFactory.createResultSet("pm1.sp119.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject rs3p1 = FakeMetadataFactory.createParameter("ret", 1, SPParameter.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs3); //$NON-NLS-1$
- FakeMetadataObject sp1 = FakeMetadataFactory.createStoredProcedure("pm1.sp119", pm1, Arrays.asList(new FakeMetadataObject[] { rs3p1, in1 }), "pm1.sp119"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject sp1 = FakeMetadataFactory.createStoredProcedure("pm1.sp119", pm1, Arrays.asList(new FakeMetadataObject[] { rs3p1, in1 })); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataStore store = new FakeMetadataStore();
store.addObject(pm1);
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -948,11 +948,11 @@
List elements = (List) ElementCollectorVisitor.getElements(resolvedQuery.getSelect(), false);
ElementSymbol elem1 = (ElementSymbol)elements.get(0);
- assertEquals("Did not get expected element", "X.e1", elem1.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Did not get expected element", "x.e1", elem1.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Did not get expected type", DataTypeManager.DefaultDataClasses.STRING, elem1.getType()); //$NON-NLS-1$
ElementSymbol elem2 = (ElementSymbol)elements.get(1);
- assertEquals("Did not get expected element", "X.e2", elem2.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Did not get expected element", "x.e2", elem2.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Did not get expected type", DataTypeManager.DefaultDataClasses.INTEGER, elem2.getType()); //$NON-NLS-1$
}
@@ -2661,7 +2661,7 @@
Command cmd = helpResolve(proc.toString());
- String sExpected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE LOCAL TEMPORARY TABLE #matt (x integer);\nINSERT INTO #matt (#MATT.x) VALUES (1);\nEND\n\tCREATE LOCAL TEMPORARY TABLE #matt (x integer)\n\tINSERT INTO #matt (#MATT.x) VALUES (1)\n"; //$NON-NLS-1$
+ String sExpected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE LOCAL TEMPORARY TABLE #matt (x integer);\nINSERT INTO #matt (#matt.x) VALUES (1);\nEND\n\tCREATE LOCAL TEMPORARY TABLE #matt (x integer)\n\tINSERT INTO #matt (#matt.x) VALUES (1)\n"; //$NON-NLS-1$
String sActual = cmd.printCommandTree();
assertEquals( sExpected, sActual );
}
@@ -2956,7 +2956,7 @@
@Test public void testParamOrder() {
Query resolvedQuery = (Query)helpResolve("SELECT * FROM (exec pm4.spRetOut()) as a", RealMetadataFactory.exampleBQTCached(), null); //$NON-NLS-1$
- assertEquals("A.ret", resolvedQuery.getProjectedSymbols().get(0).getName());
+ assertEquals("a.ret", resolvedQuery.getProjectedSymbols().get(0).getName());
}
@Test public void testOrderByAggregatesError() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestXMLResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestXMLResolver.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestXMLResolver.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -57,9 +57,8 @@
public void testXMLCriteriaShortElement() {
CompareCriteria expected = new CompareCriteria();
- ElementSymbol es = new ElementSymbol("xmltest.doc1.root.node1"); //$NON-NLS-1$
- GroupSymbol gs = new GroupSymbol("doc1"); //$NON-NLS-1$
- es.setGroupSymbol(gs);
+ GroupSymbol gs = new GroupSymbol("xmltest.doc1"); //$NON-NLS-1$
+ ElementSymbol es = new ElementSymbol("root.node1", null, gs); //$NON-NLS-1$
expected.setLeftExpression(es);
expected.setOperator(CompareCriteria.EQ);
expected.setRightExpression(new Constant("yyz")); //$NON-NLS-1$
@@ -71,8 +70,8 @@
public void testXMLCriteriaLongElement1() {
CompareCriteria expected = new CompareCriteria();
- ElementSymbol es = new ElementSymbol("xmltest.doc1.root.node1"); //$NON-NLS-1$
- GroupSymbol gs = new GroupSymbol("doc1"); //$NON-NLS-1$
+ GroupSymbol gs = new GroupSymbol("xmltest.doc1"); //$NON-NLS-1$
+ ElementSymbol es = new ElementSymbol("root.node1", null, gs); //$NON-NLS-1$
es.setGroupSymbol(gs);
expected.setLeftExpression(es);
expected.setOperator(CompareCriteria.EQ);
@@ -85,9 +84,8 @@
public void testXMLCriteriaLongElement2() {
CompareCriteria expected1 = new CompareCriteria();
- ElementSymbol es1 = new ElementSymbol("xmltest.doc4.root.node1"); //$NON-NLS-1$
- GroupSymbol gs = new GroupSymbol("doc4"); //$NON-NLS-1$
- es1.setGroupSymbol(gs);
+ GroupSymbol gs = new GroupSymbol("xmltest.doc4"); //$NON-NLS-1$
+ ElementSymbol es1 = new ElementSymbol("root.node1", null, gs); //$NON-NLS-1$
expected1.setLeftExpression(es1);
expected1.setOperator(CompareCriteria.EQ);
expected1.setRightExpression(new Constant("xyz")); //$NON-NLS-1$
@@ -98,9 +96,9 @@
}
public void testXMLCriteriaLongElement3() {
- GroupSymbol gs = new GroupSymbol("doc4"); //$NON-NLS-1$
+ GroupSymbol gs = new GroupSymbol("xmltest.doc4"); //$NON-NLS-1$
CompareCriteria expected2 = new CompareCriteria();
- ElementSymbol es2 = new ElementSymbol("xmltest.doc4.root.node1.@node2"); //$NON-NLS-1$
+ ElementSymbol es2 = new ElementSymbol("root.node1.@node2", null, gs); //$NON-NLS-1$
es2.setGroupSymbol(gs);
expected2.setLeftExpression(es2);
expected2.setOperator(CompareCriteria.EQ);
@@ -112,10 +110,9 @@
}
public void testXMLCriteriaLongElement4() {
- GroupSymbol gs = new GroupSymbol("doc4"); //$NON-NLS-1$
+ GroupSymbol gs = new GroupSymbol("xmltest.doc4"); //$NON-NLS-1$
CompareCriteria expected3 = new CompareCriteria();
- ElementSymbol es3 = new ElementSymbol("xmltest.doc4.root.node3"); //$NON-NLS-1$
- es3.setGroupSymbol(gs);
+ ElementSymbol es3 = new ElementSymbol("root.node3", null, gs); //$NON-NLS-1$
expected3.setLeftExpression(es3);
expected3.setOperator(CompareCriteria.EQ);
expected3.setRightExpression(new Constant("xyz")); //$NON-NLS-1$
@@ -196,9 +193,8 @@
public void testXMLCriteriaLongElementInAnonymous() {
CompareCriteria expected = new CompareCriteria();
- ElementSymbol es = new ElementSymbol("xmltest.doc2.root.node1.node3"); //$NON-NLS-1$
- GroupSymbol gs = new GroupSymbol("doc2"); //$NON-NLS-1$
- es.setGroupSymbol(gs);
+ GroupSymbol gs = new GroupSymbol("xmltest.doc2"); //$NON-NLS-1$
+ ElementSymbol es = new ElementSymbol("root.node1.node3", null, gs); //$NON-NLS-1$
expected.setLeftExpression(es);
expected.setOperator(CompareCriteria.EQ);
expected.setRightExpression(new Constant("yyz")); //$NON-NLS-1$
@@ -312,12 +308,9 @@
}
public void testContext() {
- ElementSymbol es1 = new ElementSymbol("xmltest.doc1.root.node1.node2.node3"); //$NON-NLS-1$
- GroupSymbol gs1 = new GroupSymbol("doc1"); //$NON-NLS-1$
- es1.setGroupSymbol(gs1);
- ElementSymbol es2 = new ElementSymbol("xmltest.doc1.root.node1"); //$NON-NLS-1$
- GroupSymbol gs2 = new GroupSymbol("doc1"); //$NON-NLS-1$
- es2.setGroupSymbol(gs2);
+ GroupSymbol gs1 = new GroupSymbol("xmltest.doc1"); //$NON-NLS-1$
+ ElementSymbol es1 = new ElementSymbol("root.node1.node2.node3", null, gs1); //$NON-NLS-1$
+ ElementSymbol es2 = new ElementSymbol("root.node1", null, gs1); //$NON-NLS-1$
Expression[] exprs = new Expression[]{es1, es2};
Function context = new Function("context", exprs); //$NON-NLS-1$
@@ -333,8 +326,8 @@
}
public void testRowLimit() {
- ElementSymbol es1 = new ElementSymbol("xmltest.doc1.root.node1.node2.node3"); //$NON-NLS-1$
- GroupSymbol gs1 = new GroupSymbol("doc1"); //$NON-NLS-1$
+ GroupSymbol gs1 = new GroupSymbol("xmltest.doc1"); //$NON-NLS-1$
+ ElementSymbol es1 = new ElementSymbol("root.node1.node2.node3", null, gs1); //$NON-NLS-1$
es1.setGroupSymbol(gs1);
Expression[] exprs = new Expression[]{es1};
@@ -351,9 +344,8 @@
}
public void testRowLimitException() {
- ElementSymbol es1 = new ElementSymbol("xmltest.doc1.root.node1.node2.node3"); //$NON-NLS-1$
- GroupSymbol gs1 = new GroupSymbol("doc1"); //$NON-NLS-1$
- es1.setGroupSymbol(gs1);
+ GroupSymbol gs1 = new GroupSymbol("xmltest.doc1"); //$NON-NLS-1$
+ ElementSymbol es1 = new ElementSymbol("root.node1.node2.node3", null, gs1); //$NON-NLS-1$
Expression[] exprs = new Expression[]{es1};
Function context = new Function("rowlimitexception", exprs); //$NON-NLS-1$
@@ -386,9 +378,8 @@
public void testConversionInXML() {
// Expected left expression
- ElementSymbol es1 = new ElementSymbol("xmltest.doc1.root.node1"); //$NON-NLS-1$
- GroupSymbol gs1 = new GroupSymbol("doc1"); //$NON-NLS-1$
- es1.setGroupSymbol(gs1);
+ GroupSymbol gs1 = new GroupSymbol("xmltest.doc1"); //$NON-NLS-1$
+ ElementSymbol es1 = new ElementSymbol("root.node1", null, gs1); //$NON-NLS-1$
// Expected right expression
Function convert = new Function("convert", new Expression[] { new Constant(new Integer(5)), new Constant("string") }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -409,9 +400,8 @@
public void testXMLWithSelect1() throws Exception {
CompareCriteria expected = new CompareCriteria();
- ElementSymbol es = new ElementSymbol("xmltest.doc1.root.node1"); //$NON-NLS-1$
- GroupSymbol gs = new GroupSymbol("doc1"); //$NON-NLS-1$
- es.setGroupSymbol(gs);
+ GroupSymbol gs = new GroupSymbol("xmltest.doc1"); //$NON-NLS-1$
+ ElementSymbol es = new ElementSymbol("root.node1", null, gs); //$NON-NLS-1$
expected.setLeftExpression(es);
expected.setOperator(CompareCriteria.EQ);
expected.setRightExpression(new Constant("yyz")); //$NON-NLS-1$
@@ -427,9 +417,8 @@
public void testXMLWithSelect2() {
CompareCriteria expected = new CompareCriteria();
- ElementSymbol es = new ElementSymbol("xmltest.doc1.root.node1"); //$NON-NLS-1$
- GroupSymbol gs = new GroupSymbol("doc1"); //$NON-NLS-1$
- es.setGroupSymbol(gs);
+ GroupSymbol gs = new GroupSymbol("xmltest.doc1"); //$NON-NLS-1$
+ ElementSymbol es = new ElementSymbol("root.node1", null, gs); //$NON-NLS-1$
expected.setLeftExpression(es);
expected.setOperator(CompareCriteria.EQ);
expected.setRightExpression(new Constant("yyz")); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -1971,7 +1971,7 @@
@Test public void testRewriteSelectInto() {
String sql = "select distinct pm1.g1.e1 into #temp from pm1.g1"; //$NON-NLS-1$
- String expected = "INSERT INTO #temp (#TEMP.e1) SELECT DISTINCT pm1.g1.e1 FROM pm1.g1"; //$NON-NLS-1$
+ String expected = "INSERT INTO #temp (#temp.e1) SELECT DISTINCT pm1.g1.e1 FROM pm1.g1"; //$NON-NLS-1$
helpTestRewriteCommand(sql, expected);
}
@@ -2038,7 +2038,7 @@
procedure += "Select x from temp;\n"; //$NON-NLS-1$
procedure += "END\n"; //$NON-NLS-1$
- helpTestRewriteCommand(procedure, "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE LOCAL TEMPORARY TABLE temp (x string, y integer, z integer);\nINSERT INTO temp (TEMP.x, TEMP.y, TEMP.z) SELECT X.e2 AS x, X.x AS y, X.X_0 AS z FROM (SELECT pm1.g1.e2, 1 AS x, 2 AS X_0 FROM pm1.g1 ORDER BY pm1.g1.e2 LIMIT 1) AS X;\nSELECT x FROM temp;\nEND"); //$NON-NLS-1$
+ helpTestRewriteCommand(procedure, "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE LOCAL TEMPORARY TABLE temp (x string, y integer, z integer);\nINSERT INTO temp (temp.x, temp.y, temp.z) SELECT X.e2 AS x, X.x AS y, X.X_0 AS z FROM (SELECT pm1.g1.e2, 1 AS x, 2 AS X_0 FROM pm1.g1 ORDER BY pm1.g1.e2 LIMIT 1) AS X;\nSELECT x FROM temp;\nEND"); //$NON-NLS-1$
}
@Test public void testRewriteNot() {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -22,23 +22,14 @@
package org.teiid.query.sql.symbol;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.GroupSymbol;
-import junit.framework.TestCase;
+@SuppressWarnings("nls")
+public class TestElementSymbol {
-
-public class TestElementSymbol extends TestCase {
-
- // ################################## FRAMEWORK ################################
-
- public TestElementSymbol(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
/** Unaliased group "m.g" */
public static final GroupSymbol sampleGroup1() {
return new GroupSymbol("m.g"); //$NON-NLS-1$
@@ -94,117 +85,117 @@
// ################################## ACTUAL TESTS ################################
- public void testParser1() {
+ @Test public void testParser1() {
helpParser(sampleElement1(), "c"); //$NON-NLS-1$
}
- public void testParser2() {
+ @Test public void testParser2() {
helpParser(sampleElement2(), "m.g.c"); //$NON-NLS-1$
}
- public void testParser3() {
+ @Test public void testParser3() {
helpParser(sampleElement3(), "c"); //$NON-NLS-1$
}
- public void testParser4() {
+ @Test public void testParser4() {
helpParser(sampleElement4(), "gg.c"); //$NON-NLS-1$
}
// Compare elements to themselves
- public void testEquals1() {
+ @Test public void testEquals1() {
ElementSymbol es = sampleElement1();
helpEquals(es, es, true);
}
- public void testEquals2() {
+ @Test public void testEquals2() {
ElementSymbol es = sampleElement2();
helpEquals(es, es, true);
}
- public void testEquals3() {
+ @Test public void testEquals3() {
ElementSymbol es = sampleElement3();
helpEquals(es, es, true);
}
- public void testEquals4() {
+ @Test public void testEquals4() {
ElementSymbol es = sampleElement4();
helpEquals(es, es, true);
}
// Compare elements to their clones
- public void testEquals5() {
+ @Test public void testEquals5() {
ElementSymbol es = sampleElement1();
helpEquals(es, (ElementSymbol)es.clone(), true);
}
- public void testEquals6() {
+ @Test public void testEquals6() {
ElementSymbol es = sampleElement2();
helpEquals(es, (ElementSymbol)es.clone(), true);
}
- public void testEquals7() {
+ @Test public void testEquals7() {
ElementSymbol es = sampleElement3();
helpEquals(es, (ElementSymbol)es.clone(), true);
}
- public void testEquals8() {
+ @Test public void testEquals8() {
ElementSymbol es = sampleElement4();
helpEquals(es, (ElementSymbol)es.clone(), true);
}
// Compare fully-qualified to short versions
- public void testEquals9() {
+ @Test public void testEquals9() {
helpEquals(sampleElement1(), sampleElement2(), true);
}
- public void testEquals10() {
+ @Test public void testEquals10() {
helpEquals(sampleElement3(), sampleElement4(), true);
}
// Compare same-named elements with same groups but different group contexts
- public void testEquals11() {
+ @Test public void testEquals11() {
helpEquals(sampleElement1(), sampleElement3(), false);
}
- public void testEquals12() {
+ @Test public void testEquals12() {
helpEquals(sampleElement2(), sampleElement4(), false);
}
// Test case sensitivity
- public void testEquals13() {
+ @Test public void testEquals13() {
ElementSymbol es1 = new ElementSymbol("abcd"); //$NON-NLS-1$
es1.setGroupSymbol(sampleGroup1());
ElementSymbol es2 = new ElementSymbol("AbCd"); //$NON-NLS-1$
- es1.setGroupSymbol(sampleGroup1());
+ es2.setGroupSymbol(sampleGroup1());
helpEquals(es1, es2, true);
}
- public void testSelfEquivalence(){
+ @Test public void testSelfEquivalence(){
Object s1 = sampleElement1();
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, s1, s1);
}
- public void testEquivalence(){
+ @Test public void testEquivalence(){
Object s1 = sampleElement1();
Object s1a = sampleElement1();
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, s1, s1a);
}
- public void testCloneEquivalence(){
+ @Test public void testCloneEquivalence(){
ElementSymbol s1 = sampleElement1();
ElementSymbol s2 = (ElementSymbol)s1.clone();
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, s1, s2);
}
- public void testNonEquivalence(){
+ @Test public void testNonEquivalence(){
Object s1 = sampleElement1();
Object s3 = sampleElement3();
int equals = -1;
@@ -212,51 +203,51 @@
}
/*
- public void testEqualsMethod(){
+ @Test public void testEqualsMethod(){
QueryUnitTestUtils.helpTestEquals(sampleElement1());
}
- public void testEqualsMethodTransitivity(){
+ @Test public void testEqualsMethodTransitivity(){
//test transitivity with two equal Objects
QueryUnitTestUtils.helpTestEqualsTransitivity(sampleElement1(), sampleElement1());
}
- public void testEqualsMethodTransitivity2(){
+ @Test public void testEqualsMethodTransitivity2(){
//test transitivity with two nonequal Objects
QueryUnitTestUtils.helpTestEqualsTransitivity(sampleElement1(), sampleElement2());
}
- public void testHashCodeConsistentWithEquals(){
+ @Test public void testHashCodeConsistentWithEquals(){
//test hash code with two equal Objects
QueryUnitTestUtils.helpTestHashCodeConsistentWithEquals(sampleElement1(), sampleElement2());
}
*/
- public void testClone1() {
+ @Test public void testClone1() {
ElementSymbol e1 = sampleElement1();
ElementSymbol copy = (ElementSymbol) e1.clone();
helpEquals(e1, copy, true);
}
- public void testClone2() {
+ @Test public void testClone2() {
ElementSymbol e1 = sampleElement2();
ElementSymbol copy = (ElementSymbol) e1.clone();
helpEquals(e1, copy, true);
}
- public void testClone3() {
+ @Test public void testClone3() {
ElementSymbol e1 = sampleElement3();
ElementSymbol copy = (ElementSymbol) e1.clone();
helpEquals(e1, copy, true);
}
- public void testClone4() {
+ @Test public void testClone4() {
ElementSymbol e1 = sampleElement4();
ElementSymbol copy = (ElementSymbol) e1.clone();
helpEquals(e1, copy, true);
}
- public void testClone5() {
+ @Test public void testClone5() {
ElementSymbol e1 = sampleElement1();
ElementSymbol copy = (ElementSymbol) e1.clone();
helpEquals(e1, copy, true);
@@ -275,4 +266,12 @@
assertTrue("Cloned value changed but should not have: ", copy.getDisplayFullyQualified() == fullyQualified); //$NON-NLS-1$
}
+ @Test public void testEqualsWithAndWithoutGroupSymbol() {
+ ElementSymbol e1 = new ElementSymbol("x.y");
+
+ ElementSymbol e2 = new ElementSymbol("y");
+ e2.setGroupSymbol(new GroupSymbol("x"));
+ helpEquals(e1, e2, true);
+ }
+
}
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestGroupSymbol.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestGroupSymbol.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestGroupSymbol.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -23,11 +23,11 @@
package org.teiid.query.sql.symbol;
-import org.teiid.query.sql.symbol.GroupSymbol;
-
import junit.framework.TestCase;
+import org.teiid.query.sql.lang.UnaryFromClause;
+
/**
* @since 4.2
*/
@@ -55,16 +55,16 @@
assertFalse(group.isTempGroupSymbol());
}
- public void defer_testInequality() {
+ public void testEquality() {
GroupSymbol group = new GroupSymbol("g1", "a"); //$NON-NLS-1$ //$NON-NLS-2$
GroupSymbol group1 = new GroupSymbol("g1", "b"); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse(group.equals(group1));
+ assertEquals(group, group1);
}
public void testInequality1() {
GroupSymbol group = new GroupSymbol("g1", "a"); //$NON-NLS-1$ //$NON-NLS-2$
GroupSymbol group1 = new GroupSymbol("g1"); //$NON-NLS-1$
- assertFalse(group.equals(group1));
+ assertFalse(new UnaryFromClause(group).equals(new UnaryFromClause(group1)));
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/sql/util/TestElementSymbolOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/util/TestElementSymbolOptimizer.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/sql/util/TestElementSymbolOptimizer.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -23,8 +23,9 @@
package org.teiid.query.sql.util;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryParserException;
import org.teiid.api.exception.query.QueryResolverException;
@@ -37,19 +38,10 @@
import org.teiid.query.sql.lang.Command;
import org.teiid.query.unittest.FakeMetadataFactory;
-
/**
*/
-public class TestElementSymbolOptimizer extends TestCase {
+public class TestElementSymbolOptimizer {
- /**
- * Constructor for TestElementSymbolOptimizer.
- * @param name
- */
- public TestElementSymbolOptimizer(String name) {
- super(name);
- }
-
public Command helpResolve(String sql, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, TeiidComponentException {
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -71,51 +63,51 @@
}
/** Can be optimized */
- public void testOptimize1() throws Exception {
+ @Test public void testOptimize1() throws Exception {
helpTestOptimize("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT e1, e2 FROM pm1.g1"); //$NON-NLS-1$
}
/** Can't be optimized */
- public void testOptimize2() throws Exception {
+ @Test public void testOptimize2() throws Exception {
helpTestOptimize("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1, pm1.g2", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1, pm1.g2"); //$NON-NLS-1$
}
- public void testOptimize3() throws Exception {
+ @Test public void testOptimize3() throws Exception {
helpTestOptimize("UPDATE pm1.g1 SET pm1.g1.e1 = 'e' WHERE pm1.g1.e2 = 3", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"UPDATE pm1.g1 SET e1 = 'e' WHERE e2 = 3"); //$NON-NLS-1$
}
- public void testOptimize4() throws Exception {
+ @Test public void testOptimize4() throws Exception {
helpTestOptimize("INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES ('e', 3)", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"INSERT INTO pm1.g1 (e1, e2) VALUES ('e', 3)"); //$NON-NLS-1$
}
- public void testOptimize5() throws Exception {
+ @Test public void testOptimize5() throws Exception {
helpTestOptimize("DELETE FROM pm1.g1 WHERE pm1.g1.e2 = 3", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"DELETE FROM pm1.g1 WHERE e2 = 3"); //$NON-NLS-1$
}
- public void testOptimize6() throws Exception {
+ @Test public void testOptimize6() throws Exception {
helpTestOptimize("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE e2 > (SELECT AVG(pm1.g2.e2) FROM pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1)", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT e1, e2 FROM pm1.g1 WHERE e2 > (SELECT AVG(e2) FROM pm1.g2 WHERE pm1.g1.e1 = e1)"); //$NON-NLS-1$
}
/** alias */
- public void testOptimize7() throws Exception {
+ @Test public void testOptimize7() throws Exception {
helpTestOptimize("SELECT 'text' AS zz, pm1.g1.e2 FROM pm1.g1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT 'text' AS zz, e2 FROM pm1.g1"); //$NON-NLS-1$
}
- public void testOptimize8() throws Exception {
+ @Test public void testOptimize8() throws Exception {
helpTestOptimize("SELECT 1, 'xyz'", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT 1, 'xyz'"); //$NON-NLS-1$
@@ -129,37 +121,37 @@
assertEquals("Expected different fully qualified string", expected, actual); //$NON-NLS-1$
}
- public void testFullyQualify1() throws Exception {
+ @Test public void testFullyQualify1() throws Exception {
helpTestFullyQualify("SELECT e1, e2 FROM pm1.g1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"); //$NON-NLS-1$
}
- public void testXMLQuery() throws Exception {
+ @Test public void testXMLQuery() throws Exception {
helpTestOptimize("SELECT root.node1.node2.node3 FROM xmltest.doc1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT root.node1.node2.node3 FROM xmltest.doc1"); //$NON-NLS-1$
}
- public void testVirtualStoredProcedure() throws Exception {
+ @Test public void testVirtualStoredProcedure() throws Exception {
helpTestOptimize("EXEC pm1.vsp7(5)", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"EXEC pm1.vsp7(5)"); //$NON-NLS-1$
}
- public void testStoredQuerySubquery() throws Exception {
+ @Test public void testStoredQuerySubquery() throws Exception {
helpTestOptimize("select x.e1 from (EXEC pm1.sq1()) as x", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT e1 FROM (EXEC pm1.sq1()) AS x"); //$NON-NLS-1$
}
- public void testStoredQuerySubquery2() throws Exception {
+ @Test public void testStoredQuerySubquery2() throws Exception {
helpTestOptimize("select x.e1 from (EXEC pm1.sq1()) as x WHERE x.e2 = 3", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT e1 FROM (EXEC pm1.sq1()) AS x WHERE e2 = 3"); //$NON-NLS-1$
}
- public void testOptimizeOrderBy() throws Exception {
+ @Test public void testOptimizeOrderBy() throws Exception {
helpTestOptimize("SELECT pm1.g1.e1 FROM pm1.g1 order by pm1.g1.e1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT e1 FROM pm1.g1 ORDER BY e1"); //$NON-NLS-1$
@@ -169,13 +161,13 @@
* It is by design that order by optimization only works in one direction. It is not desirable to
* fully qualify order by elements
*/
- public void testOptimizeOrderBy1() throws Exception {
+ @Test public void testOptimizeOrderBy1() throws Exception {
helpTestFullyQualify("SELECT e1 FROM pm1.g1 order by e1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY e1"); //$NON-NLS-1$
}
- public void testOptimizeOrderByWithoutGroup() throws Exception {
+ @Test public void testOptimizeOrderByWithoutGroup() throws Exception {
helpTestOptimize("SELECT pm1.g1.e1, count(*) as x FROM pm1.g1 order by x", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
"SELECT e1, COUNT(*) AS x FROM pm1.g1 ORDER BY x"); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -1120,7 +1120,6 @@
public void testElementSymbol4() {
ElementSymbol es = new ElementSymbol("vdb.m.g.elem", true); //$NON-NLS-1$
- es.setGroupSymbol(new GroupSymbol("m.g")); //$NON-NLS-1$
helpTest(es, "vdb.m.g.elem"); //$NON-NLS-1$
}
@@ -1853,7 +1852,7 @@
public void testLimit() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
- From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
+ From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(null, new Constant(new Integer(100))));
@@ -1863,7 +1862,7 @@
public void testLimitWithOffset() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
- From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
+ From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Constant(new Integer(50)), new Constant(new Integer(100))));
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -343,7 +343,7 @@
procInfo.setProcedureID(procedureID);
procInfo.setModelID(procedureID.getProperty(FakeMetadataObject.Props.MODEL));
procInfo.setQueryPlan((QueryNode)procedureID.getProperty(FakeMetadataObject.Props.PLAN));
- procInfo.setProcedureCallableName((String)procedureID.getProperty(FakeMetadataObject.Props.CALLABLE_NAME));
+ procInfo.setProcedureCallableName(fullyQualifiedProcedureName);
procInfo.setUpdateCount(((Integer)procedureID.getProperty(FakeMetadataObject.Props.UPDATE_COUNT, new Integer(-1))).intValue());
// Read params
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -731,7 +731,7 @@
FakeMetadataObject rs3 = createResultSet("pm1.rs3", pm1, new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FakeMetadataObject rs3p1 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs3); //$NON-NLS-1$
- FakeMetadataObject sp1 = createStoredProcedure("pm1.sp1", pm1, Arrays.asList(new FakeMetadataObject[] { rs3p1 }), "pm1.sp1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject sp1 = createStoredProcedure("pm1.sp1", pm1, Arrays.asList(new FakeMetadataObject[] { rs3p1 })); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject rs4 = createResultSet("pm1.rs4", pm1, new String[] { "e1"}, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject rs4p1 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs4); //$NON-NLS-1$
@@ -781,7 +781,7 @@
FakeMetadataObject rs13 = createResultSet("pm1.rs13", pm1, new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FakeMetadataObject rs13p1 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs13); //$NON-NLS-1$
FakeMetadataObject rs13p2 = createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject sp2 = createStoredProcedure("pm1.sp2", pm1, Arrays.asList(new FakeMetadataObject[] { rs13p1, rs13p2 }), "pm1.sp2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject sp2 = createStoredProcedure("pm1.sp2", pm1, Arrays.asList(new FakeMetadataObject[] { rs13p1, rs13p2 })); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject rs14 = createResultSet("pm1.rs14", pm1, new String[] { "e1"}, new String[] { DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject rs14p1 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs14); //$NON-NLS-1$
@@ -825,7 +825,7 @@
QueryNode sq17n1 = new QueryNode("pm1.sq17", "CREATE VIRTUAL PROCEDURE BEGIN SELECT * FROM xmltest.doc1; END"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject sq17 = createVirtualProcedure("pm1.sq17", pm1, Arrays.asList(new FakeMetadataObject[] { sq17p1 }), sq17n1); //$NON-NLS-1$
- FakeMetadataObject sp3 = createStoredProcedure("pm1.sp3", pm1, new ArrayList(), "pm1.sp3"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject sp3 = createStoredProcedure("pm1.sp3", pm1, new ArrayList()); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject rs20 = createResultSet("pm1.rs20", pm1, new String[] { "xml" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject sq18p1 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs20); //$NON-NLS-1$
@@ -839,10 +839,10 @@
FakeMetadataObject sq19 = createVirtualProcedure("pm1.sq19", pm1, Arrays.asList(new FakeMetadataObject[] { sq19p1, sq19p2 }), sq19n1); //$NON-NLS-1$
FakeMetadataObject rs22p2 = createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.BIG_INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject sp4 = createStoredProcedure("pm1.sp4", pm1, Arrays.asList(new FakeMetadataObject[] { rs13p1, rs22p2 }), "pm1.sp4"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject sp4 = createStoredProcedure("pm1.sp4", pm1, Arrays.asList(new FakeMetadataObject[] { rs13p1, rs22p2 })); //$NON-NLS-1$ //$NON-NLS-2$
// no params or result set at all
- FakeMetadataObject sp5 = createStoredProcedure("pm1.sp5", pm1, Arrays.asList(new FakeMetadataObject[] {}), "pm1.sp5"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject sp5 = createStoredProcedure("pm1.sp5", pm1, Arrays.asList(new FakeMetadataObject[] {})); //$NON-NLS-1$ //$NON-NLS-2$
//virtual stored procedures
FakeMetadataObject vsprs1 = createResultSet("pm1.vsprs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -2331,7 +2331,7 @@
FakeMetadataObject rs3p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
FakeMetadataObject rs3p3 = FakeMetadataFactory.createParameter("source_name", 3, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
rs3p3.putProperty(FakeMetadataObject.Props.NULL, Boolean.TRUE);
- FakeMetadataObject sq2 = FakeMetadataFactory.createStoredProcedure("MultiModel.proc", physModel, Arrays.asList(new FakeMetadataObject[] { rs3p1, rs3p2, rs3p3 }), "MultiModel.proc");
+ FakeMetadataObject sq2 = FakeMetadataFactory.createStoredProcedure("MultiModel.proc", physModel, Arrays.asList(new FakeMetadataObject[] { rs3p1, rs3p2, rs3p3 }));
rs3p2.putProperty(FakeMetadataObject.Props.GROUP, sq2);
rs3p3.putProperty(FakeMetadataObject.Props.GROUP, sq2);
@@ -2979,14 +2979,12 @@
* @param name Name of procedure, must match model name
* @param model Metadata object for the model
* @param params List of FakeMetadataObject that are the parameters for the procedure
- * @param callableName Callable name of procedure, usually same as procedure name
* @return Metadata object for stored procedure
*/
- public static FakeMetadataObject createStoredProcedure(String name, FakeMetadataObject model, List params, String callableName) {
+ public static FakeMetadataObject createStoredProcedure(String name, FakeMetadataObject model, List params) {
FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.PROCEDURE);
obj.putProperty(FakeMetadataObject.Props.MODEL, model);
obj.putProperty(FakeMetadataObject.Props.PARAMS, params);
- obj.putProperty(FakeMetadataObject.Props.CALLABLE_NAME, callableName);
return obj;
}
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -206,7 +206,6 @@
public static final String INSERT_PROCEDURE = "insertProcedure"; // string giving the insert procedure //$NON-NLS-1$
public static final String UPDATE_PROCEDURE = "updateProcedure"; // string giving the update procedure //$NON-NLS-1$
public static final String DELETE_PROCEDURE = "deleteProcedure"; // string giving the delete procedure //$NON-NLS-1$
- public static final String CALLABLE_NAME = "callableName"; // string giving the callable name of the procedure //$NON-NLS-1$
public static final String UPDATE_COUNT = "updateCount"; // integer giving the update count //$NON-NLS-1$
// Parameter properties
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-03-21 14:11:08 UTC (rev 3013)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-03-22 13:00:05 UTC (rev 3014)
@@ -1639,7 +1639,7 @@
FakeMetadataObject resultSet = FakeMetadataFactory.createResultSet("pm1.rs", physicalModel, new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FakeMetadataObject returnParam = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, resultSet); //$NON-NLS-1$
FakeMetadataObject inParam = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject storedProcedure = FakeMetadataFactory.createStoredProcedure("pm1.sp", physicalModel, Arrays.asList(new FakeMetadataObject[] { returnParam, inParam }), "pm1.sp2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject storedProcedure = FakeMetadataFactory.createStoredProcedure("pm1.sp", physicalModel, Arrays.asList(new FakeMetadataObject[] { returnParam, inParam })); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject virtualModel = FakeMetadataFactory.createVirtualModel("vm1"); //$NON-NLS-1$
FakeMetadataObject virtualResultSet = FakeMetadataFactory.createResultSet("vm1.rs", physicalModel, new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
13 years, 9 months
teiid SVN: r3013 - in trunk: common-core/src/main/java/org/teiid/core/types and 8 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-21 10:11:08 -0400 (Mon, 21 Mar 2011)
New Revision: 3013
Added:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java
Removed:
trunk/common-core/src/main/java/org/teiid/core/types/TeiidBigDecimal.java
Modified:
trunk/api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java
trunk/api/src/main/java/org/teiid/metadata/BaseColumn.java
trunk/api/src/main/java/org/teiid/metadata/Column.java
trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
trunk/api/src/main/java/org/teiid/metadata/Schema.java
trunk/api/src/main/java/org/teiid/metadata/Table.java
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
trunk/engine/src/main/java/org/teiid/query/metadata/CompositeMetadataStore.java
trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java
trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTriggerActions.java
trunk/engine/src/test/java/org/teiid/query/validator/TestUpdateValidator.java
Log:
TEIID-1520 adding a string pool to reduce memory footprint
Modified: trunk/api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -28,6 +28,7 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.EquivalenceUtil;
@@ -44,6 +45,7 @@
private String uuid; //globally unique id
private String name; //contextually unique name
+ private String canonicalName;
private String nameInSource;
@@ -66,7 +68,7 @@
}
public void setNameInSource(String nameInSource) {
- this.nameInSource = nameInSource;
+ this.nameInSource = DataTypeManager.getCanonicalString(nameInSource);
}
/**
@@ -90,9 +92,14 @@
}
public void setName(String name) {
- this.name = name;
+ this.name = DataTypeManager.getCanonicalString(name);
+ this.canonicalName = DataTypeManager.getCanonicalString(name.toUpperCase());
}
+ public String getCanonicalName() {
+ return canonicalName;
+ }
+
public String toString() {
StringBuffer sb = new StringBuffer(100);
sb.append(getClass().getSimpleName());
@@ -127,7 +134,7 @@
if (this.properties == null) {
this.properties = new LinkedHashMap<String, String>();
}
- this.properties.put(key, value);
+ this.properties.put(DataTypeManager.getCanonicalString(key), DataTypeManager.getCanonicalString(value));
}
public void setProperties(LinkedHashMap<String, String> properties) {
@@ -139,7 +146,7 @@
}
public void setAnnotation(String annotation) {
- this.annotation = annotation;
+ this.annotation = DataTypeManager.getCanonicalString(annotation);
}
/**
Modified: trunk/api/src/main/java/org/teiid/metadata/BaseColumn.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/BaseColumn.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/api/src/main/java/org/teiid/metadata/BaseColumn.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -22,6 +22,7 @@
package org.teiid.metadata;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.translator.TypeFacility;
public abstract class BaseColumn extends AbstractMetadataRecord {
@@ -130,7 +131,7 @@
}
public void setDefaultValue(String object) {
- defaultValue = object;
+ defaultValue = DataTypeManager.getCanonicalString(object);
}
public Datatype getDatatype() {
@@ -139,6 +140,10 @@
public void setDatatype(Datatype datatype) {
this.datatype = datatype;
+ if (datatype != null) {
+ this.datatypeUUID = this.datatype.getUUID();
+ this.runtimeType = this.datatype.getRuntimeTypeName();
+ }
}
public String getDatatypeID() {
Modified: trunk/api/src/main/java/org/teiid/metadata/Column.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/Column.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/api/src/main/java/org/teiid/metadata/Column.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -22,6 +22,7 @@
package org.teiid.metadata;
+import org.teiid.core.types.DataTypeManager;
/**
* ColumnRecordImpl
@@ -180,14 +181,14 @@
* @param object
*/
public void setMaximumValue(String object) {
- maximumValue = object;
+ maximumValue = DataTypeManager.getCanonicalString(object);
}
/**
* @param object
*/
public void setMinimumValue(String object) {
- minimumValue = object;
+ minimumValue = DataTypeManager.getCanonicalString(object);
}
/**
@@ -222,7 +223,7 @@
* @param string
*/
public void setFormat(String string) {
- format = string;
+ format = DataTypeManager.getCanonicalString(string);
}
/**
@@ -246,7 +247,7 @@
* @since 4.2
*/
public void setNativeType(String nativeType) {
- this.nativeType = nativeType;
+ this.nativeType = DataTypeManager.getCanonicalString(nativeType);
}
}
\ No newline at end of file
Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -42,7 +42,7 @@
}
public void addSchema(Schema schema) {
- this.schemas.put(schema.getName().toLowerCase(), schema);
+ this.schemas.put(schema.getCanonicalName(), schema);
}
public void addDatatype(Datatype datatype) {
Modified: trunk/api/src/main/java/org/teiid/metadata/Schema.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/Schema.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/api/src/main/java/org/teiid/metadata/Schema.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -39,21 +39,21 @@
public void addTable(Table table) {
table.setParent(this);
- if (this.tables.put(table.getName().toLowerCase(), table) != null) {
+ if (this.tables.put(table.getCanonicalName(), table) != null) {
throw new AssertionError("Duplicate Table " + table.getName()); //$NON-NLS-1$
}
}
public void addProcedure(Procedure procedure) {
procedure.setParent(this);
- if (this.procedures.put(procedure.getName().toLowerCase(), procedure) != null) {
+ if (this.procedures.put(procedure.getCanonicalName(), procedure) != null) {
throw new AssertionError("Duplicate Procedure " + procedure.getName()); //$NON-NLS-1$
}
}
public void addFunction(FunctionMethod function) {
function.setParent(this);
- if (this.functions.put(function.getName().toLowerCase(), function) != null) {
+ if (this.functions.put(function.getCanonicalName(), function) != null) {
throw new AssertionError("Duplicate function " + function.getName()); //$NON-NLS-1$
}
}
Modified: trunk/api/src/main/java/org/teiid/metadata/Table.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/Table.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/api/src/main/java/org/teiid/metadata/Table.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -26,6 +26,8 @@
import java.util.LinkedList;
import java.util.List;
+import org.teiid.core.types.DataTypeManager;
+
public class Table extends ColumnSet<Schema> {
private static final long serialVersionUID = 4891356771125218672L;
@@ -167,15 +169,15 @@
}
public void setInsertPlan(String insertPlan) {
- this.insertPlan = insertPlan;
+ this.insertPlan = DataTypeManager.getCanonicalString(insertPlan);
}
public void setUpdatePlan(String updatePlan) {
- this.updatePlan = updatePlan;
+ this.updatePlan = DataTypeManager.getCanonicalString(updatePlan);
}
public void setDeletePlan(String deletePlan) {
- this.deletePlan = deletePlan;
+ this.deletePlan = DataTypeManager.getCanonicalString(deletePlan);
}
public List<ForeignKey> getForeignKeys() {
@@ -223,7 +225,7 @@
}
public void setSelectTransformation(String selectTransformation) {
- this.selectTransformation = selectTransformation;
+ this.selectTransformation = DataTypeManager.getCanonicalString(selectTransformation);
}
public Table getMaterializedStageTable() {
@@ -243,7 +245,7 @@
}
public void setResourcePath(String resourcePath) {
- this.resourcePath = resourcePath;
+ this.resourcePath = DataTypeManager.getCanonicalString(resourcePath);
}
public String getResourcePath() {
Modified: trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -126,7 +126,31 @@
}
}
- private static Map<Class<?>, ValueCache<?>> valueMaps = new HashMap<Class<?>, ValueCache<?>>(128);
+ private static Map<Class<?>, ValueCache<?>> valueMaps = new HashMap<Class<?>, ValueCache<?>>(128);
+ private static HashedValueCache<String> stringCache = new HashedValueCache<String>(17) {
+
+ @Override
+ protected Object get(int index) {
+ WeakReference<?> ref = (WeakReference<?>) cache[index];
+ if (ref != null) {
+ return ref.get();
+ }
+ return null;
+ }
+
+ @Override
+ protected void set(int index, String value) {
+ cache[index] = new WeakReference<Object>(value);
+ }
+
+ @Override
+ protected int primaryHash(String value) {
+ if (value.length() < 14) {
+ return value.hashCode();
+ }
+ return HashCodeUtil.expHashCode(value);
+ }
+ };
public static final int MAX_STRING_LENGTH = 4000;
public static final int MAX_LOB_MEMORY_BYTES = 1 << 13;
@@ -506,13 +530,13 @@
valueMaps.put(DefaultDataClasses.CHAR, new HashedValueCache<Character>(13));
valueMaps.put(DefaultDataClasses.INTEGER, new HashedValueCache<Integer>(14));
valueMaps.put(DefaultDataClasses.LONG, new HashedValueCache<Long>(14));
- valueMaps.put(DefaultDataClasses.BIG_INTEGER, new HashedValueCache<BigInteger>(14));
+ valueMaps.put(DefaultDataClasses.BIG_INTEGER, new HashedValueCache<BigInteger>(15));
valueMaps.put(DefaultDataClasses.FLOAT, new HashedValueCache<Float>(14));
valueMaps.put(DefaultDataClasses.DOUBLE, new HashedValueCache<Double>(14));
valueMaps.put(DefaultDataClasses.DATE, new HashedValueCache<Date>(14));
valueMaps.put(DefaultDataClasses.TIME, new HashedValueCache<Time>(14));
valueMaps.put(DefaultDataClasses.TIMESTAMP, new HashedValueCache<Timestamp>(14));
- valueMaps.put(DefaultDataClasses.BIG_DECIMAL, new HashedValueCache<BigDecimal>(15) {
+ valueMaps.put(DefaultDataClasses.BIG_DECIMAL, new HashedValueCache<BigDecimal>(16) {
@Override
protected Object get(int index) {
WeakReference<?> ref = (WeakReference<?>) cache[index];
@@ -527,36 +551,7 @@
cache[index] = new WeakReference<BigDecimal>(value);
}
});
- valueMaps.put(DefaultDataClasses.STRING, new HashedValueCache<String>(15) {
- HashedValueCache<String> smallCache = new HashedValueCache<String>(13);
-
- @Override
- public String getValue(String value) {
- if (value.length() < 14) {
- return smallCache.getValue(value);
- }
- return super.getValue(value);
- }
-
- @Override
- protected Object get(int index) {
- WeakReference<?> ref = (WeakReference<?>) cache[index];
- if (ref != null) {
- return ref.get();
- }
- return null;
- }
-
- @Override
- protected void set(int index, String value) {
- cache[index] = new WeakReference<Object>(value);
- }
-
- @Override
- protected int primaryHash(String value) {
- return HashCodeUtil.expHashCode(value);
- }
- });
+ valueMaps.put(DefaultDataClasses.STRING, stringCache);
}
}
@@ -803,7 +798,7 @@
}
@SuppressWarnings("unchecked")
- public static <T> T getCanonicalValue(T value) {
+ public static final <T> T getCanonicalValue(T value) {
if (valueCacheEnabled) {
if (value == null) {
return null;
@@ -816,4 +811,11 @@
}
return value;
}
+
+ public static final String getCanonicalString(String value) {
+ if (value == null) {
+ return null;
+ }
+ return stringCache.getValue(value);
+ }
}
Deleted: trunk/common-core/src/main/java/org/teiid/core/types/TeiidBigDecimal.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/TeiidBigDecimal.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/common-core/src/main/java/org/teiid/core/types/TeiidBigDecimal.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -1,68 +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.core.types;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-/**
- * Same as a regular BigDecimal, but changes the implementation of hashCode and equals
- * so that the same numerical value regardless of scale will be equal
- */
-public class TeiidBigDecimal extends BigDecimal {
-
- private static final long serialVersionUID = -5796515987947436480L;
-
- public TeiidBigDecimal(BigInteger unscaled, int scale) {
- super(unscaled, scale);
- }
-
- public TeiidBigDecimal(BigDecimal bigDecimal) {
- this(bigDecimal.unscaledValue(), bigDecimal.scale());
- }
-
- public TeiidBigDecimal(String val) {
- super(val);
- }
-
- @Override
- public int hashCode() {
- int xsign = this.signum();
- if (xsign == 0)
- return 0;
- BigDecimal bd = this.stripTrailingZeros();
- return bd.hashCode();
- }
-
- @Override
- public boolean equals(Object x) {
- if (x == this) {
- return true;
- }
- if (!(x instanceof BigDecimal)) {
- return false;
- }
- return this.compareTo((BigDecimal)x) == 0;
- }
-
-}
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -347,7 +347,7 @@
public static boolean isConvert(Function function) {
Expression[] args = function.getArgs();
- String funcName = function.getName().toLowerCase();
+ String funcName = function.getName();
return args.length == 2 && (funcName.equalsIgnoreCase(FunctionLibrary.CONVERT) || funcName.equalsIgnoreCase(FunctionLibrary.CAST));
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/CompositeMetadataStore.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/CompositeMetadataStore.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -38,7 +38,7 @@
/**
* Aggregates the metadata from multiple stores.
- * IMPORTANT: All strings queries should be in lower case.
+ * IMPORTANT: All strings queries should be in upper case.
*/
public class CompositeMetadataStore extends MetadataStore {
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -30,6 +30,7 @@
import java.util.List;
import java.util.Map;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -48,7 +49,7 @@
this.symbolList = Collections.unmodifiableList(new ArrayList(symbols.values()));
this.shortNameToSymbolMap = new HashMap<String, ElementSymbol>(symbolList.size());
for (ElementSymbol symbol : symbolList) {
- shortNameToSymbolMap.put(symbol.getShortCanonicalName(), symbol);
+ shortNameToSymbolMap.put(DataTypeManager.getCanonicalString(symbol.getShortCanonicalName()), symbol);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -174,7 +174,7 @@
if (columnIndex == -1) {
throw new QueryMetadataException(elementName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
- Table table = this.store.findGroup(elementName.substring(0, columnIndex).toLowerCase());
+ Table table = this.store.findGroup(elementName.substring(0, columnIndex).toUpperCase());
String shortElementName = elementName.substring(columnIndex + 1);
for (Column column : (List<Column>)getElementIDsInGroupID(table)) {
if (column.getName().equalsIgnoreCase(shortElementName)) {
@@ -185,7 +185,7 @@
}
public Table getGroupID(final String groupName) throws TeiidComponentException, QueryMetadataException {
- return getMetadataStore().findGroup(groupName.toLowerCase());
+ return getMetadataStore().findGroup(groupName.toUpperCase());
}
public Collection<String> getGroupsForPartialName(final String partialGroupName)
@@ -195,7 +195,7 @@
Collection<Table> matches = this.partialNameToFullNameCache.get(partialGroupName);
if (matches == null) {
- String partialName = DELIMITER_CHAR + partialGroupName.toLowerCase();
+ String partialName = DELIMITER_CHAR + partialGroupName.toUpperCase();
matches = getMetadataStore().getGroupsForPartialName(partialName);
@@ -317,11 +317,11 @@
final String name)
throws TeiidComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(name);
- String lowerGroupName = name.toLowerCase();
- Collection<StoredProcedureInfo> results = this.procedureCache.get(lowerGroupName);
+ String canonicalName = name.toUpperCase();
+ Collection<StoredProcedureInfo> results = this.procedureCache.get(canonicalName);
if (results == null) {
- Collection<Procedure> procRecords = getMetadataStore().getStoredProcedure(lowerGroupName);
+ Collection<Procedure> procRecords = getMetadataStore().getStoredProcedure(canonicalName);
results = new ArrayList<StoredProcedureInfo>(procRecords.size());
for (Procedure procRecord : procRecords) {
String procedureFullName = procRecord.getFullName();
@@ -372,7 +372,7 @@
procInfo.setUpdateCount(procRecord.getUpdateCount() -1);
results.add(procInfo);
}
- this.procedureCache.put(lowerGroupName, results);
+ this.procedureCache.put(canonicalName, results);
}
StoredProcedureInfo result = null;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -267,6 +267,7 @@
elementSymbol.setMetadataID(resolvedSymbol.getMetadataID());
elementSymbol.setGroupSymbol(resolvedGroup);
elementSymbol.setName(resolvedSymbol.getName());
+ elementSymbol.setCanonicalName(resolvedSymbol.getCanonicalName());
elementSymbol.setOutputName(oldName);
return true;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -22,6 +22,7 @@
package org.teiid.query.sql.symbol;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.StringUtil;
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.LanguageObject;
@@ -92,7 +93,7 @@
if(name == null) {
throw new IllegalArgumentException(QueryPlugin.Util.getString("ERR.015.010.0017")); //$NON-NLS-1$
}
- this.name = name;
+ this.name = DataTypeManager.getCanonicalString(name);
this.outputName = null;
// Canonical name is lazily created
this.canonicalName = null;
@@ -116,6 +117,10 @@
computeCanonicalNameAndHash();
return this.canonicalName;
}
+
+ public void setCanonicalName(String canonicalName) {
+ this.canonicalName = canonicalName;
+ }
/**
* Returns true if this symbol has been completely resolved with respect
@@ -176,7 +181,7 @@
private void computeCanonicalNameAndHash() {
if (canonicalName == null) {
- canonicalName = StringUtil.toUpperCase(name);
+ canonicalName = DataTypeManager.getCanonicalString(StringUtil.toUpperCase(name));
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -482,7 +482,7 @@
public void visit(DeclareStatement obj) {
ElementSymbol variable = obj.getVariable();
- String elementname = variable.getShortName().toUpperCase();
+ String elementname = variable.getShortCanonicalName();
// varible cannot be one of the special variables
if(elementname.equals(ProcedureReservedWords.ROWS_UPDATED)) {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTriggerActions.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTriggerActions.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTriggerActions.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -41,10 +41,13 @@
@SuppressWarnings("nls")
public class TestTriggerActions {
+ private static final String GX = "GX";
+ private static final String VM1 = "VM1";
+
@Test public void testInsert() throws Exception {
TransformationMetadata metadata = TestUpdateValidator.example1();
- TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, "gx");
- Table t = metadata.getMetadataStore().getSchemas().get("vm1").getTables().get("gx");
+ TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, GX);
+ Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
t.setDeletePlan("");
t.setUpdatePlan("");
t.setInsertPlan("FOR EACH ROW BEGIN insert into pm1.g1 (e1) values (new.x); END");
@@ -63,8 +66,8 @@
@Test public void testInsertWithQueryExpression() throws Exception {
TransformationMetadata metadata = TestUpdateValidator.example1();
- TestUpdateValidator.createView("select '1' as x, 2 as y", metadata, "gx");
- Table t = metadata.getMetadataStore().getSchemas().get("vm1").getTables().get("gx");
+ TestUpdateValidator.createView("select '1' as x, 2 as y", metadata, GX);
+ Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
t.setDeletePlan("");
t.setUpdatePlan("");
t.setInsertPlan("FOR EACH ROW BEGIN insert into pm1.g1 (e1) values (new.x); END");
@@ -82,8 +85,8 @@
@Test public void testDelete() throws Exception {
TransformationMetadata metadata = TestUpdateValidator.example1();
- TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, "gx");
- Table t = metadata.getMetadataStore().getSchemas().get("vm1").getTables().get("gx");
+ TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, GX);
+ Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
t.setDeletePlan("FOR EACH ROW BEGIN delete from pm1.g1 where e2 = old.x; END");
t.setUpdatePlan("");
t.setInsertPlan("");
@@ -102,8 +105,8 @@
@Test public void testUpdate() throws Exception {
TransformationMetadata metadata = TestUpdateValidator.example1();
- TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, "gx");
- Table t = metadata.getMetadataStore().getSchemas().get("vm1").getTables().get("gx");
+ TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, GX);
+ Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
t.setDeletePlan("");
t.setUpdatePlan("FOR EACH ROW BEGIN update pm1.g1 set e2 = new.y where e2 = old.y; END");
t.setInsertPlan("");
@@ -123,8 +126,8 @@
@Test public void testUpdateWithNonConstant() throws Exception {
TransformationMetadata metadata = TestUpdateValidator.example1();
- TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, "gx");
- Table t = metadata.getMetadataStore().getSchemas().get("vm1").getTables().get("gx");
+ TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, GX);
+ Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
t.setDeletePlan("");
t.setUpdatePlan("FOR EACH ROW BEGIN update pm1.g1 set e2 = new.y where e2 = old.y; END");
t.setInsertPlan("");
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestUpdateValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestUpdateValidator.java 2011-03-20 15:06:45 UTC (rev 3012)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestUpdateValidator.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -84,7 +84,7 @@
throws QueryParserException, QueryResolverException,
TeiidComponentException {
QueryNode vm1g1n1 = new QueryNode(vGroup, sql);
- Table vm1g1 = RealMetadataFactory.createUpdatableVirtualGroup(vGroup, md.getMetadataStore().getSchema("vm1"), vm1g1n1);
+ Table vm1g1 = RealMetadataFactory.createUpdatableVirtualGroup(vGroup, md.getMetadataStore().getSchema("VM1"), vm1g1n1);
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, md);
Added: trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java 2011-03-21 14:11:08 UTC (rev 3013)
@@ -0,0 +1,20 @@
+package org.teiid.jdbc;
+
+import org.teiid.core.util.UnitTestUtil;
+
+public class MetadataSizeExperiment {
+
+ static FakeServer server = new FakeServer();
+
+ public static void main(String[] args) throws Exception {
+ server.deployVDB("test", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
+ server.deployVDB("QT_Ora9DS", UnitTestUtil.getTestDataPath()+"/QT_Ora9DS_1.vdb");
+ server.deployVDB("x", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
+ server.deployVDB("x1", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
+
+ Thread.sleep(10000000);
+
+ System.out.println(server);
+ }
+
+}
Property changes on: trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataSizeExperiment.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years, 9 months