void BatchUpdaterBulletinClickReplicaAdapter::click(int userId, int bulletinId) { MyUtil::IntSeq keyvalue; keyvalue.push_back(userId); keyvalue.push_back(bulletinId); _clientCS.getProxy(INDEX)->inc(keyvalue, 1, BulletinClickName); }
MyUtil::IntSeq OfferCacheDataI::getIds(){ MyUtil::IntSeq res; IceUtil::Mutex::Lock lock(_mutex); for(OfferDataNSeq::iterator iter=bestOffers.begin(); iter!=bestOffers.end(); ++iter){ res.push_back(iter->userId); } for(OfferDataNSeq::iterator iter=offers.begin(); iter!=offers.end(); ++iter){ res.push_back(iter->userId); } return res; }
void ReloadTask::handle(){ MyUtil::IntSeq buddies; try { buddies = BuddyByIdCacheAdapter::instance().getFriendListAsc( _id, -1 ); } catch( Ice::Exception e ){ MCE_WARN("[ReloadTask] id=" << _id << " found Ice::Exception : " << e.what() ); return; } catch( ... ){ MCE_WARN("[ReloadTask] id=" << _id << " found Ice::Exception" ); return; } multimap<int, int> orderFriend; try{ Statement sql; sql << "SELECT guest, UNIX_TIMESTAMP(time) AS time FROM relation_" << (_id % 100) << " WHERE host=" << _id; ostringstream pattern; pattern << "relation_" << (_id % 100); QueryRunner("relation_buddycache", CDbRServer, pattern.str()).query( sql, OrderedListHandler( buddies, orderFriend, "time", "guest" ) ); }catch(std::exception& e){ MCE_WARN( "[ReloadTask] handle " << _id << " std::exception " << e.what() ); return; }catch(...){ MCE_WARN( "[ReloadTask] handle " << _id << " unknown exception." ); return; } int time_now = (int)time(NULL); MyUtil::IntSeq times; ostringstream timestr; for( MyUtil::IntSeq::iterator itB=buddies.begin(); itB!=buddies.end(); ++itB ){ times.push_back( time_now ); timestr << time_now << " "; } for (multimap<int, int>::reverse_iterator itMap = orderFriend.rbegin(); itMap != orderFriend.rend(); ++itMap ){ buddies.push_back(itMap->second); times.push_back(itMap->first); timestr << itMap->first << " "; } BuddyByAddTimeDataNPtr obj = new BuddyByAddTimeDataN; buddies.swap(obj->friends); times.swap(obj->times); MCE_INFO("[ReloadTask] id=" << _id << " friends.size()=" << obj->friends.size() << " times=" << timestr.str() ); SetDataHelper::instance().invokeDelay(_id,obj,timestr.str()); }
void UserCounterI::sort() { map<int, int> m; for (unsigned int i = 0; i < types.size(); ++i) { m.insert(make_pair(types[i], values[i])); } MyUtil::IntSeq t; MyUtil::IntSeq v; for (map<int, int>::iterator i = m.begin(); i != m.end(); ++i) { t.push_back(i->first); v.push_back(i->second); } types = t; values = v; }
//获取uid的好友用户中不是gid的粉丝的那些用户 MyUtil::IntSeq MutualFriendsCacheManagerI::getUnMutualFriends(int uid, const MyUtil::GlobalIdPtr& gid, int begin, int limit, const Ice::Current& current) { ostringstream msg; msg << "uid = " << uid << ", gid = " << GlobalIdTransfer::get(gid) << ", begin = " << begin << ", limit = " << limit; InvokeClient ic = InvokeClient::create(current, msg.str(), InvokeClient::INVOKE_LEVEL_INFO); MyUtil::IntSeq fids = getAllFansAsc(gid); MyUtil::IntSeq uids = getFriendsAsc(uid); MyUtil::IntSeq result; if (limit < -1 || begin < 0 || uid < 0) { return result; } else { int count = 0; int countLimit = (limit == -1) ? uids.size() : limit; MyUtil::IntSeq::iterator fit = fids.begin(); MyUtil::IntSeq::iterator uit = uids.begin(); while (fit != fids.end() && uit != uids.end() && count < countLimit + begin) { if (*fit < *uit) { fit++; } else if (*uit < *fit) { if(count >= begin){ result.push_back(*uit); } count++; uit++; } else { fit++; uit++; } } return result; } }
void xce::distcache::userapicache::UpdateTask::handle() { if(xce::distcache::userapicache::DistUserApiCacheReloaderI::instance().getFilter()->filter(data_->userid)) { xce::distcache::userapicache::UserApiCacheMemDataPtr datad = NULL; try { datad = GetNewData(); } catch (std::exception e) { MCE_WARN("ReloadTask::handle exception: id=" << data_->userid << ", " << e.what()); } catch (...) { MCE_WARN("ReloadTask::handle exception: id=" << data_->userid << ", Unknown exception"); } if(datad) { try { xce::distcache::userapicache::DistUserApiCacheAdapter::instance().set(datad); }catch(...) { MCE_WARN("UpdateTask::handle set distcache Exception: id = " << data_->userid); } } xce::distcache::userapicache::DistUserApiCacheReloaderI::instance().getFilter()->remove(data_->userid); }else { MyUtil::IntSeq ids; ids.push_back(data_->userid); MCE_WARN("UpdateTask::handle muticall id = " << data_->userid); xce::distcache::userapicache::DistUserApiCacheReloaderI::instance().getFilter()->remove(ids); xce::distcache::userapicache::DistUserApiCacheReloaderI::instance().addDelayReloadIds(ids); } }
Ice::ObjectPtr UserApiCacheFactoryI::create(Ice::Long id) { MCE_WARN("UserApiCacheFactoryI::create -> No Hit For Id: "<<id); MyUtil::IntSeq ids; ids.push_back(id); UserApiCacheReloaderAdapter::instance().getProxy(0)->reload(ids); return NULL; }
void RecentContactSet::updateDb(int ownerId,const ContactInfoSeq& contactInfos){ GetProps& props = GetProps::instance(); string table = props.getTableName(ownerId); Statement sqlAdd; size_t guests_size = contactInfos.size() > size_t(GUESTS_SIZE) ? size_t(GUESTS_SIZE):contactInfos.size(); MyUtil::IntSeq byteSeq; for ( size_t i = 0; i < guests_size; ++i ) { byteSeq.push_back((contactInfos[i]->guestId)); byteSeq.push_back(time(NULL)); byteSeq.push_back((contactInfos[i]->type)); } sqlAdd << "REPLACE INTO " << table << "(" << COLUMN_HOST << ", " << COLUMN_GUESTS << ")" << " values" << " ("<< ownerId << ","<<mysqlpp::quote<<IntSeqSerialize::serialize(byteSeq)<<")"; // QueryRunner(DB_SOURCE, CDbWServer, table).execute(sqlAdd); QueryRunner(DB_SOURCE, CDbWServer, table).schedule(sqlAdd); }
MyUtil::IntSeq RecentlyOnlineBuddyData::get_most_recent(int limit) { IceUtil::Mutex::Lock lock(*this); MyUtil::IntSeq result; for (std::deque<int>::reverse_iterator it = _buddies.rbegin(); (int) result.size() < limit && it != _buddies.rend(); ++it) { if (find(result.begin(), result.end(), *it)!=result.end()) continue; result.push_back(*it); } return result; }
// FriendRankLoaderFactory::create(Ice::Int userId) {{{ Ice::ObjectPtr FriendRankLoaderFactory::create(Ice::Int userId) { MCE_INFO("FriendRankLoaderI::create single -> id: "<<userId); MyUtil::IntSeq ids; ids.push_back(userId); MyUtil::ObjectResultPtr results = create(ids); return results->data[userId]; }// }}}
void xce::compareinfo::CompareInfoReloaderI::reload(const MyUtil::IntSeq& ids, const Ice::Current& current) { ostringstream oss; oss << "CompareInfoReloaderI::reload -> size: "<<ids.size() << current.con->toString().substr(current.con->toString().find("remote",25)); TimeCost tc = TimeCost::create(oss.str(), TimeCost::LOG_LEVEL_INFO); MyUtil::IntSeq tempids; for (MyUtil::IntSeq::const_iterator i=ids.begin(); i!=ids.end();++i){ if (*i > 0) { tempids.push_back(*i); } } MyUtil::TaskManager::instance().execute(new ReloadTask(tempids, current)); }
void xce::usercache::UserCacheReloaderI::rebuildOnline(const MyUtil::IntSeq& ids, const Ice::Current& current) { ostringstream oss; oss << "UserCacheReloaderI::rebuildOnline -> size: "<< ids.size() << " " << current.con->toString().substr(current.con->toString().find("remote",25)); TimeCost tc = TimeCost::create(oss.str(), TimeCost::LOG_LEVEL_INFO); MyUtil::IntSeq rebuildIds; for (MyUtil::IntSeq::const_iterator i=ids.begin(); i!=ids.end();++i){ if (*i > 0) { rebuildIds.push_back(*i); } } RebuildOnline::instance().rebuild(rebuildIds); }
void UserAdsCacheLoaderI::load(const MyUtil::IntSeq& ids, const Ice::Current& current) { MCE_DEBUG("UserAdsCacheLoaderI::load -> size: "<<ids.size()<<" " << current.con->toString().substr(current.con->toString().find("remote",25))); MyUtil::IntSeq is; for (MyUtil::IntSeq::const_iterator i = ids.begin(); i != ids.end(); ++i) { if (*i > 0) { is.push_back(*i); } } if (is.size() <= 0) { return ; } CacheLoader<UserAdsCacheManagerPrx>::instance().reload(is); }
BuddyByOnlineTimeDataI::BuddyByOnlineTimeDataI( BuddyByOnlineTimeDataPtr data ){ std::multimap<int, int> orderFriend; for (OnlineTimeSeq::const_iterator it = data->onlinetime.begin(); it != data->onlinetime.end(); ++it) { orderFriend.insert(make_pair<int,int>(it->time,it->userId)); } MyUtil::IntSeq buddies; for (multimap<int, int>::reverse_iterator it = orderFriend.rbegin(); it != orderFriend.rend(); ++it ){ buddies.push_back(it->second); } friends.swap( buddies ); }
MyUtil::IntSeq IPRecordData::get(int limit){ IceUtil::Mutex::Lock lock(*this); if( limit < 0){ return _users; } MyUtil::IntSeq result; for( MyUtil::IntSeq::reverse_iterator it = _users.rbegin(); it != _users.rend(); ++it ) { if (--limit < 0 ) { break; } result.push_back(*it); } return result; }
void xce::distcache::userapicache::DistUserApiCacheReloaderI::reload(const MyUtil::IntSeq& ids, const Ice::Current& current) { ostringstream oss; oss << "DistUserApiCacheReloaderI::reload -> size: "<<ids.size()<< " " << current.con->toString().substr(current.con->toString().find("remote",25)); MyUtil::TimeCost tc = MyUtil::TimeCost::create(oss.str(), MyUtil::TimeCost::LOG_LEVEL_INFO); oss<<"ids = "; MyUtil::IntSeq tempids; for (MyUtil::IntSeq::const_iterator i=ids.begin(); i!=ids.end();++i){ if (*i > 0) { tempids.push_back(*i); oss<<*i<<" "; } } MCE_DEBUG(oss.str()); MyUtil::TaskManager::instance().execute(new ReloadTask(tempids)); }
MyUtil::IntSeq TalkRightAdapter::batchVerify(int index, const VerifySeq& seq) { MyUtil::IntSeq res; try { res = getManager(abs(index) % getCluster())->batchVerify(seq); } catch(...) { for(size_t i = 0; i < seq.size(); ++i){ res.push_back(seq.at(i)->index); } } return res; }
int main(int argc, char* argv[]) { MyUtil::IntSeq ids; ids.push_back(68126); std::map<int, UserCachePtr> res = UserCacheAdapter::instance().GetUserCache(ids); cout << "id: " << res.find(68126)->second->id() << endl; cout << "name: " << res.find(68126)->second->name() << endl; cout << "status: " << res.find(68126)->second->status() << endl; cout << "tinyurl: " << res.find(68126)->second->tinyurl() << endl; cout << "state: " << res.find(68126)->second->state() << endl; cout << "gender: " << res.find(68126)->second->gender() << endl; cout << "online: " << res.find(68126)->second->online() << endl; cout << "level: " << res.find(68126)->second->level() << endl; cout << "univ: " << res.find(68126)->second->univ() << endl; cout << res.find(68126)->second->IsSelected() << endl; return 0; }
Ice::ObjectPtr UserPhotosInfoFactoryI::create(Ice::Int id) { MCE_INFO("[UserPhotosInfoFactoryI::create] userId = " << id); vector<UserPhotosInfoPtr> ptrs; Statement sql; string tableName = TABLE_NAME + "_" + boost::lexical_cast<string>(id % TABLE_MOD); sql << "select " << COLUMN_USERID << ", " << COLUMN_PHOTOS << " from " << tableName << " where " << COLUMN_USERID << " = " << id; QueryRunner(DB_SOURCE, CDbRServer, tableName).query(sql, UserPhotosInfoResultHandlerI(ptrs)); if (ptrs.empty() || (*ptrs.begin())->getPhotoInfos().empty()) { return EMPTY_USER_PHOTOS_INFO_PTR; } else { MyUtil::IntSeq userIds; userIds.push_back(id); FriendsRecentPhotosWriterAdapter::instance().reloadUserPhotos(userIds); return *ptrs.begin(); } }
MyUtil::IntSeq TalkRightAdapter::batchVerify(const VerifySeq& seq) { map<int, VerifySeq> vMap; for (size_t i = 0; i < seq.size(); ++i) { vMap[abs(seq.at(i)->to) % getCluster()].push_back(seq.at(i)); } MyUtil::IntSeq res; for (map<int,VerifySeq>::iterator it = vMap.begin(); it != vMap.end(); ++it) { try { MyUtil::IntSeq tmp = getManager(it->first)->batchVerify(it->second); res.insert(res.end(),tmp.begin(),tmp.end()); } catch(...) { for(size_t i = 0; i < it->second.size(); ++i){ res.push_back(it->second.at(i)->index); } } } return res; }
MyUtil::IntSeq MutualFriendsCacheManagerI::getFans(const MyUtil::GlobalIdPtr& gid, int begin, int limit, const Ice::Current& current) { ostringstream msg; msg << "gid = " << GlobalIdTransfer::get(gid) << ", begin = " << begin << ", limit = " << limit; InvokeClient ic = InvokeClient::create(current, msg.str(), InvokeClient::INVOKE_LEVEL_INFO); MyUtil::IntSeq fans = getAllFansAsc(gid); MyUtil::IntSeq result; if (limit < -1 || begin < 0) { return result; } else { MyUtil::IntSeq::iterator it = lower_bound(fans.begin(), fans.end(), gid); int countLimit = (limit == -1) ? fans.size() : limit; for (int count = 0; it != fans.end() && count < countLimit; it++) { result.push_back(*it); count++; } return result; } }
MyUtil::IntSeq IPRecordData::getWithMask(int limit,::MyUtil::IntSeq mask){ IceUtil::Mutex::Lock lock(*this); MyUtil::IntSeq result; if( limit == 0){ return result; } std::sort( mask.begin(), mask.end(), std::less<int>() ); for( MyUtil::IntSeq::reverse_iterator it = _users.rbegin(); it != _users.rend(); ++it ) { MyUtil::IntSeq::iterator itMask = lower_bound(mask.begin(),mask.end(),*it); if( itMask!=mask.end() && *itMask==*it){ continue; } result.push_back(*it); if (--limit==0) { break; } } return result; }
bool UserCacheReloadCallGuarantee::Redo(const std::vector<int>& ids) { if (ids.size() <= 0) { return true; } std::set<int> is; MyUtil::IntSeq idss; for (std::vector<int>::const_iterator i = ids.begin(); i != ids.end(); ++i) { is.insert(*i); } for (std::set<int>::const_iterator i = is.begin(); i != is.end(); ++i) { idss.push_back(*i); } try { xce::distcache::usercache::DistUserCacheReloaderAdapter::instance().getProxy(0)->reload(ids); return true; } catch (const Ice::Exception& e) { MCE_WARN("UserCacheReloadCallGuarantee::Redo -> exception distcache: " << e.what()); } catch (...) { MCE_WARN("UserCacheReloadCallGuarantee::Redo -> unknown exception distcache"); } return false; }
MyUtil::IntSeq AccountFilterI::GetIdBySHA256(const MyUtil::StrSeq &digests, const Ice::Current ¤t) { ostringstream oss; oss << "digest.size: " << digests.size(); InvokeClient ic = InvokeClient::create(current, oss.str(), InvokeClient::INVOKE_LEVEL_DEBUG); MyUtil::IntSeq result; MyUtil::StrSeq::const_iterator it = digests.begin(); for(; it != digests.end(); ++it) { if(it->size() != SHA256::HEX_SIZE || !MyUtil::StrUtil::isXDigit(*it)) { MCE_WARN("AccountFilterI::GetIdBySHA256 invalid digest: " << *it << " ,size: " << it->size()); continue; } string digest_lower = MyUtil::StrUtil::toLower(*it); int bucket = bucket_manager_.GetBucket(digest_lower); DigestMap& digest_map = buckets_[bucket]; boost::shared_lock<boost::shared_mutex> read_lock(mutex_[bucket]); DigestMap::iterator it_digest = digest_map.find(digest_lower); if(it_digest != digest_map.end()) { BOOST_FOREACH(int id, it_digest->second.ids) { result.push_back(id); } } }
void CommonFriendCalculator::buildWeight(const MyUtil::Int2IntSeqMap& users, int weight) { MCE_DEBUG("build " << _userId << " size=" << users.size()); try { for(MyUtil::Int2IntSeqMap::const_iterator i=users.begin(); i!=users.end(); ++i) { for(MyUtil::IntSeq::const_iterator ui=i->second.begin();ui!=i->second.end();++ui) { _weightCount[*ui] += weight; MyUtil::Int2IntSeqMap::iterator sIt = _shareCount.find(*ui); if(sIt == _shareCount.end()) { MyUtil::IntSeq firstShares; firstShares.push_back( i->first ); _shareCount.insert(make_pair(*ui, firstShares)); } else { sIt->second.push_back( i->first ); } } } } catch(Ice::Exception& e) { MCE_WARN("buildUser IceException " << _userId << e.what()); } catch(std::exception& e) { MCE_WARN("buildUser stdException " << _userId << e.what()); } catch(...) { MCE_WARN("buildUser exception " << _userId); } }
void IqHandlerI::changeBuddyGroupNotify(const BuddyItemPtr& bi, const Ice::Current&) { if(!bi){ return; } MCE_DEBUG("IqHandlerI::changeBuddyGroupNotify --> host:"<<bi->host); MyUtil::IntSeq buddys; for (map<int,MyUtil::StrSeq>::iterator it = bi->items.begin(); it != bi->items.end(); ++it) { buddys.push_back(it->first); } TalkUserMap buddyInfo; try{ buddyInfo = TalkCacheClient::instance().GetUserBySeqWithLoad(bi->host, buddys); if(buddyInfo.size() != buddys.size()){ MCE_INFO("IqHandlerI::changeBuddyGroupNotify --> may be warn get from TalkCacheClient size is not equal actor = " << bi->host << " ids.size = " << buddys.size() << " map.size = " << buddyInfo.size()); }else{ MCE_INFO("IqHandlerI::changeBuddyGroupNotify --> success get from TalkCacheClient size is equal actor = " << bi->host << " ids.size = " << buddys.size() << " map.size = " << buddyInfo.size()); } }catch(Ice::Exception& e){ MCE_WARN("IqHandlerI::changeBuddyGroupNotify --> TalkCacheClient err, " << e); } MessageSeq mSeq; JidSeq jids; try{ //jids = OnlineCenterAdapter::instance().getUserJids(bi->host, 4); jids = TalkFunStateAdapter::instance().getUserJids(bi->host, 4); }catch(Ice::Exception& e){ MCE_WARN("IqHandlerI::changeBuddyGroupNotify-->OnlineCenterAdapter::getUserJids-->" << e); } for (size_t j = 0; j < jids.size(); ++j) { for (map<int,MyUtil::StrSeq>::iterator it = bi->items.begin(); it != bi->items.end(); ++it) { xml_document doc; xml_node iqNode = doc.append_child(); iqNode.set_name("iq"); iqNode.append_attribute("type") = "set"; iqNode.append_attribute("id") = (int)time(NULL); iqNode.append_attribute("to") = jidToString(jids.at(j)).c_str(); xml_node queryNode = iqNode.append_child(); queryNode.set_name("query"); queryNode.append_attribute("xmlns") = "jabber:iq:roster"; xml_node itemNode = queryNode.append_child(); itemNode.set_name("item"); ostringstream jos; jos << it->first << "@talk.xiaonei.com"; itemNode.append_attribute("jid") = jos.str().c_str();//jid.c_str(); TalkUserMap::iterator oit = buddyInfo.find(it->first); if (oit != buddyInfo.end()) { itemNode.append_attribute("name") = oit->second->name.c_str(); } else { itemNode.append_attribute("name") = boost::lexical_cast<string>(it->first).c_str(); } //itemNode.append_attribute("name") = name.c_str(); itemNode.append_attribute("subscription") = "both"; for (size_t k = 0; k < it->second.size(); ++k) { xml_node groupNode = itemNode.append_child(); groupNode.set_name("group"); groupNode.append_child(node_pcdata).set_value(it->second.at(k).c_str()); } MessagePtr mPtr = new Message(); //mPtr->from = new Jid(); mPtr->from = jids.at(j); mPtr->to = jids.at(j); mPtr->type = IQ_SET; mPtr->msg = doc.xml(); mSeq.push_back(mPtr); MCE_DEBUG("IqHandlerI::changeBuddyGroupNotify --> xml:"<<doc.xml()); } } try{ TalkDeliverAdapter::instance().deliver(mSeq); }catch(Ice::Exception& e){ MCE_WARN("IqHandlerI::changeBuddyGroupNotify-->TalkDeliverAdapter::deliver-->err" << e); } }
MyUtil::IntSeq OfferCreator::dedup(std::map<int, std::multimap<int, OfferDataN> >& typedWeightMap, const BackendDataPtr& bak, ostringstream& createLog, ostringstream& createDetail) { struct timeval tvStart, tvStage1, tvEnd; gettimeofday( &tvStart, NULL ); double linStart = ((double)tvStart.tv_sec * 1000000 + (double)tvStart.tv_usec); map<int, map<int, OfferDataN> > typedIdMap; //map<type,map<id,offer>>; typedIdMap.insert(make_pair<int, map<int, OfferDataN> >(BaseTypeMix, map<int, OfferDataN>())); //type:BaseTypeMix map<int, OfferDataN>& mixIdMap = typedIdMap[BaseTypeMix]; //& for (std::map<int, OfferDataNSeq>::iterator it = bak->_typedOfferDataNSeq.begin(); it != bak->_typedOfferDataNSeq.end(); ++it) { //it: <type,OfferDataNSeq> in bak //new <it->first,map<id,OfferDataN> > in typedIdMap typedIdMap.insert(make_pair<int, map<int, OfferDataN> >(it->first, map<int, OfferDataN>())); for (OfferDataNSeq::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { //it2: OfferDataN in bak map<int, OfferDataN>::iterator it3 = mixIdMap.find(it2->userId); //it3: <id,OfferDataN> in mixIdMap if( it3 != mixIdMap.end() ){ it3->second.weight += it2->weight + 10; it3->second.sign |= it2->sign; continue; } bool found = false; for (map<int, map<int, OfferDataN> >::iterator it4 = typedIdMap.begin(); it4 != typedIdMap.end(); ++it4) { if (it4->first == BaseTypeMix) { continue; //it4: <type,map<id,OfferDataN> > in typedIdMap without BaseTypeMix } map<int, OfferDataN>::iterator it5 = it4->second.find( it2->userId );//it5: <int,OfferDataN> in it4->second if (it5 != it4->second.end()) { it5->second.weight += it2->weight + 10; //it5->second.infos.insert( it2->infos.begin(), it2->infos.end() ); it5->second.sign |= it2->sign; mixIdMap[it2->userId] = it5->second; it4->second.erase(it5); found = true; break; } } if (!found) { typedIdMap[it->first].insert(make_pair<int, OfferDataN>(it2->userId, *it2)); } } } gettimeofday(&tvStage1, NULL); double linStage1 = ((double)tvStage1.tv_sec * 1000000 + (double)tvStage1.tv_usec); double linStage1Time = linStage1 - linStart; linStage1Time = linStage1Time / 1000000; createLog << " dedup(" << linStage1Time << "s/"; MyUtil::IntSeq ids; for (map<int, map<int, OfferDataN> >::iterator it4 = typedIdMap.begin(); it4 != typedIdMap.end(); ++it4 ) { typedWeightMap.insert(make_pair<int, multimap<int, OfferDataN> >(it4->first, multimap<int, OfferDataN>())); for (map<int, OfferDataN>::iterator it5 = it4->second.begin(); it5 != it4->second.end(); ++it5) { typedWeightMap[it4->first].insert(multimap<int, OfferDataN>::value_type(it5->second.weight, it5->second)); ids.push_back(it5->second.userId); } } gettimeofday(&tvEnd, NULL); double linEnd = ((double)tvEnd.tv_sec * 1000000 + (double)tvEnd.tv_usec); double linEndTime = linEnd - linStage1; linEndTime = linEndTime / 1000000; createLog << linEndTime << "s="; return ids; }
xce::distcache::userapicache::UserApiCacheMemDataPtr xce::distcache::userapicache::UpdateTask::GetNewData() { xce::distcache::userapicache::UserApiCacheMemDataPtr data = xce::distcache::userapicache::DistUserApiCacheAdapter::instance().get(data_->userid); if(!data) { MyUtil::IntSeq ids; ids.push_back(data_->userid); xce::distcache::userapicache::DistUserApiCacheReloaderI::instance().addDelayReloadIds(ids); return NULL; } MyUtil::Str2StrMap::const_iterator i; switch (data_->table) { case xce::userapicache::TABLEBORN: i = data_->data.find("BIRTH_DAY"); if (i != data_->data.end()) { data->set_birthday(boost::lexical_cast<int>(i->second)); } i = data_->data.find("GENDER"); if (i != data_->data.end()) { data->set_gender(i->second); } i = data_->data.find("BIRTH_YEAR"); if (i != data_->data.end()) { data->set_birthyear(boost::lexical_cast<int>(i->second)); } i = data_->data.find("BIRTH_MONTH"); if (i != data_->data.end()) { data->set_birthmonth(boost::lexical_cast<int>(i->second)); } i = data_->data.find("HOME_CITY"); if (i != data_->data.end()) { data->set_homecity(i->second); } i = data_->data.find("HOME_PROVINCE"); if (i != data_->data.end()) { data->set_homeprovince(i->second); } break; case xce::userapicache::TABLESTAGE: i = data_->data.find("STAGE"); if (i != data_->data.end()) { data->set_stage(boost::lexical_cast<int>(i->second)); } i = data_->data.find("UNIV"); if (i != data_->data.end()) { data->set_univ(boost::lexical_cast<int>(i->second)); } break; case xce::userapicache::TABLESTATE: i = data_->data.find("LEVEL"); if (i != data_->data.end()) { data->set_level(boost::lexical_cast<int>(i->second)); } i = data_->data.find("STATE"); if (i != data_->data.end()) { data->set_state(boost::lexical_cast<int>(i->second)); } break; case xce::userapicache::TABLENAMES: i = data_->data.find("NAME"); if (i != data_->data.end()) { data->set_name(i->second); } break; case xce::userapicache::TABLERIGHT: i = data_->data.find("AUTH"); if (i != data_->data.end()) { data->set_auth(boost::lexical_cast<int>(i->second)); } break; case xce::userapicache::TABLEPASSPORT: i = data_->data.find("STATUS"); if (i != data_->data.end()) { data->set_status(boost::lexical_cast<int>(i->second)); } break; case xce::userapicache::TABLEURL: i = data_->data.find("TINYURL"); if (i != data_->data.end()) { data->set_tinyurl(i->second); } i = data_->data.find("MAINURL"); if (i != data_->data.end()) { data->set_mainurl(i->second); } i = data_->data.find("HEADURL"); if (i != data_->data.end()) { data->set_headurl(i->second); } break; case xce::userapicache::TABLECONFIG: i = data_->data.find("BASIC_CONFIG"); if (i != data_->data.end()) { data->set_basicconfig(boost::lexical_cast<int>(i->second)); } i = data_->data.find("STATUS_CONFIG"); if (i != data_->data.end()) { data->set_statusconfig(boost::lexical_cast<int>(i->second)); } i = data_->data.find("PROFILE_PRIVACY"); if (i != data_->data.end()) { data->set_profileprivacy(i->second); } break; default: MCE_WARN("UpdateTask::GetNewData -> Oh, no!"); } return data; }