LuciferYang commented on PR #51954:
URL: https://github.com/apache/spark/pull/51954#issuecomment-3174893371
Today, while attempting to modify the test cases related to
`ImmutableMap.builder()` in the `RetryingBlockTransferorSuite`, I noticed a
minor difference between `Map.of` and `ImmutableMap.of`:
The map constructed by `Map.of` more like a `HashMap`, where the iteration
order is not necessarily the same as the order of data insertion. In contrast,
the map built by `ImmutableMap.of` resembles more of a `LinkedHashMap`, with
the iteration order matching the insertion order. I wonder if you've observed
this distinction. @dongjoon-hyun
```
scala> java.util.Map.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val res0: java.util.Map[Int,Int] = {5=6, 7=8, 9=10, 1=2, 3=4}
val res0: java.util.Map[Int,Int]
scala> res0.keySet
val res1: java.util.Set[Int] = [5, 7, 9, 1, 3]
scala> com.google.common.collect.ImmutableMap.of(1, 2, 3, 4, 5, 6, 7, 8, 9,
10)
val res2: com.google.common.collect.ImmutableMap[Int,Int] = {1=2, 3=4, 5=6,
7=8, 9=10}
val res2: com.google.common.collect.ImmutableMap[Int,Int]
scala> res2.keySet
val res3: com.google.common.collect.ImmutableSet[Int] = [1, 3, 5, 7, 9]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]