Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-9124

SortedMapWritable violates contract of Map interface for equals() and hashCode()

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.1.1, 2.0.2-alpha
    • 1.2.0, 2.0.3-alpha, 0.23.7
    • io
    • None
    • Reviewed

    Description

      This issue is similar to HADOOP-7153. It was found when using MRUnit - see MRUNIT-158, specifically https://issues.apache.org/jira/browse/MRUNIT-158?focusedCommentId=13501985&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13501985


      o.a.h.io.SortedMapWritable implements the java.util.Map interface, however it does not define an implementation of the equals() or hashCode() methods; instead the default implementations in java.lang.Object are used.

      This violates the contract of the Map interface which defines different behaviour for equals() and hashCode() than Object does. More information here: http://download.oracle.com/javase/6/docs/api/java/util/Map.html#equals(java.lang.Object)

      The practical consequence is that SortedMapWritables containing equal entries cannot be compared properly. We were bitten by this when trying to write an MRUnit test for a Mapper that outputs MapWritables; the MRUnit driver cannot test the equality of the expected and actual MapWritable objects.

      Attachments

        1. HADOOP-9124.patch
          5 kB
          Thomas White
        2. HADOOP-9124.patch
          5 kB
          Surenkumar Nihalani
        3. HADOOP-9124.patch
          4 kB
          Surenkumar Nihalani
        4. HADOOP-9124.patch
          5 kB
          Surenkumar Nihalani
        5. HADOOP-9124.patch
          5 kB
          Surenkumar Nihalani
        6. HADOOP-9124.patch
          4 kB
          Surenkumar Nihalani
        7. HADOOP-9124.patch
          5 kB
          Surenkumar Nihalani
        8. HADOOP-9124.patch
          4 kB
          Surenkumar Nihalani
        9. HADOOP-9124.patch
          4 kB
          Surenkumar Nihalani
        10. HADOOP-9124.patch
          0.6 kB
          Surenkumar Nihalani
        11. hadoop-9124-branch1.patch
          4 kB
          Karthik Kambatla

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            snihalani Surenkumar Nihalani Assign to me
            phunt Patrick D. Hunt
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment