You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/06/16 08:33:30 UTC

git commit: SPARK-2148 Add link to requirements for custom equals() and hashcode() methods

Repository: spark
Updated Branches:
  refs/heads/master a63aa1adb -> 9672ee07f


SPARK-2148 Add link to requirements for custom equals() and hashcode() methods

https://issues.apache.org/jira/browse/SPARK-2148

Author: Andrew Ash <an...@andrewash.com>

Closes #1092 from ash211/SPARK-2148 and squashes the following commits:

93513df [Andrew Ash] SPARK-2148 Add link to requirements for custom equals() and hashcode() methods


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/9672ee07
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/9672ee07
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/9672ee07

Branch: refs/heads/master
Commit: 9672ee07fb1c3583c70f23a699de3b2282eb0f98
Parents: a63aa1a
Author: Andrew Ash <an...@andrewash.com>
Authored: Sun Jun 15 23:32:55 2014 -0700
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Sun Jun 15 23:33:22 2014 -0700

----------------------------------------------------------------------
 docs/programming-guide.md | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/9672ee07/docs/programming-guide.md
----------------------------------------------------------------------
diff --git a/docs/programming-guide.md b/docs/programming-guide.md
index ef0c0e3..0b24a8b 100644
--- a/docs/programming-guide.md
+++ b/docs/programming-guide.md
@@ -762,6 +762,11 @@ val counts = pairs.reduceByKey((a, b) => a + b)
 We could also use `counts.sortByKey()`, for example, to sort the pairs alphabetically, and finally
 `counts.collect()` to bring them back to the driver program as an array of objects.
 
+**Note:** when using custom objects as the key in key-value pair operations, you must be sure that a
+custom `equals()` method is accompanied with a matching `hashCode()` method.  For full details, see
+the contract outlined in the [Object.hashCode()
+documentation](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()).
+
 </div>
 
 <div data-lang="java" markdown="1">
@@ -794,6 +799,10 @@ JavaPairRDD<String, Integer> counts = pairs.reduceByKey((a, b) -> a + b);
 We could also use `counts.sortByKey()`, for example, to sort the pairs alphabetically, and finally
 `counts.collect()` to bring them back to the driver program as an array of objects.
 
+**Note:** when using custom objects as the key in key-value pair operations, you must be sure that a
+custom `equals()` method is accompanied with a matching `hashCode()` method.  For full details, see
+the contract outlined in the [Object.hashCode()
+documentation](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()).
 
 </div>