From c272dbec7ebd18f810ecdd13c63cd0c767b4ed4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=E5=98=89=E9=98=B3?= Date: Wed, 18 Apr 2018 22:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8Combiner=E5=8A=A0=E5=BF=AB?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 69 +++++++++++-------- pom.xml | 2 +- .../fjy/hadoop/mapreduce/WordCountApp.java | 4 ++ 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 02c16e1..e128e88 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,6 +3,7 @@ + @@ -19,8 +20,8 @@ - - + + @@ -29,7 +30,7 @@ - + @@ -41,8 +42,8 @@ - - + + @@ -122,8 +123,8 @@ @@ -505,7 +506,7 @@ - + 1521904777876 @@ -542,7 +543,14 @@ - @@ -578,7 +586,7 @@ - @@ -625,7 +633,8 @@ - @@ -918,14 +927,6 @@ - - - - - - - - @@ -943,16 +944,6 @@ - - - - - - - - - - @@ -991,10 +982,28 @@ + + + + + + + + + + + + + + + + + + - - + + diff --git a/pom.xml b/pom.xml index fd500f3..6137ba9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.fjy.hadoop hadoopstudy - 1.0-SNAPSHOT + 0.3 jar hadoopstudy diff --git a/src/main/java/com/fjy/hadoop/mapreduce/WordCountApp.java b/src/main/java/com/fjy/hadoop/mapreduce/WordCountApp.java index c75ed56..20e6953 100644 --- a/src/main/java/com/fjy/hadoop/mapreduce/WordCountApp.java +++ b/src/main/java/com/fjy/hadoop/mapreduce/WordCountApp.java @@ -119,6 +119,10 @@ public class WordCountApp { job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); + //通过job设置combiner处理类,逻辑上与reduce一致,注意,如果要计算平均数等不能使用Combiner! + job.setCombinerClass(MyReducer.class); + + //设置作业处理输出结果的输出路径 FileOutputFormat.setOutputPath(job, new Path(args[1]));