Should I use a binary or a text file for storing protobuf messages?

The best practice for concatenating messages in this way is to prepend each message with its size. That way you read in the size (try a 32bit int or something), then read that number of bytes into a buffer and deserialize it. Then read the next size, etc.Etc The same goes for writing, you first write out the size of the message, then the message itself See Streaming Multiple Messages on the protobuf documentation for more information.

The best practice for concatenating messages in this way is to prepend each message with its size. That way you read in the size (try a 32bit int or something), then read that number of bytes into a buffer and deserialize it. Then read the next size, etc.Etc.

The same goes for writing, you first write out the size of the message, then the message itself. See Streaming Multiple Messages on the protobuf documentation for more information.

– nbolton Dec 7 '09 at 11:45 The protobuf data is always binary, it's just that python and C++ strings can hold binary data. So it doesn't matter what data type you end up using. – Mike Weller Dec 8 '09 at 6:28.

We have had great success base64 encoding the messages, and using a simple \n to separate messages. This will ofcoirse depend a lot on your use - we need to store the messages in "log" files. It naturally has overhead encoding/decoding this - but this has not even remotely been an issue for us.

The advantage of keeping these messages as line separated text has so far been invaluable for maintenance and debugging. Figure out how many messages are in a file? Wc -l .

Find the Nth message - head ... | tail. Figure out what's wrong with a record on a remote system you need to access through 2 VPNs and a citrix solution? Copy paste the message and mail it to the programmer.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions