List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 27 1999 2:24am
Subject:Re: binary write
View as plain text  
On Sun, 1999-09-26 19:53:14 +1000, Michael Farr wrote:
> Hi, I want to write the following class (and a whole bunch of sister
> types) to a database field (I use borland builder C++ ) [...]
[...]
> Problem 1 is there are many different types of MPeriodicEvent that
> have differing numbers of parameters, and I dont want to have to
> create a character representation for each one.

The process of converting some binary structure into a (readable)
character stream normally is called serialization, so maybe Borland
Builder C++ does have some 'serialize' function?  This would relieve
you of writing your own code ... :)

> Problem 2 is I dont want to use a blob field in my database, because it
> will force it to use variable width rows which decrease speed and
> increase fragmentation.  The table I want to put it in is quite large
> and this would create a significant performance drop (probably anyway).

Standard solution to this problem is to use BLOBs, but put them all
into a seperate table and address the blobs with an additional id
field.

But if you can predict how large the biggest type of MPeriodicEvent is
going to be, and a maximum of 255 is sufficient, then just use a CHAR
column!  You can store binary data in CHAR and VARCHAR and TEXT fields
without a problem ...

> Is there a sensible way to convert the binary stream into a
> character stream (if not is there a crazy way of doing it)?

uuencode, base64, quoted-printable, ...
or WDDX (see <URL: http://www.wddx.org/ >).
But I guess, you won't need any of these methods.

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
binary writeMichael Farr26 Sep
  • Re: binary writeMartin Ramsch27 Sep