> In the case of repeated strings etc (excluding the "enum" case), I've been > toying whether something is possible by associating certain objects / values > with unique identifiers on the wire. Potentially this would also allow > "graph" (rather than "tree") serialization. > This is obviously well into the hazy area of "outside what protobuf offers, > but possible to represent as valid protobuf fragments / messages", but I'd > be interested in people's thoughts... worth investigating? Or silly?
We've done that before to save space. In the simplest case, you can just put a repeated string field in your outermost message that's a list of every unique string in the rest of the message, and then anywhere else in the message that you would have put a string, you put an int that says which string should go there. There are downsides to that approach, though. The biggest one is that you can't build your message up piece by piece, you have to build the whole message object in one go, because all of them need to have input into this one global data structure; similarly, you can't process the message on the other side without carrying around the index everywhere you're using any part of the message. It can save a lot of space if you end up repeating the same strings over and over, though. - Adam -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
