嗨,我是使用还原剂的新手
将其视为我的输入文件
hi,how,1,a,b,are,you,xxx,xxxx,xxxxx
hi,how,1,a,b,are,you,xxx,xxxx,xxxxx
hi,how,1,a,b,i,am,yyyy,yyyy,yyyy
hi,how,1,a,b,i,am,yyyy,yyyy,yyyy
hi,how,2,a,b,are,you,xxx,xxxx,xxxxx
hi,how,2,a,b,are,you,xxx,xxxx,xxxxx
hi,how,2,a,b,i,am,yyyy,yyyy,yyyy
hi,how,3,a,b,are,you,yyyy,yyyy,yyyy
hi,how,3,a,b,i,am,yyyy,yyyy,yyyy
hi,how,4,a,b,are,you,yyyy,yyyy,yyyy
hi,how,4,a,b,are,you,yyyy,yyyy,yyyy
hi,how,4,a,b,i,am,xxx,xxxx,xxxxx
这是我的地图功能
@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
{
String Str_line = value.toString();
String[] input = Str_line.split(",");
Text Outkey = new Text();
Outkey.set(input[2]);
context.write(Outkey),null);
}
这是我的还原函数
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
context.write(key, null);
}
我需要这样的输出你好,你好吗,你嗨,你好,我你好,你好,你嗨,你好,2,我嗨,你好,3嗨,你好,3,我你好,你好,你你好,我是
映射器代码:-
@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
{
String Str_line = value.toString();
String[] input = Str_line.split(",");
Text Outkey = new Text();
Outkey.set(input[0]+","+input[1]+","+input[2]+","+input[5]+","+input[6]);
context.write(Outkey,NullWritable.get);
}
减速器代码:-
public void reduce(Text Key,Iterable<NullWritable> Values,Context context) throws IOException, InterruptedException {
context.write(NullWritable.get(),key);
}