Author: shawkins
Date: 2012-06-05 10:52:51 -0400 (Tue, 05 Jun 2012)
New Revision: 4165
Modified:
trunk/common-core/src/main/java/org/teiid/core/types/BlobType.java
trunk/common-core/src/main/java/org/teiid/core/types/ClobType.java
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/common-core/src/main/java/org/teiid/core/util/HashCodeUtil.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
Log:
TEIID-2061 allowing for comparable object values
Modified: trunk/common-core/src/main/java/org/teiid/core/types/BlobType.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/BlobType.java 2012-06-05 10:45:58
UTC (rev 4164)
+++ trunk/common-core/src/main/java/org/teiid/core/types/BlobType.java 2012-06-05 14:52:51
UTC (rev 4165)
@@ -34,6 +34,7 @@
import org.teiid.core.CorePlugin;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.ObjectConverterUtil;
@@ -197,4 +198,28 @@
}
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof BlobType)) {
+ return false;
+ }
+ BlobType other = (BlobType)obj;
+ if (EquivalenceUtil.areEqual(reference, other.reference)) {
+ return true;
+ }
+ try {
+ return this.compareTo(other) == 0;
+ } catch (TeiidRuntimeException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+
}
Modified: trunk/common-core/src/main/java/org/teiid/core/types/ClobType.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/ClobType.java 2012-06-05 10:45:58
UTC (rev 4164)
+++ trunk/common-core/src/main/java/org/teiid/core/types/ClobType.java 2012-06-05 14:52:51
UTC (rev 4165)
@@ -35,6 +35,8 @@
import org.teiid.core.CorePlugin;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
import org.teiid.core.util.ObjectConverterUtil;
@@ -273,5 +275,29 @@
throw new TeiidRuntimeException(CorePlugin.Event.TEIID10057, e);
}
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof ClobType)) {
+ return false;
+ }
+ ClobType other = (ClobType)obj;
+ if (EquivalenceUtil.areEqual(reference, other.reference)) {
+ return true;
+ }
+ try {
+ return this.compareTo(other) == 0;
+ } catch (TeiidRuntimeException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeUtil.expHashCode(this.getCharSequence());
+ }
}
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 2012-06-05
10:45:58 UTC (rev 4164)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2012-06-05
14:52:51 UTC (rev 4165)
@@ -67,6 +67,7 @@
private static final boolean USE_VALUE_CACHE =
PropertiesUtils.getBooleanProperty(System.getProperties(),
"org.teiid.useValueCache", false); //$NON-NLS-1$
private static final boolean COMPARABLE_LOBS =
PropertiesUtils.getBooleanProperty(System.getProperties(),
"org.teiid.comparableLobs", false); //$NON-NLS-1$
+ private static final boolean COMPARABLE_OBJECT =
PropertiesUtils.getBooleanProperty(System.getProperties(),
"org.teiid.comparableObject", false); //$NON-NLS-1$
public static final boolean PAD_SPACE =
PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.padSpace",
false); //$NON-NLS-1$
private static boolean valueCacheEnabled;
@@ -854,7 +855,7 @@
}
public static boolean isNonComparable(String type) {
- return DataTypeManager.DefaultDataTypes.OBJECT.equals(type)
+ return (!COMPARABLE_OBJECT &&
DataTypeManager.DefaultDataTypes.OBJECT.equals(type))
|| (!COMPARABLE_LOBS &&
DataTypeManager.DefaultDataTypes.BLOB.equals(type))
|| (!COMPARABLE_LOBS &&
DataTypeManager.DefaultDataTypes.CLOB.equals(type))
|| DataTypeManager.DefaultDataTypes.XML.equals(type);
Modified: trunk/common-core/src/main/java/org/teiid/core/util/HashCodeUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/HashCodeUtil.java 2012-06-05
10:45:58 UTC (rev 4164)
+++ trunk/common-core/src/main/java/org/teiid/core/util/HashCodeUtil.java 2012-06-05
14:52:51 UTC (rev 4165)
@@ -140,11 +140,11 @@
return hc;
}
- public static final int expHashCode(String x) {
+ public static final int expHashCode(CharSequence x) {
return expHashCode(x, true);
}
- public static final int expHashCode(String x, boolean caseSensitive) {
+ public static final int expHashCode(CharSequence x, boolean caseSensitive) {
if(x == null) {
return 0;
}
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2012-06-05
10:45:58 UTC (rev 4164)
+++
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2012-06-05
14:52:51 UTC (rev 4165)
@@ -74,6 +74,7 @@
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.Reference;
import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
import org.teiid.query.util.CommandContext;
@@ -242,8 +243,6 @@
return buffer.createIndexedTupleSource();
}
//construct a query with a no cache hint
- //note that it's safe to use the stringified form of the parameters because
- //it's not possible to use xml/clob/blob/object
CacheHint hint = proc.getCacheHint();
proc.setCacheHint(null);
Option option = new Option();
@@ -251,7 +250,12 @@
option.addNoCacheGroup(fullName);
proc.setOption(option);
Determinism determinismLevel = context.resetDeterminismLevel();
- QueryProcessor qp =
context.getQueryProcessorFactory().createQueryProcessor(proc.toString(),
fullName.toUpperCase(), context);
+ StoredProcedure cloneProc = (StoredProcedure)proc.clone();
+ int i = 0;
+ for (SPParameter param : cloneProc.getInputParameters()) {
+ param.setExpression(new Reference(i++));
+ }
+ QueryProcessor qp =
context.getQueryProcessorFactory().createQueryProcessor(cloneProc.toString(),
fullName.toUpperCase(), context, vals.toArray());
qp.setNonBlocking(true);
qp.getContext().setDataObjects(null);
BatchCollector bc = qp.createBatchCollector();
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2012-06-05
10:45:58 UTC (rev 4164)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2012-06-05
14:52:51 UTC (rev 4165)
@@ -514,5 +514,5 @@
process(sql, expected);
}
-
+
}
Show replies by date