aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/org/apache
diff options
context:
space:
mode:
authorCodingCat <zhunansjtu@gmail.com>2016-04-18 18:51:23 -0700
committerReynold Xin <rxin@databricks.com>2016-04-18 18:51:23 -0700
commit4b3d1294aeecc0001a7fa48c92796e6075d34540 (patch)
tree51b4bb62bcbec0bf13c41457b9d0eacd543ea274 /core/src/main/scala/org/apache
parent2b151b6b93e7ef747c625d3a2b0f0732039de3b8 (diff)
downloadspark-4b3d1294aeecc0001a7fa48c92796e6075d34540.tar.gz
spark-4b3d1294aeecc0001a7fa48c92796e6075d34540.tar.bz2
spark-4b3d1294aeecc0001a7fa48c92796e6075d34540.zip
[SPARK-13227] Risky apply() in OpenHashMap
https://issues.apache.org/jira/browse/SPARK-13227 It might confuse the future developers when they use OpenHashMap.apply() with a numeric value type. null.asInstance[Int], null.asInstance[Long], null.asInstace[Float] and null.asInstance[Double] will return 0/0.0/0L, which might confuse the developer if the value set contains 0/0.0/0L with an existing key The current patch only adds the comments describing the issue, with the respect to apply the minimum changes to the code base The more direct, yet more aggressive, approach is use Option as the return type andrewor14 JoshRosen any thoughts about how to avoid the potential issue? Author: CodingCat <zhunansjtu@gmail.com> Closes #11107 from CodingCat/SPARK-13227.
Diffstat (limited to 'core/src/main/scala/org/apache')
-rw-r--r--core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala b/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala
index 22d7a4988b..10ab0b3f89 100644
--- a/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala
+++ b/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala
@@ -25,6 +25,9 @@ import scala.reflect.ClassTag
* space overhead.
*
* Under the hood, it uses our OpenHashSet implementation.
+ *
+ * NOTE: when using numeric type as the value type, the user of this class should be careful to
+ * distinguish between the 0/0.0/0L and non-exist value
*/
private[spark]
class OpenHashMap[K : ClassTag, @specialized(Long, Int, Double) V: ClassTag](