jav*_*Man 31 java serialization protocol-buffers
我必须编写一个protobuf消息,它应该有1个整数变量和一个整数数组.
package protobuf;
message myProto {
optional uint32 message_id =1;
optional int update = 2;
//here I have to add a array of integers
//can I write like optional int[] array =3;
//or should I use optional repeated array;
//where array is another message with int variable
}
Run Code Online (Sandbox Code Playgroud)
我的方法是否正确?请帮我
谢谢
Mar*_*ell 40
数组通过"重复"映射:
repeated int32 data = 4;
Run Code Online (Sandbox Code Playgroud)
请注意,您可能需要sint32/uint32.还要注意,在所有三种情况下都可以使用"打包阵列",这样更有效;
repeated int32 data = 4 [packed=true];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
38820 次 |
最近记录: |