Search in sources :

Example 1 with LobChunkInputStream

use of org.teiid.client.lob.LobChunkInputStream in project teiid by teiid.

the class TestLobChunkInputStream method testReadByteArray.

public void testReadByteArray() throws Exception {
    LobChunkProducer chunkProducer = new LobChunkProducer() {

        // $NON-NLS-1$ //$NON-NLS-2$
        Iterator<LobChunk> chuncks = Arrays.asList(new LobChunk("hello ".getBytes(), false), new LobChunk("world".getBytes(), true)).iterator();

        @Override
        public LobChunk getNextChunk() throws IOException {
            return chuncks.next();
        }

        @Override
        public void close() throws IOException {
        }
    };
    LobChunkInputStream stream = new LobChunkInputStream(chunkProducer);
    // $NON-NLS-1$
    assertEquals("hello world", ObjectConverterUtil.convertToString(stream));
}
Also used : LobChunkProducer(org.teiid.client.lob.LobChunkProducer) LobChunk(org.teiid.client.lob.LobChunk) Iterator(java.util.Iterator) LobChunkInputStream(org.teiid.client.lob.LobChunkInputStream)

Example 2 with LobChunkInputStream

use of org.teiid.client.lob.LobChunkInputStream in project teiid by teiid.

the class TestByteLobChunkStream method testGetChunk.

public void testGetChunk() throws Exception {
    // $NON-NLS-1$
    byte[] bytes = "hello world".getBytes();
    ByteLobChunkStream stream = new ByteLobChunkStream(new ByteArrayInputStream(bytes), 5);
    assertTrue(Arrays.equals(bytes, ObjectConverterUtil.convertToByteArray(new LobChunkInputStream(stream))));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) LobChunkInputStream(org.teiid.client.lob.LobChunkInputStream)

Example 3 with LobChunkInputStream

use of org.teiid.client.lob.LobChunkInputStream in project teiid by teiid.

the class ResultSetImpl method createInputStreamFactory.

private InputStreamFactory createInputStreamFactory(Streamable<?> type) {
    final StreamingLobChunckProducer.Factory factory = new StreamingLobChunckProducer.Factory(this.statement.getDQP(), this.requestID, type);
    InputStreamFactory isf = new InputStreamFactory() {

        @Override
        public InputStream getInputStream() throws IOException {
            return new LobChunkInputStream(factory.getLobChunkProducer());
        }
    };
    return isf;
}
Also used : StreamingLobChunckProducer(org.teiid.client.lob.StreamingLobChunckProducer) LobChunkInputStream(org.teiid.client.lob.LobChunkInputStream) InputStreamFactory(org.teiid.core.types.InputStreamFactory) InputStreamFactory(org.teiid.core.types.InputStreamFactory)

Aggregations

LobChunkInputStream (org.teiid.client.lob.LobChunkInputStream)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Iterator (java.util.Iterator)1 LobChunk (org.teiid.client.lob.LobChunk)1 LobChunkProducer (org.teiid.client.lob.LobChunkProducer)1 StreamingLobChunckProducer (org.teiid.client.lob.StreamingLobChunckProducer)1 InputStreamFactory (org.teiid.core.types.InputStreamFactory)1