void MyUtil::__readInt2IntMap(::IceInternal::BasicStream* __is, ::MyUtil::Int2IntMap& v) { ::Ice::Int sz; __is->readSize(sz); while(sz--) { ::std::pair<const ::Ice::Int, ::Ice::Int> pair; __is->read(const_cast< ::Ice::Int&>(pair.first)); ::MyUtil::Int2IntMap::iterator __i = v.insert(v.end(), pair); __is->read(__i->second); } }
MyUtil::Int2IntMap BuddyByAddTimeCacheAdapter::getFriendCounts(const MyUtil::IntSeq& ids){ if (ids.empty()){ return MyUtil::Int2IntMap(); } size_t numCluster_sizeT = getCluster(); int numCluster = (int)numCluster_sizeT; if (numCluster < 0) { MCE_WARN("[BuddyByAddTimeCacheAdapter::getFriendCounts] this should not be seen! Why cluster=" << numCluster_sizeT << " ???" ); return MyUtil::Int2IntMap(); } if (numCluster == 0 || numCluster == 1) { try { return getProxy(ids.at(0))->getFriendCounts(ids); } catch (...) { return MyUtil::Int2IntMap(); } } else { vector< vector<int> > seperatedIds; seperatedIds.resize(numCluster); for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) { seperatedIds.at(*it % numCluster).push_back(*it); } MyUtil::Int2IntMap result; for (int posCluster = 0; posCluster < numCluster; ++posCluster) { MyUtil::Int2IntMap someResult; if( seperatedIds.at(posCluster).size() > 0 ){ try { someResult = getProxy(posCluster)->getFriendCounts(seperatedIds.at(posCluster)); } catch (...) { MCE_WARN( "BuddyByAddTimeCacheAdapter::getFriendCounts from Proxy(" << posCluster << ") handle unknown exception." ); } result.insert( someResult.begin(), someResult.end() ); } } return result; } }
void SetDataHelper::SetDataThread::run() { while (true){ std::vector< pair<long,Ice::ObjectPtr> > to_be_set_; helper_.swap( to_be_set_ ); if( to_be_set_.empty() ){ MCE_INFO("[SetDataHelper::SetDataThread::run] setData: 0 objs." ); continue; } ostringstream idstr; MyUtil::ObjectResultPtr objs = new MyUtil::ObjectResult(); MyUtil::Int2IntSeqMap lists; MyUtil::Int2IntMap counts; for ( std::vector< pair<long, Ice::ObjectPtr> >::iterator it = to_be_set_.begin(); it != to_be_set_.end(); ++it ){ objs->data.insert(*it); MyUtil::IntSeq& list = BuddyFriendsDataPtr::dynamicCast( it->second )->friends; lists.insert( make_pair<Ice::Int,MyUtil::IntSeq>(it->first,list) ); counts.insert( make_pair<Ice::Int,Ice::Int>(it->first,list.size()) ); idstr << " " << it->first << "(" << list.size() << ")"; } MCE_INFO("[SetDataHelper::SetDataThread::run] setData:" << idstr.str() ); BuddyFriendsCacheAdapter::instance().setData(objs); } }