Hadoop Map/Reduce
  1. Hadoop Map/Reduce
  2. MAPREDUCE-2249

Better to check the reflexive property of the object while overriding equals method of it

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.22.0, 0.23.0
    • Fix Version/s: 0.23.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      NA

    • Hadoop Flags:
      Reviewed

      Description

      It is better to check the reflexive property of the object while overriding equals method of it.

      It improves the performance when a heavy object is compared to itself.

      1. MAPREDUCE-2249-2.patch
        1 kB
        Devaraj K
      2. MAPREDUCE-2249.patch
        1 kB
        Devaraj K
      3. MAPREDUCE-2249-1.patch
        0.8 kB
        Bhallamudi Venkata Siva Kamesh

        Activity

        Bhallamudi Venkata Siva Kamesh created issue -
        Owen O'Malley made changes -
        Field Original Value New Value
        Description It is better to check the reflexive property of the object while overriding equals method of it.
         
        It improves the performance when a heavy object is compared to itself.

        For example pls find the below snippet from Counters.java

          {code:title=Current Implementation|borderStyle=solid}
          @Override
          public synchronized boolean equals(Object obj) {
            boolean isEqual = false;
            if (obj != null && obj instanceof Counters) {
              Counters other = (Counters) obj;
              if (size() == other.size()) {
                isEqual = true;
                for (Map.Entry<String, Group> entry : this.counters.entrySet()) {
                  String key = entry.getKey();
                  Group sourceGroup = entry.getValue();
                  Group targetGroup = other.getGroup(key);
                  if (!sourceGroup.equals(targetGroup)) {
                    isEqual = false;
                    break;
                  }
                }
              }
            }
            return isEqual;
          }
          {code}

          {code:title=Proposed Implementation|borderStyle=solid}
          @Override
          public synchronized boolean equals(Object obj) {
            if(this == obj) {
              return true;
            }
            boolean isEqual = false;
            if (obj != null && obj instanceof Counters) {
              Counters other = (Counters) obj;
              if (size() == other.size()) {
                isEqual = true;
                for (Map.Entry<String, Group> entry : this.counters.entrySet()) {
                  String key = entry.getKey();
                  Group sourceGroup = entry.getValue();
                  Group targetGroup = other.getGroup(key);
                  if (!sourceGroup.equals(targetGroup)) {
                    isEqual = false;
                    break;
                  }
                }
              }
            }
            return isEqual;
          }
          {code}
        It is better to check the reflexive property of the object while overriding equals method of it.
         
        It improves the performance when a heavy object is compared to itself.
        Nigel Daley made changes -
        Fix Version/s 0.22.0 [ 12314184 ]
        Fix Version/s 0.23.0 [ 12315570 ]
        Bhallamudi Venkata Siva Kamesh made changes -
        Attachment MAPREDUCE-2249-1.patch [ 12469150 ]
        Bhallamudi Venkata Siva Kamesh made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Affects Version/s 0.22.0 [ 12314184 ]
        Affects Version/s 0.21.0 [ 12314045 ]
        Todd Lipcon made changes -
        Status Patch Available [ 10002 ] Open [ 1 ]
        Devaraj K made changes -
        Attachment MAPREDUCE-2249.patch [ 12472670 ]
        Devaraj K made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Affects Version/s 0.23.0 [ 12315570 ]
        Todd Lipcon made changes -
        Status Patch Available [ 10002 ] Open [ 1 ]
        Devaraj K made changes -
        Attachment MAPREDUCE-2249-2.patch [ 12472831 ]
        Devaraj K made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Devaraj K made changes -
        Assignee Devaraj K [ devaraj.k ]
        Devaraj K made changes -
        Component/s tasktracker [ 12312906 ]
        Component/s jobtracker [ 12312907 ]
        Todd Lipcon made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Hadoop Flags [Reviewed]
        Fix Version/s 0.23.0 [ 12315570 ]
        Resolution Fixed [ 1 ]
        Arun C Murthy made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Devaraj K
            Reporter:
            Bhallamudi Venkata Siva Kamesh
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 48h
              48h
              Remaining:
              Remaining Estimate - 48h
              48h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development