hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [30/30] hadoop git commit: MAPREDUCE-6730. Use StandardCharsets instead of String overload in TextOutputFormat. Contributed by Sahil Kang.
Date Thu, 04 Aug 2016 12:42:19 GMT
MAPREDUCE-6730. Use StandardCharsets instead of String overload in TextOutputFormat. Contributed
by Sahil Kang.

This closes #114


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/70c27811
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/70c27811
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/70c27811

Branch: refs/heads/HADOOP-12756
Commit: 70c278115249898132490a89a548fd936c09f54b
Parents: 08e3338
Author: Akira Ajisaka <aajisaka@apache.org>
Authored: Thu Aug 4 20:13:11 2016 +0900
Committer: Akira Ajisaka <aajisaka@apache.org>
Committed: Thu Aug 4 20:13:11 2016 +0900

----------------------------------------------------------------------
 .../apache/hadoop/mapred/TextOutputFormat.java  | 24 ++++++--------------
 .../mapreduce/lib/output/TextOutputFormat.java  | 24 ++++++--------------
 2 files changed, 14 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/70c27811/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TextOutputFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TextOutputFormat.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TextOutputFormat.java
index ca499e4..bf2f447 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TextOutputFormat.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TextOutputFormat.java
@@ -20,7 +20,7 @@ package org.apache.hadoop.mapred;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
@@ -43,26 +43,16 @@ public class TextOutputFormat<K, V> extends FileOutputFormat<K,
V> {
 
   protected static class LineRecordWriter<K, V>
     implements RecordWriter<K, V> {
-    private static final String utf8 = "UTF-8";
-    private static final byte[] newline;
-    static {
-      try {
-        newline = "\n".getBytes(utf8);
-      } catch (UnsupportedEncodingException uee) {
-        throw new IllegalArgumentException("can't find " + utf8 + " encoding");
-      }
-    }
+    private static final byte[] NEWLINE =
+      "\n".getBytes(StandardCharsets.UTF_8);
 
     protected DataOutputStream out;
     private final byte[] keyValueSeparator;
 
     public LineRecordWriter(DataOutputStream out, String keyValueSeparator) {
       this.out = out;
-      try {
-        this.keyValueSeparator = keyValueSeparator.getBytes(utf8);
-      } catch (UnsupportedEncodingException uee) {
-        throw new IllegalArgumentException("can't find " + utf8 + " encoding");
-      }
+      this.keyValueSeparator =
+        keyValueSeparator.getBytes(StandardCharsets.UTF_8);
     }
 
     public LineRecordWriter(DataOutputStream out) {
@@ -80,7 +70,7 @@ public class TextOutputFormat<K, V> extends FileOutputFormat<K,
V> {
         Text to = (Text) o;
         out.write(to.getBytes(), 0, to.getLength());
       } else {
-        out.write(o.toString().getBytes(utf8));
+        out.write(o.toString().getBytes(StandardCharsets.UTF_8));
       }
     }
 
@@ -101,7 +91,7 @@ public class TextOutputFormat<K, V> extends FileOutputFormat<K,
V> {
       if (!nullValue) {
         writeObject(value);
       }
-      out.write(newline);
+      out.write(NEWLINE);
     }
 
     public synchronized void close(Reporter reporter) throws IOException {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/70c27811/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/TextOutputFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/TextOutputFormat.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/TextOutputFormat.java
index 1522c4c..1c8ea72 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/TextOutputFormat.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/TextOutputFormat.java
@@ -20,7 +20,7 @@ package org.apache.hadoop.mapreduce.lib.output;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
@@ -45,26 +45,16 @@ public class TextOutputFormat<K, V> extends FileOutputFormat<K,
V> {
   public static String SEPERATOR = "mapreduce.output.textoutputformat.separator";
   protected static class LineRecordWriter<K, V>
     extends RecordWriter<K, V> {
-    private static final String utf8 = "UTF-8";
-    private static final byte[] newline;
-    static {
-      try {
-        newline = "\n".getBytes(utf8);
-      } catch (UnsupportedEncodingException uee) {
-        throw new IllegalArgumentException("can't find " + utf8 + " encoding");
-      }
-    }
+    private static final byte[] NEWLINE =
+      "\n".getBytes(StandardCharsets.UTF_8);
 
     protected DataOutputStream out;
     private final byte[] keyValueSeparator;
 
     public LineRecordWriter(DataOutputStream out, String keyValueSeparator) {
       this.out = out;
-      try {
-        this.keyValueSeparator = keyValueSeparator.getBytes(utf8);
-      } catch (UnsupportedEncodingException uee) {
-        throw new IllegalArgumentException("can't find " + utf8 + " encoding");
-      }
+      this.keyValueSeparator =
+        keyValueSeparator.getBytes(StandardCharsets.UTF_8);
     }
 
     public LineRecordWriter(DataOutputStream out) {
@@ -82,7 +72,7 @@ public class TextOutputFormat<K, V> extends FileOutputFormat<K,
V> {
         Text to = (Text) o;
         out.write(to.getBytes(), 0, to.getLength());
       } else {
-        out.write(o.toString().getBytes(utf8));
+        out.write(o.toString().getBytes(StandardCharsets.UTF_8));
       }
     }
 
@@ -103,7 +93,7 @@ public class TextOutputFormat<K, V> extends FileOutputFormat<K,
V> {
       if (!nullValue) {
         writeObject(value);
       }
-      out.write(newline);
+      out.write(NEWLINE);
     }
 
     public synchronized 


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message