Subject RE: [Firebird-Java] Re: Streamed Blob
Author Robert DiFalco
Ugh, that kind of sucks (i.e. having to read the entire blob into
memory). Seems (as you imply) that a better pattern matching algorithm
is required, and one that can work on streamed data (i.e. does not rely
on the entire blob being read into memory).

Btw, I'm having trouble finding doc on how (in my DDL) I create a Stream
Blob Column.


-----Original Message-----
From: Nickolay Samofatov [mailto:skidder@...]
Sent: Monday, October 06, 2003 5:56 AM
To: Roman Rokytskyy
Subject: Re: [Firebird-Java] Re: Streamed Blob

Hello, Roman, All,

>> Are streamed blobs a possibility when using JayBird? I cannot
>> use LIKE queries that contain wild cards with a segmented blob. The
>> wild card breaks if it goes across a segment boundary. For example,
>> I select LIKE "%line2%line200%" and the blob segments on say line 50,

>> the query will fail.

> Yes, current version of JayBird in CVS uses stream blobs by default
> (and probably using segemented blobs needs recompilation :)). But as
> long as your blob was created segmented, you cannot switch it to
> streamed and vice versa. So, if your test works in IBExpert with the
> same blob it fails in JayBird, then something wrong is somewhere else.

Engine evaluates "LIKE" statement in 1024-byte chunks for streamed
blobs. Here is the relevant code:

blob =
reinterpret_cast < bid *

/* Performs the string_function on each segment of the
blob until
a positive result is obtained */

ret_val = FALSE;
while (!(blob->blb_flags & BLB_eof)) {
l1 = BLB_get_segment(tdbb, blob, buffer,
if (string_function(tdbb, node, l1, buffer, l2,
p2, type1)) {
ret_val = TRUE;
if (node->nod_type == nod_starts)

BLB_close(tdbb, blob);

buffer has the size of 1024 bytes.

It seems obvious to apply a little bit of hacking and fetch entire
blob before doing pattern-matching, but it opens another problem.
Implementation of pattern-matching algorithm is very far from being
perfect, it has max cost of O(N^3*M^2) where N and M are lengths of LIKE
arguments. So if this algorithm is applied to large BLOB with string
like this it will run forever. This has to be fixed first.
Any volunteers to implement good pattern-matching algorithm ?

> Roman

Nickolay Samofatov mailto:skidder@...

Yahoo! Groups Sponsor

To unsubscribe from this group, send an email to:

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.