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:34 -0700
commitb1c2199bff05b648654fc7219329bae48a91551b (patch)
tree3cc56f91f8f17369a8630e2f902b1ed9ede1dc9a /docs/programming-guide.md
parent5e85f87ace799bc66ec8d5f639591964be9843c2 (diff)
downloadspark-b1c2199bff05b648654fc7219329bae48a91551b.tar.gz
spark-b1c2199bff05b648654fc7219329bae48a91551b.tar.bz2
spark-b1c2199bff05b648654fc7219329bae48a91551b.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 (cherry picked from commit 9672ee07fb1c3583c70f23a699de3b2282eb0f98) Signed-off-by: Patrick Wendell <pwendell@gmail.com>
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 b667aa0d17..8d4c6b1148 100644
--- a/docs/programming-guide.md
+++ b/docs/programming-guide.md
@@ -684,6 +684,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">
@@ -716,6 +721,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>