static class ReadFromGzipFileToTextFileMapper extends Mapper<LongWritable,
Text, NullWritable, Text> {
protected void map(LongWritable key, Text value, Context context) throws
IOException, InterruptedException {
Counter counter = context.getCounter("file_records_counters", "Files
of User Records");
counter.increment(1);
context.write(NullWritable.get(), value);
}
}
static class ReadFromGzipFileToTextFileReducer extends Reducer<NullWritable,
Text, NullWritable, Text> {
protected void reduce(NullWritable key, Iterable<Text> values, Context
context)
throws IOException, InterruptedException {
for (Text value : values) {
context.write(NullWritable.get(), value);
}
}
}
}
mvn clean package -Pdist,native -DskipTests -Dtar -Dbundle.snappy -
Dsnappy.lib=/usr/local/lib
//配置Map输出结果压缩为Snappy格式
// conf.set("mapreduce.map.output.compress","true");
//
conf.set("mapreduce.map.output.compress.codec","org.apache.hadoop.io.compress.Sn
appyCodec");
//配置Reduce输出结果压缩为Snappy格式
// conf.set("mapreduce.output.fileoutputformat.compress","true");
评论0