thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nevo Hed <nhed+thrift...@aereo.com>
Subject Re: Serialisation of default values
Date Mon, 31 Mar 2014 17:16:05 GMT
I think this behaves right

To attain the behaviour you desire you just need to omit default values and
in your own code you can ask if None assign value



On Wed, Nov 20, 2013 at 6:47 PM, James Haggerty <mumbler@gmail.com> wrote:

> Hey all,
>
> Consider a struct like:
>
> struct Dummy {
>    1: optional i32 id;
>    2: optional i32 age = 10;
> }
>
> So, at least with the Python libs, what appear to happen with default
> values using TBinaryProtocol is:
>
>  - if I construct Dummy(), it serialises age (as 10)
>  - if I construct Dummy(age=None), it doesn't serialise age, but age is set
> to 10 when it deserialises
>
> In the interests of reducing the amount of stuff serialised, could this be
> changed so that default values are not serialised (i.e. Dummy() is
> equivalent to Dummy(age=None)?). The only possible disadvantage is that it
> means you get the receiver's default rather than the sender's default if
> there's a mismatch - but it's unclear what the desired behaviour would be
> in this case anyway.
>
> Thanks,
> James.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message