Subject Re: [Firebird-Java] Re: Picture Servlet Problems possibly OT
Author Ann W. Harrison
At 07:16 PM 6/8/2003 +0000, Roman Rokytskyy wrote:

>In old good times idea was to introduce some kind of "natural" block
>size for some content. If I remember correctly, Ann or Paul B. have
>told that the idea was to add automatically a new line in text fields
>(that is why in documentation you see segment size 80, size of one
>line of ASCII on the screen).

The segment length was an indicator for gpre and qli and other tools
that automatically generated requests from higher level language as
to the appropriate length for transmission between the database and
the client.

> As I understand, segment size influences
>the way blob is stored on the database page.

Yes, but you can store different length segments in a single blob.
A segmented blob contains two bytes of segment length, followed by
that many bytes of data, followed by the length of the next segment,
that segment, etc.

> Also it is used in blob
>filters.

The get_segment and put_segment calls are used in both stream and
segmented blobs. In the case of a stream blob get_segment will
return full buffers as long as there is still data in the blob.
In the case of a segmented blob, get_segment will either return
a segment which may be the size of the buffer or smaller, or it
will return a full buffer and a status code saying that the
segment is not yet complete.

>But I may confuse something. Anyway, remote protocol requires
>us to provide a size we want to fetch from the current position, not
>the segment number to fetch.

Right. There are no segment numbers.


>Also, engine supports streem blobs (in fact arrays are stored as
>streem blobs) and I plan to switch from segmented blobs to streamed
>blobs (at least to provide length() and seek() methods on blobs).

Length is easy in either case. Use the blob-info call. It returns
the number of segments (segmented only, of course), the length of
the longest segment (handy if you're constructing buffers on the
fly), and the total length of the blob. Seek works only on stream
blobs (because of the length bytes that occur at irregular intervals
in segmented blobs), but it provides three modes - from start,
from current position, and from end (requires a negative offset).

Regards


Ann