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 git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@789242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1d6d98c9fb
commit
e93ebeae51
|
@ -464,6 +464,10 @@ Trunk (unreleased changes)
|
||||||
|
|
||||||
HADOOP-5925. EC2 scripts should exit on error. (tomwhite)
|
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
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-5595. NameNode does not need to run a replicator to choose a
|
HADOOP-5595. NameNode does not need to run a replicator to choose a
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.nio.charset.CodingErrorAction;
|
||||||
import java.nio.charset.MalformedInputException;
|
import java.nio.charset.MalformedInputException;
|
||||||
import java.text.CharacterIterator;
|
import java.text.CharacterIterator;
|
||||||
import java.text.StringCharacterIterator;
|
import java.text.StringCharacterIterator;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -237,11 +238,11 @@ public class Text extends BinaryComparable
|
||||||
*/
|
*/
|
||||||
private void setCapacity(int len, boolean keepData) {
|
private void setCapacity(int len, boolean keepData) {
|
||||||
if (bytes == null || bytes.length < len) {
|
if (bytes == null || bytes.length < len) {
|
||||||
byte[] newBytes = new byte[len];
|
|
||||||
if (bytes != null && keepData) {
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue