teiid SVN: r3569 - in trunk: common-core/src/main/java/org/teiid/core/types and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-19 10:17:27 -0400 (Wed, 19 Oct 2011)
New Revision: 3569
Modified:
trunk/client/src/main/java/org/teiid/client/BatchSerializer.java
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/FunctionModifier.java
Log:
TEIID-1750 pushing type codes down to datatypemanager
Modified: trunk/client/src/main/java/org/teiid/client/BatchSerializer.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/BatchSerializer.java 2011-10-18 19:02:39 UTC (rev 3568)
+++ trunk/client/src/main/java/org/teiid/client/BatchSerializer.java 2011-10-19 14:17:27 UTC (rev 3569)
@@ -35,7 +35,6 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
@@ -54,59 +53,6 @@
*/
public class BatchSerializer {
- /*
- * Public sharing part for the mapping between class and type in format of Map<class->Integer>.
- */
- public static final int STRING = 0;
- public static final int CHAR = 1;
- public static final int BOOLEAN = 2;
- public static final int BYTE = 3;
- public static final int SHORT = 4;
- public static final int INTEGER = 5;
- public static final int LONG = 6;
- public static final int BIGINTEGER = 7;
- public static final int FLOAT = 8;
- public static final int DOUBLE = 9;
- public static final int BIGDECIMAL = 10;
- public static final int DATE = 11;
- public static final int TIME = 12;
- public static final int TIMESTAMP = 13;
- public static final int OBJECT = 14;
- public static final int BLOB = 15;
- public static final int CLOB = 16;
- public static final int XML = 17;
- public static final int NULL = 18;
-
- private static final Map<Class<?>, Integer> typeMap = new LinkedHashMap<Class<?>, Integer>(64);
- private static final List<Class<?>> typeList;
-
- static {
- typeMap.put(DataTypeManager.DefaultDataClasses.STRING, STRING);
- typeMap.put(DataTypeManager.DefaultDataClasses.CHAR, CHAR);
- typeMap.put(DataTypeManager.DefaultDataClasses.BOOLEAN, BOOLEAN);
- typeMap.put(DataTypeManager.DefaultDataClasses.BYTE, BYTE);
- typeMap.put(DataTypeManager.DefaultDataClasses.SHORT, SHORT);
- typeMap.put(DataTypeManager.DefaultDataClasses.INTEGER, INTEGER);
- typeMap.put(DataTypeManager.DefaultDataClasses.LONG, LONG);
- typeMap.put(DataTypeManager.DefaultDataClasses.BIG_INTEGER, BIGINTEGER);
- typeMap.put(DataTypeManager.DefaultDataClasses.FLOAT, FLOAT);
- typeMap.put(DataTypeManager.DefaultDataClasses.DOUBLE, DOUBLE);
- typeMap.put(DataTypeManager.DefaultDataClasses.BIG_DECIMAL, BIGDECIMAL);
- typeMap.put(DataTypeManager.DefaultDataClasses.DATE, DATE);
- typeMap.put(DataTypeManager.DefaultDataClasses.TIME, TIME);
- typeMap.put(DataTypeManager.DefaultDataClasses.TIMESTAMP, TIMESTAMP);
- typeMap.put(DataTypeManager.DefaultDataClasses.OBJECT, OBJECT);
- typeMap.put(DataTypeManager.DefaultDataClasses.BLOB, BLOB);
- typeMap.put(DataTypeManager.DefaultDataClasses.CLOB, CLOB);
- typeMap.put(DataTypeManager.DefaultDataClasses.XML, XML);
- typeMap.put(DataTypeManager.DefaultDataClasses.NULL, NULL);
- typeList = new ArrayList<Class<?>>(typeMap.keySet());
- }
-
- public static int getCode(Class<?> source) {
- return typeMap.get(source).intValue();
- }
-
private BatchSerializer() {} // Uninstantiable
private static ColumnSerializer defaultSerializer = new ColumnSerializer();
@@ -145,15 +91,15 @@
@Override
protected void writeObject(ObjectOutput out, Object obj)
throws IOException {
- int code = getCode(obj.getClass());
+ int code = DataTypeManager.getTypeCode(obj.getClass());
out.writeByte((byte)code);
- if (code == BOOLEAN) {
+ if (code == DataTypeManager.BOOLEAN) {
if (Boolean.TRUE.equals(obj)) {
out.write((byte)1);
} else {
out.write((byte)0);
}
- } else if (code != OBJECT) {
+ } else if (code != DataTypeManager.OBJECT) {
ColumnSerializer s = getSerializer(DataTypeManager.getDataTypeName(obj.getClass()), (byte)1);
s.writeObject(out, obj);
} else {
@@ -165,14 +111,14 @@
protected Object readObject(ObjectInput in) throws IOException,
ClassNotFoundException {
int code = in.readByte();
- if (code == BOOLEAN) {
+ if (code == DataTypeManager.BOOLEAN) {
if (in.readByte() == (byte)0) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
- if (code != OBJECT) {
- ColumnSerializer s = getSerializer(DataTypeManager.getDataTypeName(typeList.get(code)), (byte)1);
+ if (code != DataTypeManager.OBJECT) {
+ ColumnSerializer s = getSerializer(DataTypeManager.getDataTypeName(DataTypeManager.getClass(code)), (byte)1);
return s.readObject(in);
}
return super.readObject(in);
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-10-18 19:02:39 UTC (rev 3568)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-10-19 14:17:27 UTC (rev 3569)
@@ -75,6 +75,8 @@
* need to load the Class object, which may not be in the classpath. The
* advantage of the Class option is speed.
* </p>
+ *
+ * TODO: refactor the string/class/code into an enum
*/
public class DataTypeManager {
@@ -224,6 +226,62 @@
public static final Class<ClobType> CLOB = ClobType.class;
public static final Class<XMLType> XML = XMLType.class;
}
+
+ public static final class DefaultTypeCodes {
+ public static final int STRING = 0;
+ public static final int CHAR = 1;
+ public static final int BOOLEAN = 2;
+ public static final int BYTE = 3;
+ public static final int SHORT = 4;
+ public static final int INTEGER = 5;
+ public static final int LONG = 6;
+ public static final int BIGINTEGER = 7;
+ public static final int FLOAT = 8;
+ public static final int DOUBLE = 9;
+ public static final int BIGDECIMAL = 10;
+ public static final int DATE = 11;
+ public static final int TIME = 12;
+ public static final int TIMESTAMP = 13;
+ public static final int OBJECT = 14;
+ public static final int BLOB = 15;
+ public static final int CLOB = 16;
+ public static final int XML = 17;
+ public static final int NULL = 18;
+ }
+
+ private static final Map<Class<?>, Integer> typeMap = new LinkedHashMap<Class<?>, Integer>(64);
+ private static final List<Class<?>> typeList;
+
+ static {
+ typeMap.put(DataTypeManager.DefaultDataClasses.STRING, DefaultTypeCodes.STRING);
+ typeMap.put(DataTypeManager.DefaultDataClasses.CHAR, DefaultTypeCodes.CHAR);
+ typeMap.put(DataTypeManager.DefaultDataClasses.BOOLEAN, DefaultTypeCodes.BOOLEAN);
+ typeMap.put(DataTypeManager.DefaultDataClasses.BYTE, DefaultTypeCodes.BYTE);
+ typeMap.put(DataTypeManager.DefaultDataClasses.SHORT, DefaultTypeCodes.SHORT);
+ typeMap.put(DataTypeManager.DefaultDataClasses.INTEGER, DefaultTypeCodes.INTEGER);
+ typeMap.put(DataTypeManager.DefaultDataClasses.LONG, DefaultTypeCodes.LONG);
+ typeMap.put(DataTypeManager.DefaultDataClasses.BIG_INTEGER, DefaultTypeCodes.BIGINTEGER);
+ typeMap.put(DataTypeManager.DefaultDataClasses.FLOAT, DefaultTypeCodes.FLOAT);
+ typeMap.put(DataTypeManager.DefaultDataClasses.DOUBLE, DefaultTypeCodes.DOUBLE);
+ typeMap.put(DataTypeManager.DefaultDataClasses.BIG_DECIMAL, DefaultTypeCodes.BIGDECIMAL);
+ typeMap.put(DataTypeManager.DefaultDataClasses.DATE, DefaultTypeCodes.DATE);
+ typeMap.put(DataTypeManager.DefaultDataClasses.TIME, DefaultTypeCodes.TIME);
+ typeMap.put(DataTypeManager.DefaultDataClasses.TIMESTAMP, DefaultTypeCodes.TIMESTAMP);
+ typeMap.put(DataTypeManager.DefaultDataClasses.OBJECT, DefaultTypeCodes.OBJECT);
+ typeMap.put(DataTypeManager.DefaultDataClasses.BLOB, DefaultTypeCodes.BLOB);
+ typeMap.put(DataTypeManager.DefaultDataClasses.CLOB, DefaultTypeCodes.CLOB);
+ typeMap.put(DataTypeManager.DefaultDataClasses.XML, DefaultTypeCodes.XML);
+ typeMap.put(DataTypeManager.DefaultDataClasses.NULL, DefaultTypeCodes.NULL);
+ typeList = new ArrayList<Class<?>>(typeMap.keySet());
+ }
+
+ public static int getTypeCode(Class<?> source) {
+ return typeMap.get(source).intValue();
+ }
+
+ public static Class<?> getClass(int code) {
+ return typeList.get(code);
+ }
/**
* Doubly-nested map of String srcType --> Map of String targetType -->
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/FunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/FunctionModifier.java 2011-10-18 19:02:39 UTC (rev 3568)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/FunctionModifier.java 2011-10-19 14:17:27 UTC (rev 3569)
@@ -26,7 +26,7 @@
import java.util.List;
-import org.teiid.client.BatchSerializer;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.language.Function;
import org.teiid.language.LanguageObject;
@@ -41,28 +41,28 @@
/*
* Public sharing part for the mapping between class and type in format of Map<class->Integer>.
*/
- public static final int STRING = BatchSerializer.STRING;
- public static final int CHAR = BatchSerializer.CHAR;
- public static final int BOOLEAN = BatchSerializer.BOOLEAN;
- public static final int BYTE = BatchSerializer.BYTE;
- public static final int SHORT = BatchSerializer.SHORT;
- public static final int INTEGER = BatchSerializer.INTEGER;
- public static final int LONG = BatchSerializer.LONG;
- public static final int BIGINTEGER = BatchSerializer.BIGINTEGER;
- public static final int FLOAT = BatchSerializer.FLOAT;
- public static final int DOUBLE = BatchSerializer.DOUBLE;
- public static final int BIGDECIMAL = BatchSerializer.BIGDECIMAL;
- public static final int DATE = BatchSerializer.DATE;
- public static final int TIME = BatchSerializer.TIME;
- public static final int TIMESTAMP = BatchSerializer.TIMESTAMP;
- public static final int OBJECT = BatchSerializer.OBJECT;
- public static final int BLOB = BatchSerializer.BLOB;
- public static final int CLOB = BatchSerializer.CLOB;
- public static final int XML = BatchSerializer.XML;
- public static final int NULL = BatchSerializer.NULL;
+ public static final int STRING = DataTypeManager.DefaultTypeCodes.STRING;
+ public static final int CHAR = DataTypeManager.DefaultTypeCodes.CHAR;
+ public static final int BOOLEAN = DataTypeManager.DefaultTypeCodes.BOOLEAN;
+ public static final int BYTE = DataTypeManager.DefaultTypeCodes.BYTE;
+ public static final int SHORT = DataTypeManager.DefaultTypeCodes.SHORT;
+ public static final int INTEGER = DataTypeManager.DefaultTypeCodes.INTEGER;
+ public static final int LONG = DataTypeManager.DefaultTypeCodes.LONG;
+ public static final int BIGINTEGER = DataTypeManager.DefaultTypeCodes.BIGINTEGER;
+ public static final int FLOAT = DataTypeManager.DefaultTypeCodes.FLOAT;
+ public static final int DOUBLE = DataTypeManager.DefaultTypeCodes.DOUBLE;
+ public static final int BIGDECIMAL = DataTypeManager.DefaultTypeCodes.BIGDECIMAL;
+ public static final int DATE = DataTypeManager.DefaultTypeCodes.DATE;
+ public static final int TIME = DataTypeManager.DefaultTypeCodes.TIME;
+ public static final int TIMESTAMP = DataTypeManager.DefaultTypeCodes.TIMESTAMP;
+ public static final int OBJECT = DataTypeManager.DefaultTypeCodes.OBJECT;
+ public static final int BLOB = DataTypeManager.DefaultTypeCodes.BLOB;
+ public static final int CLOB = DataTypeManager.DefaultTypeCodes.CLOB;
+ public static final int XML = DataTypeManager.DefaultTypeCodes.XML;
+ public static final int NULL = DataTypeManager.DefaultTypeCodes.NULL;
public static int getCode(Class<?> source) {
- return BatchSerializer.getCode(source);
+ return DataTypeManager.getTypeCode(source);
}
/**
13 years, 2 months
teiid SVN: r3568 - in trunk/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 15:02:39 -0400 (Tue, 18 Oct 2011)
New Revision: 3568
Modified:
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-1789 fixing serial type
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-10-18 18:59:58 UTC (rev 3567)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-10-18 19:02:39 UTC (rev 3568)
@@ -114,7 +114,7 @@
}
for (int i = 0; i < indexes.length; i++) {
if (indexes[i] == -1) {
- AtomicInteger sequence = sequences.get(i);
+ AtomicInteger sequence = sequences.get(i + (addRowId?1:0));
if (sequence != null) {
newTuple.add(sequence.getAndIncrement());
} else {
@@ -560,6 +560,7 @@
public void remove() {
lock.writeLock().lock();
try {
+ tid.getTableData().removed();
tree.remove();
if (this.indexTables != null) {
for (TempTable indexTable : this.indexTables.values()) {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-10-18 18:59:58 UTC (rev 3567)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-10-18 19:02:39 UTC (rev 3568)
@@ -434,6 +434,13 @@
execute("select * from x", new List[] {Arrays.asList(1, 1), Arrays.asList(2, 3)});
}
+ @Test public void testAutoIncrement1() throws Exception {
+ execute("create local temporary table x (e1 serial, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2) values (1)", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2) values (3)", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x", new List[] {Arrays.asList(1, 1), Arrays.asList(2, 3)});
+ }
+
@Test(expected=TeiidProcessingException.class) public void testNotNull() throws Exception {
execute("create local temporary table x (e1 serial, e2 integer not null, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
execute("insert into x (e1, e2) values ((select null), 1)", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
13 years, 2 months
teiid SVN: r3567 - in trunk: engine/src/main/java/org/teiid/dqp/internal/process and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 14:59:58 -0400 (Tue, 18 Oct 2011)
New Revision: 3567
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-1788 preventing the plan from being reported unnecessarily and preventing prepared plans from expiring needlessly TEIID-1750 updating the release notes
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-10-18 17:24:41 UTC (rev 3566)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-10-18 18:59:58 UTC (rev 3567)
@@ -33,6 +33,7 @@
<LI><B>Buffering Improvements</B> - Added the ability to inline memory based or small lobs and added tracking of the memory held by soft references. Also switched to a LFRU algorithm that significantly reduces writes and read misses with temporary tables.
<LI><B>GSSAPI</B> - both the Teiid JDBC client/server and the ODBC pg backend can now support GSSAPI for single sign-on.
<LI><B>Server-side Query Timeouts</B> - default query timeouts can be configured at both the VDB (via the query-timeout VDB property) and entire server (via the teiid-jboss-beans.xml queryTimeout property).
+ <LI><B>Memory Improvements</B> - buffering was optimized for concurrency and to better handle table querying instead of tuple buffers. Added a memory buffer to better handle file storage. The memory buffer may be optional configured as off-heap for better large memory performance.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java 2011-10-18 17:24:41 UTC (rev 3566)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java 2011-10-18 18:59:58 UTC (rev 3567)
@@ -52,7 +52,7 @@
private static final long serialVersionUID = -2608267960584191359L;
private transient Set<Object> objectsAccessed;
-
+ private boolean sensitiveToMetadataChanges = true;
private List<List<String>> externalNames;
private transient long creationTime = System.currentTimeMillis();
@@ -67,6 +67,14 @@
this.creationTime = System.currentTimeMillis();
}
+ public boolean isSensitiveToMetadataChanges() {
+ return sensitiveToMetadataChanges;
+ }
+
+ public void setSensitiveToMetadataChanges(boolean sensitiveToMetadataChanges) {
+ this.sensitiveToMetadataChanges = sensitiveToMetadataChanges;
+ }
+
private static List<List<String>> initExternalList(List<List<String>> externalNames, Set<? extends Object> accessed) {
if (externalNames == null) {
externalNames = new ArrayList<List<String>>(accessed.size());
@@ -153,8 +161,14 @@
}
for (Object o : this.objectsAccessed) {
if (!data) {
- if (o instanceof Modifiable && ((Modifiable)o).getLastModified() - modTime > this.creationTime) {
- return false;
+ if (o instanceof Modifiable) {
+ Modifiable m = (Modifiable)o;
+ if (m.getLastModified() < 0) {
+ return false; //invalid object
+ }
+ if (sensitiveToMetadataChanges && m.getLastModified() - modTime > this.creationTime) {
+ return false;
+ }
}
} else if (o instanceof DataModifiable && ((DataModifiable)o).getLastDataModification() - modTime > this.creationTime) {
return false;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2011-10-18 17:24:41 UTC (rev 3566)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2011-10-18 18:59:58 UTC (rev 3567)
@@ -54,7 +54,9 @@
SEVEN_1("7.1"), //$NON-NLS-1$
SEVEN_2("7.2"), //$NON-NLS-1$
SEVEN_3("7.3"), //$NON-NLS-1$
- SEVEN_4("7.4"); //$NON-NLS-1$
+ SEVEN_4("7.4"), //$NON-NLS-1$
+ SEVEN_5("7.5"), //$NON-NLS-1$
+ SEVEN_6("7.6"); //$NON-NLS-1$
private String string;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java 2011-10-18 17:24:41 UTC (rev 3566)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java 2011-10-18 18:59:58 UTC (rev 3567)
@@ -29,6 +29,8 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.util.CommandContext;
@@ -77,6 +79,13 @@
public void setPlan(ProcessorPlan planValue, CommandContext context){
plan = planValue;
this.accessInfo.populate(context, false);
+ //TODO: expand this logic
+ if (planValue instanceof RelationalPlan) {
+ RelationalPlan rp = (RelationalPlan)planValue;
+ if (rp.getRootNode() instanceof AccessNode) {
+ this.accessInfo.setSensitiveToMetadataChanges(false);
+ }
+ }
}
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-10-18 17:24:41 UTC (rev 3566)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-10-18 18:59:58 UTC (rev 3567)
@@ -52,6 +52,7 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.process.DQPCore.CompletionListener;
import org.teiid.dqp.internal.process.DQPCore.FutureWork;
+import org.teiid.dqp.internal.process.DQPWorkContext.Version;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.dqp.internal.process.ThreadReuseExecutor.PrioritizedRunnable;
import org.teiid.dqp.message.AtomicRequestID;
@@ -543,7 +544,6 @@
resultsBuffer = this.processor.getBufferManager().createTupleBuffer(this.originalCommand.getProjectedSymbols(), this.request.context.getConnectionID(), TupleSourceType.FINAL);
}
analysisRecord = request.analysisRecord;
- analysisRecord.setQueryPlan(processor.getProcessorPlan().getDescriptionProperties());
transactionContext = request.transactionContext;
if (this.transactionContext != null && this.transactionContext.getTransactionType() != Scope.NONE) {
this.transactionState = TransactionState.ACTIVE;
@@ -677,6 +677,7 @@
dataTypes[i] = DataTypeManager.getDataTypeName(symbol.getType());
}
ResultsMessage result = new ResultsMessage(batch, columnNames, dataTypes);
+ result.setClientSerializationVersion((byte)(this.dqpWorkContext.getClientVersion().compareTo(Version.SEVEN_6) >= 0?1:0));
setAnalysisRecords(result);
return result;
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2011-10-18 17:24:41 UTC (rev 3566)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2011-10-18 18:59:58 UTC (rev 3567)
@@ -62,13 +62,17 @@
List<List<TempMetadataID>> keys;
List<List<TempMetadataID>> indexes;
long lastDataModification;
- long lastModified;
+ long lastModified = System.currentTimeMillis();
int modCount;
public long getLastDataModification() {
return lastDataModification;
}
+ public void removed() {
+ this.lastModified = -1;
+ }
+
public void dataModified(int updateCount) {
if (updateCount == 0) {
return;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-10-18 17:24:41 UTC (rev 3566)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-10-18 18:59:58 UTC (rev 3567)
@@ -441,22 +441,35 @@
assertNull(rm.getException());
assertEquals(0, rm.getResultsList().size());
}
-
+
@Test public void testPreparedPlanInvalidation() throws Exception {
- String sql = "insert into #temp select * FROM vqt.SmallB"; //$NON-NLS-1$
+ helpTestPlanInvalidation("select * from #temp a, #temp b limit 10");
+
+ assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount());
+ }
+
+ @Test public void testPreparedPlanSimpleNoInvalidation() throws Exception {
+ helpTestPlanInvalidation("select * from #temp");
+
+ assertEquals(3, this.core.getPrepPlanCache().getCacheHitCount());
+ }
+
+ private void helpTestPlanInvalidation(String query) throws InterruptedException,
+ ExecutionException, TimeoutException {
+ String sql = "insert into #temp select * FROM vqt.SmallB"; //$NON-NLS-1$
String userName = "1"; //$NON-NLS-1$
int sessionid = 1; //$NON-NLS-1$
RequestMessage reqMsg = exampleRequestMessage(sql);
ResultsMessage rm = execute(userName, sessionid, reqMsg);
assertEquals(1, rm.getResultsList().size()); //$NON-NLS-1$
- sql = "select * from #temp"; //$NON-NLS-1$
+ sql = query;
reqMsg = exampleRequestMessage(sql);
reqMsg.setStatementType(StatementType.PREPARED);
rm = execute(userName, sessionid, reqMsg);
assertEquals(10, rm.getResultsList().size()); //$NON-NLS-1$
- sql = "select * from #temp"; //$NON-NLS-1$
+ sql = query;
reqMsg = exampleRequestMessage(sql);
reqMsg.setStatementType(StatementType.PREPARED);
rm = execute(userName, sessionid, reqMsg);
@@ -472,7 +485,7 @@
rm = execute(userName, sessionid, reqMsg);
assertEquals(1, rm.getResultsList().size()); //$NON-NLS-1$
- sql = "select * from #temp"; //$NON-NLS-1$
+ sql = query;
reqMsg = exampleRequestMessage(sql);
reqMsg.setStatementType(StatementType.PREPARED);
rm = execute(userName, sessionid, reqMsg);
@@ -480,20 +493,18 @@
assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount());
- //perform a major update, we will purge the plan
+ //perform a major update, it might purge the plan
sql = "delete from #temp"; //$NON-NLS-1$
reqMsg = exampleRequestMessage(sql);
rm = execute(userName, sessionid, reqMsg);
assertEquals(1, rm.getResultsList().size()); //$NON-NLS-1$
- sql = "select * from #temp"; //$NON-NLS-1$
+ sql = query;
reqMsg = exampleRequestMessage(sql);
reqMsg.setStatementType(StatementType.PREPARED);
rm = execute(userName, sessionid, reqMsg);
assertEquals(0, rm.getResultsList().size()); //$NON-NLS-1$
-
- assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount());
- }
+ }
@Test public void testRsCacheInvalidation() throws Exception {
String sql = "select * FROM vqt.SmallB"; //$NON-NLS-1$
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-10-18 17:24:41 UTC (rev 3566)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-10-18 18:59:58 UTC (rev 3567)
@@ -38,6 +38,7 @@
import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.deployers.CompositeVDB;
import org.teiid.deployers.MetadataStoreGroup;
import org.teiid.deployers.UDFMetaData;
@@ -65,6 +66,7 @@
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.query.tempdata.GlobalTableStoreImpl;
+import org.teiid.services.BufferServiceImpl;
import org.teiid.services.SessionServiceImpl;
import org.teiid.transport.ClientServiceRegistry;
import org.teiid.transport.ClientServiceRegistryImpl;
@@ -91,6 +93,10 @@
}
public FakeServer(DQPConfiguration config) {
+ this(config, false);
+ }
+
+ public FakeServer(DQPConfiguration config, boolean realBufferMangaer) {
this.logon = new LogonImpl(sessionService, null);
this.repo.addListener(new VDBLifeCycleListener() {
@@ -118,7 +124,14 @@
this.repo.start();
this.sessionService.setVDBRepository(repo);
- this.dqp.setBufferService(new FakeBufferService());
+ if (!realBufferMangaer) {
+ this.dqp.setBufferService(new FakeBufferService());
+ } else {
+ BufferServiceImpl bsi = new BufferServiceImpl();
+ bsi.setDiskDirectory(UnitTestUtil.getTestScratchPath());
+ this.dqp.setBufferService(bsi);
+ }
+
this.dqp.setCacheFactory(new DefaultCacheFactory());
this.dqp.setTransactionService(new FakeTransactionService());
@@ -144,6 +157,10 @@
registerClientService(DQP.class, dqp, null);
}
+ public DQPCore getDqp() {
+ return dqp;
+ }
+
public void setConnectorManagerRepository(ConnectorManagerRepository cmr) {
this.cmr = cmr;
}
13 years, 2 months
teiid SVN: r3566 - in branches/7.4.x/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 13:24:41 -0400 (Tue, 18 Oct 2011)
New Revision: 3566
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-1789 fix for serial type
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-10-18 16:56:57 UTC (rev 3565)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-10-18 17:24:41 UTC (rev 3566)
@@ -96,7 +96,7 @@
}
for (int i = 0; i < indexes.length; i++) {
if (indexes[i] == -1) {
- AtomicInteger sequence = sequences.get(i);
+ AtomicInteger sequence = sequences.get(i + (addRowId?1:0));
if (sequence != null) {
newTuple.add(sequence.getAndIncrement());
} else {
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-10-18 16:56:57 UTC (rev 3565)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-10-18 17:24:41 UTC (rev 3566)
@@ -294,6 +294,13 @@
execute("select * from x", new List[] {Arrays.asList(1, 1), Arrays.asList(2, 3)});
}
+ @Test public void testAutoIncrement1() throws Exception {
+ execute("create local temporary table x (e1 serial, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2) values (1)", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e2) values (3)", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select * from x", new List[] {Arrays.asList(1, 1), Arrays.asList(2, 3)});
+ }
+
@Test(expected=TeiidProcessingException.class) public void testNotNull() throws Exception {
execute("create local temporary table x (e1 serial, e2 integer not null, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
execute("insert into x (e1, e2) values ((select null), 1)", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
13 years, 2 months
teiid SVN: r3565 - in trunk: engine/src/main/java/org/teiid/common/buffer/impl and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 12:56:57 -0400 (Tue, 18 Oct 2011)
New Revision: 3565
Modified:
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/SizeUtility.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java
trunk/engine/src/test/java/org/teiid/common/buffer/impl/TestSizeUtility.java
Log:
TEIID-1788 improving typing and size logic
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-10-18 16:56:26 UTC (rev 3564)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-10-18 16:56:57 UTC (rev 3565)
@@ -340,14 +340,20 @@
* this is simply the class of the object. Some special cases are when the
* value is of type Object or Null.
*/
- public static Class determineDataTypeClass(Object value) {
+ public static Class<?> determineDataTypeClass(Object value) {
// Handle null case
if (value == null) {
return DefaultDataClasses.NULL;
}
-
- return getDataTypeClass(getDataTypeName(convertToRuntimeType(value)
- .getClass()));
+ Class<?> clazz = value.getClass();
+ if (DATA_TYPE_CLASSES.contains(clazz)) {
+ return clazz;
+ }
+ clazz = convertToRuntimeType(value).getClass();
+ if (DATA_TYPE_CLASSES.contains(clazz)) {
+ return clazz;
+ }
+ return DefaultDataClasses.OBJECT;
}
/**
@@ -748,7 +754,7 @@
return null;
}
Class<?> c = value.getClass();
- if (getAllDataTypeClasses().contains(c)) {
+ if (DATA_TYPE_CLASSES.contains(c)) {
return value;
}
SourceTransform t = sourceConverters.get(c);
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/SizeUtility.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/impl/SizeUtility.java 2011-10-18 16:56:26 UTC (rev 3564)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/SizeUtility.java 2011-10-18 16:56:57 UTC (rev 3565)
@@ -90,15 +90,14 @@
size += (rowLength * (48 + alignMemory(colLength * REFERENCE_SIZE)));
for (int col = 0; col < colLength; col++) {
Class<?> type = types[col];
+ int rowsSampled = 0;
+ int estimatedSize = 0;
if (VARIABLE_SIZE_TYPES.contains(type)) {
- int estRow = 0;
- for (int row = 0; row < rowLength; row++) {
- boolean updateEst = row == estRow;
- size += getSize(data.get(row).get(col), updateEst, accountForValueCache);
- if (updateEst) {
- estRow = estRow * 2 + 1;
- }
+ for (int row = 0; row < rowLength; row=(row*2)+1) {
+ rowsSampled++;
+ estimatedSize += getSize(data.get(row).get(col), types[col], true, accountForValueCache);
}
+ size += estimatedSize/(float)rowsSampled * rowLength;
} else {
size += getSize(accountForValueCache, type) * rowLength;
}
@@ -120,25 +119,17 @@
* Get size of object
* @return Size in bytes
*/
- protected long getSize(Object obj, boolean updateEstimate, boolean accountForValueCache) {
+ protected long getSize(Object obj, Class<?> type, boolean updateEstimate, boolean accountForValueCache) {
if(obj == null) {
return 0;
}
- Class<?> type = DataTypeManager.determineDataTypeClass(obj);
if(type == DataTypeManager.DefaultDataClasses.STRING) {
int length = ((String)obj).length();
if (length > 0) {
return alignMemory(40 + (2 * length));
}
return 40;
- } else if(obj instanceof Iterable<?>) {
- Iterable<?> i = (Iterable<?>)obj;
- long total = 16;
- for (Object object : i) {
- total += getSize(object, true, false) + REFERENCE_SIZE;
- }
- return total;
} else if(type == DataTypeManager.DefaultDataClasses.BIG_DECIMAL) {
if (!updateEstimate) {
return bigDecimalEstimate;
@@ -160,13 +151,20 @@
bigIntegerEstimate = (bigIntegerEstimate + result)/2;
}
return result;
+ } else if(obj instanceof Iterable<?>) {
+ Iterable<?> i = (Iterable<?>)obj;
+ long total = 16;
+ for (Object object : i) {
+ total += getSize(object, DataTypeManager.determineDataTypeClass(object), true, false) + REFERENCE_SIZE;
+ }
+ return total;
} else if(obj.getClass().isArray()) {
Class<?> componentType = obj.getClass().getComponentType();
if (!componentType.isPrimitive()) {
Object[] rows = (Object[]) obj;
long total = 16 + alignMemory(rows.length * REFERENCE_SIZE); // Array overhead
for(int i=0; i<rows.length; i++) {
- total += getSize(rows[i], true, false);
+ total += getSize(rows[i], DataTypeManager.determineDataTypeClass(rows[i]), true, false);
}
return total;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java 2011-10-18 16:56:26 UTC (rev 3564)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java 2011-10-18 16:56:57 UTC (rev 3565)
@@ -75,7 +75,13 @@
*/
public Constant(Object value) {
this.value = DataTypeManager.convertToRuntimeType(value);
- this.type = DataTypeManager.determineDataTypeClass(this.value);
+ if (this.value == null) {
+ this.type = DataTypeManager.DefaultDataClasses.NULL;
+ } else if (DataTypeManager.getAllDataTypeClasses().contains(this.value.getClass())) {
+ this.type = this.value.getClass();
+ } else {
+ this.type = DataTypeManager.DefaultDataClasses.OBJECT;
+ }
}
/**
Modified: trunk/engine/src/test/java/org/teiid/common/buffer/impl/TestSizeUtility.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/buffer/impl/TestSizeUtility.java 2011-10-18 16:56:26 UTC (rev 3564)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/impl/TestSizeUtility.java 2011-10-18 16:56:57 UTC (rev 3565)
@@ -43,7 +43,7 @@
}
public void helpTestGetSize(Object obj, long expectedSize) {
- long actualSize = new SizeUtility(null).getSize(obj, true, false);
+ long actualSize = new SizeUtility(null).getSize(obj, DataTypeManager.determineDataTypeClass(obj), true, false);
assertEquals("Got unexpected size: ", expectedSize, actualSize); //$NON-NLS-1$
}
13 years, 2 months
teiid SVN: r3564 - trunk/engine/src/main/java/org/teiid/query/processor.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 12:56:26 -0400 (Tue, 18 Oct 2011)
New Revision: 3564
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/BatchedUpdatePlan.java
Log:
TEIID-1787 fix for batched update
Modified: trunk/engine/src/main/java/org/teiid/query/processor/BatchedUpdatePlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/BatchedUpdatePlan.java 2011-10-18 16:53:54 UTC (rev 3563)
+++ trunk/engine/src/main/java/org/teiid/query/processor/BatchedUpdatePlan.java 2011-10-18 16:56:26 UTC (rev 3564)
@@ -68,8 +68,8 @@
* commands have been batched together.
* @since 4.2
*/
- public BatchedUpdatePlan(List childPlans, int commandsInBatch, List<VariableContext> contexts) {
- this.updatePlans = (ProcessorPlan[])childPlans.toArray(new ProcessorPlan[childPlans.size()]);
+ public BatchedUpdatePlan(List<? extends ProcessorPlan> childPlans, int commandsInBatch, List<VariableContext> contexts) {
+ this.updatePlans = childPlans.toArray(new ProcessorPlan[childPlans.size()]);
this.planOpened = new boolean[updatePlans.length];
this.updateCounts = new List[commandsInBatch];
this.contexts = contexts;
13 years, 2 months
teiid SVN: r3563 - in trunk/engine/src: main/java/org/teiid/query/optimizer and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 12:53:54 -0400 (Tue, 18 Oct 2011)
New Revision: 3563
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/query/optimizer/BatchedUpdatePlanner.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
Log:
TEIID-1787 fix for batched update
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2011-10-18 16:43:21 UTC (rev 3562)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2011-10-18 16:53:54 UTC (rev 3563)
@@ -220,8 +220,8 @@
} else { //just accumulate copies of the command/plan - clones are not necessary
if (command == null) {
command = this.prepPlan.getCommand();
- command.setProcessorPlan(this.processPlan);
}
+ command.setProcessorPlan(this.processPlan);
commands.add(command);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/BatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/BatchedUpdatePlanner.java 2011-10-18 16:43:21 UTC (rev 3562)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/BatchedUpdatePlanner.java 2011-10-18 16:53:54 UTC (rev 3563)
@@ -90,8 +90,8 @@
AnalysisRecord analysisRecord, CommandContext context)
throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
BatchedUpdateCommand batchedUpdateCommand = (BatchedUpdateCommand)command;
- List childPlans = new ArrayList(batchedUpdateCommand.getUpdateCommands().size());
- List updateCommands = batchedUpdateCommand.getUpdateCommands();
+ List<ProcessorPlan> childPlans = new ArrayList<ProcessorPlan>(batchedUpdateCommand.getUpdateCommands().size());
+ List<Command> updateCommands = batchedUpdateCommand.getUpdateCommands();
int numCommands = updateCommands.size();
List<VariableContext> allContexts = batchedUpdateCommand.getVariableContexts();
List<VariableContext> planContexts = null;
@@ -100,7 +100,7 @@
}
for (int commandIndex = 0; commandIndex < numCommands; commandIndex++) {
// Potentially the first command of a batch
- Command updateCommand = (Command)updateCommands.get(commandIndex);
+ Command updateCommand = updateCommands.get(commandIndex);
boolean commandWasBatched = false;
// If this command can be placed in a batch
if (isEligibleForBatching(updateCommand, metadata)) {
@@ -125,7 +125,7 @@
// Find out if there are other commands called on the same physical model
// immediately and contiguously after this one
batchLoop: for (int batchIndex = commandIndex+1; batchIndex < numCommands; batchIndex++) {
- Command batchingCandidate = (Command)updateCommands.get(batchIndex);
+ Command batchingCandidate = updateCommands.get(batchIndex);
// If this command updates the same model, and is eligible for batching, add it to the batch
if (canBeAddedToBatch(batchingCandidate, batchModelID, metadata, capFinder)) {
batch.add(batchingCandidate);
@@ -165,7 +165,7 @@
}
}
if (!commandWasBatched) { // If the command wasn't batched, just add the plan for this command to the list of plans
- Command cmd = (Command)batchedUpdateCommand.getUpdateCommands().get(commandIndex);
+ Command cmd = batchedUpdateCommand.getUpdateCommands().get(commandIndex);
ProcessorPlan plan = cmd.getProcessorPlan();
if (plan == null) {
plan = QueryOptimizer.optimizePlan(cmd, metadata, idGenerator, capFinder, analysisRecord, context);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2011-10-18 16:43:21 UTC (rev 3562)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2011-10-18 16:53:54 UTC (rev 3563)
@@ -79,6 +79,37 @@
assertTrue(((Constant)update.getChangeList().getClauses().get(0).getValue()).isMultiValued());
}
+ @Test public void testBatchedUpdateNotPushdown() throws Exception {
+ // Create query
+ String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
+
+ // Create a testable prepared plan cache
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ dataManager.addData("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ // Source capabilities must support batched updates
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.BULK_UPDATE, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // batch with two commands
+ ArrayList<ArrayList<Object>> values = new ArrayList<ArrayList<Object>>(2);
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "a", Boolean.FALSE, new Integer(0) }))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { null, Boolean.FALSE, new Integer(1) })));
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(2),
+ Arrays.asList(2)
+ };
+
+ // Create the plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, RealMetadataFactory.example1Cached(), prepPlanCache, false, false, false,RealMetadataFactory.example1VDB());
+ }
+
/**
* Test prepared statements that use batched updates using the same prepared
* command with same number of commands in the batch.
13 years, 2 months
teiid SVN: r3562 - trunk/engine/src/test/java/org/teiid/common/queue.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 12:43:21 -0400 (Tue, 18 Oct 2011)
New Revision: 3562
Modified:
trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java
Log:
relaxing the test to prevent random test failures
Modified: trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java 2011-10-18 16:04:46 UTC (rev 3561)
+++ trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java 2011-10-18 16:43:21 UTC (rev 3562)
@@ -81,7 +81,7 @@
pool.shutdown();
WorkerPoolStatisticsMetadata stats = pool.getStats();
- assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
+ assertTrue("Expected approximately 1 thread for serial execution", stats.getHighestActiveThreads() <= 2); //$NON-NLS-1$
pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
}
13 years, 2 months
teiid SVN: r3561 - in branches/7.4.x/engine/src: main/java/org/teiid/query/processor/relational and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 12:04:46 -0400 (Tue, 18 Oct 2011)
New Revision: 3561
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
Log:
TEIID-1784 fix for sort batch accounting issue
Modified: branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-10-18 16:03:32 UTC (rev 3560)
+++ branches/7.4.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-10-18 16:04:46 UTC (rev 3561)
@@ -457,6 +457,10 @@
public int getMaxProcessingKB() {
return maxProcessingKB;
}
+
+ public int getReserveBatchKB() {
+ return reserveBatchKB;
+ }
/**
* Get processor batch size
@@ -597,12 +601,17 @@
//don't wait for more than is available
int waitCount = Math.min(count, this.maxReserveKB);
while (waitCount > 0 && waitCount > this.reserveBatchKB) {
+ int reserveBatchSample = this.reserveBatchKB;
try {
- batchesFreed.await(100, TimeUnit.MILLISECONDS);
+ batchesFreed.await(50, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new TeiidRuntimeException(e);
}
- waitCount /= 2;
+ if (reserveBatchSample >= this.reserveBatchKB) {
+ waitCount >>= 3;
+ } else {
+ waitCount >>= 1;
+ }
}
}
if (this.reserveBatchKB >= count || mode == BufferReserveMode.FORCE) {
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2011-10-18 16:03:32 UTC (rev 3560)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2011-10-18 16:04:46 UTC (rev 3561)
@@ -230,10 +230,10 @@
if (workingTuples.size() >= maxRows) {
int reserved = bufferManager.reserveBuffers(schemaSize,
(totalReservedBuffers + schemaSize <= bufferManager.getMaxProcessingKB())?BufferReserveMode.FORCE:BufferReserveMode.NO_WAIT);
- if (reserved != schemaSize) {
+ totalReservedBuffers += reserved;
+ if (reserved != schemaSize) {
break;
- }
- totalReservedBuffers += reserved;
+ }
maxRows += bufferManager.getProcessorBatchSize();
}
try {
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2011-10-18 16:03:32 UTC (rev 3560)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2011-10-18 16:04:46 UTC (rev 3561)
@@ -37,6 +37,7 @@
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.TupleSource;
import org.teiid.common.buffer.BufferManager.TupleSourceType;
+import org.teiid.common.buffer.impl.BufferManagerImpl;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
@@ -52,7 +53,8 @@
public static final int BATCH_SIZE = 100;
private void helpTestSort(List elements, List[] data, List sortElements, List sortTypes, List[] expected, Mode mode) throws TeiidComponentException, TeiidProcessingException {
- BufferManager mgr = BufferManagerFactory.getTestBufferManager(100, BATCH_SIZE, BATCH_SIZE);
+ BufferManagerImpl mgr = BufferManagerFactory.getTestBufferManager(4000, BATCH_SIZE, BATCH_SIZE);
+ int reserve = mgr.getReserveBatchKB();
CommandContext context = new CommandContext ("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
BlockingFakeRelationalNode dataNode = new BlockingFakeRelationalNode(2, data);
@@ -87,6 +89,7 @@
}
}
assertEquals(expected.length, currentRow - 1);
+ assertEquals(reserve, mgr.getReserveBatchKB());
}
/*
13 years, 2 months
teiid SVN: r3560 - in branches/7.4.x/engine/src: test/java/org/teiid/dqp/internal/process and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-10-18 12:03:32 -0400 (Tue, 18 Oct 2011)
New Revision: 3560
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
Log:
TEIID-1787 fix for batching NPE
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2011-10-18 15:56:08 UTC (rev 3559)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2011-10-18 16:03:32 UTC (rev 3560)
@@ -220,8 +220,8 @@
} else { //just accumulate copies of the command/plan - clones are not necessary
if (command == null) {
command = this.prepPlan.getCommand();
- command.setProcessorPlan(this.processPlan);
}
+ command.setProcessorPlan(this.processPlan);
commands.add(command);
}
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2011-10-18 15:56:08 UTC (rev 3559)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2011-10-18 16:03:32 UTC (rev 3560)
@@ -79,6 +79,37 @@
assertTrue(((Constant)update.getChangeList().getClauses().get(0).getValue()).isMultiValued());
}
+ @Test public void testBatchedUpdateNotPushdown() throws Exception {
+ // Create query
+ String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
+
+ // Create a testable prepared plan cache
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ dataManager.addData("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ // Source capabilities must support batched updates
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.BULK_UPDATE, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // batch with two commands
+ ArrayList<ArrayList<Object>> values = new ArrayList<ArrayList<Object>>(2);
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "a", Boolean.FALSE, new Integer(0) }))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { null, Boolean.FALSE, new Integer(1) })));
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(2),
+ Arrays.asList(2)
+ };
+
+ // Create the plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, RealMetadataFactory.example1Cached(), prepPlanCache, false, false, false,RealMetadataFactory.example1VDB());
+ }
+
/**
* Test prepared statements that use batched updates using the same prepared
* command with same number of commands in the batch.
13 years, 2 months