You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ae...@apache.org on 2016/02/01 19:40:21 UTC

[02/50] [abbrv] hadoop git commit: HADOOP-12731. Remove useless boxing/unboxing code. Contributed by Kousuke Saruta.

HADOOP-12731. Remove useless boxing/unboxing code. Contributed by Kousuke Saruta.


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

Branch: refs/heads/HDFS-7240
Commit: 736eb17a796a1c1ad5f4db2c6a64f6752db7bec3
Parents: 2b83329
Author: Akira Ajisaka <aa...@apache.org>
Authored: Mon Jan 25 13:47:29 2016 +0900
Committer: Akira Ajisaka <aa...@apache.org>
Committed: Mon Jan 25 13:47:29 2016 +0900

----------------------------------------------------------------------
 .../util/TestZKSignerSecretProvider.java        |  2 +-
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 ++
 .../java/org/apache/hadoop/fs/FileContext.java  |  4 +-
 .../org/apache/hadoop/ha/SshFenceByTcpPort.java |  4 +-
 .../apache/hadoop/io/AbstractMapWritable.java   | 54 +++++++-------------
 .../hadoop/security/ShellBasedIdMapping.java    |  9 ++--
 .../java/org/apache/hadoop/util/bloom/Key.java  |  4 +-
 .../apache/hadoop/ha/TestSshFenceByTcpPort.java |  8 +--
 .../apache/hadoop/test/GenericTestUtils.java    |  2 +-
 .../gridmix/DistributedCacheEmulator.java       |  4 +-
 .../hadoop/mapred/gridmix/CommonJobTest.java    |  2 +-
 .../mapred/gridmix/TestPseudoLocalFs.java       |  2 +-
 .../apache/hadoop/streaming/DelayEchoApp.java   |  2 +-
 13 files changed, 43 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestZKSignerSecretProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestZKSignerSecretProvider.java b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestZKSignerSecretProvider.java
index 4f8b5ae..8211314 100644
--- a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestZKSignerSecretProvider.java
+++ b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestZKSignerSecretProvider.java
@@ -35,7 +35,7 @@ public class TestZKSignerSecretProvider {
 
   // rollover every 2 sec
   private final int timeout = 4000;
-  private final long rolloverFrequency = Long.valueOf(timeout / 2);
+  private final long rolloverFrequency = timeout / 2;
 
   @Before
   public void setup() throws Exception {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 36cac2f..3db68fb 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -1645,6 +1645,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12730. Hadoop streaming -mapper and -reducer options are wrongly
     documented as required. (Kengo Seki via aajisaka)
 
+    HADOOP-12731. Remove useless boxing/unboxing code.
+    (Kousuke Saruta via aajisaka)
+
 Release 2.7.3 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java
index 2456154..d96abad 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java
@@ -761,7 +761,7 @@ public class FileContext {
       @Override
       public Boolean next(final AbstractFileSystem fs, final Path p) 
         throws IOException, UnresolvedLinkException {
-        return Boolean.valueOf(fs.delete(p, recursive));
+        return fs.delete(p, recursive);
       }
     }.resolve(this, absF);
   }
@@ -895,7 +895,7 @@ public class FileContext {
       @Override
       public Boolean next(final AbstractFileSystem fs, final Path p) 
         throws IOException, UnresolvedLinkException {
-        return Boolean.valueOf(fs.setReplication(p, replication));
+        return fs.setReplication(p, replication);
       }
     }.resolve(this, absF);
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java
index 90eb915..5815564 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java
@@ -256,10 +256,10 @@ public class SshFenceByTcpPort extends Configured
       }
     }
 
-    private Integer parseConfiggedPort(String portStr)
+    private int parseConfiggedPort(String portStr)
         throws BadFencingConfigurationException {
       try {
-        return Integer.valueOf(portStr);
+        return Integer.parseInt(portStr);
       } catch (NumberFormatException nfe) {
         throw new BadFencingConfigurationException(
             "Port number '" + portStr + "' invalid");

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java
index cc1e517..7dd9e69 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java
@@ -116,55 +116,39 @@ public abstract class AbstractMapWritable implements Writable, Configurable {
         DataInputBuffer in = new DataInputBuffer();
         in.reset(out.getData(), out.getLength());
         readFields(in);
-        
+
       } catch (IOException e) {
         throw new IllegalArgumentException("map cannot be copied: " +
             e.getMessage());
       }
-      
+
     } else {
       throw new IllegalArgumentException("source map cannot be null");
     }
   }
