You can't distinguish an empty repeated from one that's not there at all. If you need that, you'll need a manual presence field.
On Tue, Mar 29, 2016 at 2:02 AM, Yoav H <[email protected]> wrote: > How do they handle collections (repeated, non packed) in this case? > The absence of the tag is not conclusive. > Actually, even packed collection (and strings, and binary data) suffer from > that, as you are "expected" to not include a packed collection with zero > bytes. > > > On Saturday, March 26, 2016 at 1:08:23 PM UTC-7, Ilia Mirkin wrote: >> >> Encoding is identical... just the API is different. In proto2, you >> have (in C++) FooMessage->has_field() which will tell you whether a >> field was present in the encoded version (or has been set prior if >> you're building a new message). The Java API has something rather >> similar... hasField() I think? >> >> On Sat, Mar 26, 2016 at 4:00 PM, Yoav H <[email protected]> wrote: >> > Thanks all, >> > >> > Do you know where I can find the proto2 encoding guide? >> > The proto site has only the proto3 encoding described. >> > >> > On Saturday, March 26, 2016 at 12:21:39 PM UTC-7, Tim Kientzle wrote: >> >> >> >> >> >> > On Mar 26, 2016, at 11:43 AM, Yoav H <[email protected]> wrote: >> >> > >> >> > Hi, >> >> > >> >> > I wanted ask regarding the decision to populate fields with default >> >> > values, even if they do not appear in the encoded message. >> >> > If I want to send a "patch" message, where I want to update just the >> >> > provided fields, how can I do that with protobuf (without adding >> >> > IsXXXSet >> >> > for every field)? >> >> > >> >> > Why not add another type, representing a default value? >> >> > So the schematics would be, if the field is missing, it is null, and >> >> > if >> >> > the field exists, but with this "missing value" type, it will get the >> >> > default value? >> >> >> >> As Ilia pointed out, proto2 still exists, is still supported, and can >> >> be >> >> used for >> >> cases where you require these particular semantics. >> >> >> >> For proto3, you might look at google.protobuf.FieldMask, which is a new >> >> standard message (one of the "well-known types") specifically designed >> >> to store a set of field names. You might be able to achieve what you >> >> want >> >> by >> >> providing a FieldMask with your data listing the specific fields to >> >> be updated. >> >> >> >> Tim >> >> >> >> >> > -- >> > 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 [email protected]. >> > To post to this group, send email to [email protected]. >> > Visit this group at https://groups.google.com/group/protobuf. >> > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
