Github user Whoosh commented on a diff in the pull request:
https://github.com/apache/spark/pull/19553#discussion_r147591080
--- Diff: core/src/main/scala/org/apache/spark/api/java/JavaUtils.scala ---
@@ -43,10 +43,15 @@ private[spark] object JavaUtils {
override def size: Int = underlying.size
- override def get(key: AnyRef): B = try {
- underlying.getOrElse(key.asInstanceOf[A], null.asInstanceOf[B])
- } catch {
- case ex: ClassCastException => null.asInstanceOf[B]
+ // Delegate to implementation because AbstractMap implementation
iterates over whole key set
+ override def containsKey(key: AnyRef): Boolean = key match {
+ case key: A => underlying.contains(key)
--- End diff --
@srowen
It can't be so. Will cause "abstract type A is unchecked since it is
eliminated by erasure" compile-time error.
As I guess, there is no need any type checking before a get because it'll
have cast to Object anyway and get(key) it's only compiling issues, please
correct me if I'm wrong, I've added a simple test for this.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]