-  
+
   /** constructor. */
   protected AbstractMapWritable() {
     this.conf = new AtomicReference<Configuration>();
 
-    addToMap(ArrayWritable.class,
-        Byte.valueOf(Integer.valueOf(-127).byteValue())); 
-    addToMap(BooleanWritable.class,
-        Byte.valueOf(Integer.valueOf(-126).byteValue()));
-    addToMap(BytesWritable.class,
-        Byte.valueOf(Integer.valueOf(-125).byteValue()));
-    addToMap(FloatWritable.class,
-        Byte.valueOf(Integer.valueOf(-124).byteValue()));
-    addToMap(IntWritable.class,
-        Byte.valueOf(Integer.valueOf(-123).byteValue()));
-    addToMap(LongWritable.class,
-        Byte.valueOf(Integer.valueOf(-122).byteValue()));
-    addToMap(MapWritable.class,
-        Byte.valueOf(Integer.valueOf(-121).byteValue()));
-    addToMap(MD5Hash.class,
-        Byte.valueOf(Integer.valueOf(-120).byteValue()));
-    addToMap(NullWritable.class,
-        Byte.valueOf(Integer.valueOf(-119).byteValue()));
-    addToMap(ObjectWritable.class,
-        Byte.valueOf(Integer.valueOf(-118).byteValue()));
-    addToMap(SortedMapWritable.class,
-        Byte.valueOf(Integer.valueOf(-117).byteValue()));
-    addToMap(Text.class,
-        Byte.valueOf(Integer.valueOf(-116).byteValue()));
-    addToMap(TwoDArrayWritable.class,
-        Byte.valueOf(Integer.valueOf(-115).byteValue()));
-    
-    // UTF8 is deprecated so we don't support it
+    addToMap(ArrayWritable.class, (byte)-127);
+    addToMap(BooleanWritable.class, (byte)-126);
+    addToMap(BytesWritable.class, (byte)-125);
+    addToMap(FloatWritable.class, (byte)-124);
+    addToMap(IntWritable.class, (byte)-123);
+    addToMap(LongWritable.class, (byte)-122);
+    addToMap(MapWritable.class, (byte)-121);
+    addToMap(MD5Hash.class, (byte)-120);
+    addToMap(NullWritable.class, (byte)-119);
+    addToMap(ObjectWritable.class, (byte)-118);
+    addToMap(SortedMapWritable.class, (byte)-117);
+    addToMap(Text.class, (byte)-116);
+    addToMap(TwoDArrayWritable.class, (byte)-115);
 
-    addToMap(VIntWritable.class,
-        Byte.valueOf(Integer.valueOf(-114).byteValue()));
-    addToMap(VLongWritable.class,
-        Byte.valueOf(Integer.valueOf(-113).byteValue()));
+    // UTF8 is deprecated so we don't support it
 
+    addToMap(VIntWritable.class, (byte)-114);
+    addToMap(VLongWritable.class, (byte)-113);
   }
 
   /** @return the conf */

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java
index fd362d0..20bccd5 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java
@@ -203,9 +203,8 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider {
    * Integer, e.g. 4294967294 maps to -2 and 4294967295 maps to -1.
    */
   private static Integer parseId(final String idStr) {
-    Long longVal = Long.parseLong(idStr);
-    int intVal = longVal.intValue();
-    return Integer.valueOf(intVal);
+    long longVal = Long.parseLong(idStr);
+    return Integer.valueOf((int)longVal);
   }
   
   /**
@@ -605,8 +604,8 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider {
         // We know the line is fine to parse without error checking like this
         // since it matched the regex above.
         String firstComponent = lineMatcher.group(1);
-        int remoteId = parseId(lineMatcher.group(2));
-        int localId = parseId(lineMatcher.group(3));
+        Integer remoteId = parseId(lineMatcher.group(2));
+        Integer localId = parseId(lineMatcher.group(3));
         if (firstComponent.equals("uid")) {
           uidMapping.put(localId, remoteId);
         } else {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/Key.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/Key.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/Key.java
index 7ac134c..e8ad18c 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/Key.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/Key.java
@@ -177,8 +177,8 @@ public class Key implements WritableComparable<Key> {
     }
     
     if (result == 0) {
-      result = Double.valueOf(this.weight - other.weight).intValue();
+      result = (int)(this.weight - other.weight);
     }
     return result;
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestSshFenceByTcpPort.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestSshFenceByTcpPort.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestSshFenceByTcpPort.java
index 4796fe6..fb238fe 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestSshFenceByTcpPort.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestSshFenceByTcpPort.java
@@ -34,20 +34,20 @@ public class TestSshFenceByTcpPort {
   static {
     ((Log4JLogger)SshFenceByTcpPort.LOG).getLogger().setLevel(Level.ALL);
   }
-  
+
   private static String TEST_FENCING_HOST = System.getProperty(
       "test.TestSshFenceByTcpPort.host", "localhost");
   private static final String TEST_FENCING_PORT = System.getProperty(
       "test.TestSshFenceByTcpPort.port", "8020");
   private static final String TEST_KEYFILE = System.getProperty(
       "test.TestSshFenceByTcpPort.key");
-  
+
   private static final InetSocketAddress TEST_ADDR =
     new InetSocketAddress(TEST_FENCING_HOST,
-      Integer.valueOf(TEST_FENCING_PORT));
+      Integer.parseInt(TEST_FENCING_PORT));
   private static final HAServiceTarget TEST_TARGET =
     new DummyHAService(HAServiceState.ACTIVE, TEST_ADDR);
-  
+
   /**
    *  Connect to Google's DNS server - not running ssh!
    */

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
index 9c14bb4..7e494a8 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
@@ -479,6 +479,6 @@ public abstract class GenericTestUtils {
    */
   public static void assumeInNativeProfile() {
     Assume.assumeTrue(
-        Boolean.valueOf(System.getProperty("runningWithNative", "false")));
+        Boolean.parseBoolean(System.getProperty("runningWithNative", "false")));
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/DistributedCacheEmulator.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/DistributedCacheEmulator.java b/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/DistributedCacheEmulator.java
index d30a51d..72027c1 100644
--- a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/DistributedCacheEmulator.java
+++ b/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/DistributedCacheEmulator.java
@@ -330,7 +330,7 @@ class DistributedCacheEmulator {
         // Check if visibilities are available because older hadoop versions
         // didn't have public, private Distributed Caches separately.
         boolean visibility =
-            (visibilities == null) ? true : Boolean.valueOf(visibilities[i]);
+            (visibilities == null) || Boolean.parseBoolean(visibilities[i]);
         if (isLocalDistCacheFile(files[i], user, visibility)) {
           // local FS based distributed cache file.
           // Create this file on the pseudo local FS on the fly (i.e. when the
@@ -514,7 +514,7 @@ class DistributedCacheEmulator {
           // Check if visibilities are available because older hadoop versions
           // didn't have public, private Distributed Caches separately.
           boolean visibility =
-            (visibilities == null) ? true : Boolean.valueOf(visibilities[i]);
+              (visibilities == null) || Boolean.parseBoolean(visibilities[i]);
           if (isLocalDistCacheFile(files[i], user, visibility)) {
             // local FS based distributed cache file.
             // Create this file on the pseudo local FS.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/CommonJobTest.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/CommonJobTest.java b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/CommonJobTest.java
index 24e5aad..6a45ba7 100644
--- a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/CommonJobTest.java
+++ b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/CommonJobTest.java
@@ -172,7 +172,7 @@ public class CommonJobTest {
         assertTrue("Gridmix job name is not in the expected format.",
                 jobName.equals(GridmixJob.JOB_NAME_PREFIX + jobSeqNum));
         final FileStatus stat = GridmixTestUtils.dfs.getFileStatus(new Path(
-                GridmixTestUtils.DEST, "" + Integer.valueOf(jobSeqNum)));
+                GridmixTestUtils.DEST, "" + Integer.parseInt(jobSeqNum)));
         assertEquals("Wrong owner for " + jobName, spec.getUser(),
                 stat.getOwner());
         final int nMaps = spec.getNumberMaps();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestPseudoLocalFs.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestPseudoLocalFs.java b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestPseudoLocalFs.java
index b9c2728..a607ece 100644
--- a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestPseudoLocalFs.java
+++ b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestPseudoLocalFs.java
@@ -95,7 +95,7 @@ public class TestPseudoLocalFs {
 
       // validate fileSize
       String[] parts = path.toUri().getPath().split("\\.");
-      long expectedFileSize = Long.valueOf(parts[parts.length - 1]);
+      long expectedFileSize = Long.parseLong(parts[parts.length - 1]);
       assertEquals("Invalid file size.", expectedFileSize, stat.getLen());
     } else {
       assertTrue("getFileStatus() did not throw Exception for invalid file "

http://git-wip-us.apache.org/repos/asf/hadoop/blob/736eb17a/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/DelayEchoApp.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/DelayEchoApp.java b/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/DelayEchoApp.java
index 546b7eb..a912dc9 100644
--- a/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/DelayEchoApp.java
+++ b/hadoop-tools/hadoop-streaming/src/test/java/org/apache/hadoop/streaming/DelayEchoApp.java
@@ -45,7 +45,7 @@ public class DelayEchoApp {
     int seconds = 5;
     if (args.length >= 1) {
       try {
-        seconds = Integer.valueOf(args[0]);
+        seconds = Integer.parseInt(args[0]);
       } catch (NumberFormatException e) {
         // just use default 5.
       }