hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1442486 - in /hama/trunk/core/src/main/java/org/apache/hama: bsp/ bsp/sync/ monitor/fd/
Date Tue, 05 Feb 2013 07:38:25 GMT
Author: tommaso
Date: Tue Feb  5 07:38:24 2013
New Revision: 1442486

URL: http://svn.apache.org/viewvc?rev=1442486&view=rev
Log:
HAMA-572 - small improvements to code performance

Modified:
    hama/trunk/core/src/main/java/org/apache/hama/bsp/BSPJobClient.java
    hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileInputFormat.java
    hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileSplit.java
    hama/trunk/core/src/main/java/org/apache/hama/bsp/Counters.java
    hama/trunk/core/src/main/java/org/apache/hama/bsp/FileInputFormat.java
    hama/trunk/core/src/main/java/org/apache/hama/bsp/KillJobAction.java
    hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskLog.java
    hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskRunner.java
    hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java
    hama/trunk/core/src/main/java/org/apache/hama/monitor/fd/UDPSupervisor.java

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/BSPJobClient.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/BSPJobClient.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/BSPJobClient.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/BSPJobClient.java Tue Feb  5 07:38:24
2013
@@ -561,8 +561,7 @@ public class BSPJobClient extends Config
             && job.getConfiguration().get(Constants.RUNTIME_PARTITIONING_CLASS) !=
null
             && job.get("bsp.partitioning.runner.job") == null) {
           LOG.debug(((FileSplit) split).getPath().getName());
-          String[] extractPartitionID = ((FileSplit) split).getPath().getName()
-              .toString().split("[-]");
+          String[] extractPartitionID = ((FileSplit) split).getPath().getName().split("[-]");
           rawSplit.setPartitionID(Integer.parseInt(extractPartitionID[1]));
         }
 

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileInputFormat.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileInputFormat.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileInputFormat.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileInputFormat.java Tue Feb
 5 07:38:24 2013
@@ -20,6 +20,7 @@ package org.apache.hama.bsp;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -388,9 +389,7 @@ public abstract class CombineFileInputFo
 
       // This might cause an exiting rack location to be re-added,
       // but it should be ok.
-      for (int i = 0; i < oneblock.racks.length; i++) {
-        racks.add(oneblock.racks[i]);
-      }
+        Collections.addAll(racks, oneblock.racks);
 
       // if the accumulated split size exceeds the maximum, then
       // create this split.
@@ -428,7 +427,7 @@ public abstract class CombineFileInputFo
 
     // add this split to the list that is returned
     CombineFileSplit thissplit = new CombineFileSplit(job, fl, offset, length,
-        locations.toArray(new String[0]));
+            locations.toArray(new String[locations.size()]));
     splitList.add(thissplit);
   }
 

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileSplit.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileSplit.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileSplit.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/CombineFileSplit.java Tue Feb  5 07:38:24
2013
@@ -179,8 +179,7 @@ public class CombineFileSplit implements
       if (i == 0) {
         sb.append("Paths:");
       }
-      sb.append(paths[i].toUri().getPath() + ":" + startoffset[i] + "+"
-          + lengths[i]);
+      sb.append(paths[i].toUri().getPath()).append(":").append(startoffset[i]).append("+").append(lengths[i]);
       if (i < paths.length - 1) {
         sb.append(",");
       }
@@ -189,10 +188,10 @@ public class CombineFileSplit implements
       String locs = "";
       StringBuffer locsb = new StringBuffer();
       for (int i = 0; i < locations.length; i++) {
-        locsb.append(locations[i] + ":");
+        locsb.append(locations[i]).append(":");
       }
       locs = locsb.toString();
