db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TomohitoNakayama <tomon...@basil.ocn.ne.jp>
Subject Re: Question about length information removed in BinaryToRawStream
Date Wed, 21 Dec 2005 15:34:13 GMT
Hello .

I see ...
I took that the information of length is removed from BinaryToRawStream 
as a manner of InputStream .

I think there exists room to be improved in 
org.apache.derby.impl.jdbc.EmbedBlob#length() .
I saw this method read through whole BinaryToRawStream to know length to 
return .
//There may be bug caused by this internal behavior ....

I will survey more and file this issue .

Best regards.

Daniel John Debrunner wrote:

>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 .
>>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.


        Tomohito Nakayama



View raw message