aboutsummaryrefslogtreecommitdiff
path: root/docs/programming-guide.md
diff options
context:
space:
mode:
authorAndrew Ash <andrew@andrewash.com>2014-06-15 23:32:55 -0700
committerPatrick Wendell <pwendell@gmail.com>2014-06-15 23:33:22 -0700
commit9672ee07fb1c3583c70f23a699de3b2282eb0f98 (patch)
tree755570ac56ea1248db3f1a509fa9fb6a4e0a4b75 /docs/programming-guide.md
parenta63aa1adb2dfb19c8189167932ee8569840f96a0 (diff)
downloadspark-9672ee07fb1c3583c70f23a699de3b2282eb0f98.tar.gz
spark-9672ee07fb1c3583c70f23a699de3b2282eb0f98.tar.bz2
spark-9672ee07fb1c3583c70f23a699de3b2282eb0f98.zip
SPARK-2148 Add link to requirements for custom equals() and hashcode() methods
https://issues.apache.org/jira/browse/SPARK-2148 Author: Andrew Ash <andrew@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
Diffstat (limited to 'docs/programming-guide.md')
-rw-r--r--docs/programming-guide.md9
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>