hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x...@apache.org
Subject [18/44] hadoop git commit: YARN-7336. Unsafe cast from long to int Resource.hashCode() method (Contributed by Miklos Szegedi via Daniel Templeton)
Date Wed, 01 Nov 2017 22:22:25 GMT
YARN-7336. Unsafe cast from long to int Resource.hashCode() method
(Contributed by Miklos Szegedi via Daniel Templeton)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d64736d5
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d64736d5
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d64736d5

Branch: refs/heads/HDFS-7240
Commit: d64736d58965722b71d6eade578b6c4c266e6448
Parents: 9a7e810
Author: Daniel Templeton <templedf@apache.org>
Authored: Mon Oct 30 12:40:29 2017 -0700
Committer: Daniel Templeton <templedf@apache.org>
Committed: Mon Oct 30 12:41:28 2017 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/yarn/api/records/Resource.java  | 4 ++--
 .../hadoop/yarn/api/records/impl/LightWeightResource.java       | 5 +----
 2 files changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/d64736d5/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java
index 796b666..6bdde18 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java
@@ -463,11 +463,11 @@ public abstract class Resource implements Comparable<Resource>
{
   @Override
   public int hashCode() {
     final int prime = 47;
-    long result = 0;
+    int result = 0;
     for (ResourceInformation entry : resources) {
       result = prime * result + entry.hashCode();
     }
-    return (int) result;
+    return result;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/d64736d5/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/LightWeightResource.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/LightWeightResource.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/LightWeightResource.java
index a64d242..7b07bbd 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/LightWeightResource.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/LightWeightResource.java
@@ -155,9 +155,6 @@ public class LightWeightResource extends Resource {
   @Override
   public int hashCode() {
     final int prime = 47;
-    long result = prime + getMemorySize();
-    result = prime * result + getVirtualCores();
-
-    return (int) result;
+    return prime * (prime + Long.hashCode(getMemorySize())) + getVirtualCores();
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message