Is there an equivalent to int8 or byte type in proto buffs? I would like to send a byte array object.
Protobuf strings are always valid UTF-8 strings. See the Language Guide: A string must always contain UTF-8 encoded or 7-bit ASCII text.
Protobuf is a binary message format crafted by Google and is efficient compared to other message formats like JSON & XML.
Protobuf achieves good compression ratios through varint encoding. It might not be necessary to add an extra layer of compression in most cases. However, to arrive at a payload size equivalent to the compressed JSON payload size, we applied ZSTD compression to the Protobuf object.
http://code.google.com/apis/protocolbuffers/docs/proto.html#scalar
bytes
If you are looking to store a single byte, however, I would suggest using the Int32. It is a 'variant' type variable that will change size depending on the data that is stored in it. So if you are storing a single byte, it will be the smallest structure. The byteS data type is actually quite large in comparison. This is because the bytes structure holds data such as index length and other properties.
On serialization, I noticed a size difference of about half when switching from a single byte stored in a byteS to an int32.
Note, however, that this does not apply to multiple bytes being stored in the byteS, which I suspect will be much smaller than storing individual Int32.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With