hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r789242 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/io/Text.java
Date Mon, 29 Jun 2009 07:16:57 GMT
Author: cdouglas
Date: Mon Jun 29 07:16:56 2009
New Revision: 789242

URL: http://svn.apache.org/viewvc?rev=789242&view=rev
Log:
HADOOP-6109. Change Text to grow its internal buffer exponentially, rather
than the max of the current length and the proposed length to improve
performance reading large values. Contributed by thushara wijeratna

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/io/Text.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=789242&r1=789241&r2=789242&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Mon Jun 29 07:16:56 2009
@@ -464,6 +464,10 @@
 
     HADOOP-5925. EC2 scripts should exit on error. (tomwhite)
 
+    HADOOP-6109. Change Text to grow its internal buffer exponentially, rather
+    than the max of the current length and the proposed length to improve
+    performance reading large values. (thushara wijeratna via cdouglas)
+
   OPTIMIZATIONS
 
     HADOOP-5595. NameNode does not need to run a replicator to choose a

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/Text.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/Text.java?rev=789242&r1=789241&r2=789242&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/Text.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/Text.java Mon Jun 29 07:16:56 2009
@@ -31,6 +31,7 @@
 import java.nio.charset.MalformedInputException;
 import java.text.CharacterIterator;
 import java.text.StringCharacterIterator;
+import java.util.Arrays;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -237,11 +238,11 @@
    */
   private void setCapacity(int len, boolean keepData) {
     if (bytes == null || bytes.length < len) {
-      byte[] newBytes = new byte[len];
       if (bytes != null && keepData) {
-        System.arraycopy(bytes, 0, newBytes, 0, length);
+        bytes = Arrays.copyOf(bytes, Math.max(len,length << 1));
+      } else {
+        bytes = new byte[len];
       }
-      bytes = newBytes;
     }
   }
    



Mime
View raw message