Author: shawkins
Date: 2012-08-30 14:08:53 -0400 (Thu, 30 Aug 2012)
New Revision: 4383
Removed:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SerializableTupleBatch.java
Modified:
trunk/client/src/main/java/org/teiid/jdbc/BaseDataSource.java
trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
trunk/client/src/test/java/org/teiid/client/TestBatchSerializer.java
trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
Log:
TEIID-2171 various cleanups/performance tweaks
Modified: trunk/client/src/main/java/org/teiid/jdbc/BaseDataSource.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/BaseDataSource.java 2012-08-30 17:48:02 UTC
(rev 4382)
+++ trunk/client/src/main/java/org/teiid/jdbc/BaseDataSource.java 2012-08-30 18:08:53 UTC
(rev 4383)
@@ -241,8 +241,8 @@
props.setProperty(ExecutionProperties.NOEXEC, String.valueOf(this.isNoExec()));
}
- if ( this.getTransactionAutoWrap() != null &&
this.getTransactionAutoWrap().trim().length() != 0 ) {
- props.setProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP,
this.getTransactionAutoWrap());
+ if ( this.getAutoCommitTxn() != null &&
this.getAutoCommitTxn().trim().length() != 0 ) {
+ props.setProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP,
this.getAutoCommitTxn());
}
if (this.getDisableLocalTxn() != null) {
@@ -250,7 +250,7 @@
}
if (!this.getUseJDBC4ColumnNameAndLabelSemantics()) {
- props.setProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS,
"false");
+ props.setProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS,
Boolean.FALSE.toString());
}
if (this.additionalProperties != null) {
Modified: trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2012-08-30 17:48:02 UTC
(rev 4382)
+++ trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2012-08-30 18:08:53 UTC
(rev 4383)
@@ -124,11 +124,6 @@
private void setExecutionProperties(Properties info) {
this.propInfo = new Properties();
- String overrideProp = info.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP);
- if ( overrideProp == null || overrideProp.trim().length() == 0 ) {
- propInfo.put(ExecutionProperties.PROP_TXN_AUTO_WRAP,
ExecutionProperties.TXN_WRAP_DETECT);
- }
-
String defaultFetchSize = info.getProperty(ExecutionProperties.PROP_FETCH_SIZE);
if (defaultFetchSize != null) {
propInfo.put(ExecutionProperties.PROP_FETCH_SIZE, defaultFetchSize);
@@ -158,11 +153,9 @@
}
for (String key : info.stringPropertyNames()) {
- for (String prop : JDBCURL.EXECUTION_PROPERTIES) {
- if (prop.equalsIgnoreCase(key)) {
- propInfo.setProperty(key, info.getProperty(key));
- break;
- }
+ String actualKey = JDBCURL.EXECUTION_PROPERTIES.get(key);
+ if (actualKey != null) {
+ propInfo.setProperty(actualKey, info.getProperty(key));
}
}
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2012-08-30 17:48:02 UTC (rev
4382)
+++ trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2012-08-30 18:08:53 UTC (rev
4383)
@@ -32,6 +32,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -47,20 +48,27 @@
static final String URL_PATTERN = JDBC_PROTOCOL +
"([\\w-\\.]+)(?:@([^;]*))?(;.*)?"; //$NON-NLS-1$
static Pattern urlPattern = Pattern.compile(URL_PATTERN);
- public static final Set<String> EXECUTION_PROPERTIES =
Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
- ExecutionProperties.PROP_TXN_AUTO_WRAP,
- ExecutionProperties.PROP_PARTIAL_RESULTS_MODE,
- ExecutionProperties.RESULT_SET_CACHE_MODE,
- ExecutionProperties.ANSI_QUOTED_IDENTIFIERS,
- ExecutionProperties.SQL_OPTION_SHOWPLAN,
- ExecutionProperties.NOEXEC,
- ExecutionProperties.PROP_FETCH_SIZE,
- ExecutionProperties.PROP_XML_FORMAT,
- ExecutionProperties.PROP_XML_VALIDATION,
- EmbeddedProfile.USE_CALLING_THREAD,
- ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
- ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS)));
-
+ public static final Map<String, String> EXECUTION_PROPERTIES =
Collections.unmodifiableMap(buildProps());
+
+ private static Map<String, String> buildProps() {
+ Map<String, String> result = new TreeMap<String,
String>(String.CASE_INSENSITIVE_ORDER);
+ for (String key : new String[] {ExecutionProperties.PROP_TXN_AUTO_WRAP,
+ ExecutionProperties.PROP_PARTIAL_RESULTS_MODE,
+ ExecutionProperties.RESULT_SET_CACHE_MODE,
+ ExecutionProperties.ANSI_QUOTED_IDENTIFIERS,
+ ExecutionProperties.SQL_OPTION_SHOWPLAN,
+ ExecutionProperties.NOEXEC,
+ ExecutionProperties.PROP_FETCH_SIZE,
+ ExecutionProperties.PROP_XML_FORMAT,
+ ExecutionProperties.PROP_XML_VALIDATION,
+ EmbeddedProfile.USE_CALLING_THREAD,
+ ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
+ ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS}) {
+ result.put(key, key);
+ }
+ return result;
+ }
+
public static final Set<String> KNOWN_PROPERTIES = getKnownProperties();
private static Set<String> getKnownProperties() {
@@ -78,7 +86,7 @@
TeiidURL.CONNECTION.JAAS_NAME,
TeiidURL.CONNECTION.KERBEROS_SERVICE_PRINCIPLE_NAME,
TeiidURL.CONNECTION.ENCRYPT_REQUESTS));
- props.addAll(EXECUTION_PROPERTIES);
+ props.addAll(EXECUTION_PROPERTIES.keySet());
return Collections.unmodifiableSet(props);
}
Modified: trunk/client/src/test/java/org/teiid/client/TestBatchSerializer.java
===================================================================
--- trunk/client/src/test/java/org/teiid/client/TestBatchSerializer.java 2012-08-30
17:48:02 UTC (rev 4382)
+++ trunk/client/src/test/java/org/teiid/client/TestBatchSerializer.java 2012-08-30
18:08:53 UTC (rev 4383)
@@ -22,6 +22,8 @@
package org.teiid.client;
+import static org.junit.Assert.*;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -32,19 +34,16 @@
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.teiid.core.types.BinaryType;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.TimestampWithTimezone;
-
-
/**
* @since 4.2
*/
-public class TestBatchSerializer extends TestCase {
+public class TestBatchSerializer {
private static void helpTestSerialization(String[] types, List<?>[] batch)
throws IOException, ClassNotFoundException {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
@@ -117,7 +116,7 @@
return batch;
}
- public void testSerializeBasicTypes() throws Exception {
+ @Test public void testSerializeBasicTypes() throws Exception {
// The number 8 is important here because boolean isNull information is packed
into bytes,
// so we want to make sure the boundary cases are handled correctly
helpTestSerialization(sampleBatchTypes, sampleBatchWithNulls(1)); // Less than 8
rows
@@ -128,16 +127,16 @@
helpTestSerialization(sampleBatchTypes, sampleBatchWithNulls(4096)); // A bunch
of rows. This should also test large strings
}
- public void testSerializeLargeStrings() throws Exception {
+ @Test public void testSerializeLargeStrings() throws Exception {
List<?> row = Arrays.asList(new Object[] {sampleString(66666)});
helpTestSerialization(new String[] {DataTypeManager.DefaultDataTypes.STRING}, new
List[] {row});
}
- public void testSerializeNoData() throws Exception {
+ @Test public void testSerializeNoData() throws Exception {
helpTestSerialization(sampleBatchTypes, new List[0]);
}
- public void testSerializeDatatypeMismatch() throws Exception {
+ @Test public void testSerializeDatatypeMismatch() throws Exception {
try {
helpTestSerialization(new String[] {DataTypeManager.DefaultDataTypes.DOUBLE},
new List[] {Arrays.asList(new Object[] {"Hello!"})}); //$NON-NLS-1$
} catch (RuntimeException e) {
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java 2012-08-30 17:48:02
UTC (rev 4382)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java 2012-08-30 18:08:53
UTC (rev 4383)
@@ -26,6 +26,7 @@
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.Properties;
import junit.framework.TestCase;
@@ -71,7 +72,7 @@
dataSource.setDatabaseName(STD_DATABASE_NAME);
dataSource.setPortNumber(STD_PORT_NUMBER);
dataSource.setDataSourceName(STD_DATA_SOURCE_NAME);
- dataSource.setTransactionAutoWrap(STD_TXN_WRAP);
+ dataSource.setAutoCommitTxn(STD_TXN_WRAP);
dataSource.setPartialResultsMode(STD_PARTIAL_MODE);
dataSource.setSecure(true);
dataSource.setAlternateServers(STD_ALTERNATE_SERVERS);
@@ -161,7 +162,7 @@
ds.setDatabaseName(vdbName);
ds.setPortNumber(portNumber);
ds.setFetchSize(fetchSize);
- ds.setTransactionAutoWrap(txnAutoWrap);
+ ds.setAutoCommitTxn(txnAutoWrap);
ds.setPartialResultsMode(partialMode);
if(showPlan) {
ds.setShowPlan(ShowPlan.ON.toString());
@@ -196,7 +197,7 @@
ds.setUser(user);
ds.setPassword(password);
ds.setDataSourceName(dataSourceName);
- ds.setTransactionAutoWrap(txnAutoWrap);
+ ds.setAutoCommitTxn(txnAutoWrap);
ds.setPartialResultsMode(partialMode);
ds.setAlternateServers(alternateServers);
ds.setUseJDBC4ColumnNameAndLabelSemantics(true);
@@ -272,7 +273,9 @@
}
public void testGetTransactionAutoWrap() {
- final String result = dataSource.getTransactionAutoWrap();
+ final String result = dataSource.getAutoCommitTxn();
+ Properties p = dataSource.buildProperties("foo", "bar");
+ assertEquals(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP),
STD_TXN_WRAP);
assertEquals(result,STD_TXN_WRAP);
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2012-08-30
17:48:02 UTC (rev 4382)
+++
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2012-08-30
18:08:53 UTC (rev 4383)
@@ -55,7 +55,6 @@
import org.teiid.core.types.Streamable;
import org.teiid.core.types.DataTypeManager.WeakReferenceHashedValueCache;
import org.teiid.dqp.internal.process.DQPConfiguration;
-import org.teiid.dqp.internal.process.SerializableTupleBatch;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
@@ -998,6 +997,7 @@
try {
ObjectOutputStream out = new ObjectOutputStream(ostream);
getTupleBufferState(out, buffer);
+ out.flush();
} catch (TeiidComponentException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30054, e);
} catch (IOException e) {
@@ -1012,7 +1012,7 @@
out.writeObject(buffer.getTypes());
for (int row = 1; row <= buffer.getRowCount(); row+=buffer.getBatchSize()) {
TupleBatch b = buffer.getBatch(row);
- out.writeObject(new SerializableTupleBatch(b, buffer.getTypes()));
+ BatchSerializer.writeBatch(out, buffer.getTypes(), b.getTuples());
}
}
@@ -1053,13 +1053,15 @@
buffer.setId(state_id);
for (int row = 1; row <= rowCount; row+=batchSize) {
- TupleBatch batch = (TupleBatch)in.readObject();
- if (batch == null) {
- buffer.remove();
- throw new IOException(QueryPlugin.Util.getString("not_found_cache"));
//$NON-NLS-1$
- }
- buffer.addTupleBatch(batch, true);
+ List<List<Object>> batch = BatchSerializer.readBatch(in, types);
+ for (int i = 0; i < batch.size(); i++) {
+ buffer.addTuple(batch.get(i));
+ }
}
+ if (buffer.getRowCount() != rowCount) {
+ buffer.remove();
+ throw new IOException(QueryPlugin.Util.getString("not_found_cache"));
//$NON-NLS-1$
+ }
buffer.close();
addTupleBuffer(buffer);
}
Deleted:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SerializableTupleBatch.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SerializableTupleBatch.java 2012-08-30
17:48:02 UTC (rev 4382)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SerializableTupleBatch.java 2012-08-30
18:08:53 UTC (rev 4383)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.List;
-
-import org.teiid.client.BatchSerializer;
-import org.teiid.common.buffer.TupleBatch;
-import org.teiid.core.util.ExternalizeUtil;
-
-public class SerializableTupleBatch extends TupleBatch implements Externalizable {
-
- private String[] types;
-
- public SerializableTupleBatch() {
- //for Externalizable
- }
-
- public SerializableTupleBatch(TupleBatch batch, String[] types) {
- super(batch.getBeginRow(), batch.getTuples());
- this.types = types;
- }
-
- @Override
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- String[] types = ExternalizeUtil.readStringArray(in);
- this.setRowOffset(in.readInt());
- this.setTerminationFlag(in.readBoolean());
- this.tuples = (List)BatchSerializer.readBatch(in, types);
- }
-
- @Override
- public void writeExternal(ObjectOutput out) throws IOException {
- ExternalizeUtil.writeArray(out, types);
- out.writeInt(this.getBeginRow());
- out.writeBoolean(this.getTerminationFlag());
- BatchSerializer.writeBatch(out, types, this.getTuples());
- }
-
-}