Database Reference
In-Depth Information
/* (non-Javadoc)
* @see org.apache.hadoop.mapreduce.Mapper#map(KEYIN,
VALUEIN, org.apache.hadoop.mapreduce.
Mapper.Context)
*/
public void map(LongWritable key, Text value, Context
context)
throws IOException, InterruptedException
{
// split into tokens and pass date and count as
key.
String[] values =
StringUtils.split(value.toString(), "\001");
if(values.length >=2 && values.length <=3)
{
context.write(new Text(values[0]), one); //
count on by date.
context.write(new Text(values[1]), one); //
count on users.
}
}
}
}
Now, let's have a look at the reducer ( TweetAggregator ):
public static class TweetAggregator extends
org.apache.hadoop.mapreduce.Reducer<Text, IntWritable,
ByteBuffer, List<Mutation>>
{
public void reduce(Text word,
Iterable<IntWritable> values, Context context) throws
IOException,
InterruptedException
{
int sum = 0;
for (IntWritable val : values)
Search WWH ::




Custom Search