Author: shawkins
Date: 2012-08-21 22:39:00 -0400 (Tue, 21 Aug 2012)
New Revision: 4356
Modified:
trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
Log:
TEIID-2153 allowing cached lobs to be referenced after close
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java 2012-08-21 17:49:10
UTC (rev 4355)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/LobManager.java 2012-08-22 02:39:00
UTC (rev 4356)
@@ -247,11 +247,16 @@
Streamable<?> persistedLob;
OutputStream fsos = store.createOutputStream();
-byteLength = ObjectConverterUtil.write(fsos, is, bytes, -1);
+ byteLength = ObjectConverterUtil.write(fsos, is, bytes, -1);
// re-construct the new lobs based on the file store
final long lobOffset = offset;
final long lobLength = byteLength;
+ /*
+ * Using an inner class here will hold a reference to the LobManager
+ * which prevents the removal of the FileStore until all of the
+ * lobs have been gc'd
+ */
InputStreamFactory isf = new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
@@ -263,7 +268,7 @@
return StorageMode.PERSISTENT;
}
};
-
+ isf.setLength(byteLength);
if (lob instanceof BlobType) {
persistedLob = new BlobType(new BlobImpl(isf));
}
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-21
17:49:10 UTC (rev 4355)
+++
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2012-08-22
02:39:00 UTC (rev 4356)
@@ -465,16 +465,13 @@
Class<?>[] types = getTypeClasses(elements);
BatchManagerImpl batchManager = createBatchManager(newID, types);
LobManager lobManager = null;
- FileStore lobStore = null;
if (lobIndexes != null) {
- lobStore = createFileStore(newID + "_lobs"); //$NON-NLS-1$
+ FileStore lobStore = createFileStore(newID + "_lobs"); //$NON-NLS-1$
lobManager = new LobManager(lobIndexes, lobStore);
+ AutoCleanupUtil.setCleanupReference(lobManager, lobStore);
batchManager.setLobManager(lobManager);
}
TupleBuffer tupleBuffer = new TupleBuffer(batchManager, String.valueOf(newID),
elements, lobManager, getProcessorBatchSize(elements));
- if (lobStore != null) {
- AutoCleanupUtil.setCleanupReference(batchManager, lobStore);
- }
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR,
MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating
TupleBuffer:", newID, elements, Arrays.toString(types), "of type",
tupleSourceType); //$NON-NLS-1$ //$NON-NLS-2$
}
Show replies by date