You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Robey Pointer (JIRA)" <ji...@apache.org> on 2009/08/14 01:10:16 UTC

[jira] Commented: (THRIFT-144) Generated classes should implement Comparable

    [ https://issues.apache.org/jira/browse/THRIFT-144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743012#action_12743012 ] 

Robey Pointer commented on THRIFT-144:
--------------------------------------

i think this is the patch that broke returing a map from a method:

typedef map<string, i64> StatsGroup
typedef map<string, double> StatsDGroup
typedef map<string, Timing> TimingStats

struct StatsResult {
  1: StatsGroup jvm
  2: StatsGroup counters
  3: TimingStats timings
  4: StatsDGroup gauges  
}

...

    [javac] /Users/robey/twitter/thrift-admin/target/gen-java/com/twitter/service/admin/StatsResult.java:333: cannot find symbol
    [javac] symbol  : method compareTo(java.util.Map<java.lang.String,java.lang.Long>,java.util.Map<java.lang.String,java.lang.Long>)
    [javac] location: class org.apache.thrift.TBaseHelper
    [javac]     lastComparison = TBaseHelper.compareTo(jvm, typedOther.jvm);
    [javac]                                 ^


> 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
>            Assignee: Bryan Duxbury
>            Priority: Minor
>             Fix For: 0.2
>
>         Attachments: thrift-144-v2.patch, thrift-144.patch
>
>
> 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.