瀏覽代碼

MAPREDUCE-5995. native-task: Revert changes to Text internals. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/MR-2841@1613828 13f79535-47bb-0310-9956-ffa450edef68
Todd Lipcon 10 年之前
父節點
當前提交
78d86a9839

+ 1 - 5
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/Text.java

@@ -226,10 +226,6 @@ public class Text extends BinaryComparable
     this.length = len;
   }
 
-  public void setLength(int len) {
-    this.length = len;
-  }
-
   /**
    * Append a range of bytes to the end of the given text
    * @param utf8 the data to copy from
@@ -264,7 +260,7 @@ public class Text extends BinaryComparable
    * @param len the number of bytes we need
    * @param keepData should the old data be kept
    */
-  public void setCapacity(int len, boolean keepData) {
+  private void setCapacity(int len, boolean keepData) {
     if (bytes == null || bytes.length < len) {
       if (bytes != null && keepData) {
         bytes = Arrays.copyOf(bytes, Math.max(len,length << 1));

+ 1 - 0
hadoop-mapreduce-project/CHANGES.MAPREDUCE-2841.txt

@@ -7,3 +7,4 @@ MAPREDUCE-5996. native-task: Rename system tests into standard directory layout
 MAPREDUCE-5997. native-task: Use DirectBufferPool from Hadoop Common (todd)
 MAPREDUCE-6000. native-task: Simplify ByteBufferDataReader/Writer (todd)
 MAPREDUCE-5991. native-task should not run unit tests if native profile is not enabled. (Binglin Chang)
+MAPREDUCE-5995. native-task: Revert changes to Text internals (todd)

+ 1 - 8
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/java/org/apache/hadoop/mapred/nativetask/serde/TextSerializer.java

@@ -42,13 +42,6 @@ public class TextSerializer implements INativeSerializer<Text>, INativeComparabl
 
   @Override
   public void deserialize(DataInput in, int length, Text w) throws IOException {
-    try {
-      w.setCapacity(length, true);
-      w.setLength(length);
-    } catch (final Exception e) {
-      throw new IOException(e);
-    }
-    final byte[] bytes = w.getBytes();
-    in.readFully(bytes, 0, length);
+    w.readWithKnownLength(in, length);
   }
 }