更新 '2.4.cpp'

This commit is contained in:
Kirigaya Kazuto 2017-09-17 20:35:02 +08:00
parent 4b0eed8e40
commit 37b51e3775

21
2.4.cpp
View File

@ -64,6 +64,27 @@ int main()
});
});
conn.exec("use bigdata2",nullptr);
conn.exec("select job_city,count(*) from (select job_city from pages group by company_name) as B group by job_city",
[&](MySQLResult& res)
{
res.stepRow([&](char** val,unsigned long* len)
{
string city(val[0]);
int cnt=ParseInt(val[1]);
auto iter=mp.find(city);
if(iter!=mp.end())
{
iter->second += cnt;
}
else
{
mp.insert(make_pair(city,cnt));
}
});
});
for(auto iter=mp.begin();iter!=mp.end(); )
{
bool updated=false;