谢谢Trisha。上面的链接正在执行MongoDB中可用的内置映射。我想要一个使用Hadoop和MongoDB的Map Reduce示例。我终于明白了。
public static class MongoMapper extends
Mapper<Object, BasicDBObject, Text, BSONWritable> {
public void map(Object key, BasicDBObject value, Context context)
throws IOException, InterruptedException {
//This gives all the documents of the company
BasicDBObject company = (BasicDBObject) value.get("company");
// This gets the company name
name = (String) company.get("name");
//This gives the phone number
phone = (String) company.get("phone");
如果我们需要访问公司的产品列表中,我们可以检索使用BasicDBList
// This will give the list of products and we can use product.get()
// to get the product name and other details.
BasicDBList product = (BasicDBList) company.get("products");
我提到了这个链接SlideShare上。
http://www.slideshare.net/spf13/introduction-to-mongodb-and-hadoop
有通过Java驱动程序在这里降低地图的例子:http://www.javacodegeeks.com/2012/06/mapreduce-with-mongodb.html。我发现把“mongodb map reduce java”放入Google,那里有更多的答案... – Trisha
谢谢Trisha。上面的链接正在执行MongoDB中可用的内置映射。我想要一个使用Hadoop和MongoDB的Map Reduce示例。我终于明白了。 – krish