謝謝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