Closed cporter closed 8 years ago
Saying "don't ask" makes me even more curious. But jokes aside, I'd like to have a use case posted, at the very least for documentation?
Let's say you have a type of message A
that you're storing as a blob in a database. You want to create a repeated
field of type A
out of those blobs, but you don't want to deserialize and then re-serialize them. If you know the tag number of the repeated
type you can construct the serialized repeated message by hand and save yourself the cost of running each A
through an object. The advantage of going to the trouble rather than sending the blobs as one concatenated bytes
array with a list of lengths for each is that whoever is reading the message can treat it as a normal repeated
field.
That sounds reasonable, I hadn't quite thought of that. Give me a few minutes to take care of some things and we should be good to go.
Agreed with that! protobuf have not just a markers of message members, but count numbers (ids) too then it's needs to add possibility to use it!
I have a project where I'm assembling messages by hand. (Don't ask.) For this I need to know the values of some of the tags. It's better to have it available in code than to try to keep source and .proto files up to date. (Even though the tag numbers should never change.)