I have 2 files of the form
File 1:
key1 value1
key2 value2
...
File 2:
key1 value3
key2 value4
...
I would like to produce a reduce output of the form
key1 (value1-value3)/value1
key2 (value2-value4)/value2
I have the map write the key and the value is prepended with a character telling it is coming from file1 or file2, but not sure how to write the reduce stage
My map method is
public void map(LongWritable key,Text val,Context context) throws IOException, InterruptedException
{
Text outputKey = new Text();
Text outputValue = new Text();
outputKey.set(key.toString());
if ("A")
{
outputValue.set("A,"+val);
}
else
{
outputValue.set("B," + val);
}
context.write(outputKey, outputValue);
}
}