How to Assign encoding number to the field inside message

18 views
Skip to first unread message

rohit nv

unread,
Jun 30, 2020, 2:47:25 PM6/30/20
to Protocol Buffers

I am new to the gRPC and Protobuf. Wanted to know the significance of encoding
number infront of field. In tutorial I saw about the usage of no between 1-15 for frequently used fields as it require 1 byte of encoding and 16 to remaining carries 2 bytes of encoding. May I know when to to use what.

Marc Gravell

unread,
Jun 30, 2020, 4:12:01 PM6/30/20
to rohit nv, Protocol Buffers
See https://developers.google.com/protocol-buffers/docs/overview#assigning_field_numbers

Basically:

- positive integers
- unique within each message (can reuse between different messages)
- lower is cheaper
- avoid some reserved ranges

On Tue, 30 Jun 2020, 20:12 rohit nv, <san...@gmail.com> wrote:

I am new to the gRPC and Protobuf. Wanted to know the significance of encoding
number infront of field. In tutorial I saw about the usage of no between 1-15 for frequently used fields as it require 1 byte of encoding and 16 to remaining carries 2 bytes of encoding. May I know when to to use what.

--
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 protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/78789856-f4cf-444b-a7a7-14ff3f260595n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages