@Override protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException { Blob rsBlob = rs.getBlob( name ); if ( rsBlob == null || rsBlob.length() < HANABlobTypeDescriptor.this.maxLobPrefetchSize ) { return javaTypeDescriptor.wrap( rsBlob, options ); } Blob blob = new MaterializedBlob( DataHelper.extractBytes( rsBlob.getBinaryStream() ) ); return javaTypeDescriptor.wrap( blob, options ); }
@Override public InputStream getBinaryStream() throws SQLException { return new ByteArrayInputStream( this.getBytes() ); }
@Override public long length() { return this.getBytes().length; }
public MaterializedBlob(byte[] bytes) { this.setBytes( bytes ); }
@Override public InputStream getBinaryStream(long pos, long length) { return new ByteArrayInputStream( this.getBytes(), (int) ( pos - 1 ), (int) length ); }
@Override public InputStream getBinaryStream() { return new ByteArrayInputStream( this.getBytes() ); }
@Override public void free() { this.setBytes( null ); }
@Override protected X doExtract(ResultSet rs, int position, ExecutionContext executionContext) throws SQLException { Blob rsBlob = rs.getBlob( position ); if ( rsBlob == null || rsBlob.length() < HANAStreamBlobTypeDescriptor.this.maxLobPrefetchSize ) { return javaTypeDescriptor.wrap( rsBlob, executionContext.getSession() ); } Blob blob = new MaterializedBlob( LobStreamDataHelper.extractBytes( rsBlob.getBinaryStream() ) ); return javaTypeDescriptor.wrap( blob, executionContext.getSession() ); }
@Override protected X doExtract( ResultSet rs, int position, ExecutionContext executionContext) throws SQLException { Blob rsBlob = rs.getBlob( position ); if ( rsBlob == null || rsBlob.length() < HANABlobTypeDescriptor.this.maxLobPrefetchSize ) { return javaTypeDescriptor.wrap( rsBlob, executionContext.getSession() ); } Blob blob = new MaterializedBlob( LobStreamDataHelper.extractBytes( rsBlob.getBinaryStream() ) ); return javaTypeDescriptor.wrap( blob, executionContext.getSession() ); }
@Override public OutputStream setBinaryStream(long pos) { return new ByteArrayOutputStream() { { this.buf = getBytes(); } }; }
public MaterializedBlob(byte[] bytes) { this.setBytes( bytes ); }
@Override public long length() throws SQLException { return this.getBytes().length; }
@Override public void free() throws SQLException { this.setBytes( null ); }
@Override protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException { Blob rsBlob = rs.getBlob( name ); if ( rsBlob == null || rsBlob.length() < HANAStreamBlobTypeDescriptor.this.maxLobPrefetchSize ) { return javaTypeDescriptor.wrap( rsBlob, options ); } Blob blob = new MaterializedBlob( DataHelper.extractBytes( rsBlob.getBinaryStream() ) ); return javaTypeDescriptor.wrap( blob, options ); }
@Override public InputStream getBinaryStream(long pos, long length) throws SQLException { return new ByteArrayInputStream( this.getBytes(), (int) ( pos - 1 ), (int) length ); }
@Override public OutputStream setBinaryStream(long pos) throws SQLException { return new ByteArrayOutputStream() { { this.buf = getBytes(); } }; }