Bladeren bron

HDFS-288. Redundant computation in hashCode() implementation. Contributed by Tsz Wo (Nicholas), SZE.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@812080 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 16 jaren geleden
bovenliggende
commit
83482aee55

+ 3 - 0
CHANGES.txt

@@ -128,6 +128,9 @@ Trunk (unreleased changes)
     HDFS-551. Create new functional test for a block report. (Konstantin
     Boudnik via hairong)
 
+    HDFS-288. Redundant computation in hashCode() implementation.
+    (szetszwo via tomwhite)
+
   BUG FIXES
 
     HDFS-76. Better error message to users when commands fail because of 

+ 1 - 1
src/java/org/apache/hadoop/hdfs/protocol/Block.java

@@ -207,6 +207,6 @@ public class Block implements Writable, Comparable<Block> {
   /** {@inheritDoc} */
   public int hashCode() {
     //GenerationStamp is IRRELEVANT and should not be used here
-    return 37 * 17 + (int) (blockId^(blockId>>>32));
+    return (int)(blockId^(blockId>>>32));
   }
 }

+ 1 - 1
src/java/org/apache/hadoop/hdfs/server/common/GenerationStamp.java

@@ -109,6 +109,6 @@ public class GenerationStamp implements WritableComparable<GenerationStamp> {
 
   /** {@inheritDoc} */
   public int hashCode() {
-    return 37 * 17 + (int) (genstamp^(genstamp>>>32));
+    return (int) (genstamp^(genstamp>>>32));
   }
 }

+ 1 - 1
src/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java

@@ -113,7 +113,7 @@ public class DirectoryScanner {
 
     @Override // Object
     public int hashCode() {
-      return 37 * 17 + (int) (blockId^(blockId>>>32));
+      return (int)(blockId^(blockId>>>32));
     }
 
     public long getGenStamp() {