Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CCECB200B5A for ; Thu, 4 Aug 2016 13:18:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CB753160AAB; Thu, 4 Aug 2016 11:18:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EAA0E160A7C for ; Thu, 4 Aug 2016 13:18:51 +0200 (CEST) Received: (qmail 86183 invoked by uid 500); 4 Aug 2016 11:18:51 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 86174 invoked by uid 99); 4 Aug 2016 11:18:51 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2016 11:18:51 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EEFA1E0A7D; Thu, 4 Aug 2016 11:18:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aajisaka@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: MAPREDUCE-6730. Use StandardCharsets instead of String overload in TextOutputFormat. Contributed by Sahil Kang. Date: Thu, 4 Aug 2016 11:18:50 +0000 (UTC) archived-at: Thu, 04 Aug 2016 11:18:53 -0000 Repository: hadoop Updated Branches: refs/heads/branch-2.8 ceac62837 -> 59693ebbd MAPREDUCE-6730. Use StandardCharsets instead of String overload in TextOutputFormat. Contributed by Sahil Kang. This closes #114 (cherry picked from commit 70c278115249898132490a89a548fd936c09f54b) (cherry picked from commit e54de94e5ab40405d837ee7664e90921f5bc38e4) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/59693ebb Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/59693ebb Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/59693ebb Branch: refs/heads/branch-2.8 Commit: 59693ebbd51e9219f3e8733becf52788668da884 Parents: ceac628 Author: Akira Ajisaka Authored: Thu Aug 4 20:13:11 2016 +0900 Committer: Akira Ajisaka Committed: Thu Aug 4 20:18:37 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/59693ebb/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 extends FileOutputFormat { protected static class LineRecordWriter implements RecordWriter { - 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 extends FileOutputFormat { 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 extends FileOutputFormat { 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/59693ebb/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 extends FileOutputFormat { public static String SEPERATOR = "mapreduce.output.textoutputformat.separator"; protected static class LineRecordWriter extends RecordWriter { - 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 extends FileOutputFormat { 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 extends FileOutputFormat { 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