use of org.teiid.core.types.BlobType in project teiid by teiid.
the class CouchbaseProcedureExecution method next.
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
if (this.results != null && this.results.hasNext()) {
final N1qlQueryRow row = this.results.next();
String procName = this.call.getProcedureName();
if (procName.equalsIgnoreCase(GETDOCUMENTS) || procName.equalsIgnoreCase(GETDOCUMENT)) {
ArrayList<Object> result = new ArrayList<>(1);
InputStreamFactory isf = new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(row.byteValue());
}
};
Object value = new BlobType(new BlobImpl(isf));
result.add(value);
return result;
}
}
return null;
}
use of org.teiid.core.types.BlobType in project teiid by teiid.
the class TestJSONProcessing method testJSONParseBlob.
@Test
public void testJSONParseBlob() throws Exception {
HardcodedDataManager dataManager = new HardcodedDataManager();
// $NON-NLS-1$
String sql = "select jsonParse(cast(? as blob), false) x";
String json = "{\"name\":123}";
List<?>[] expected = new List[] { Arrays.asList(json) };
processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), RealMetadataFactory.example1Cached(), Arrays.asList(new BlobType(new SerialBlob(json.getBytes(Charset.forName("UTF-16BE"))))));
}
use of org.teiid.core.types.BlobType in project teiid by teiid.
the class TestJDBCSocketTransport method testStreamingLob.
@Test
public void testStreamingLob() throws Exception {
HardCodedExecutionFactory ef = new HardCodedExecutionFactory();
ef.addData("SELECT helloworld.x FROM helloworld", Arrays.asList(Arrays.asList(new BlobType(new BinaryWSProcedureExecution.StreamingBlob(new ByteArrayInputStream(new byte[100]))))));
server.addTranslator("custom", ef);
server.deployVDB(new ByteArrayInputStream("<vdb name=\"test\" version=\"1\"><model name=\"test\"><source name=\"test\" translator-name=\"custom\"/><metadata type=\"DDL\"><![CDATA[CREATE foreign table helloworld (x blob);]]> </metadata></model></vdb>".getBytes("UTF-8")));
conn = TeiidDriver.getInstance().connect("jdbc:teiid:test@mm://" + addr.getHostName() + ":" + jdbcTransport.getPort(), null);
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("select to_chars(x, 'UTF-8') from helloworld");
rs.next();
// TODO: if we use getString streaming will still fail because the string logic gets the length first
assertEquals(100, ObjectConverterUtil.convertToCharArray(rs.getCharacterStream(1), -1).length);
}
Aggregations