#include "MySQLWrapper.h" #include #include #include #include #include #include #include #include #include using namespace std; #include "local_db_account.h" #include "util.hpp" int main() { MySQLConn conn; conn.connect("127.0.0.1",db_user,db_passwd,"bigdata3",3306); cout<<"Connected to DB"<> mp; conn.exec("select job_city,salary from lagou_job",[&](MySQLResult& res) { res.stepRow([&](char** val,unsigned long* len) { string city(val[0]); cash_pack pk=ParseCash(val[1]); mp[Trim(city)].push_back(pk); }); }); conn.exec("use bigdata5",nullptr); conn.exec("select job_city,salary from lagou_job",[&](MySQLResult& res) { res.stepRow([&](char** val,unsigned long* len) { string city(val[0]); cash_pack pk=ParseCash(val[1]); mp[Trim(city)].push_back(pk); }); }); ofstream ofs("result/2.1.csv"); for(auto iter=mp.begin();iter!=mp.end(); ) { bool updated=false; for(auto xiter=mp.begin();xiter!=iter; ) { if(iter->first.find(xiter->first)!=string::npos) { /// Found something? /// targetvec.push_back(thisvec) : Add current vector to the previous vector. xiter->second.insert(xiter->second.end(), iter->second.begin(),iter->second.end()); /// iter should now be deleted. Get next iter first auto nowiter=iter; ++iter; mp.erase(nowiter); /// Stop internal loop. updated=true; break; } else ++xiter; } if(!updated) ++iter; } #define cout ofs for(auto& pr:mp) { cout<