Slide 25
Slide 25 text
Mapper Example
public
class
Map
extends
Mapper
{
public
void
map(Object
key,
BSONObject
doc,
Context
context)
{
List
genres
=
(List)doc.get("genres");
for(String
genre
:
genres)
{
context.write(new
Text(genre),
new
IntWritable(1));
}
}
}
{
_id:
ObjectId(…),
title:
“Toy
Story”,
genres:
[“Animation”,
“Children”]
}
{
_id:
ObjectId(…),
title:
“Goldeneye”,
genres:
[“Action”,
“Crime”,
“Thriller”]
}
{
_id:
ObjectId(…),
title:
“Jumanji”,
genres:
[“Adventure”,
“Children”,
“Fantasy”]
}