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

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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0.0
    • 1.0.1, 1.1.0
    • Documentation
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: