db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@debrunners.com>
Subject Re: Question about length information removed in BinaryToRawStream
Date Tue, 20 Dec 2005 17:10:38 GMT
TomohitoNakayama wrote:
> Hello .
> 
> I found that length information of source InputStream was removed in
> org.apache.derby.impl.jdbc.BinaryToRawStream .
> 
> Comment in source of BinaryToRawStream tells that this length
> information was what exists in Cloudscape stored binary form .
> I imagine this may have something to do with Disk Page Format , but not
> sure exactly .
> http://db.apache.org/derby/papers/pageformats.html
> 
> I want to know answer for next 2 question .
> 1: Why this length information was not used ?
> 2: Is it impossible to use this length information as length of
> BinaryToRawStream ?

On disk a binary value is logically stored like this:

   <length> <value as bytes>

The length, I think, may correctly represent the length of the following
bytes or might represent that the length is not known.

The purpose of BinaryToRawStream is to take a stream returned from the
Derby store and convert it to the value expected by the user when using
getBinaryStream. When the store returns a stream for this column it
returns a stream containing

  <length> <value as bytes>

The user on the other hand is expecting a stream that just contains the
value, not one with the length. Thus the only purpose of
BinaryToRawStream is to remove the leading length from the stream it wraps.

  ResultSet.getBinaryStream() returns

      BinaryToRawStream() wrapping a stream from the Derby store.


And then BinaryToRawStream just reads the bytes representing the length
from the store stream before allow the application to read any bytes.

So to answer the questions:

A1) The length is not required as part of this api, an application
cannot get the length of a binary column from the JDBC api.

A2) Probably depends how you want to use it. For a user application no,
if you want some extra information passed to the network server then I'm
sure would could design some api for that.

Dan.




Mime
View raw message