Re: Fastest way to serialize arbitrary objects ???
On Apr 30, 7:29 pm, Brian <c...@mailvault.com> wrote:
On Apr 30, 4:05 am, James Kanze <james.ka...@gmail.com> wrote:
Another advantage is that you can define a protocol which puts
the length of each object at its beginning. This can
considerably speed up skipping an object you're not interested
in.
When do you do that?
It depends. It's not that frequent, but I've needed it once or
twice.
It sounds like you're skipping over an object on the receiving
side.
Exactly.
I prepend the message length and the size of containers and
strings, but I can't think of much reason to skip over
objects.
Two possible reasons: you write out a large set of possibly
relevant objects, but each execution only needs a few of them,
and for journal files---when recovering, you can skip
transactions that are already in the database.
At the marshalling/serial- ization level, I'm not sure if you
could decide to skip something. I guess the application would
have to tell the marshalling code to skip over something.
Typically, such applications use a special record format, with
identifying information in the first couple of bytes of the
record. The reading code reads this information, then decides
whether it wants the record or not.
--
James Kanze