[ 
https://issues.apache.org/jira/browse/CALCITE-1735?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde resolved CALCITE-1735.
----------------------------------
       Resolution: Invalid
    Fix Version/s: 1.13.0

I was wrong. ImmutableBitSet is fine. Its {{compareTo}} method uses 
lexicographic ordering, which is a total order.

> ImmutableBitSet should not implement Comparable
> -----------------------------------------------
>
>                 Key: CALCITE-1735
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1735
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>             Fix For: 1.13.0
>
>
> {{ImmutableBitSet}} should not implement the {{Comparable}} interface. 
> {{Comparable}} requires a total order -- in particular, {{x.compareTo\(y)}} 
> should return 0 if and only if {{x.equals\(y)} -- but {{ImmutableBitSet}} is 
> a partial order (set inclusion).
> Bad things happen if you use non-compliant {{Comparable}}s as keys in a 
> {{HashMap}} in JDK 8 or later. It uses a red-black tree and some of the keys 
> just disappear. (I was using {{ImmutableBitSet}} as a key within a 
> {{PartiallyOrderedSet}}, which has a {{HashMap}} inside.)
> Remove {{implements Comparable}} and add a field {{public static 
> Comparator<ImmutableBitSet> COMPARATOR}} instead. People can use it if they 
> know the risks.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to