GideonPotok commented on code in PR #46917:
URL: https://github.com/apache/spark/pull/46917#discussion_r1635142593


##########
core/src/main/scala/org/apache/spark/util/collection/OpenHashSet.scala:
##########
@@ -118,8 +125,21 @@ class OpenHashSet[@specialized(Long, Int, Double, Float) 
T: ClassTag](
    * See: https://issues.apache.org/jira/browse/SPARK-45599
    */
   @annotation.nowarn("cat=other-non-cooperative-equals")
-  private def keyExistsAtPos(k: T, pos: Int) =
-    _data(pos) equals k
+  protected def keyExistsAtPos(k: T, pos: Int) = {
+    classTag[T] match {
+      case ClassTag.Long => _data(pos) equals k
+      case ClassTag.Int => _data(pos) equals k
+      case ClassTag.Double => _data(pos) equals k
+      case ClassTag.Float => _data(pos) equals k
+      case _ => nonClassTagKeyExistsAtPos(k, _data(pos))

Review Comment:
   @uros-db the specialized annotation is a performance optimization for 
versions of the generic class with those primitive types. But the type can 
still be anything else. The annotation results in the compiler generating the 
versions of generic classes for the specific types being specialized. The 
generic class can still be any other type, but boxing and unboxing will occur. 
   
   Source: https://www.scala-lang.org/api/current/scala/specialized.html
    
https://www.waitingforcode.com/scala-types/type-specialization-scala/read#:~:text=Scala%20uses%20the%20%40specialized%20class,classes%20for%20the%20specific%20types.
   https://www.baeldung.com/scala/specialized-annotation



-- 
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]

Reply via email to