Skip to content

Commit 9672ee0

Browse files
ash211pwendell
authored andcommitted
SPARK-2148 Add link to requirements for custom equals() and hashcode() methods
https://issues.apache.org/jira/browse/SPARK-2148 Author: Andrew Ash <[email protected]> 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
1 parent a63aa1a commit 9672ee0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/programming-guide.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,11 @@ val counts = pairs.reduceByKey((a, b) => a + b)
762762
We could also use `counts.sortByKey()`, for example, to sort the pairs alphabetically, and finally
763763
`counts.collect()` to bring them back to the driver program as an array of objects.
764764

765+
**Note:** when using custom objects as the key in key-value pair operations, you must be sure that a
766+
custom `equals()` method is accompanied with a matching `hashCode()` method. For full details, see
767+
the contract outlined in the [Object.hashCode()
768+
documentation](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()).
769+
765770
</div>
766771

767772
<div data-lang="java" markdown="1">
@@ -794,6 +799,10 @@ JavaPairRDD<String, Integer> counts = pairs.reduceByKey((a, b) -> a + b);
794799
We could also use `counts.sortByKey()`, for example, to sort the pairs alphabetically, and finally
795800
`counts.collect()` to bring them back to the driver program as an array of objects.
796801

802+
**Note:** when using custom objects as the key in key-value pair operations, you must be sure that a
803+
custom `equals()` method is accompanied with a matching `hashCode()` method. For full details, see
804+
the contract outlined in the [Object.hashCode()
805+
documentation](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()).
797806

798807
</div>
799808

0 commit comments

Comments
 (0)