[
https://issues.apache.org/jira/browse/THRIFT-4510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16734123#comment-16734123
]
Brian Forbis commented on THRIFT-4510:
--------------------------------------
[~jking3] Yes, this is a duplicate of THRIFT-4623
[~jgmath2000] I'm not sure what you mean by "={}" not being valid. I've used it
in other languages and it has worked fine.
You should be able to use {} containers to specify default values for both maps
and structs
For example, if you wanted to set keys you can do the following
{code:java}
struct NestedStruct {
1: map<string, string> nestedMap = {"defaultKey": "defaultValue"}
}
struct ParentStruct {
1: NestedStruct nestedStruct = {"nestedMap": {"overriddenKey":
"overridenValue"}}
}
{code}
> Regression in 0.11: Arrays with default values in python
> --------------------------------------------------------
>
> Key: THRIFT-4510
> URL: https://issues.apache.org/jira/browse/THRIFT-4510
> Project: Thrift
> Issue Type: Bug
> Components: Python - Compiler
> Affects Versions: 0.11.0
> Reporter: Jason Gauci
> Priority: Critical
>
> We are getting reports from users that our project is broken on thrift 0.11.
> Arrays with default values are newly broken in 0.11 because thrift_spec is
> not defined soon enough.
>
> To reproduce:
>
> brew install thrift
> git clone [https://github.com/caffe2/BlueWhale.git]
> cd BlueWhale
> thrift --gen py --out . ml/rl/thrift/core.thrift
> cat ml/rl/thrift/core/ttypes.py
>
> Notice that the TrainingParameters.__init__ tries to use thrift_spec to
> handle the default array when thrift_spec doesn't exist yet. This results in
> this failure upon import:
>
> AttributeError: 'TrainingParameters' object has no attribute 'thrift_spec'
>
> The same thing works when using 0.10
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)