protocol buffers - Differences between various protobuf implementations -


what trade-offs, advantages , disadvantages of each of these implementations ? different @ ? want achieve store vector of box'es, protobuf.

impl 1 :

package foo;  message boxes {    message box    { required int32 w = 1;     required int32 h = 2;   }    repeated box boxes = 1;  } 

impl 2:

package foo;  message box  { required int32 w = 1;   required int32 h = 2; }  message boxes  { repeated box boxes = 1;  } 

impl 3 : stream multiple of these messages same file.

package foo;  message box  { required int32 w = 1;   required int32 h = 2; } 

1 & 2 change / how types declared. work identical.

3 more interesting: can't just stream box after box after box, because root object in protobuf not terminated (to allow concat === merge). if only write boxes, when deserialize have 1 box last w , h written. need add length-prefix; arbitrarily, but: if happen choose "varint"-encode length, you're close repeated gives - except repeated includes field-header (field 1, type 2 - binary 1010 = decimal 10) before each "varint" length.

if you, i'd use repeated simplicity. of 1 / 2 choose depend on personal choice.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -