[
https://issues.apache.org/jira/browse/CALCITE-4096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17152265#comment-17152265
]
Julian Hyde commented on CALCITE-4096:
--------------------------------------
It's not "insane".
* {{Map.Entry}} is so widely used in Java libraries that it is practically a
language feature. For example, Guava has {{ImmutableMap.copyOf(Iterable<?
extends Entry<? extends K, ? extends V>> entries)}}.
* (In Kotlin, [pairs are actually a language
feature|https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/to.html]. The infix
'to' function creates a Pair, and pairs can be used to make map literals.
However they did not make {{Pair}} extend Java's {{Map.Entry}}.)
* Commons-lang's
[Pair|https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/tuple/Pair.html]
also implements {{Map.Entry}}.
* {{RelDataTypeFactory.createStructType(List<? extends Map.Entry<String,
RelDataType>> fieldList)}} is variously used with lists of {{Pair}}, lists of
{{RelDataTypeField}} (which implements {{Map.Entry<String, RelDataType>}} but
does not extend {{Pair}}), and lists of {{Map.Entry}}.
> Change Pair.hashCode() not to use XOR
> -------------------------------------
>
> Key: CALCITE-4096
> URL: https://issues.apache.org/jira/browse/CALCITE-4096
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Haisheng Yuan
> Priority: Major
>
> JDK Map Entry uses XOR maybe because it is unlikely to use Map Entry as the
> HashMap key.
> But Pair in Calcite is a general data structure, it is used in several places
> as the key of HashMap/HashSet. XOR is not a good candidate for hash
> algorithm, it is more likely to generate hash collision than simple prime
> multiplication, especially when pair.left equals pair.right.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)