1. 问题的由来
相信大多数数据挖掘(准确的说数据仓库挖掘 MSR )爱好者,都热衷于通过软件开发过程中的种种数据来挖掘出我们想要的模式,经验,或者未知的东西。因此,之前 MSR 社区研究者经常活跃在 SVN,CVS 等代码管理系统上,自从 2008 年 GitHub 出生以后,大多数人的目光逐渐转移到了 GitHub 这个如今最大的开源代码托管平台上了,人们希望得到 GitHub 上项目开发过程中的种种数据,包括项目开发者信息,代码库信息,提交信息,合并信息,bug 信息等等。
为了方便人们进入更深次的研究,GitHub 决定开放其接口,便于人们通过接口的调用形式来获取相应的信息。接口名字为REST API (已更新到第三版,故又称 REST API v3) [4]。原理也很简单,就是用过 GET 等基本 http 请求来想接口进行请求,然后服务器 (
https://api.github.com/) [5] 返回结果。例如,我想要查询名字叫 Gu-Youngfeng 这个开发者 (正是鄙人) 的信息,我可以在浏览器中输入,
https://api.github.com/users/Gu-Youngfeng
或者你在 Linux 终端输入 curl 命令,
curl -i
https://api.github.com/users/Gu-Youngfeng
二者效果一样,服务器都会监听到我的请求,并且返回相应我的信息,如下 (直截取部分信息)
{
"
login": "Gu-Youngfeng",
"
id": 30207109,
"
avatar_url": "https://avatars1.githubusercontent.com/u/30207109?v=4",
...
"
name": "Gu-youngfeng",
"
company": null,
"
blog": "",
"
location": "Wuhan, China",
...
}
但是很快,研究者就发现了这套 api 接口的局限性:
单个账号每小时只能调用 5000 次。要知道 Gihub 平均每小时要处理 8300 次事件 (event),这也就意味着单个账号无法获取整个数据集的镜像 (因为有额外的几千次事件,我们无法在同一个小时获取到)。
2. GHTorrent 诞生
2013年,荷兰 Delft 科技大学的软件工程组的 Gousios 在 MSR 发表论文 The GHTorrent dataset and tool suite [2],正式推出了 GHTorrent 工具,这个工具通过缓存和并行技术,很好的突破了每小时5000次调用的瓶颈,官方网站 [1] 给出了 GHTorrent 的简单介绍,
GHTorrent project, an effort to create a scalable, queriable, offline mirror of data offered through the Github REST API.
GHTorrent monitors the Github public event time line. For each event, it retrieves its contents and their dependencies, exhaustively. It then stores the raw JSON responses to a MongoDB database, while also extracting their structure in a MySQL database.
由官网的这2句话可知,首先 GHTorrent 是一个能够给我们提供可拓展的,可查询的,离线的 GitHub 数据镜像。它的原理是通过调用 Github REST API 接口的来获取数据的。其次 GHTorrent 记录的是 GitHub 上的公共事件时间线(public event time line),对于每一个事件,它都会记录依赖和内容,然后以 JSON 格式存储在 MongoDB 的数据库中。
未完待遇 To be continued...
---------------
参考
[1] The GHTorrent project.
http://www.ghtorrent.org/
[2] Gousios, Georgios. The GHTorrent dataset and tool suite[J]. 2013:233-236.
[3] Gousios G, Vasilescu B, Serebrenik A, et al. Lean GHTorrent: GitHub data on demand[C]// Working Conference on Mining Software Repositories. ACM, 2014:384-387.
[4] REST API v3.
https://developer.github.com/v3/