[
https://issues.apache.org/jira/browse/CALCITE-1735?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Julian Hyde updated CALCITE-1735:
---------------------------------
Description:
{{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.
was:
{{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.
Remove {{implements Comparable}} and add a field {{public static
Comparator<ImmutableBitSet> COMPARATOR}} instead. People can use it if they
know the risks.
> 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
>
> {{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)