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;
}
}