void distribution(string filename) { SimpleHash* hash = new SimpleHash(100000000); ifstream ifs(filename.c_str()); string line; while (ifs && getline(ifs,line)) { vector<string> k = split(line,'\t'); if (k.size() > 1) hash->increment(k[1].c_str()); } vector<string> keys = hash->keySet(); sort(keys.begin(),keys.end(), [](const string& x, const string& y) { return atoi(x.c_str()) < atoi(y.c_str()); }); for (uint i = 0; i < keys.size(); i++) { cout << keys[i] << "\t" << hash->get(keys[i].c_str()) << endl; } delete hash; }
//Get data from cache std::string getFromCache(std::string url){ return cacheTable.get(url); //return data obtained }