Created
July 22, 2012 14:25
-
-
Save kei-q/3159851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 以下ghci | |
| # まずは結果を適当な名前(mrlout)を付けて記録 | |
| # それを対象にfindとかでqueryを投げる | |
| # rSortは結局なにに使うのかわからなかった | |
| > (Right cursor) <- access' $ DB.runMR' mapReduce {DB.rOut = DB.Output DB.Replace "mrlout" Nothing} | |
| >(Right result) <- access' $ DB.find (DB.select [] "mrlout") {DB.sort=["value"=:1]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dbname = "hoge" | |
| access' action = do | |
| pipe <- DB.runIOE $ DB.connect (DB.host "localhost") | |
| DB.access pipe DB.master dbname action | |
| mapFn = Bson.Javascript [] "function() {for(i in this.category) {emit(this.category[i], 1);}}" | |
| reduceFn = Bson.Javascript [] "function(p, cur) {var c=0; for(i in cur){c+= cur[i];}; return c;}" | |
| mapReduce = DB.mapReduce "Pkg" mapFn reduceFn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment