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);
- }
-
-}