You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Dmitry Chechik (JIRA)" <ji...@apache.org> on 2010/03/03 06:19:29 UTC

[jira] Created: (THRIFT-723) Thrift buffers with set and map types in Java should implement Comparable

Thrift buffers with set and map types in Java should implement Comparable
-------------------------------------------------------------------------

                 Key: THRIFT-723
                 URL: https://issues.apache.org/jira/browse/THRIFT-723
             Project: Thrift
          Issue Type: Bug
          Components: Compiler (Java), Library (Java)
            Reporter: Dmitry Chechik


Currently, Thrift objects in Java don't implement Comparable if any field is a set or a map.
The patch attached implements Comparable for those cases. If we can compare a List, we should be able to compare a Set just as easily. This implementation compares two thrift objects by comparing the sorted entries of each set or map.

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


[jira] Updated: (THRIFT-723) Thrift buffers with set and map types in Java should implement Comparable

Posted by "Dmitry Chechik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dmitry Chechik updated THRIFT-723:
----------------------------------

    Attachment: thrift-compare-to.patch

> Thrift buffers with set and map types in Java should implement Comparable
> -------------------------------------------------------------------------
>
>                 Key: THRIFT-723
>                 URL: https://issues.apache.org/jira/browse/THRIFT-723
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java), Library (Java)
>            Reporter: Dmitry Chechik
>         Attachments: thrift-compare-to.patch
>
>
> Currently, Thrift objects in Java don't implement Comparable if any field is a set or a map.
> The patch attached implements Comparable for those cases. If we can compare a List, we should be able to compare a Set just as easily. This implementation compares two thrift objects by comparing the sorted entries of each set or map.

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


[jira] Commented: (THRIFT-723) Thrift buffers with set and map types in Java should implement Comparable

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840495#action_12840495 ] 

Bryan Duxbury commented on THRIFT-723:
--------------------------------------

The reason I chose to consider Sets and Maps incomparable is because there is no natural ordering to them. Lists are fundamentally ordered, making it obvious how to compose their ordering into a larger ordering.

I'm not completely against adding this feature, but it does seem a bit unnatural. The sort order of structs containing sets or maps would be somewhat unintuitive, which is probably fine if you just want "some" consistent ordering. 

> Thrift buffers with set and map types in Java should implement Comparable
> -------------------------------------------------------------------------
>
>                 Key: THRIFT-723
>                 URL: https://issues.apache.org/jira/browse/THRIFT-723
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java), Library (Java)
>            Reporter: Dmitry Chechik
>         Attachments: thrift-compare-to.patch
>
>
> Currently, Thrift objects in Java don't implement Comparable if any field is a set or a map.
> The patch attached implements Comparable for those cases. If we can compare a List, we should be able to compare a Set just as easily. This implementation compares two thrift objects by comparing the sorted entries of each set or map.

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


[jira] Commented: (THRIFT-723) Thrift buffers with set and map types in Java should implement Comparable

Posted by "Dmitry Chechik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840959#action_12840959 ] 

Dmitry Chechik commented on THRIFT-723:
---------------------------------------

For what it's worth, neither Lists, Sets or Maps are Comparable in the Java JDK implementation, but thrift implement comparison for Lists anyway -- might as well do it for the other basic types. This allows thrift buffers with those types to be used as keys in mapreduce operations so it's fairly useful.

As another data point, python implements comparison of dictionaries (i.e. Maps) in the same way -- if the dictionaries are the same size, the keys are sorted and then compared.

> Thrift buffers with set and map types in Java should implement Comparable
> -------------------------------------------------------------------------
>
>                 Key: THRIFT-723
>                 URL: https://issues.apache.org/jira/browse/THRIFT-723
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java), Library (Java)
>            Reporter: Dmitry Chechik
>         Attachments: thrift-compare-to.patch
>
>
> Currently, Thrift objects in Java don't implement Comparable if any field is a set or a map.
> The patch attached implements Comparable for those cases. If we can compare a List, we should be able to compare a Set just as easily. This implementation compares two thrift objects by comparing the sorted entries of each set or map.

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


