[
https://issues.apache.org/jira/browse/THRIFT-2429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13957931#comment-13957931
]
ASF GitHub Bot commented on THRIFT-2429:
----------------------------------------
GitHub user djwatson opened a pull request:
https://github.com/apache/thrift/pull/93
THRIFT-2429
Original diff summary:
Add "terse_writes" c++ gen option to thrift compiler.
Summary:
Add "terse_writes" c++ generator option to thrift compiler, to
suppress writing non-optional/non-required fields if they haven't
changed from the default value.
- This is default-off, whitelist-only.
It may be whitelisted per-.thrift, or per struct.
- On a Unicorn loadgen benchmark appeared to save roughly 2/3rds of
the SearchRequest deserialization cost (fields are only sparsely
set).
- This will not affect embedded structs, or strings with non-""
default values, since we only want this change to do inexpensive
integer-like comparisons.
- Also, the user is advised that:
- default values for whitelisted structs shouldn't be changed.
(or, if they are, upgraded to optional/required)
- if one re-read()s into an old struct, one should __clear() it
first.
however, this is not a new problem for anybody with optional
fields.
This diff introduces "safe" mode for `terse_writes` in order to
prevent us from producing stupid bugs in PHP (and Python) land.
If we don't require explicit default value to be set, we have to
make PHP / Python logic to correctly understand `null` / `None` and
treat them as default field values.
davejwatson:
It sounds like the proposal in THRIFT-2429 is to make this the default for
optional fields as well, with no compiler flag, which is just minor changes to
this diff.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/djwatson/thrift THRIFT-2429
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/93.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #93
----
commit 15dbcec763821b296a246c0b2572b410792a4809
Author: Dave Watson <[email protected]>
Date: 2014-04-01T22:24:37Z
Original diff:
Add "terse_writes" c++ gen option to thrift compiler.
Summary:
Add "terse_writes" c++ generator option to thrift compiler, to
suppress writing non-optional/non-required fields if they haven't
changed from the default value.
- This is default-off, whitelist-only.
It may be whitelisted per-.thrift, or per struct.
- On a Unicorn loadgen benchmark appeared to save roughly 2/3rds of
the SearchRequest deserialization cost (fields are only sparsely
set).
- This will not affect embedded structs, or strings with non-""
default values, since we only want this change to do inexpensive
integer-like comparisons.
- Also, the user is advised that:
- default values for whitelisted structs shouldn't be changed.
(or, if they are, upgraded to optional/required)
- if one re-read()s into an old struct, one should __clear() it
first.
however, this is not a new problem for anybody with optional
fields.
This diff introduces "safe" mode for `terse_writes` in order to
prevent us from producing stupid bugs in PHP (and Python) land.
If we don't require explicit default value to be set, we have to
make PHP / Python logic to correctly understand `null` / `None` and
treat them as default field values.
davejwatson:
It sounds like the proposal in THRIFT-2429 is to make this the default for
optional fields as well, with no compiler flag, which is just minor changes to
this diff.
----
> Provide option to not write default values, rely on receiver default
> construction instead
> -----------------------------------------------------------------------------------------
>
> Key: THRIFT-2429
> URL: https://issues.apache.org/jira/browse/THRIFT-2429
> Project: Thrift
> Issue Type: Improvement
> Components: C++ - Compiler
> Affects Versions: 0.9.1
> Reporter: Chris Stylianou
> Assignee: Randy Abernethy
> Labels: thrift
>
> Would there be any objections to a patch that does not write default values
> (essentially the same logic as the optional attributes). This obviously
> relies on the receiving application using the same IDL version to ensure the
> defaults used on object construction match the senders.
--
This message was sent by Atlassian JIRA
(v6.2#6252)