依然是mapper代码
import net.sf.json.JSONObject;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;
public class mappp extends Mapper <LongWritable, Text,Text, NullWritable>{
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
Text k=new Text();
String line=value.toString();
net.sf.json.JSONObject j = JSONObject.fromObject(line);
String[] d = new String[5];
d[1]=j.getString("date");
d[0]=j.getString("city");
d[1]=d[1].replace(".","/");
d[2] = j.getString("temp");
d[3] = j.getString("wind");
d[4] = j.getString("weather");
j.put("date",d[1]);
j.put("city",d[0]);
String end = "";
for (String item: d){
end = end + item + " ";
}
k.set(end);
context.write(k,NullWritable.get());
}
}