hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r926256 - in /hadoop/common/trunk: ./ src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/ src/java/org/apache/hadoop/conf/ src/java/org/apache/hadoop/fs/ src/java/org/apache/hadoop/io/ src/java/org/apache/hadoop/io/compress/ src...
Date Mon, 22 Mar 2010 19:08:04 GMT
Author: tomwhite
Date: Mon Mar 22 19:08:03 2010
New Revision: 926256

URL: http://svn.apache.org/viewvc?rev=926256&view=rev
Log:
HADOOP-6471. StringBuffer -> StringBuilder - conversion of references as necessary. Contributed
by Kay Kay.

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Anonymizer.java
    hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/CPUParser.java
    hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Environment.java
    hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/HadoopLogParser.java
    hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/LocalStore.java
    hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/NICParser.java
    hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SMARTParser.java
    hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SensorsParser.java
    hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileUtil.java
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/Path.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/BytesWritable.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/UTF8.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java
    hadoop/common/trunk/src/java/org/apache/hadoop/ipc/WritableRpcEngine.java
    hadoop/common/trunk/src/java/org/apache/hadoop/net/NetworkTopology.java
    hadoop/common/trunk/src/java/org/apache/hadoop/net/ScriptBasedMapping.java
    hadoop/common/trunk/src/java/org/apache/hadoop/record/Buffer.java
    hadoop/common/trunk/src/java/org/apache/hadoop/record/CsvRecordInput.java
    hadoop/common/trunk/src/java/org/apache/hadoop/record/Utils.java
    hadoop/common/trunk/src/java/org/apache/hadoop/record/XmlRecordOutput.java
    hadoop/common/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java
    hadoop/common/trunk/src/java/org/apache/hadoop/util/Progress.java
    hadoop/common/trunk/src/java/org/apache/hadoop/util/StringUtils.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/io/RandomDatum.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestText.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestUTF8.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/util/TestIndexedSort.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Mon Mar 22 19:08:03 2010
@@ -199,6 +199,9 @@ Trunk (unreleased changes)
     HADOOP-3659. Patch to allow hadoop native to compile on Mac OS X.
     (Colin Evans and Allen Wittenauer via tomwhite)
 
+    HADOOP-6471. StringBuffer -> StringBuilder - conversion of references
+    as necessary. (Kay Kay via tomwhite)
+
   OPTIMIZATIONS
 
     HADOOP-6467. Improve the performance on HarFileSystem.listStatus(..).

Modified: hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Anonymizer.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Anonymizer.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Anonymizer.java
(original)
+++ hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Anonymizer.java
Mon Mar 22 19:08:03 2010
@@ -136,7 +136,7 @@ public class Anonymizer {
   }
 
   private static String convertToHex(byte[] data) {
-    StringBuffer buf = new StringBuffer();
+    StringBuilder buf = new StringBuilder();
     for (int i = 0; i < data.length; i++) {
       int halfbyte = (data[i] >>> 4) & 0x0F;
       int two_halfs = 0;

Modified: hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/CPUParser.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/CPUParser.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/CPUParser.java
(original)
+++ hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/CPUParser.java
Mon Mar 22 19:08:03 2010
@@ -46,7 +46,7 @@ public class CPUParser extends ShellPars
    * @return the EventRecord created
    */
   public EventRecord query(String s) throws Exception {
-    StringBuffer sb = Environment.runCommand("cat /proc/cpuinfo");
+    CharSequence sb = Environment.runCommandGeneric("cat /proc/cpuinfo");
     EventRecord retval = new EventRecord(InetAddress.getLocalHost()
         .getCanonicalHostName(), InetAddress.getAllByName(InetAddress.getLocalHost()
         .getHostName()), Calendar.getInstance(), "CPU", "Unknown", "CPU", "-");

Modified: hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Environment.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Environment.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Environment.java
(original)
+++ hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/Environment.java
Mon Mar 22 19:08:03 2010
@@ -247,7 +247,7 @@ public class Environment {
         
         if (!file_present) 
           if (superuser) {
-              StringBuffer sb = runCommand("sudo smartctl -i " + devices[i]);
+              CharSequence sb = runCommandGeneric("sudo smartctl -i " + devices[i]);
               String patternStr = "[(failed)(device not supported)]";
               Pattern pattern = Pattern.compile(patternStr);
               Matcher matcher = pattern.matcher(sb.toString());
@@ -263,7 +263,7 @@ public class Environment {
       } 
       
       // now remove disks that dont exist
-      StringBuffer resetSB = new StringBuffer();
+      StringBuilder resetSB = new StringBuilder();
       for (int j = 0; j < devices.length; j++) {
         resetSB.append(devices[j] == null ? "" : devices[j] + ", ");
 	if (devices[j] != null)
@@ -323,7 +323,7 @@ public class Environment {
    *  @return true, if the command is availble, false otherwise
    */
   public static boolean checkExistence(String cmd) {
-    StringBuffer sb = runCommand("which " + cmd);
+    CharSequence sb = runCommandGeneric("which " + cmd);
     if (sb.length() > 1)
       return true;
 
@@ -331,15 +331,30 @@ public class Environment {
   }
 
   /**
-   * Runs a shell command in the system and provides a StringBuffer
+   * Runs a shell command in the system and provides a StringBuilder
    * with the output of the command.
+   * <p>This method is deprecated. See related method that returns a CharSequence as
oppposed to a StringBuffer.
    * 
    *  @param cmd an array of string that form the command to run 
    *  
-   *  @return a StringBuffer that contains the output of the command 
+   *  @return a text that contains the output of the command 
+   *  @see #runCommandGeneric(String[])
+   *  @deprecated
    */
   public static StringBuffer runCommand(String[] cmd) {
-    StringBuffer retval = new StringBuffer(MAX_OUTPUT_LENGTH);
+    return new StringBuffer(runCommandGeneric(cmd));
+  }
+
+  /**
+   * Runs a shell command in the system and provides a StringBuilder
+   * with the output of the command.
+   * 
+   *  @param cmd an array of string that form the command to run 
+   *  
+   *  @return a text that contains the output of the command 
+   */
+  public static CharSequence runCommandGeneric(String[] cmd) {
+    StringBuilder retval = new StringBuilder(MAX_OUTPUT_LENGTH);
     Process p;
     try {
       p = Runtime.getRuntime().exec(cmd);
@@ -356,20 +371,33 @@ public class Environment {
 
     return retval;
   }
-
+  
   /**
-   * Runs a shell command in the system and provides a StringBuffer
+   * Runs a shell command in the system and provides a StringBuilder
    * with the output of the command.
-   * 
+   * <p>This method is deprecated in favor of the one that returns CharSequence as
opposed to StringBuffer
    *  @param cmd the command to run 
    *  
-   *  @return a StringBuffer that contains the output of the command 
+   *  @return a text that contains the output of the command 
+   *  @see #runCommandGeneric(String)
+   *  @deprecated
    */
   public static StringBuffer runCommand(String cmd) {
-    return runCommand(cmd.split("\\s+"));
+    return new StringBuffer(runCommandGeneric(cmd));
   }
 
   /**
+   * Runs a shell command in the system and provides a StringBuilder
+   * with the output of the command.
+   * 
+   *  @param cmd the command to run 
+   *  
+   *  @return a text that contains the output of the command 
+   */
+  public static CharSequence runCommandGeneric(String cmd) {
+    return runCommandGeneric(cmd.split("\\s+"));
+  }  
+  /**
    * Determines the greatest common divisor (GCD) of two integers.
    * 
    *  @param m the first integer

Modified: hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/HadoopLogParser.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/HadoopLogParser.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/HadoopLogParser.java
(original)
+++ hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/HadoopLogParser.java
Mon Mar 22 19:08:03 2010
@@ -113,7 +113,7 @@ public class HadoopLogParser extends Log
    * 
    */
   private void findHostname() {
-    String startupInfo = Environment.runCommand(
+    String startupInfo = Environment.runCommandGeneric(
         "grep --max-count=1 STARTUP_MSG:\\s*host " + file.getName()).toString();
     Pattern pattern = Pattern.compile("\\s+(\\w+/.+)\\s+");
     Matcher matcher = pattern.matcher(startupInfo);

Modified: hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/LocalStore.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/LocalStore.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/LocalStore.java
(original)
+++ hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/LocalStore.java
Mon Mar 22 19:08:03 2010
@@ -144,11 +144,25 @@ public class LocalStore {
 
   /**
    * Pack a SerializedRecord into an array of bytes
-   * 
+   * <p>
+   * This method is deprecated. 
    * @param sr the SerializedRecord to be packed
+   * @return Packed representation fo the Serialized Record
+   * @see #packConcurrent(SerializedRecord)
+   * @deprecated
    */
   public static StringBuffer pack(SerializedRecord sr) {
-    StringBuffer sb = new StringBuffer();
+    return new StringBuffer(packConcurrent(sr));
+  }
+
+  /**
+   * Pack a SerializedRecord into an array of bytes
+   * 
+   * @param sr the SerializedRecord to be packed
+   * @return Packed representation fo the Serialized Record
+   */
+  public static CharSequence packConcurrent(SerializedRecord sr) {
+    StringBuilder sb = new StringBuilder();
 
     ArrayList<String> keys = new ArrayList<String>(sr.fields.keySet());
 
@@ -162,7 +176,7 @@ public class LocalStore {
     }
     return sb;
   }
-
+  
   /**
    * Upload the local file store into HDFS, after it 
    * compressing it. Then a new local file is created 

Modified: hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/NICParser.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/NICParser.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/NICParser.java
(original)
+++ hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/NICParser.java
Mon Mar 22 19:08:03 2010
@@ -54,7 +54,7 @@ public class NICParser extends ShellPars
    * @return the EventRecord created
    */
   public EventRecord query(String device) throws UnknownHostException {
-    StringBuffer sb = Environment.runCommand("/sbin/ifconfig " + device);
+    CharSequence sb = Environment.runCommandGeneric("/sbin/ifconfig " + device);
     EventRecord retval = new EventRecord(InetAddress.getLocalHost()
         .getCanonicalHostName(), InetAddress.getAllByName(InetAddress.getLocalHost()
         .getHostName()), Calendar.getInstance(), "NIC", "Unknown", device, "-");

Modified: hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SMARTParser.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SMARTParser.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SMARTParser.java
(original)
+++ hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SMARTParser.java
Mon Mar 22 19:08:03 2010
@@ -66,12 +66,12 @@ public class SMARTParser extends ShellPa
    */
   public EventRecord query(String device) throws Exception {
     String conf = Environment.getProperty("disks." + device + ".source");
-    StringBuffer sb;
+    CharSequence sb;
 
     if (conf == null)
-      sb = Environment.runCommand("sudo smartctl --all " + device);
+      sb = Environment.runCommandGeneric("sudo smartctl --all " + device);
     else
-      sb = Environment.runCommand("cat " + conf);
+      sb = Environment.runCommandGeneric("cat " + conf);
 
     EventRecord retval = new EventRecord(InetAddress.getLocalHost()
         .getCanonicalHostName(), InetAddress.getAllByName(InetAddress.getLocalHost()
@@ -146,11 +146,11 @@ public class SMARTParser extends ShellPa
    * This format is mostly found in IDE and SATA disks.
    * 
    * @param er the EventRecord in which to store attributes found
-   * @param sb the StringBuffer with the text to parse
+   * @param sb the text to parse
    * 
    * @return the EventRecord in which new attributes are stored.
    */
-  private EventRecord readColumns(EventRecord er, StringBuffer sb) {
+  private EventRecord readColumns(EventRecord er, CharSequence sb) {
 
     Pattern pattern = Pattern.compile("^\\s{0,2}(\\d{1,3}\\s+.*)$",
         Pattern.MULTILINE);

Modified: hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SensorsParser.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SensorsParser.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SensorsParser.java
(original)
+++ hadoop/common/trunk/src/contrib/failmon/src/java/org/apache/hadoop/contrib/failmon/SensorsParser.java
Mon Mar 22 19:08:03 2010
@@ -42,10 +42,10 @@ public class SensorsParser extends Shell
    * @return the EventRecord created
    */
   public EventRecord query(String s) throws Exception {
-    StringBuffer sb;
+    CharSequence sb;
 
-    //sb = Environment.runCommand("sensors -A");
-     sb = Environment.runCommand("cat sensors.out");
+    //sb = Environment.runCommandGeneric("sensors -A");
+     sb = Environment.runCommandGeneric("cat sensors.out");
 
     EventRecord retval = new EventRecord(InetAddress.getLocalHost()
         .getCanonicalHostName(), InetAddress.getAllByName(InetAddress.getLocalHost()
@@ -70,7 +70,7 @@ public class SensorsParser extends Shell
    * 
    * @return the EventRecord created
    */
-  private EventRecord readGroup(EventRecord er, StringBuffer sb, String prefix) {
+  private EventRecord readGroup(EventRecord er, CharSequence sb, String prefix) {
 
     Pattern pattern = Pattern.compile(".*(" + prefix
         + "\\s*\\d*)\\s*:\\s*(\\+?\\d+)", Pattern.MULTILINE);

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java Mon Mar 22 19:08:03
2010
@@ -934,7 +934,7 @@ public class Configuration implements It
     
     @Override
     public String toString() {
-      StringBuffer result = new StringBuffer();
+      StringBuilder result = new StringBuilder();
       boolean first = true;
       for(Range r: ranges) {
         if (first) {
@@ -1846,7 +1846,7 @@ public class Configuration implements It
   
   @Override
   public String toString() {
-    StringBuffer sb = new StringBuffer();
+    StringBuilder sb = new StringBuilder();
     sb.append("Configuration: ");
     if(loadDefaults) {
       toString(defaultResources, sb);
@@ -1858,8 +1858,8 @@ public class Configuration implements It
     return sb.toString();
   }
 
-  private void toString(List resources, StringBuffer sb) {
-    ListIterator i = resources.listIterator();
+  private <T> void toString(List<T> resources, StringBuilder sb) {
+    ListIterator<T> i = resources.listIterator();
     while (i.hasNext()) {
       if (i.nextIndex() != 0) {
         sb.append(", ");

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileUtil.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileUtil.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileUtil.java Mon Mar 22 19:08:03 2010
@@ -166,7 +166,7 @@ public class FileUtil {
                              throws IOException {
     boolean gotException = false;
     boolean returnVal = true;
-    StringBuffer exceptions = new StringBuffer();
+    StringBuilder exceptions = new StringBuilder();
 
     if (srcs.length == 1)
       return copy(srcFS, srcs[0], dstFS, dst, deleteSource, overwrite, conf);
@@ -529,7 +529,7 @@ public class FileUtil {
       }
     }
 
-    StringBuffer untarCommand = new StringBuffer();
+    StringBuilder untarCommand = new StringBuilder();
     boolean gzipped = inFile.toString().endsWith("gz");
     if (gzipped) {
       untarCommand.append(" gzip -dc '");
@@ -745,7 +745,7 @@ public class FileUtil {
    */
   public static int chmod(String filename, String perm, boolean recursive)
                             throws IOException, InterruptedException {
-    StringBuffer cmdBuf = new StringBuffer();
+    StringBuilder cmdBuf = new StringBuilder();
     cmdBuf.append("chmod ");
     if (recursive) {
       cmdBuf.append("-R ");

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/Path.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/Path.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/Path.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/Path.java Mon Mar 22 19:08:03 2010
@@ -238,7 +238,7 @@ public class Path implements Comparable 
   public String toString() {
     // we can't use uri.toString(), which escapes everything, because we want
     // illegal characters unescaped in the string, for glob processing, etc.
-    StringBuffer buffer = new StringBuffer();
+    StringBuilder buffer = new StringBuilder();
     if (uri.getScheme() != null) {
       buffer.append(uri.getScheme());
       buffer.append(":");

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/BytesWritable.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/BytesWritable.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/BytesWritable.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/BytesWritable.java Mon Mar 22 19:08:03
2010
@@ -177,7 +177,7 @@ public class BytesWritable extends Binar
    * Generate the stream of bytes as hex pairs separated by ' '.
    */
   public String toString() { 
-    StringBuffer sb = new StringBuffer(3*size);
+    StringBuilder sb = new StringBuilder(3*size);
     for (int idx = 0; idx < size; idx++) {
       // if not the first, put a blank separator in
       if (idx != 0) {

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java Mon Mar 22 19:08:03 2010
@@ -183,7 +183,7 @@ public class MD5Hash implements Writable
 
   /** Returns a string representation of this object. */
   public String toString() {
-    StringBuffer buf = new StringBuffer(MD5_LEN*2);
+    StringBuilder buf = new StringBuilder(MD5_LEN*2);
     for (int i = 0; i < MD5_LEN; i++) {
       int b = digest[i];
       buf.append(HEX_DIGITS[(b >> 4) & 0xf]);

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java Mon Mar 22 19:08:03
2010
@@ -780,7 +780,7 @@ public class SequenceFile {
     }
     
     public String toString() {
-      StringBuffer sb = new StringBuffer();
+      StringBuilder sb = new StringBuilder();
       sb.append("size: ").append(this.theMetadata.size()).append("\n");
       Iterator<Map.Entry<Text, Text>> iter =
         this.theMetadata.entrySet().iterator();

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/UTF8.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/UTF8.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/UTF8.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/UTF8.java Mon Mar 22 19:08:03 2010
@@ -132,7 +132,7 @@ public class UTF8 implements WritableCom
 
   /** Convert to a String. */
   public String toString() {
-    StringBuffer buffer = new StringBuffer(length);
+    StringBuilder buffer = new StringBuilder(length);
     try {
       synchronized (IBUF) {
         IBUF.reset(bytes, length);
@@ -204,12 +204,12 @@ public class UTF8 implements WritableCom
    */
   public static String readString(DataInput in) throws IOException {
     int bytes = in.readUnsignedShort();
-    StringBuffer buffer = new StringBuffer(bytes);
+    StringBuilder buffer = new StringBuilder(bytes);
     readChars(in, buffer, bytes);
     return buffer.toString();
   }
 
-  private static void readChars(DataInput in, StringBuffer buffer, int nBytes)
+  private static void readChars(DataInput in, StringBuilder buffer, int nBytes)
     throws IOException {
     DataOutputBuffer obuf = OBUF_FACTORY.get();
     obuf.reset();

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java
(original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/compress/CompressionCodecFactory.java
Mon Mar 22 19:08:03 2010
@@ -42,14 +42,14 @@ public class CompressionCodecFactory {
   
   private void addCodec(CompressionCodec codec) {
     String suffix = codec.getDefaultExtension();
-    codecs.put(new StringBuffer(suffix).reverse().toString(), codec);
+    codecs.put(new StringBuilder(suffix).reverse().toString(), codec);
   }
   
   /**
    * Print the extension map out as a string.
    */
   public String toString() {
-    StringBuffer buf = new StringBuffer();
+    StringBuilder buf = new StringBuilder();
     Iterator<Map.Entry<String, CompressionCodec>> itr = 
       codecs.entrySet().iterator();
     buf.append("{ ");
@@ -112,7 +112,7 @@ public class CompressionCodecFactory {
    */
   public static void setCodecClasses(Configuration conf,
                                      List<Class> classes) {
-    StringBuffer buf = new StringBuffer();
+    StringBuilder buf = new StringBuilder();
     Iterator<Class> itr = classes.iterator();
     if (itr.hasNext()) {
       Class cls = itr.next();
@@ -154,7 +154,7 @@ public class CompressionCodecFactory {
     CompressionCodec result = null;
     if (codecs != null) {
       String filename = file.getName();
-      String reversedFilename = new StringBuffer(filename).reverse().toString();
+      String reversedFilename = new StringBuilder(filename).reverse().toString();
       SortedMap<String, CompressionCodec> subMap = 
         codecs.headMap(reversedFilename);
       if (!subMap.isEmpty()) {

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/ipc/WritableRpcEngine.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/ipc/WritableRpcEngine.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/ipc/WritableRpcEngine.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/ipc/WritableRpcEngine.java Mon Mar 22 19:08:03
2010
@@ -90,7 +90,7 @@ class WritableRpcEngine implements RpcEn
     }
 
     public String toString() {
-      StringBuffer buffer = new StringBuffer();
+      StringBuilder buffer = new StringBuilder();
       buffer.append(methodName);
       buffer.append("(");
       for (int i = 0; i < parameters.length; i++) {

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/net/NetworkTopology.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/net/NetworkTopology.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/net/NetworkTopology.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/net/NetworkTopology.java Mon Mar 22 19:08:03
2010
@@ -580,7 +580,7 @@ public class NetworkTopology {
   /** convert a network tree to a string */
   public String toString() {
     // print the number of racks
-    StringBuffer tree = new StringBuffer();
+    StringBuilder tree = new StringBuilder();
     tree.append("Number of racks: ");
     tree.append(numOfRacks);
     tree.append("\n");

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/net/ScriptBasedMapping.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/net/ScriptBasedMapping.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/net/ScriptBasedMapping.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/net/ScriptBasedMapping.java Mon Mar 22
19:08:03 2010
@@ -124,7 +124,7 @@ implements Configurable
     if (args.size() == 0) {
       return null;
     }
-    StringBuffer allOutput = new StringBuffer();
+    StringBuilder allOutput = new StringBuilder();
     int numProcessed = 0;
     if (maxArgs < MIN_ALLOWABLE_ARGS) {
       LOG.warn("Invalid value " + Integer.toString(maxArgs)

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/record/Buffer.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/record/Buffer.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/record/Buffer.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/record/Buffer.java Mon Mar 22 19:08:03
2010
@@ -221,7 +221,7 @@ public class Buffer implements Comparabl
   
   // inheric javadoc
   public String toString() {
-    StringBuffer sb = new StringBuffer(2*count);
+    StringBuilder sb = new StringBuilder(2*count);
     for(int idx = 0; idx < count; idx++) {
       sb.append(Character.forDigit((bytes[idx] & 0xF0) >> 4, 16));
       sb.append(Character.forDigit(bytes[idx] & 0x0F, 16));

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/record/CsvRecordInput.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/record/CsvRecordInput.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/record/CsvRecordInput.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/record/CsvRecordInput.java Mon Mar 22 19:08:03
2010
@@ -51,7 +51,7 @@ public class CsvRecordInput implements R
     
   private String readField(String tag) throws IOException {
     try {
-      StringBuffer buf = new StringBuffer();
+      StringBuilder buf = new StringBuilder();
       while (true) {
         char c = (char) stream.read();
         switch (c) {

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/record/Utils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/record/Utils.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/record/Utils.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/record/Utils.java Mon Mar 22 19:08:03 2010
@@ -45,7 +45,7 @@ public class Utils {
    * @return
    */
   static String toXMLString(String s) {
-    StringBuffer sb = new StringBuffer();
+    StringBuilder sb = new StringBuilder();
     for (int idx = 0; idx < s.length(); idx++) {
       char ch = s.charAt(idx);
       if (ch == '<') {
@@ -86,7 +86,7 @@ public class Utils {
    * @return
    */
   static String fromXMLString(String s) {
-    StringBuffer sb = new StringBuffer();
+    StringBuilder sb = new StringBuilder();
     for (int idx = 0; idx < s.length();) {
       char ch = s.charAt(idx++);
       if (ch == '%') {
@@ -109,7 +109,7 @@ public class Utils {
    * @return
    */
   static String toCSVString(String s) {
-    StringBuffer sb = new StringBuffer(s.length()+1);
+    StringBuilder sb = new StringBuilder(s.length()+1);
     sb.append('\'');
     int len = s.length();
     for (int i = 0; i < len; i++) {
@@ -151,7 +151,7 @@ public class Utils {
       throw new IOException("Error deserializing string.");
     }
     int len = s.length();
-    StringBuffer sb = new StringBuffer(len-1);
+    StringBuilder sb = new StringBuilder(len-1);
     for (int i = 1; i < len; i++) {
       char c = s.charAt(i);
       if (c == '%') {
@@ -214,7 +214,7 @@ public class Utils {
    * @return
    */
   static String toCSVBuffer(Buffer buf) {
-    StringBuffer sb = new StringBuffer("#");
+    StringBuilder sb = new StringBuilder("#");
     sb.append(buf.toString());
     return sb.toString();
   }

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/record/XmlRecordOutput.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/record/XmlRecordOutput.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/record/XmlRecordOutput.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/record/XmlRecordOutput.java Mon Mar 22
19:08:03 2010
@@ -41,7 +41,7 @@ public class XmlRecordOutput implements 
   private Stack<String> compoundStack;
     
   private void putIndent() {
-    StringBuffer sb = new StringBuffer("");
+    StringBuilder sb = new StringBuilder("");
     for (int idx = 0; idx < indent; idx++) {
       sb.append("  ");
     }

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java Mon Mar 22
19:08:03 2010
@@ -782,7 +782,7 @@ public class JRecord extends JCompType {
     // precompute signature
     int idx = name.lastIndexOf('.');
     String recName = name.substring(idx+1);
-    StringBuffer sb = new StringBuffer();
+    StringBuilder sb = new StringBuilder();
     sb.append("L").append(recName).append("(");
     for (Iterator<JField<JType>> i = flist.iterator(); i.hasNext();) {
       String s = i.next().getType().getSignature();

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/util/Progress.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/util/Progress.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/util/Progress.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/util/Progress.java Mon Mar 22 19:08:03
2010
@@ -211,12 +211,12 @@ public class Progress {
   }
 
   public String toString() {
-    StringBuffer result = new StringBuffer();
+    StringBuilder result = new StringBuilder();
     toString(result);
     return result.toString();
   }
 
-  private synchronized void toString(StringBuffer buffer) {
+  private synchronized void toString(StringBuilder buffer) {
     buffer.append(status);
     if (phases.size() != 0 && currentPhase < phases.size()) {
       buffer.append(" > ");

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/util/StringUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/util/StringUtils.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/util/StringUtils.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/util/StringUtils.java Mon Mar 22 19:08:03
2010
@@ -128,7 +128,7 @@ public class StringUtils {
   
   public static String arrayToString(String[] strs) {
     if (strs.length == 0) { return ""; }
-    StringBuffer sbuf = new StringBuffer();
+    StringBuilder sbuf = new StringBuilder();
     sbuf.append(strs[0]);
     for (int idx = 1; idx < strs.length; idx++) {
       sbuf.append(",");
@@ -183,7 +183,7 @@ public class StringUtils {
     if (uris == null) {
       return null;
     }
-    StringBuffer ret = new StringBuffer(uris[0].toString());
+    StringBuilder ret = new StringBuilder(uris[0].toString());
     for(int i = 1; i < uris.length;i++){
       ret.append(",");
       ret.append(uris[i].toString());
@@ -247,7 +247,7 @@ public class StringUtils {
    * @param timeDiff The time difference to format
    */
   public static String formatTime(long timeDiff){
-    StringBuffer buf = new StringBuffer();
+    StringBuilder buf = new StringBuilder();
     long hours = timeDiff / (60*60*1000);
     long rem = (timeDiff % (60*60*1000));
     long minutes =  rem / (60*1000);
@@ -279,7 +279,7 @@ public class StringUtils {
    */
   public static String getFormattedTimeWithDiff(DateFormat dateFormat, 
                                                 long finishTime, long startTime){
-    StringBuffer buf = new StringBuffer();
+    StringBuilder buf = new StringBuilder();
     if (0 != finishTime) {
       buf.append(dateFormat.format(new Date(finishTime)));
       if (0 != startTime){
@@ -533,7 +533,7 @@ public class StringUtils {
    * @return a message for logging
    */
   private static String toStartupShutdownString(String prefix, String [] msg) {
-    StringBuffer b = new StringBuffer(prefix);
+    StringBuilder b = new StringBuilder(prefix);
     b.append("\n/************************************************************");
     for(String s : msg)
       b.append("\n" + prefix + s);
@@ -645,7 +645,7 @@ public class StringUtils {
       if(string == null) {
         return null;
       }
-      StringBuffer sb = new StringBuffer();
+      StringBuilder sb = new StringBuilder();
       boolean lastCharacterWasSpace = false;
       char[] chars = string.toCharArray();
       for(char c : chars) {
@@ -708,7 +708,7 @@ public class StringUtils {
    * @param strings Strings to join.
    */
   public static String join(CharSequence separator, Iterable<String> strings) {
-    StringBuffer sb = new StringBuffer();
+    StringBuilder sb = new StringBuilder();
     boolean first = true;
     for (String s : strings) {
       if (first) {

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/io/RandomDatum.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/io/RandomDatum.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/io/RandomDatum.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/io/RandomDatum.java Mon Mar 22 19:08:03
2010
@@ -64,7 +64,7 @@ public class RandomDatum implements Writ
 
   /** Returns a string representation of this object. */
   public String toString() {
-    StringBuffer buf = new StringBuffer(length*2);
+    StringBuilder buf = new StringBuilder(length*2);
     for (int i = 0; i < length; i++) {
       int b = data[i];
       buf.append(HEX_DIGITS[(b >> 4) & 0xf]);

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestText.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestText.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestText.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestText.java Mon Mar 22 19:08:03
2010
@@ -35,7 +35,7 @@ public class TestText extends TestCase {
   
   // generate a valid java String
   private static String getTestString(int len) throws Exception {
-    StringBuffer buffer = new StringBuffer();    
+    StringBuilder buffer = new StringBuilder();    
     int length = (len==RAND_LEN) ? RANDOM.nextInt(1000) : len;
     while (buffer.length()<length) {
       int codePoint = RANDOM.nextInt(Character.MAX_CODE_POINT);
@@ -60,7 +60,7 @@ public class TestText extends TestCase {
   public static String getLongString() throws Exception {
     String str = getTestString();
     int length = Short.MAX_VALUE+str.length();
-    StringBuffer buffer = new StringBuffer();
+    StringBuilder buffer = new StringBuilder();
     while(buffer.length()<length)
       buffer.append(str);
       

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestUTF8.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestUTF8.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestUTF8.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/io/TestUTF8.java Mon Mar 22 19:08:03
2010
@@ -29,7 +29,7 @@ public class TestUTF8 extends TestCase {
   private static final Random RANDOM = new Random();
 
   public static String getTestString() throws Exception {
-    StringBuffer buffer = new StringBuffer();
+    StringBuilder buffer = new StringBuilder();
     int length = RANDOM.nextInt(100);
     for (int i = 0; i < length; i++) {
       buffer.append((char)(RANDOM.nextInt(Character.MAX_VALUE)));

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/util/TestIndexedSort.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/util/TestIndexedSort.java?rev=926256&r1=926255&r2=926256&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/util/TestIndexedSort.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/util/TestIndexedSort.java Mon Mar
22 19:08:03 2010
@@ -294,7 +294,7 @@ public class TestIndexedSort extends Tes
       seed = r.nextLong();
       r.setSeed(seed);
       Text t = new Text();
-      StringBuffer sb = new StringBuffer();
+      StringBuilder sb = new StringBuilder();
       indices = new int[j];
       offsets = new int[j];
       check = new String[j];
@@ -315,7 +315,7 @@ public class TestIndexedSort extends Tes
       return seed;
     }
 
-    private static void genRandom(Text t, int len, StringBuffer sb) {
+    private static void genRandom(Text t, int len, StringBuilder sb) {
       sb.setLength(0);
       for (int i = 0; i < len; ++i) {
         sb.append(Integer.toString(r.nextInt(26) + 10, 36));



Mime
View raw message