Multiple Types serialization/deserialization to/from stream

375 views
Skip to first unread message

Pratap Koritala

unread,
Nov 19, 2015, 1:18:06 PM11/19/15
to protostuff
The serialization/deserialization to/from stream with Multiple Types  is not working.

PS: Cross posting as I am not sure if it is bug, and for visibility !!

Kostiantyn Shchepanovskyi

unread,
Nov 19, 2015, 3:32:07 PM11/19/15
to proto...@googlegroups.com
There is an issue with your example, you forget about framing. 


Streaming Multiple Messages
If you want to write multiple messages to a single file or stream, it is up to you to keep track of where one message ends and the next begins. The Protocol Buffer wire format is not self-delimiting, so protocol buffer parsers cannot determine where a message ends on their own. The easiest way to solve this problem is to write the size of each message before you write the message itself. When you read the messages back in, you read the size, then read the bytes into a separate buffer, then parse from that buffer. (If you want to avoid copying bytes to a separate buffer, check out theCodedInputStream class (in both C++ and Java) which can be told to limit reads to a certain number of bytes.)
 
David already responded on the gihub, so let's continue discussion there.

--
You received this message because you are subscribed to the Google Groups "protostuff" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protostuff+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards,

Konstantin
Reply all
Reply to author
Forward
0 new messages