thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Duxbury <br...@rapleaf.com>
Subject Re: C++ deserialization - record length?
Date Fri, 23 Jul 2010 20:38:47 GMT
Serialized thrift objects aren't fixed size, nor do their in-memory
representations reflect their serialized representation. Unless there's more
magic to sizeof() than I was expecting, you need to look at the size of the
buffer after you write out, not the size of the struct.

On Fri, Jul 23, 2010 at 1:27 PM, Raghava Mutharaju <
m.vijayaraghava@gmail.com> wrote:

> Hi all,
>
> I have serialized couple of Employee objects (binary protocol) and saved
> the
> byte array into a file. I am using C++ to deserialize. I would reach bytes
> of one Employee from the file each time and give it to read() method. If I
> use sizeof(Employee), it does not give the right size.
>
> Some statistics from a sample run:
>
> Total Employee objects serialized = 10
> Total bytes in the file = 690. So each Employee object size should be 69
> bytes.
> sizeof(Employee) gives 96.
>
> This seems to be a frequently used operation. How can this be done?
> I would read each object, fill the TMemoryBuffer and use it to construct
> TBinaryProtocol.
>
> Thank you.
>
> Regards,
> Raghava.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message