diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/programming-guide.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/programming-guide.md b/docs/programming-guide.md index ef0c0e3430..0b24a8b88b 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> |