直接上代碼 java.util.List<ServerAddress> mongoHostList = new ArrayList<ServerAddress>();mongoHostList.add(new ServerAddress("192.168.1.102",27017));Mongo mg = new Mongo(mongoHostList);DB db = mg.getDB("recommend");if (
下面的例子是在小資料下測試的,我嘗試在單機的千萬層級測試,等很久都沒結果... 資料有表:crawler.videos,表結構是: _id, playUrl, siteId...只有_id是有索引的,siteId不同的值分別代表不同的網站。值有:1,2,3三個值。現在要統計資料庫中每個網站的所含有的id數。就是相當於在mySql中select count(_id),siteId from videos group by siteId 的語句。以siteId分組,統計各siteId所含有的id數。
直接貼英文,翻譯不好反而影響讀者,英文如下:GridFS ExampleThis example shows how to use gridfs to store large binaryobjects (e.g. files) in MongoDB.See alsoThe API docs for gridfs.See alsoThis blog postfor some motivation behind this API.SetupWe start by creating a
文章目錄 Relational vs. Documentoriented http://www.blogjava.net/czihong/archive/2012/02/18/370250.html, Schema Design for MongoDBhttp://docs.mongodb.org/manual/core/data-modeling/, Data Modeling Considerations for MongoDB