Generated classes should implement Comparable
---------------------------------------------

                 Key: THRIFT-144
                 URL: https://issues.apache.org/jira/browse/THRIFT-144
             Project: Thrift
          Issue Type: New Feature
          Components: Compiler (Java)
            Reporter: Bryan Duxbury
            Priority: Minor


We use our Thrift types in Hadoop map/reduce, sometimes as keys. As such, they 
need to be compared to other keys to be sorted. Right now, the only way to 
compare two Thrift objects is to serialize them and do byte comparison. It'd be 
nice if we could compare two objects directly. 

The implementation of such a compareTo would look a lot like the equals() 
implementation already present, and delegate to the subtypes' compareTo methods 
appropriately. The ordering of the field declarations in the .thrift file would 
indicate the sort order between fields. In some situations this would make the 
sorting somewhat arbitrary, but it would be stable, and if you really needed 
the sorting to take into account fields in a specific order, you could order 
your fields appropriately. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to