[jira] Assigned: (THRIFT-723) Thrift buffers with set and map types in Java should implement Comparable

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury reassigned THRIFT-723:
------------------------------------

    Assignee: Bryan Duxbury

> Thrift buffers with set and map types in Java should implement Comparable
> -------------------------------------------------------------------------
>
>                 Key: THRIFT-723
>                 URL: https://issues.apache.org/jira/browse/THRIFT-723
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java), Library (Java)
>            Reporter: Dmitry Chechik
>            Assignee: Bryan Duxbury
>         Attachments: thrift-compare-to.patch
>
>
> Currently, Thrift objects in Java don't implement Comparable if any field is a set or a map.
> The patch attached implements Comparable for those cases. If we can compare a List, we should be able to compare a Set just as easily. This implementation compares two thrift objects by comparing the sorted entries of each set or map.

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


[jira] Commented: (THRIFT-723) Thrift buffers with set and map types in Java should implement Comparable

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850395#action_12850395 ] 

Bryan Duxbury commented on THRIFT-723:
--------------------------------------

Dmitry - I tried to apply this patch today, and it didn't apply cleanly. Can you try to update it and resubmit? Sorry for letting it hang out for so long.

> Thrift buffers with set and map types in Java should implement Comparable
> -------------------------------------------------------------------------
>
>                 Key: THRIFT-723
>                 URL: https://issues.apache.org/jira/browse/THRIFT-723
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java), Library (Java)
>            Reporter: Dmitry Chechik
>         Attachments: thrift-compare-to.patch
>
>
> Currently, Thrift objects in Java don't implement Comparable if any field is a set or a map.
> The patch attached implements Comparable for those cases. If we can compare a List, we should be able to compare a Set just as easily. This implementation compares two thrift objects by comparing the sorted entries of each set or map.

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


[jira] Updated: (THRIFT-723) Thrift buffers with set and map types in Java should implement Comparable

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury updated THRIFT-723:
---------------------------------

    Attachment: thrift-723-v2.patch

OK, I reworked your patch to fit in with the new test suite. I also simplified the changes needed to the compiler - with this change to support sets and maps, *every* thrift struct can now be compared. I'll commit this shortly.

> Thrift buffers with set and map types in Java should implement Comparable
> -------------------------------------------------------------------------
>
>                 Key: THRIFT-723
>                 URL: https://issues.apache.org/jira/browse/THRIFT-723
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java), Library (Java)
>            Reporter: Dmitry Chechik
>            Assignee: Bryan Duxbury
>         Attachments: thrift-723-v2.patch, thrift-compare-to.patch
>
>
> Currently, Thrift objects in Java don't implement Comparable if any field is a set or a map.
> The patch attached implements Comparable for those cases. If we can compare a List, we should be able to compare a Set just as easily. This implementation compares two thrift objects by comparing the sorted entries of each set or map.

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


[jira] Closed: (THRIFT-723) Thrift buffers with set and map types in Java should implement Comparable

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury closed THRIFT-723.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 0.3

I just committed this. Thanks for getting me started, Dmitry!

> Thrift buffers with set and map types in Java should implement Comparable
> -------------------------------------------------------------------------
>
>                 Key: THRIFT-723
>                 URL: https://issues.apache.org/jira/browse/THRIFT-723
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java), Library (Java)
>            Reporter: Dmitry Chechik
>            Assignee: Bryan Duxbury
>             Fix For: 0.3
>
>         Attachments: thrift-723-v2.patch, thrift-compare-to.patch
>
>
> Currently, Thrift objects in Java don't implement Comparable if any field is a set or a map.
> The patch attached implements Comparable for those cases. If we can compare a List, we should be able to compare a Set just as easily. This implementation compares two thrift objects by comparing the sorted entries of each set or map.

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