Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-2148

Document custom class as key needing equals() AND hashcode()

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0
    • Fix Version/s: 1.0.1, 1.1.0
    • Component/s: Documentation
    • Labels:
      None

      Description

      Several support requests on user@ have been tracked down to using a custom class as the key in a groupByKey() or reduceByKey() that has a custom equals() method but not the corresponding custom hashCode() method.

      Let's add a note in the documentation that custom keys need both equals() and hashCode() overridden, never just equals()

      The right place for this addition might be as a sub-section or note in http://spark.apache.org/docs/latest/programming-guide.html#working-with-key-value-pairs

      It should probably include a link to http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()

        Attachments

          Activity

            People

            • Assignee:
              ash211@gmail.com Andrew Ash
              Reporter:
              aash Andrew Ash
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: