Timothy Parez
unread,Feb 1, 2011, 6:01:21 AM2/1/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Protocol Buffers
Hello,
Considering the following proto file:
message FileDescriptor
{
required string Filename = 1;
optional int64 Size = 2 [default = 0];
}
message FileList
{
repeated FileDescriptor Files = 1;
}
If you create something like this:
(and I'm duplicating the data because it made it easier to spot in a
hex editor)
files.Files.Add(new FileDescriptor() { Filename = "AAAAAAA", Size =
100 });
files.Files.Add(new FileDescriptor() { Filename = "AAAAAAA", Size =
100 });
files.Files.Add(new FileDescriptor() { Filename = "AAAAAAA", Size =
100 });
files.Files.Add(new FileDescriptor() { Filename = "AAAAAAA", Size =
100 });
and then serialize it using the Protobuf.Serializer I expected it to
generate something like
Tag for the FileList -> Id 1, WireType 2 => 0x0A
Length of the payload (all the bytes for all the files that follow)
But instead I found everything is simply repeated.
0A 0B 0A 07 41 41 41 41 41 41 41 10 64
0A 0B 0A 07 41 41 41 41 41 41 41 10 64
0A 0B 0A 07 41 41 41 41 41 41 41 10 64
0A 0B 0A 07 41 41 41 41 41 41 41 10 64
I'm wondering, is this an implementation detail (and allowed by the
protobol buffer specifications)
or a requirement of the google protocol buffer specifications ?
It does seem to add quite a bit of overhead, imagine the FileList has
other properties,
they would be repeated for every instance of FileDescriptor ?
Or am I missing something ?