FirebirdSQL / jaybird

JDBC driver for Firebird

Home Page:https://www.firebirdsql.org/en/jdbc-driver/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add methods for reading blob content directly to an array

mrotteveel opened this issue · comments

There is a bit of overhead for reading blobs using FbBlob.getSegment(int), because Jaybird reads segments, which are received in an array (ByteBuffer for JNA), and then from that array, the segments are decoded into a new array, which is then returned. These reads will generally use the blobBufferSize.

If we are reading into an array, needing a length larger than the blobBufferSize, we could optimize this read - at least for the pure Java code - by requesting larger segments and reading (decoding the segments) directly into the array, foregoing allocation of additional arrays (for the response and the return value). A similar optimization could also be performed for BlobInputStream.transferTo, and potentially for BlobInputStream.read(byte[], int, int) and/or readFully. In the case of JNA the optimization would be less pronounced (as there we do need to read into and from a ByteBuffer and use blobBufferSize), but we could forego the allocation of the array returned from getSegment.

Similar optimizations might also be possible for writing blobs, but we will consider those separately.

I have not optimized transferTo at this time, I will consider that at a later time.