{"id":20578782,"url":"https://github.com/cclient/mongo_hadoop_map-reduce","last_synced_at":"2026-04-14T23:34:35.260Z","repository":{"id":31906902,"uuid":"35475982","full_name":"cclient/mongo_hadoop_map-reduce","owner":"cclient","description":"Hadoop引用mongodb支持包，实现MapReduce分析Mongodb数据库基础示例。spark支持mongodb后，该方法已无价值","archived":false,"fork":false,"pushed_at":"2017-09-06T13:33:33.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T11:43:47.947Z","etag":null,"topics":["hadoop","mongodb","spark"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cclient.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-12T08:22:52.000Z","updated_at":"2019-03-15T03:06:39.000Z","dependencies_parsed_at":"2022-08-25T05:41:18.359Z","dependency_job_id":null,"html_url":"https://github.com/cclient/mongo_hadoop_map-reduce","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cclient/mongo_hadoop_map-reduce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fmongo_hadoop_map-reduce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fmongo_hadoop_map-reduce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fmongo_hadoop_map-reduce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fmongo_hadoop_map-reduce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cclient","download_url":"https://codeload.github.com/cclient/mongo_hadoop_map-reduce/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fmongo_hadoop_map-reduce/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31819950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hadoop","mongodb","spark"],"created_at":"2024-11-16T06:14:34.560Z","updated_at":"2026-04-14T23:34:35.220Z","avatar_url":"https://github.com/cclient.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"### 官方 http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-hadoop/\n\n### mongo-haoop项目地址 https://github.com/mongodb/mongo-hadoop\n\n\n原业务 由nodejs+async编写,较耗时且分布式实现复杂,改为map、reduce实现。\n\nMongo collection 数据格式\n\nclientMac和url 先拼在一起，再按mac长度分割\n\nmongodb 原始数据\n{\n    \"_id\" : ObjectId(\"54d83f3548c9bc218e056ce6\"),\n    \"apMac\" : \"aa:bb:cc:dd:ee:ff\",\n    \"proto\" : \"http\",\n    \"url\" : \"extshort.weixin.qq.com\",\n    \"clientMac\" : \"ff:ee:dd:cc:bb:aa\"\n}\n\n要求 计算每个apMac下每个clientMac top100的url\n\nmap:因(clientMac长度固定,按字符分拆clientMac和url即可,因此未用分隔符)\n\n[{apmac:[clientmac+url]}]\n\n例\n\n[{\"aa:bb:cc:dd:ee:ff\":[ff:ee:dd:cc:bb:aaextshort.weixin.qq.com]}]\n\ncompine: 如果有相同的client+url 则统计个数，以|分隔\n\n[{apmca:[clientmac+url|url_num]}]\n\n例\n\n[{\"aa:bb:cc:dd:ee:ff\":[ff:ee:dd:cc:bb:aaextshort.weixin.qq.com|100]}]\n\nreducer:按mac长度和\"|\"分隔出clientMac、url、url_num\n\n聚合取url_num sum,取top100\n\n最后结果如下\n\n{\n    \"_id\": \"00:21:26:00:0A:FF\",\n    \"aa:bb:cc:1c:b9:8f\": {\n        \"c.tieba.baidu.com\": 1,\n        \"short.weixin.qq.com\": 1,\n        \"get.sogou.com\": 1,\n        \"md.openapi.360.cn\": 1,\n        \"74.125.235.224\": 1,\n        \"mmbiz.qpic.cn\": 1,\n        \"tb.himg.baidu.com\": 1\n    },\n    \"cc:bb:aa:d5:30:8a\": {\n        \"captive.apple.com\": 2,\n        \"www.airport.us\": 1,\n        \"www.itools.info\": 2,\n        \"www.thinkdifferent.us\": 1,\n        \"www.ibook.info\": 1\n    },\n    \"ee:ee:bb:78:31:74\": {\n        \"www.itools.info\": 1,\n        \"www.ibook.info\": 1\n    }\n}\n\n因为不同版本的mongo对 key里的.号处理方式不同(字符串或子对象的key),实际执行时.都先统一替换为}再处理,为方便理解,文档依然用.表示\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcclient%2Fmongo_hadoop_map-reduce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcclient%2Fmongo_hadoop_map-reduce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcclient%2Fmongo_hadoop_map-reduce/lists"}