-      sb.append(" Locations:" + locs + "; ");
+      sb.append(" Locations:").append(locs).append("; ");
     }
     return sb.toString();
   }

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/Counters.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/Counters.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/Counters.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/Counters.java Tue Feb  5 07:38:24 2013
@@ -612,10 +612,9 @@ public class Counters implements Writabl
   public synchronized String toString() {
     StringBuilder sb = new StringBuilder("Counters: " + size());
     for (Group group : this) {
-      sb.append("\n\t" + group.getDisplayName());
+      sb.append("\n\t").append(group.getDisplayName());
       for (Counter counter : group) {
-        sb.append("\n\t\t" + counter.getDisplayName() + "="
-            + counter.getCounter());
+        sb.append("\n\t\t").append(counter.getDisplayName()).append("=").append(counter.getCounter());
       }
     }
     return sb.toString();

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/FileInputFormat.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/FileInputFormat.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/FileInputFormat.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/FileInputFormat.java Tue Feb  5 07:38:24
2013
@@ -143,10 +143,8 @@ public abstract class FileInputFormat<K,
       } else {
         for (FileStatus globStat : matches) {
           if (globStat.isDir()) {
-            for (FileStatus stat : fs.listStatus(globStat.getPath(),
-                inputFilter)) {
-              result.add(stat);
-            }
+              Collections.addAll(result, fs.listStatus(globStat.getPath(),
+                      inputFilter));
           } else {
             result.add(globStat);
           }
@@ -416,7 +414,7 @@ public abstract class FileInputFormat<K,
     }
     pathStrings.add(commaSeparatedPaths.substring(pathStart, length));
 
-    return pathStrings.toArray(new String[0]);
+    return pathStrings.toArray(new String[pathStrings.size()]);
   }
 
   /**

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/KillJobAction.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/KillJobAction.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/KillJobAction.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/KillJobAction.java Tue Feb  5 07:38:24
2013
@@ -33,7 +33,7 @@ class KillJobAction extends GroomServerA
 
   public KillJobAction() {
     super(ActionType.KILL_JOB);
-    jobId = new String();
+    jobId = "";
   }
 
   public KillJobAction(String killJobId) {

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskLog.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskLog.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskLog.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskLog.java Tue Feb  5 07:38:24 2013
@@ -291,7 +291,7 @@ public class TaskLog {
     StringBuilder mergedCmd = new StringBuilder();
 
     mergedCmd.append(addCommand(cmd, true));
-    mergedCmd.append(" 2>&1 | tee " + stdout);
+    mergedCmd.append(" 2>&1 | tee ").append(stdout);
 
     result.add(mergedCmd.toString());
     return result;

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskRunner.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskRunner.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskRunner.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/TaskRunner.java Tue Feb  5 07:38:24
2013
@@ -28,6 +28,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -207,13 +208,11 @@ public class TaskRunner extends Thread {
     javaOpts = javaOpts.replace("@taskid@", task.getTaskID().toString());
 
     String[] javaOptsSplit = javaOpts.split(" ");
-    for (int i = 0; i < javaOptsSplit.length; i++) {
-      vargs.add(javaOptsSplit[i]);
-    }
+      Collections.addAll(vargs, javaOptsSplit);
 
     // Add classpath.
     vargs.add("-classpath");
-    vargs.add(classPath.toString());
+    vargs.add(classPath);
     // Add main class and its arguments
     LOG.debug("Executing child Process " + child.getName());
     vargs.add(child.getName()); // bsp class name

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java Tue
Feb  5 07:38:24 2013
@@ -276,8 +276,9 @@ public class ZooKeeperSyncClientImpl ext
     if (allPeers == null) {
       TreeMap<Integer, String> sortedMap = new TreeMap<Integer, String>();
       try {
-        allPeers = zk.getChildren(constructKey(taskId.getJobID(), "peers"),
-            this).toArray(new String[0]);
+          List<String> var = zk.getChildren(constructKey(taskId.getJobID(), "peers"),
+                  this);
+          allPeers = var.toArray(new String[var.size()]);
 
         for (String s : allPeers) {
           byte[] data = zk.getData(constructKey(taskId.getJobID(), "peers", s),

Modified: hama/trunk/core/src/main/java/org/apache/hama/monitor/fd/UDPSupervisor.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/monitor/fd/UDPSupervisor.java?rev=1442486&r1=1442485&r2=1442486&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/monitor/fd/UDPSupervisor.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/monitor/fd/UDPSupervisor.java Tue Feb  5
07:38:24 2013
@@ -249,7 +249,7 @@ public class UDPSupervisor implements Su
       Double[] samples = samples();
       StringBuilder builder = new StringBuilder();
       for (double d : samples) {
-        builder.append(" " + d + " ");
+        builder.append(" ").append(d).append(" ");
       }
       return "Node host:" + this.host + " mean:" + mean(samples) + " variance:"
           + variance(samples) + " samples:[" + builder.toString() + "]";



Mime
View raw message