Author: shawkins
Date: 2010-09-09 11:59:30 -0400 (Thu, 09 Sep 2010)
New Revision: 2554
Modified:
branches/7.1.x/api/src/main/java/org/teiid/translator/ExecutionContext.java
branches/7.1.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/7.1.x/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/message/AtomicResultsMessage.java
Log:
TEIID-1252 took the simplest approach, which is to have the executionfactory indicate if
lobs are usable after close
Modified: branches/7.1.x/api/src/main/java/org/teiid/translator/ExecutionContext.java
===================================================================
--- branches/7.1.x/api/src/main/java/org/teiid/translator/ExecutionContext.java 2010-09-08
21:22:26 UTC (rev 2553)
+++ branches/7.1.x/api/src/main/java/org/teiid/translator/ExecutionContext.java 2010-09-09
15:59:30 UTC (rev 2554)
@@ -109,8 +109,14 @@
/**
* When the execution is turned on with "alive=true", the execution object
will not
* be implicitly closed at the end of the last batch. It will only be closed at end
- * of the user query. This is useful in keeping the connection open for
+ * of the user query.
+ * <p>
+ * The engine will already detect situations when the connection should stay open for
* LOB (clob/blob/xml) streaming.
+ * <p>
+ * Keeping the execution alive unnecessarily may cause issues with connection usage
+ * as the connection instance may not be usable by other queries.
+ *
* @param alive
*/
void keepExecutionAlive(boolean alive);
Modified: branches/7.1.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/7.1.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-09-08
21:22:26 UTC (rev 2553)
+++ branches/7.1.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-09-09
15:59:30 UTC (rev 2554)
@@ -753,7 +753,7 @@
try {
if (className == null) {
if (defaultClass == null) {
- throw new TranslatorException("Neither class name or default class specified
to create an instance"); //$NON-NLS-1$
+ throw new TranslatorException("Neither class name nor default class
specified to create an instance"); //$NON-NLS-1$
}
return expectedType.cast(defaultClass.newInstance());
}
@@ -777,4 +777,12 @@
public void getMetadata(MetadataFactory metadataFactory, C conn) throws
TranslatorException {
}
+
+ /**
+ * Indicates if LOBs are usable after the execution is closed.
+ * @return true if LOBs can be used after close
+ */
+ public boolean areLobsUsableAfterClose() {
+ return false;
+ }
}
Modified:
branches/7.1.x/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
===================================================================
---
branches/7.1.x/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java 2010-09-08
21:22:26 UTC (rev 2553)
+++
branches/7.1.x/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java 2010-09-09
15:59:30 UTC (rev 2554)
@@ -221,4 +221,9 @@
param.setAnnotation("The contents to save. Can be one of CLOB, BLOB, or
XML");
}
+ @Override
+ public boolean areLobsUsableAfterClose() {
+ return true;
+ }
+
}
Modified:
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
===================================================================
---
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-08
21:22:26 UTC (rev 2553)
+++
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-09
15:59:30 UTC (rev 2554)
@@ -159,5 +159,10 @@
metadataFactory.addProcedureParameter("result",
TypeFacility.RUNTIME_NAMES.BLOB, Type.ReturnValue, p); //$NON-NLS-1$
metadataFactory.addProcedureParameter("contentType",
TypeFacility.RUNTIME_NAMES.STRING, Type.Out, p); //$NON-NLS-1$
}
+
+ @Override
+ public boolean areLobsUsableAfterClose() {
+ return true;
+ }
}
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java 2010-09-08
21:22:26 UTC (rev 2553)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java 2010-09-09
15:59:30 UTC (rev 2554)
@@ -136,7 +136,6 @@
}
public ConnectorWork registerRequest(AtomicRequestMessage message) throws
TeiidComponentException {
- // Set the connector ID to be used; if not already set.
checkStatus();
AtomicRequestID atomicRequestId = message.getAtomicRequestID();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId,
"Create State"}); //$NON-NLS-1$
@@ -156,7 +155,7 @@
*/
void removeState(AtomicRequestID id) {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {id, "Remove
State"}); //$NON-NLS-1$
- ConnectorWorkItem cwi = requestStates.remove(id);
+ requestStates.remove(id);
}
int size() {
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-09-08
21:22:26 UTC (rev 2553)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-09-09
15:59:30 UTC (rev 2554)
@@ -335,6 +335,7 @@
response.setSupportsImplicitClose(!this.securityContext.keepExecutionAlive());
response.setTransactional(this.securityContext.isTransactional());
response.setWarnings(this.securityContext.getWarnings());
+ response.setSupportsCloseWithLobs(this.connector.areLobsUsableAfterClose());
if ( lastBatch ) {
response.setFinalRow(rowCount);
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-09-08
21:22:26 UTC (rev 2553)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-09-09
15:59:30 UTC (rev 2554)
@@ -23,7 +23,6 @@
package org.teiid.dqp.internal.process;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
@@ -70,21 +69,21 @@
* notify the parent plan and just schedule the next poll.
*/
public class DataTierTupleSource implements TupleSource {
-
+
// Construction state
private final AtomicRequestMessage aqr;
private final RequestWorkItem workItem;
private final ConnectorWork cwi;
private final DataTierManagerImpl dtm;
- private List<Integer> convertToRuntimeType;
+ private boolean[] convertToRuntimeType;
private boolean[] convertToDesiredRuntimeType;
private Class<?>[] schema;
// Data state
private int index;
private int rowsProcessed;
- private volatile AtomicResultsMessage arm;
+ private AtomicResultsMessage arm;
private boolean closed;
private volatile boolean canceled;
private boolean executed;
@@ -102,12 +101,12 @@
List<SingleElementSymbol> symbols = this.aqr.getCommand().getProjectedSymbols();
this.schema = new Class[symbols.size()];
this.convertToDesiredRuntimeType = new boolean[symbols.size()];
- this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
+ this.convertToRuntimeType = new boolean[symbols.size()];
for (int i = 0; i < symbols.size(); i++) {
SingleElementSymbol symbol = symbols.get(i);
this.schema[i] = symbol.getType();
this.convertToDesiredRuntimeType[i] = true;
- this.convertToRuntimeType.add(i);
+ this.convertToRuntimeType[i] = true;
}
Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
@@ -132,25 +131,26 @@
}
private List correctTypes(List row) throws TransformationException {
- for (int i = convertToRuntimeType.size() - 1; i >= 0; i--) {
- int idx = convertToRuntimeType.get(i);
- Object value = row.get(idx);
- if (value != null) {
- Object result = convertToRuntimeType(value, this.schema[idx]);
- if (DataTypeManager.isLOB(result.getClass())) {
- explicitClose = true;
+ //TODO: add a proper intermediate schema
+ for (int i = 0; i < row.size(); i++) {
+ Object value = row.get(i);
+ if (value == null) {
+ continue;
+ }
+ if (convertToRuntimeType[i]) {
+ boolean lob = !arm.supportsCloseWithLobs() &&
DataTypeManager.isLOB(value.getClass());
+ Object result = convertToRuntimeType(value, this.schema[i]);
+ if (value == result &&
!DataTypeManager.DefaultDataClasses.OBJECT.equals(this.schema[i])) {
+ convertToRuntimeType[i] = false;
+ } else {
+ if (lob && DataTypeManager.isLOB(result.getClass()) &&
DataTypeManager.isLOB(this.schema[i])) {
+ explicitClose = true;
+ }
+ row.set(i, result);
+ value = result;
}
- if (value == result &&
!DataTypeManager.DefaultDataClasses.OBJECT.equals(this.schema[idx])) {
- convertToRuntimeType.remove(i);
- continue;
- }
- row.set(idx, result);
}
- }
- //TODO: add a proper intermediate schema
- for (int i = 0; i < row.size(); i++) {
if (convertToDesiredRuntimeType[i]) {
- Object value = row.get(i);
if (value != null) {
Object result = DataTypeManager.transformValue(value, value.getClass(),
this.schema[i]);
if (value == result) {
@@ -160,7 +160,7 @@
row.set(i, result);
}
} else {
- row.set(i, DataTypeManager.getCanonicalValue(row.get(i)));
+ row.set(i, DataTypeManager.getCanonicalValue(value));
}
}
return row;
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/message/AtomicResultsMessage.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/message/AtomicResultsMessage.java 2010-09-08
21:22:26 UTC (rev 2553)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/message/AtomicResultsMessage.java 2010-09-09
15:59:30 UTC (rev 2554)
@@ -42,6 +42,8 @@
// by default we support implicit close.
private boolean supportsImplicitClose = true;
+
+ private boolean supportsCloseWithLobs;
private boolean isTransactional;
@@ -60,6 +62,14 @@
return this.supportsImplicitClose;
}
+ public boolean supportsCloseWithLobs() {
+ return supportsCloseWithLobs;
+ }
+
+ public void setSupportsCloseWithLobs(boolean supportsCloseWithLobs) {
+ this.supportsCloseWithLobs = supportsCloseWithLobs;
+ }
+
public void setSupportsImplicitClose(boolean supportsImplicitClose) {
this.supportsImplicitClose = supportsImplicitClose;
}
@@ -83,6 +93,7 @@
supportsImplicitClose = in.readBoolean();
warnings = (List<Exception>)in.readObject();
isTransactional = in.readBoolean();
+ supportsCloseWithLobs = in.readBoolean();
}
public void writeExternal(ObjectOutput out) throws IOException {
@@ -92,6 +103,7 @@
out.writeBoolean(supportsImplicitClose);
out.writeObject(warnings);
out.writeBoolean(isTransactional);
+ out.writeBoolean(supportsCloseWithLobs);
}
public boolean isTransactional() {