/** * Expert users can override this method for more complete control over the execution of the * Mapper. * * @param context * @throws IOException */ public void run(Context context) throws IOException, InterruptedException { setup(context); while (context.nextKeyValue()) { map(context.getCurrentKey(), context.getCurrentValue(), context); } cleanup(context); }
@Override protected void map(Text key, PageInvertWritable value, Context context) throws IOException, InterruptedException { if (key.getBytes()[0] == 'W') { super.map(new Text(new String(key.toString()).substring(1)), value, context); } }
@Override protected void map( final LongWritable key, final DoubleWritable value, final org.apache.hadoop.mapreduce.Mapper.Context context) throws IOException, InterruptedException { long positiveKey = key.get(); double adjustedValue = value.get(); if (positiveKey < 0) { positiveKey = -positiveKey - 1; adjustedValue *= -1; } super.map(new LongWritable(positiveKey), new DoubleWritable(adjustedValue), context); }