use of org.teiid.common.buffer.FileStore in project teiid by teiid.
the class XMLSystemFunctions method saveToBufferManager.
/**
* This method saves the given XML object to the buffer manager's disk process
* Documents less than the maxMemorySize will be held directly in memory
*/
public static SQLXMLImpl saveToBufferManager(BufferManager bufferMgr, XMLTranslator translator, CommandContext context) throws TeiidComponentException, TeiidProcessingException {
boolean success = false;
// $NON-NLS-1$
final FileStore lobBuffer = bufferMgr.createFileStore("xml");
final FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(lobBuffer, Streamable.ENCODING);
try {
Writer writer = fsisf.getWriter();
final ExtendedWriter ew = new ExtendedWriter(writer, fsisf);
translator.translate(ew);
ew.close();
success = true;
return createSQLXML(fsisf, ew, context);
} catch (IOException e) {
throw new TeiidComponentException(QueryPlugin.Event.TEIID30444, e);
} catch (TransformerException e) {
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30445, e);
} finally {
if (!success && lobBuffer != null) {
lobBuffer.remove();
}
}
}
use of org.teiid.common.buffer.FileStore in project teiid by teiid.
the class TestFileStorageManager method testSetLength.
@Test
public void testSetLength() throws Exception {
FileStorageManager sm = getStorageManager(null, null);
// $NON-NLS-1$
String tsID = "0";
FileStore store = sm.createFileStore(tsID);
store.setLength(1000);
assertEquals(1000, sm.getUsedBufferSpace());
store.setLength(200);
assertEquals(200, sm.getUsedBufferSpace());
store.setLength(1000);
assertEquals(1000, sm.getUsedBufferSpace());
}
use of org.teiid.common.buffer.FileStore in project teiid by teiid.
the class TestFileStorageManager method testWrite.
@Test
public void testWrite() throws Exception {
FileStorageManager sm = getStorageManager(null, null);
// $NON-NLS-1$
String tsID = "0";
FileStore store = sm.createFileStore(tsID);
writeBytes(store);
assertEquals(2048, sm.getUsedBufferSpace());
store.remove();
assertEquals(0, sm.getUsedBufferSpace());
}
use of org.teiid.common.buffer.FileStore in project teiid by teiid.
the class TestFileStorageManager method testMaxSpace.
@Test(expected = IOException.class)
public void testMaxSpace() throws Exception {
FileStorageManager sm = getStorageManager(null, null);
sm.setMaxBufferSpace(1);
// $NON-NLS-1$
String tsID = "0";
// Add one batch
FileStore store = sm.createFileStore(tsID);
writeBytes(store);
}
use of org.teiid.common.buffer.FileStore in project teiid by teiid.
the class TestFileStorageManager method testMaxSpaceSplit.
@Test(expected = IOException.class)
public void testMaxSpaceSplit() throws Exception {
FileStorageManager sm = getStorageManager(null, null);
sm.setMaxBufferSpace(1);
// $NON-NLS-1$
String tsID = "0";
SplittableStorageManager ssm = new SplittableStorageManager(sm);
FileStore store = ssm.createFileStore(tsID);
try {
writeBytes(store);
} finally {
assertEquals(0, sm.getUsedBufferSpace());
}
}
Aggregations