/ / Cómo mostrar valores en la función Reducir - json, hadoop, mapreduce

Cómo mostrar valores en la función Reducir - json, hadoop, mapreduce

Soy capaz de analizar los datos de Json usando mapreduce en hadoop, y quería mostrar 2 variables de cadena, ya que está en función de reducción. A continuación se muestra el código que probé

  public static class Map extends Mapper<LongWritable, Text, Text, Text>{
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException{

Double overall;
String reviewtime;
String line = value.toString();
//line  = line.replaceAll("\s+","");
String[] tuple = line.split("\n");
try{
for(int i=0;i<tuple.length; i++){
JSONObject obj = new JSONObject(tuple[i]);
overall = obj.getDouble("overall");
reviewtime = obj.getString("reviewTime");
context.write(new Text(String.valueOf(overall)), new Text(reviewtime));

}
}catch(JSONException e){
e.printStackTrace();
}
}
}

Qué escribir en la función Reducir para que pueda desplegar más de 2 variables de cadena en la función Reducir ... Soy nuevo en mapreduce y hadoop. Por favor, ayúdenme, a continuación se muestra el cuerpo de la función Reducir.

 public static class Reduce extends Reducer<Text,Text,NullWritable,Text>{

public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException{

try{



}catch(JSONException e){
e.printStackTrace();
}
}
}

Respuestas

0 para la respuesta № 1

Lo tengo, esta es la correcta,

 public static class Reduce extends Reducer<Text,Text,NullWritable,Text>{

public void reduce(NullWritable key, Iterable<Text> values, Context context) throws IOException, InterruptedException{

try{
for(Text val : values){

context.write(key, new Text(val.toString()));
}
}catch(JSONException e){
e.printStackTrace();
}
}
}