Hi Martin, On Tue, Jul 9, 2024 at 12:31 PM Martin Desruisseaux < martin.desruisse...@geomatys.com> wrote:
> I was using a custom OutputStream implementation for getting the value of > that field, avoiding any form of copy. > Gotcha - so in other words, you want a way to effectively "unwrap" the original byte[] array so you can access the whole thing at one time (random access), as opposed to just accessing it in online fashion as a stream of bytes. It seems that the root of this dilemma is really the java.sql API. For example, you would think there should be a method java.sql.Blob.asByteBuffer() (and Clob.asCharBuffer()). Maybe adding such methods would be a more precise way to fix this. In looking at this, I noticed that Blob.getBytes() does not specify whether, when the entire array is asked for, a copy must (or must not) be returned. So you can't rely on that method for any particular behavior either. Basically, the BLOB API seems clearly designed to allow the implementation to stream the data on demand if it wants to (which is good), but as a side effect it doesn't provide a way for the caller to guarantee avoidance of copying the entire array (if the implementation happens to not stream the data on demand). -Archie -- Archie L. Cobbs