void Server::reduce() { stringstream ss; string day; Cities cities; vector<Reducer*> reducers; Reducer* reducer; for (size_t i = 1; i <= MARCH_DAYS;) { for (size_t j = 0; j < MAX_REDUCERS && i <= MARCH_DAYS; ++j) { ss << i; day = ss.str(); if (tmpts.get_if_has_key(day, cities)) { reducers.push_back(new Reducer(day, cities, results)); reducers.back()->start(); } ss.str(""); ++i; } while (!reducers.empty()) { reducer = reducers.back(); reducers.pop_back(); reducer->join(); delete reducer; } } }
void ExpressionVariable::Output(std::ostream &out) const { output_cast(out); Reducer* reducer = CGOptions::get_reducer(); if (reducer && reducer->output_expr(this, out)) { return; } int i; int indirect_level = get_indirect_level(); if (indirect_level > 0) { out << "("; for (i=0; i<indirect_level; i++) { out << "*"; } } else if (indirect_level < 0) { assert(indirect_level == -1); out << "&"; } var.Output(out); if (indirect_level > 0) { out << ")"; } }
void ExpressionFuncall::Output(std::ostream &out) const { output_cast(out); Reducer* reducer = CGOptions::get_reducer(); if (reducer && reducer->output_expr(this, out)) { return; } invoke.Output(out); }
RankingMaker::RankingMaker(WeatherMap *weather_info){ WeatherMapIt it = weather_info->begin(); WeatherMapIt it_end = weather_info->end(); for (; it != it_end; ++it){ Reducer *reducer; if (reducers.find(it->first)!= reducers.end()){ reducer = reducers.find(it->first)->second; }else{ reducer = new Reducer(); reducers.insert(ReducerMap::value_type(it->first, reducer)); } reducer->add(it->second); } }
void ExpressionComma::Output(std::ostream &out) const { output_cast(out); Reducer* reducer = CGOptions::get_reducer(); if (reducer && reducer->output_expr(this, out)) { return; } out << "("; lhs.Output(out); out << " , "; rhs.Output(out); out << ")"; }