Subject | Re: Database grows rapidly (3 to 770MB) when using BLOB views/UDFs |
---|---|
Author | mircostange |
Post date | 2002-03-18T09:55:13Z |
The UDF is written in C (actually C++ with VC). It tried to extract
the relevant pieces.
The function is defined as
__declspec(dllexport) void ProPXMakeBitmap(
IBBLOB b,
double *scaleFactor,
IBBLOB ret)
As you see, it takes a BLOB b, a scaleFactor and also a handle to the
BLOB to be returned. As I understood, this is how the signature is
supposed to look like for BLOB UDFs, i.e. there is an additional
param for the return BLOB.
The UDF then reads data from the source BLOB, e.g.
while ((*b->blob_get_segment) (b->blob_handle, tmp, b->max_seglen ,
&length))
{
tmp += length;
}
Then it does the transformation
char *buf2 = makePicture(..., tmp, ...);
And writes the data into "ret"
bool done = false;
long rest = len;
long pos = 0;
while (!done)
{
long chunksize = b->max_seglen;
if (rest < b->max_seglen )
chunksize = rest;
(*ret->blob_put_segment) (ret->blob_handle, buf2+pos,
chunksize);
pos += chunksize;
rest -= chunksize;
if (rest <= 0)
done = true;
}
Finally, temp memory is freed and the function returns.
Anything wrong with this? Do I have to call some function to tell
Firebird that this BLOB is temporary?
Mirco
the relevant pieces.
The function is defined as
__declspec(dllexport) void ProPXMakeBitmap(
IBBLOB b,
double *scaleFactor,
IBBLOB ret)
As you see, it takes a BLOB b, a scaleFactor and also a handle to the
BLOB to be returned. As I understood, this is how the signature is
supposed to look like for BLOB UDFs, i.e. there is an additional
param for the return BLOB.
The UDF then reads data from the source BLOB, e.g.
while ((*b->blob_get_segment) (b->blob_handle, tmp, b->max_seglen ,
&length))
{
tmp += length;
}
Then it does the transformation
char *buf2 = makePicture(..., tmp, ...);
And writes the data into "ret"
bool done = false;
long rest = len;
long pos = 0;
while (!done)
{
long chunksize = b->max_seglen;
if (rest < b->max_seglen )
chunksize = rest;
(*ret->blob_put_segment) (ret->blob_handle, buf2+pos,
chunksize);
pos += chunksize;
rest -= chunksize;
if (rest <= 0)
done = true;
}
Finally, temp memory is freed and the function returns.
Anything wrong with this? Do I have to call some function to tell
Firebird that this BLOB is temporary?
Mirco