I am comparing ecoding a message that has two field where each field is a
64 bit ints (value ULLONG_MAX) versus encoding a message with two fields
where each field is a message that contains a 64 bit int.
I think that I undertand the encoding of the message that has two field
where each field is a 64 bit int - each varintt consumes 10 bytes (9 * 7 =
63 + 1), and one byte for tag number/wire type. In the following example,
byte 0 says "the next field is a varint with a tag of 1" and bytes 1-9
contain the varint encoding of data1. byte 10 "the next field is a varint
with a tag of 2".
message two_unsigned_sixty_four_bit_ints {
optional uint64 data1 = 1;
optional uint64 data2 = 2;
};
two_sixty_four_bit_ints size 22
[0]: 0x8
[1]: 0xff
[2]: 0xff
[3]: 0xff
[4]: 0xff
[5]: 0xff
[6]: 0xff
[7]: 0xff
[8]: 0xff
[9]: 0xff
[10]: 0x1
[11]: 0x10
[12]: 0xff
[13]: 0xff
[14]: 0xff
[15]: 0xff
[16]: 0xff
[17]: 0xff
[18]: 0xff
[19]: 0xff
[20]: 0xff
[21]: 0x1
When IU look at the output from the message message with two fields where
each field is a message that contains a 64 bit int, I see the following. I
think that bytes 1 and 14 are the size of the following message (10 bytes
for the varint), but what is byte 0, and byte 13? I assume they somehow
encode the type and tag of the next field.
message unsigned_sixty_four_bit_int {
optional uint64 data = 1;
};
message two_unsigned_sixty_four_bit_int_messages {
optional unsigned_sixty_four_bit_int data1 = 1;
optional unsigned_sixty_four_bit_int data2 = 2;
};
two_sixty_four_bit_int_messages size 26
[0]: 0xa
[1]: 0xb
[2]: 0x8
[3]: 0xff
[4]: 0xff
[5]: 0xff
[6]: 0xff
[7]: 0xff
[8]: 0xff
[9]: 0xff
[10]: 0xff
[11]: 0xff
[12]: 0x1
[13]: 0x12
[14]: 0xb
[15]: 0x8
[16]: 0xff
[17]: 0xff
[18]: 0xff
[19]: 0xff
[20]: 0xff
[21]: 0xff
[22]: 0xff
[23]: 0xff
[24]: 0xff
[25]: 0x1
Thanks,
Mike
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.