我的結構包含重複的字段是自身結構小,只包含兩個整數:在Google Protocol Buffers中是否需要字段更有效地編碼?
message Bin {
optional int32 slot = 1;
optional int32 count = 2;
}
message Histogram {
repeated Bin bin = 1; // Might be about 200 - 400 bins.
}
請問Bin
得到更有效的,如果我定義slot
和count
爲required
,而不是編碼?
我認爲,在不太可能的變化情況下,我可以完全重新定義Bin
消息,並修改Histogram
作爲
repeated Bin2 bin2 = 2;
(repeated
字段可以被丟棄)
否,每個字段之前還有一個Field_Number/Field_Type字段後跟數據 – 2014-09-05 06:30:58