手游-cfm星辰裸奔吸附公益辅助
卡密随便输入即可
地址:
**** Hidden Message *****
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;
// Mapper 类
public static class PurchaseCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
String[] parts = line.split("\t");// 根据实际数据的分隔符进行拆分
String goods = parts;// 假设商品名称在第二列
context.write(new Text(goods), new IntWritable(1));
}
}
// Reducer 类
public static class PurchaseCountReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
@Override
protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable value : values) {
sum += value.get();
}
context.write(key, new IntWritable(sum));
}
}
啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊 谢谢你的支持! :lol:lol:lol:lol 应该不会被封吧?
支持你奥,正需要,辛苦啦!
页:
[1]