On Apr 2, 2012, at 12:47 AM, Piscium wrote: > On C++ generated code, __isset is set to true in the read function > for the fields that have been received, however it is not looked at at > all by the write function which always writes all fields regardless of > the __isset value. > > What is the reasoning behind this asymmetry? Is __isset intended only > to cater for the receiving side, in particular for the use case in > which the receiver is of a different software version than the sender?
Anyone else feel free to correct me... I don't think this is quite true. All required fields are always written, regardless of the state of their __isset. Optional fields are only written if their __isset is true. The read side always sets the __isset for everything it receives, but it doesn't receive the fields that are optional and didn't have __isset true when written. So __isset on the read side of the wire really only means that an optional field is present. We use Thrift classes in other ways that don't necessarily result in them being sent over the wire. In those cases our code generally requires that the __isset be true for all required fields, and we have a macro that both sets a field and sets its __isset true. This is designed to detect when someone forgot to initialize a required field. If the __isset is true, then we feel safe in assuming that the data value was written intentionally. (or is empty intentionally if it is a string, etc.) - Rush
