https://stackoverflow.com/q/46804847/499466
-----Ursprüngliche Nachricht----- From: Randy Abernethy Sent: Wednesday, October 18, 2017 9:18 PM To: [email protected] Subject: Re: Extra boolean set fields in java generated file using thrift Hello, Maybe you are looking for "required"? user@ubuntu:~/test$ cat point.thrift struct Point { 1: required double lat, 2: required double lon} user@ubuntu:~/test$ thrift -gen java point.thrift user@ubuntu:~/test$ cat gen-java/Point.java | grep public | grep -v '{' public double lat; // required public double lon; // required public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; public Point( user@ubuntu:~/test$ Required means the field must always be present so make sure the semantics fit. -Randy On Wed, Oct 18, 2017 at 2:14 AM, Abhinav Jain <[email protected]> wrote: > I have a thrift file point.thrift that has only two variables as follows: > > struct Point { > 1: double lat, > 2: double lon} > > But when I generate the java file using, > > thrift --gen java point.thrift > > then the generated java code has other boolean variables, setLat and > setLon. So, my Point object looks like below: > > "point": { > "lat": 12.983451879142935, > "lon": 77.75181960314512, > "setLat": true, > "setLon": true} > > Is there any way these extra boolean variables can be removed from my > point > object because it is increasing the size of my object, which in turn will > take up a lot of space when I store them. Note that this is the basic > definition but the actual definition will have lots of other fields. So, > storage is a concern for me. >
