コード例 #1
0
ファイル: UseredTribeI.cpp プロジェクト: bradenwu/oce
TribeTinyViewSeq
mop::hi::svc::model::UseredTribeManagerI::getMemberedTribeTinyViews(::Ice::Int userId,
                               ::Ice::Int offset,
                               ::Ice::Int limit,
                               const Ice::Current& current)
{
	UseredTribeServiceI& service = UseredTribeServiceI::instance();
    IntSeq memberedTribeIds = service.getMemberedTribeSet(userId)
    		->getAll(offset, limit);
   	TribeTinyViewSeq result;
    if (offset <= 0) {
    	offset = 0;
    }
    if (limit <= 0) {
    	limit = memberedTribeIds.size();
    }
    for (int i = 0; i < memberedTribeIds.size(); ++i) {
    	if (i < offset) {
    		continue;
    	}
    	if (result.size() >= limit) {
    		break;
    	}
    	try {
    		result.push_back(service.getTribeTinyView(memberedTribeIds.at(i)));
    	} catch (Ice::Exception& e) {
    	
    	}
    }
    return result;    
}   
コード例 #2
0
ファイル: UserFeedsI.cpp プロジェクト: gunner14/old_rr_code
FeedMetaSeq UserFeedsI::get(const IntSeq& userids, ::Ice::Int begin, ::Ice::Int limit, const ::Ice::Current& current) {
	ostringstream oss;
	oss << " userids.size: " << userids.size() << " begin: " << begin << " limit: " << limit;
	InvokeClient tm = InvokeClient::create(current, oss.str(), InvokeClient::INVOKE_LEVEL_INFO);

	try {
		return getSegment(fs_.gets(userids, begin + limit), userids, begin, limit);
	} catch (std::exception& e) {
		MCE_WARN("UserFeedsI::get Exception! " << e.what());
	} catch (...) {
		MCE_WARN("UserFeedsI::get Exception, userids.size: " << userids.size());
	}

	return FeedMetaSeq();
}
コード例 #3
0
ファイル: NotifyCacheI.cpp プロジェクト: bradenwu/oce
ObjectResultPtr NoteFactory::create(const IntSeq& keys) {
	ConnectionHolder conn(_database);
	mysqlpp::Query query = conn.query();
	query << "SELECT * FROM " << _noteTable << " WHERE noteId in (";
	for (size_t i = 0; i < keys.size(); ++i) {
		query << keys.at(i) << ", ";
	}
	query << "0)";
	mysqlpp::Result res = query.store();
	ObjectResultPtr result = new ObjectResult;
	for (size_t i = 0; i < res.size(); ++i) {
		mysqlpp::Row row = res.at(i);
		NotePtr n = new Note;
		n->noteId = row["NOTEID"];
		n->quoteeId = row["QUOTEEID"];
		n->resource = row["RESOURCE"];
		n->type = row["TYPE"];
		n->unread = (int)row["UNREAD"] == 0 ? false : true;
		n->fromName = row["FROMNAME"].get_string();
		n->fromId = row["FROMID"];
		n->toId = row["TOID"];
		n->ownerName = row["OWNERNAME"].get_string();
		n->ownerId = row["OWNERID"];
		n->title = row["TITLE"].get_string();
		n->link = row["LINK"].get_string();
		n->imageLink = row["IMAGELINK"].get_string();
		n->timestamp = (time_t)mysqlpp::DateTime(row["TIMESTAMP"]);
		n->security = row["SECURITY"];
		result->data[n->noteId] = n;
	}
	return result;
}
コード例 #4
0
ファイル: UserFeedsI.cpp プロジェクト: bradenwu/oce
FeedMetaSeq UserFeedsI::get(const IntSeq& userids, ::Ice::Int begin, ::Ice::Int limit, const ::Ice::Current& current) {
	ostringstream oss;
	oss << "UserFeedsI::get, userids.size: " << userids.size() << " begin: " << begin << " limit: " << limit;
	TimeCost tm = TimeCost::create(oss.str(), TimeCost::LOG_LEVEL_INFO);

	return getSegment(fs_.gets(userids, begin + limit), userids, begin, limit);
}
コード例 #5
0
ファイル: UserFeedsI.cpp プロジェクト: bradenwu/oce
FeedMetaSeq UserFeedsI::getLessThanFeedidByTypesWithFilter(const IntSeq& userids, ::Ice::Long feedid, ::Ice::Int limit, const IntSeq& types, const StrSeq& filter, const ::Ice::Current& current) {
	ostringstream oss;
	oss << "UserFeedsI::getLessThanFeedidByTypesWithFilter, userids.size: " << userids.size() << " limit: " << limit << " feedid: " << feedid;
	TimeCost tm = TimeCost::create(oss.str(), TimeCost::LOG_LEVEL_INFO);

	return getSegment(fs_.gets_less_feedid_with_filter(userids, TypesFilter(types), IdsFilter(filter), feedid, limit), userids, 0, limit);
}
コード例 #6
0
ファイル: MyTasks.cpp プロジェクト: bradenwu/oce
void AppendSingleRelationAndSetCacheTask::handle() {
	IntSeq resultList;
	HotFeedSeq feedSeq;

    //try {
	//	feedSeq = HotFeedRecommendCacheAdapter::instance().Get(_ownerId, -1);
    //} catch (Ice::Exception& e) {
    //	cout << "AppendSingleRelationAndSetCacheTask HotFeedRecommendCacheAdapter Ice exception " << e.what() << endl;
    //} catch (std::exception& e) {
    //    cout << "AppendSingleRelationAndSetCacheTask HotFeedRecommendCacheAdapter std exception " << e.what() << endl;
    //} catch (...) {
    //    cout << "AppendSingleRelationAndSetCacheTask HotFeedRecommendCacheAdapter unknow exception" << endl;
    //}
	cout << "feedSeq size = " << feedSeq.size() << endl;

	for (HotFeedSeq::iterator iter = feedSeq.begin();
			iter != feedSeq.end(); ++iter) {
		resultList.push_back(iter->userId);
	}

	//resultList.push_back(285340707);
	//resultList.push_back(1331);
	//resultList.push_back(2055206602);

	set<int> checkSet(resultList.begin(), resultList.end());

	//cout << "AppendSingleRelationAndSetCacheTask" << endl;
	//for (vector<int>::iterator iter = _negtiveFriendList.begin();
	//		iter != _negtiveFriendList.end(); ++iter) {
	//	cout << *iter << " ";
	//}
	//cout << endl;


	for (vector<int>::iterator iter = _negtiveFriendList.begin();
			iter != _negtiveFriendList.end(); ++iter) {
		if (checkSet.find(*iter) == checkSet.end()) {
			resultList.push_back(*iter);
		}
	}
	
	//cout << "iijiojonojh f**k you" << endl;
	//for (vector<int>::iterator iter = resultList.begin();
	//		iter != resultList.end(); ++iter) {
	//	cout << *iter << " ";
	//}
	//cout << endl;
	cout << "AppendSingleRelationAndSetCacheTask " << _ownerId << " : " << resultList.size() << endl;

    try {
		NegtiveListCacheAdapter::instance().Set(_ownerId, resultList);
    } catch (Ice::Exception& e) {
    	cout << "AppendSingleRelationAndSetCacheTask NegtiveListCacheAdapter Ice exception " << e.what() << endl;
    } catch (std::exception& e) {
        cout << "AppendSingleRelationAndSetCacheTask NegtiveListCacheAdapter std exception " << e.what() << endl;
    } catch (...) {
        cout << "AppendSingleRelationAndSetCacheTask NegtiveListCacheAdapter unknow exception" << endl;
    }
}
コード例 #7
0
ファイル: RoomPool.cpp プロジェクト: bradenwu/oce
IntSeq RoomMemberList::GetAllMembersSeq(){
  IntSeq ans;
  MemberSetIt it = _members.begin();
  for(; it != _members.end(); ++it){
    ans.push_back((*it));
  }
	MCE_DEBUG("RoomMemberList::GetAllMemberSeq --> ans.size =  "<<ans.size());
  return ans;
}
コード例 #8
0
ファイル: UserFeedsI.cpp プロジェクト: bradenwu/oce
FeedMetaSeq UserFeedsI::getWithFilter(const IntSeq& userids, ::Ice::Int begin, ::Ice::Int limit, const StrSeq& filter, const ::Ice::Current& current) {
	ostringstream oss;
	oss << "UserFeedsI::getWithFilter, userids.size: " << userids.size() << " begin: " << begin << " limit: " << limit;
	TimeCost tm = TimeCost::create(oss.str(), TimeCost::LOG_LEVEL_INFO);

	if(filter.empty())
		return getSegment(fs_.gets(userids, begin + limit), userids, begin, limit);
	return getSegment(fs_.gets_with_filter(userids, TypesFilter(std::vector<int>()), IdsFilter(filter), begin + limit), userids, begin, limit);
}
コード例 #9
0
ファイル: FeedItemI.cpp プロジェクト: gunner14/old_rr_code
FeedDataResPtr FeedItemManagerI::GetFeedDataImpl(int uid, const IntSeq& types,
    bool stype, int begin, int limit, bool hot) {
	FeedDataResPtr res = new FeedDataRes;

	try{
	TimeStat ts; GetCost tc;
	GetRequest req(uid,types,stype,begin,limit,hot);
	if(!req.CheckArgs()) return res;

	UserInfoPtr uinfo = LocateUserInfo(uid);

	if(!uinfo) return res;
	tc.loadtime = ts.Get();

	uinfo->GetFeeds(req);

	tc.mergetime = ts.Get();

	FeedContentDict fdict;
	GetFeedContentDict(req,fdict);
//	tc.contenttime = ts.Get();
//
	FeedBuilder builder(uid,fdict,req.showed_comment_map_,req.sort_);
	res = builder.BuildFeedData(req);
//	tc.buildtime = ts.Get();
//
	uinfo->SetMaxRead(req.GetMaxFid());
	uinfo->SetReadByIdsExactly(builder.GetNullFids());
//	tc.othertime = ts.Get();
//
	uinfo->UploadMaxRead();
//	uinfo->RefreshPreMaxRead();
//	uinfo->AddRefresh(req.GetNowTime(),req.GetMaxFid());
//
//
	MCE_INFO("FeedItemManagerI::GetFeedDataImpl --> uid:" << uid << " begin:" << begin << " limit:" << limit
			<< " types:" << types.size() << " bystype:" << stype << " hot:" << hot << " feedsize:" << uinfo->Size()
//			<< " res:" << builder.GetSucc()
			<< tc.ToString()
			<< " fdict:" << fdict.size()
			<< " nullfids:" << PrintHelper::Print(builder.GetNullFids())
			<< " types:" << PrintHelper::Print(types)
			<< " mark_fids:" << PrintHelper::Print(req.GetMarkedFids())
	);

	return res;

	} catch(Ice::Exception& e) {
		MCE_WARN(" FeedItemManagerI::GetFeedDataImpl uid:" << uid
				<<" error:" << e);
		return res;
	}
}
コード例 #10
0
ファイル: UserFeedsI.cpp プロジェクト: gunner14/old_rr_code
::Ice::Int UserFeedsI::getItemCount(const IntSeq& userIds, const ::Ice::Current& current) {
	ostringstream oss;
	oss << " userId.size: " << userIds.size();
	InvokeClient tm = InvokeClient::create(current, oss.str(), InvokeClient::INVOKE_LEVEL_INFO);

	int count = 0;
	for(IntSeq::const_iterator it = userIds.begin();
			it != userIds.end(); ++it) {
		count += fs_.item_count(*it);
	}

	return count;
}
コード例 #11
0
ファイル: UserFeedsI.cpp プロジェクト: gunner14/old_rr_code
FeedMetaSeq UserFeedsI::getLessThanFeedidByTypesWithFilter(const IntSeq& userids, ::Ice::Long feedid, ::Ice::Int limit, const IntSeq& types, const StrSeq& filter, const ::Ice::Current& current) {
	ostringstream oss;
	oss << " userids.size: " << userids.size() << " limit: " << limit << " feedid: " << feedid;
	InvokeClient tm = InvokeClient::create(current, oss.str(), InvokeClient::INVOKE_LEVEL_INFO);
	try {
		return getSegment(fs_.gets_less_feedid_with_filter(userids, TypesFilter(types), IdsFilter(filter), feedid, limit), userids, 0, limit);
	} catch (std::exception& e) {
		MCE_WARN("UserFeedsI::getLessThanFeedidByTypesWithFilter Exception! " << e.what());
	} catch (...) {
		MCE_WARN("UserFeedsI::getLessThanFeedidByTypesWithFilter Exception!");
	}

	return FeedMetaSeq();
}
コード例 #12
0
MyUtil::IntSeq RecommendData::getWriteRecommendRandom(int limit) {
    IceUtil::Mutex::Lock lock(*this);
    checkTimeout(); 

    Int2IntMap writeRecommendRank;
    for(Int2IntSeqMap::iterator iter = _recommendMap.begin();
            iter != _recommendMap.end(); ++iter) {
        if( iter->second.empty() ) {
            writeRecommendRank[ iter->first ] = _friendrank[ iter->first ];
        }
    }

    multimap<int, int> orderedRank;
    for(Int2IntMap::iterator iter = writeRecommendRank.begin(); 
            iter != writeRecommendRank.end(); ++iter) {
        orderedRank.insert( make_pair<int, int>(iter->second, iter->first) );   
    }  
       
    IntSeq writeRecommendList;
    for(multimap<int, int>::reverse_iterator iter = orderedRank.rbegin();
            iter != orderedRank.rend(); ++iter) {
        writeRecommendList.push_back( iter->second );   
    }  

	MCE_INFO("[RecommendData] getWriteRecommendRandom ownerId(" << _ownerId << ") limit(" << 
			limit << ") writeRecommendRank size(" << writeRecommendRank.size() << 
			") writeRecommendList size(" << writeRecommendList.size() << ")");
       
    if( limit >= (int)writeRecommendList.size() || limit <= 0 ) {
        return writeRecommendList;
    }

    writeRecommendList.resize( limit );

    return writeRecommendList;
}
コード例 #13
0
ファイル: UserFeedsI.cpp プロジェクト: gunner14/old_rr_code
FeedMetaSeq UserFeedsI::getByTypes(const IntSeq& userids, ::Ice::Int begin, ::Ice::Int limit, const IntSeq& types, const ::Ice::Current& current) {
	ostringstream oss;
	oss << " userids.size: " << userids.size() << " begin: " << begin << " limit: " << limit;
	InvokeClient tm = InvokeClient::create(current, oss.str(), InvokeClient::INVOKE_LEVEL_INFO);

	try {
		if(types.empty())
			return getSegment(fs_.gets(userids, begin + limit), userids, begin, limit);
		return getSegment(fs_.gets_with_filter(userids, TypesFilter(types), IdsFilter(std::vector<string>()), begin + limit), userids, begin, limit);
	} catch (std::exception& e) {
		MCE_WARN("UserFeedsI::getByTypes Exception! " << e.what());
	} catch (...) {
		MCE_WARN("UserFeedsI::getByTypes Exception!");
	}
	return FeedMetaSeq();
}
コード例 #14
0
ファイル: FeedMini.cpp プロジェクト: bradenwu/oce
FeedDataSeq UserFeedSet::getFeedDataSeqByType(const IntSeq& types, int begin,
    int limit) {

  IceUtil::Mutex::Lock lock(_mutex);

  time_t t = time(NULL);
  _lastAccessTime = t;
  //	if (t - _lastSortTime > 300) {
  //		_lastSortTime = t;
  //		TaskManager::instance().execute(new SortTask(this));
  //	}

  WeightIndex& index = _mergeGroupSet.get<1> ();
  FeedDataSeq seq;
  vector<WeightIndex::iterator> itSeq;

  if (index.size() < (unsigned int) (begin + limit) + 10) {
    //		MCE_DEBUG("UserFeedSet::getFeedContentSeq --> _loadStat:"<<_loadStat<<"  index.size(): "<<index.size()<<"  begin: "<<begin<<"   limit: "<<limit);
    if (_loadStat == 0) {
      load();
      FeedItemManagerI::instance().addkickUser(_user);
    }
  }
  set<int> typeSet;
  for (size_t i = 0; i < types.size(); ++i) {
    typeSet.insert(types.at(i));
  }
  WeightIndex::iterator iter = index.begin();
  for (int k = 0; iter != index.end() && k < begin; ++iter) {
    int type = (*iter)->type();
    if (typeSet.find(type) != typeSet.end()) {
      ++k;
    }
  }
  for (int h = 0; iter != index.end() && h < limit; ++iter) {
    int type = (*iter)->type();
    if (typeSet.find(type) != typeSet.end()) {
      itSeq.push_back(iter);
      ++h;
    }
  }

  _buildFeedContents(index, itSeq, seq);
  MCE_DEBUG("UserFeedSet::getFeedContentSeq --> content.size:"<<seq.size());
  return seq;
}
コード例 #15
0
ファイル: UserAdsCacheI.cpp プロジェクト: goby/oce
Int2UserAdsCacheDataMap UserAdsCacheManagerI::getUserAdsCacheList(const IntSeq& userIds, const Ice::Current& current) {
    ostringstream msg;
    msg << "UserAdsCacheManagerI::getUserAdsCacheList -> size: " << userIds.size() << " "
        << current.con->toString().substr(current.con->toString().find("remote",25));
    TimeCost tc = TimeCost::create(msg.str());

    ObjectResultPtr objres = getUserAdsCacheData(userIds);
    Int2UserAdsCacheDataMap result;
    for (MyUtil::IntSeq::const_iterator it = userIds.begin(); it != userIds.end(); ++it) {
        ObjectMap::iterator hasRes = objres->data.find(*it);
        if (hasRes != objres->data.end()) {
            result[*it]=toOld(UserAdsCacheUrlDataPtr::dynamicCast(hasRes->second));
        } else {
            MCE_WARN("Not Exists: " << *it);
        }
    }
    return result;
}
コード例 #16
0
ファイル: UseredTribeI.cpp プロジェクト: bradenwu/oce
::MyUtil::IntSeq
mop::hi::svc::model::UseredTribeSetI::getAll(::Ice::Int begin,
                         ::Ice::Int limit,
                         const Ice::Current& current)
{
	if (begin < 0) {
		begin = 0;
	}
	IceUtil::Mutex::Lock lock(*this);
	IntSeq result;
	for(IntSeq::iterator it = tribeIds.begin();
		it != tribeIds.end();
		++it)
	{
		if(begin-- > 0)	continue;
		result.push_back(*it);
		if(limit > 0 && result.size() >= limit) break;
	}
    return result;
}
コード例 #17
0
ファイル: UserFeedsI.cpp プロジェクト: bradenwu/oce
FeedMetaSeq UserFeedsI::getSegment(const std::vector<std::vector<FeedMetaData> > & data, const IntSeq& userids, int begin, int limit) {

	int sum_size = 0;
	for(size_t i = 0; i < data.size(); ++i) {
		sum_size+=data[i].size();
	}

	FeedMetaSeq seq;
	seq.reserve(sum_size);

	for(size_t i = 0; i < userids.size(); ++i)
	{
		const std::vector<FeedMetaData>& v = data[i];
		int uid = userids[i];
		for(size_t j = 0; j < v.size(); ++j)
			seq.push_back(v[j].createFrom(uid));
	}
	if(begin >= (int)seq.size())
		return FeedMetaSeq();
	if(begin + limit > (int)seq.size())
		limit = seq.size() - begin;

	// option 1
	//std::partial_sort(seq.begin(), seq.begin() + (begin + limit), seq.end(), FeedMetaComp());
	//return ::Feed::SeqFeedMeta(seq.begin() + begin, seq.begin() + (begin + limit));

	// option 2
	//partial_quick_sort(seq, begin, limit, FeedMetaComp());
	//return ::Feed::SeqFeedMeta(seq.begin() + begin, seq.begin() + (begin + limit));

	// option 3
	FeedMetaSeq::iterator it = seq.begin();
	std::nth_element(it, it + (begin + limit) - 1, seq.end(), FeedMetaCompare());
	if(limit > 1)
		std::nth_element(it, it + begin, it + (begin + limit) - 1, FeedMetaCompare());
	std::sort(it + begin, it + begin + limit, FeedMetaCompare());

	return FeedMetaSeq(it +begin, it + (begin+limit));
}
コード例 #18
0
MyUtil::IntSeq RecommendData::getRecommendFriendList(int friendId, int begin, int limit) {
	MCE_INFO("[RecommendData] getRecommendFriendList friendId(" << friendId << ") begin(" << begin << ") limit(" << limit << ")");
	IceUtil::Mutex::Lock lock(*this);
	checkTimeout();	
	
	Int2IntSeqMap::iterator fIt = _recommendMap.find(friendId);
	if (fIt == _recommendMap.end() || fIt->second.empty()) {
		return IntSeq();
	}

	const IntSeq& friendList = fIt->second;

	size_t realBegin = begin < 0 ? 0 : begin;
 	realBegin = realBegin < friendList.size() ? realBegin : 0;

	size_t realLimit = limit < 0 ? friendList.size() - realBegin : limit;
	realLimit = realLimit < friendList.size() - realBegin ? realLimit : friendList.size() - realBegin;
	
	MCE_DEBUG("[RecommendData] getRecommendFriendList realBegin=" << realBegin << ", realLimit=" << realLimit);

	IntSeq result;
	for (IntSeq::const_iterator iter = friendList.begin();
			iter != friendList.end(); ++iter) {
		if (realBegin > 0) {
			--realBegin;
			continue;
		}
		result.push_back(*iter);
		if (result.size() >= realLimit) {
			break;
		}
	}
	MCE_DEBUG("[RecommendData] getRecommendFriendList friendId=" << friendId << ", begin:" << begin << ", realBegin:" << 
			realBegin << ", limit:" << limit << ", realLimit:" << realLimit << "   result size=" << result.size());
	return result; 
}
コード例 #19
0
ファイル: IPRecordI.cpp プロジェクト: bradenwu/oce
IntSeq IPRecordManagerI::getUsersWithMask(::Ice::Long ip,::Ice::Int limit,const MyUtil::IntSeq& mask,
			const Ice::Current& current){
	IPRecordDataPtr obj = locateIPRecordData(ip);
	IntSeq res = obj->getWithMask(limit,mask);
	MCE_INFO( "[IPRecordManagerI::getUsersWithMask] ip=" << ip << " size=" << obj->size() << " limit=" << limit << " mask.size=" << mask.size() << " res.size()=" << res.size() 
                << " " << current.con->toString().substr(current.con->toString().find("remote", 25)));
	return res;
}
コード例 #20
0
ファイル: UserStateFilterI.cpp プロジェクト: bradenwu/oce
MyUtil::IntSeq UserStateFilterManagerI::getGuideIdsFrom(const MyUtil::IntSeq& ids, const Ice::Current& current){
	ostringstream op;
	IntSeq res;
	for( MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it ){
		if( _user_state_guide[*it] ){
			res.push_back( *it );
		} else{
			op << *it << " ";
		}
	}
	MCE_INFO("UserStateFilterManagerI::getGuideIdsFrom " << ids.size() << " ids -> res: " << res.size() << " ids. filter: " << op.str()
                << " " << current.con->toString().substr(current.con->toString().find("remote", 25)));
	return res;
}
コード例 #21
0
ファイル: BackendUtil.cpp プロジェクト: gunner14/old_rr_code
std::map<int, OfferDataNSeq> BackendProducer::createFromSameInfoFriendForHighSchool(int userId,
																																		 								int infoLimit,
																																		 								const std::map<int,int>& weights,
																																		 								const MyUtil::IntSeq& applyList,
																																		 								const MyUtil::IntSeq& friendList,
																																		 								const MyUtil::IntSeq& blockList,
																																		 								const MyUtil::IntSeq& commBlockList,
																																		 								std::ostringstream& createLog,
																																		 								std::ostringstream& createDetail)
{
	MCE_INFO("[BackendProducer] createFromSameInfoFriendForHighSchool userId:" << userId << " infoLimit:" << infoLimit);
	struct timeval tvStart, tvInfo;
	gettimeofday( &tvStart, NULL );

	map<int, OfferDataNSeq> res;
	IntSeq filterList = friendList;
	filterList.push_back(userId);
	MCE_INFO("[BackendProducer] createFromSameInfoFriendForHighSchool filterList size:" << filterList.size());

  NetworkInfo sameInfoFriends = OfferFriendsUtil::getNetworkInfoWithHostageFromDB(userId, infoLimit, filterList);

	int base_weight = 0;
	map<int, int>::const_iterator weiIt = weights.find(BaseTypeSameInfoUniv);
	if (weiIt != weights.end()) {
		base_weight = weiIt->second;
		MCE_INFO("BaseTypeSameInfoUniv: " << base_weight);
	}

	int univCount = 0;
	createDetail << " univ_";
	pair<map<int, OfferDataNSeq>::iterator, bool> ins_univ_iter = res.insert(make_pair(BaseTypeSameInfoUniv, OfferDataNSeq()));

	for (ItemSeq::iterator iter = sameInfoFriends.univInfo.begin(); 
			iter != sameInfoFriends.univInfo.end(); ++iter) {   //添加大学资料匹配好友
		for(MyUtil::IntSeq::iterator it = iter->idSeq.begin(); 
				it != iter->idSeq.end(); ++it) {
			OfferDataN infoFriend;
			infoFriend.weight = base_weight;
			infoFriend.userId = *it;
			infoFriend.sign = ((int)0) | (((int)1)<<BaseTraitSameInfoUniv);
			ins_univ_iter.first->second.push_back(infoFriend);
			createDetail << infoFriend.userId << "_";
			++univCount;
		}
	}

	base_weight = 0;
	weiIt = weights.find(BaseTypeSameInfoHighSchool);
	if (weiIt != weights.end()) {
		base_weight = weiIt->second;
	}

	int highCount = 0;
	createDetail << " high_";
	pair<map<int, OfferDataNSeq>::iterator, bool> ins_high_iter = res.insert(make_pair(BaseTypeSameInfoHighSchool, OfferDataNSeq()));

	for (ItemSeq::iterator iter = sameInfoFriends.highschoolInfo.begin(); 
			iter != sameInfoFriends.highschoolInfo.end(); ++iter) {   //添加高中资料匹配好友
		for(MyUtil::IntSeq::iterator it=iter->idSeq.begin(); it!=iter->idSeq.end(); ++it) {
			OfferDataN infoFriend;
			infoFriend.weight = base_weight;
			infoFriend.userId = *it;
			infoFriend.sign = ((int)0) | (((int)1)<<BaseTraitSameInfoHighSchool);
			ins_high_iter.first->second.push_back(infoFriend);
			createDetail << infoFriend.userId << "_";
			++highCount;
		}
	}

	base_weight = 0;
	weiIt = weights.find(BaseTypeSameInfoJuniorSchool);
	if (weiIt!=weights.end()) {
		base_weight = weiIt->second;
	}
	int juCount = 0;
	createDetail << " juni_";
	pair<map<int, OfferDataNSeq>::iterator, bool> ins_junior_iter = res.insert(make_pair(BaseTypeSameInfoJuniorSchool, OfferDataNSeq()));

	for (ItemSeq::iterator iter = sameInfoFriends.juniorschoolInfo.begin(); 
			iter != sameInfoFriends.juniorschoolInfo.end(); ++iter) {  //添加初中资料匹配好友
		for(MyUtil::IntSeq::iterator it = iter->idSeq.begin(); 
				it != iter->idSeq.end(); ++it) {
			OfferDataN infoFriend;
			infoFriend.weight = base_weight;
			infoFriend.userId = *it;
			infoFriend.sign = ((int)0) | (((int)1)<<BaseTraitSameInfoJuniorSchool);
			ins_junior_iter.first->second.push_back(infoFriend);
			createDetail << infoFriend.userId << "_";
			++juCount;
		}
	}

	base_weight = 0;
	weiIt = weights.find(BaseTypeSameInfoElementarySchool);
	if (weiIt != weights.end()) {
		base_weight = weiIt->second;
	}

	int eleCount = 0;
	createDetail << " elem_";
	pair<map<int, OfferDataNSeq>::iterator, bool> ins_ele_iter = res.insert(make_pair(BaseTypeSameInfoElementarySchool, OfferDataNSeq()));
	for (ItemSeq::iterator iter = sameInfoFriends.elementaryschoolInfo.begin(); 
			iter != sameInfoFriends.elementaryschoolInfo.end(); ++iter) {  //添加小学资料匹配好友
		for (MyUtil::IntSeq::iterator it = iter->idSeq.begin(); 
				it!=iter->idSeq.end(); ++it) {
			OfferDataN infoFriend;
			infoFriend.weight = base_weight;
			infoFriend.userId = *it;

			infoFriend.sign = ((int)0) | (((int)1)<<BaseTraitSameInfoElementarySchool);
			ins_ele_iter.first->second.push_back(infoFriend);
			createDetail << infoFriend.userId << "_";
			++eleCount;
		}
	}

	/*中学推荐*/
  HighSchoolInfo highSchoolFriends = OfferFriendsUtil::getHighSchoolInfo(userId, infoLimit, filterList);
	base_weight = 0;
	weiIt = weights.find(BaseTypeAreaEnrollSame);
	if (weiIt != weights.end()) {
		base_weight = weiIt->second;
		MCE_INFO("BaseTypeAreaEnrollSame : " << base_weight);
	}

	int areaCount = 0;
	createDetail << " area_";
	pair<map<int, OfferDataNSeq>::iterator, bool> ins_area_iter = res.insert(make_pair(BaseTypeAreaEnrollSame, OfferDataNSeq()));
	for (RecommendItemSeq::iterator iter = highSchoolFriends.highschoolseq.begin(); 
			iter != highSchoolFriends.highschoolseq.end(); ++iter) {
		OfferDataN infoFriend;
		infoFriend.weight = base_weight;
		infoFriend.userId = iter->uid;

		infoFriend.sign = ((int)0) | (((int)1)<<BaseTraitAreaEnrollSame);
		ins_area_iter.first->second.push_back(infoFriend);
		createDetail << infoFriend.userId << "_";
		++areaCount;
	}
	for (RecommendItemSeq::iterator iter = highSchoolFriends.juniorschoolseq.begin(); 
			iter != highSchoolFriends.juniorschoolseq.end(); ++iter) {
		OfferDataN infoFriend;
		infoFriend.weight = base_weight;
		infoFriend.userId = iter->uid;

		infoFriend.sign = ((int)0) | (((int)1)<<BaseTraitAreaEnrollSame);
		ins_area_iter.first->second.push_back(infoFriend);
		createDetail << infoFriend.userId << "_";
		++areaCount;
	}
	for (RecommendItemSeq::iterator iter = highSchoolFriends.collegeseq.begin(); 
			iter != highSchoolFriends.collegeseq.end(); ++iter) {
		OfferDataN infoFriend;
		infoFriend.weight = base_weight;
		infoFriend.userId = iter->uid;

		infoFriend.sign = ((int)0) | (((int)1)<<BaseTraitAreaEnrollSame);
		ins_area_iter.first->second.push_back(infoFriend);
		createDetail << infoFriend.userId << "_";
		++areaCount;
	}

	gettimeofday(&tvInfo, NULL);
	double linInfoStart = ((double)tvStart.tv_sec*1000000 + (double)tvStart.tv_usec);	
	double linInfoEnd = ((double)tvInfo.tv_sec*1000000 + (double)tvInfo.tv_usec);
	double linInfoTime = linInfoEnd - linInfoStart;
	linInfoTime = linInfoTime/1000000;
	createLog	<< " sameInfoFriends("
			<< "(u" << sameInfoFriends.univInfo.size() << ":" << univCount << ")"
			<< "(h" << sameInfoFriends.highschoolInfo.size() << ":" << highCount << ")"
			<< "(j" << sameInfoFriends.juniorschoolInfo.size() << ":" << juCount << ")"
			<< "(e" << sameInfoFriends.elementaryschoolInfo.size() << ":" << eleCount << ")"
			<< "(a" << res[BaseTypeAreaEnrollSame].size() << ":" << areaCount << ")"
			<< "(" << linInfoTime << "s)";
	MCE_INFO("BackendUtil createlog << " << createLog.str());

	return res;
}
コード例 #22
0
ファイル: OfferCreator.cpp プロジェクト: bradenwu/oce
OfferCacheDataNPtr OfferCreator::create(int userId,
																				int resultSize,
																				ostringstream& createRes)
{
	MCE_INFO("OfferCreator create userId:" << userId << " resultSize:" << resultSize);
	ostringstream createLog;
	ostringstream createDetail;

	if (resultSize <= 0) {
		createLog << "resultSize error";
		return new OfferCacheDataN;
	}

	//struct timeval tvStart, tvPref,
	//tvApply, tvFriend, tvBlock, tvCommBlock,
	//tvCreate, tvDedup,
	//tvPhotoFilter, tvStatusFilter, tvViewCountFilter, tvStarFilter,
	//tvEnd;
	//gettimeofday(&tvStart, NULL);
	//double linStart = ((double)tvStart.tv_sec * 1000000 + (double)tvStart.tv_usec);

	PreferenceDataPtr pref = PreferenceProducer::instance().create(userId, createLog);

	//gettimeofday(&tvPref, NULL);	
	//double linPrefEnd = ((double)tvPref.tv_sec * 1000000 + (double)tvPref.tv_usec);
	//double linPrefTime = linPrefEnd - linStart;
	//linPrefTime = linPrefTime/1000000;	
	//createLog	<< "(" << linPrefTime << "s)";

	std::ostringstream app_tmp;
	IntSeq applyList = OfferFriendsUtil::getApplySeq(userId);
	MCE_INFO("applyList size : " << applyList.size());

	//gettimeofday(&tvApply, NULL);	
	//double linApplyEnd = ((double)tvApply.tv_sec * 1000000 + (double)tvApply.tv_usec);
	//double linApplyTime = linApplyEnd - linPrefEnd;
	//linApplyTime = linApplyTime/1000000;	
	//createLog	<< " applyList(" << applyList.size() << ")(" << linApplyTime << "s)";

	IntSeq friendList = OfferFriendsUtil::getFriendSeq(userId);
	MCE_INFO("friendList size : " << friendList.size());

	//gettimeofday( &tvFriend, NULL );	
	//double linFriendEnd = ((double)tvFriend.tv_sec * 1000000 + (double)tvFriend.tv_usec);
	//double linFriendTime = linFriendEnd - linApplyEnd;
	//linFriendTime = linFriendTime/1000000;	
	//createLog	<< " friendList(" << friendList.size() << ")(" << linFriendTime << "s)";

  IntSeq blockList = OfferFriendsUtil::getBlockSeq(userId);
	MCE_INFO("blockList size : " << blockList.size());

	//gettimeofday(&tvBlock, NULL);	
	//double linBlockEnd = ((double)tvBlock.tv_sec * 1000000 + (double)tvBlock.tv_usec);
	//double linBlockTime = linBlockEnd - linFriendEnd;
	//linBlockTime = linBlockTime/1000000;	
	//createLog	<< " blockList(" << blockList.size() << ")(" << linBlockTime << "s)";

  IntSeq commBlockList = OfferFriendsUtil::getCommBlockSeq(userId);
	MCE_INFO("commBlockList size : " << commBlockList.size());

	//gettimeofday(&tvCommBlock, NULL);	
	//double linCommBlockEnd = ((double)tvCommBlock.tv_sec * 1000000 + (double)tvCommBlock.tv_usec);
	//double linCommBlockTime = linCommBlockEnd - linBlockEnd;
	//linCommBlockTime = linCommBlockTime/1000000;	
	//createLog	<< " commBlockList(" << commBlockList.size() << ")(" << linCommBlockTime << "s)";

	//createLog	<< " >> ";

	BackendDataPtr bak = BackendProducer::instance().create(userId, pref->getWeights(), applyList, friendList,
																												blockList, commBlockList, createLog, createDetail);

	//gettimeofday(&tvCreate, NULL);
	//double linCreateEnd = ((double)tvCreate.tv_sec * 1000000 + (double)tvCreate.tv_usec);
	//double linCreateTime = linCreateEnd - linCommBlockEnd;
	//linCreateTime = linCreateTime/1000000;	
	//createLog	<< " create(" << linCreateTime << "s)>> ";

	//make offerSource list from backendResult,calculate weight of the ids repeated in more than 1 type
	//按类型保存权重排序后的用户
	map<int, multimap<int, OfferDataN> > typedWeightMap;
	MyUtil::IntSeq ids = dedup(typedWeightMap, bak, createLog, createDetail);

	MCE_INFO("[OfferCreator] create ids size:" << ids.size());
	//gettimeofday(&tvDedup, NULL);
	//double linDedupEnd = ((double)tvDedup.tv_sec * 1000000 + (double)tvDedup.tv_usec);
	//double linDedupTime = linDedupEnd - linCreateEnd;
	//linDedupTime = linDedupTime/1000000;	
	//createLog	<< linDedupTime << "s)";

	map<int, bool> photo_map = OfferFriendsUtil::getPhotoStateBatch(ids);
	photo_filter(typedWeightMap, photo_map, createLog, createDetail);

	//gettimeofday(&tvPhotoFilter, NULL);
	//double linPhotoFilterEnd = ((double)tvPhotoFilter.tv_sec * 1000000 + (double)tvPhotoFilter.tv_usec);
	//double linPhotoFilterTime = linPhotoFilterEnd - linDedupEnd;
	//linPhotoFilterTime = linPhotoFilterTime / 1000000;
	//createLog	<< "(" << linPhotoFilterTime << "s)";

	map<int, bool> status_map = OfferFriendsUtil::getStatusBatch(ids);
	status_filter(typedWeightMap, status_map, createLog, createDetail);

	//gettimeofday( &tvStatusFilter, NULL );
	//double linStatusFilterEnd = ((double)tvStatusFilter.tv_sec*1000000 + (double)tvStatusFilter.tv_usec);
	//double linStatusFilterTime = linStatusFilterEnd - linPhotoFilterEnd;
	//linStatusFilterTime = linStatusFilterTime/1000000;
	//createLog	<< "(" << linStatusFilterTime << "s)";

	map<int, int> view_count_map = OfferFriendsUtil::getViewCountMap(ids);
	view_count_filter(typedWeightMap, view_count_map, createLog, createDetail);

	//gettimeofday( &tvViewCountFilter, NULL );
	//double linViewCountFilterEnd = ((double)tvViewCountFilter.tv_sec*1000000 + (double)tvViewCountFilter.tv_usec);
	//double linViewCountFilterTime = linViewCountFilterEnd - linStatusFilterEnd;
	//linViewCountFilterTime = linViewCountFilterTime/1000000;
	//createLog	<< "(" << linViewCountFilterTime << "s)";

	map<int,bool> star_map = OfferFriendsUtil::getStateStarBatch( ids );
	star_filter(typedWeightMap, star_map, createLog, createDetail);

	//gettimeofday( &tvStarFilter, NULL );
	//double linStarFilterEnd = ((double)tvStarFilter.tv_sec*1000000 + (double)tvStarFilter.tv_usec);
	//double linStarFilterTime = linStarFilterEnd - linViewCountFilterEnd;
	//linStarFilterTime = linStarFilterTime/1000000;
	//createLog	<< "(" << linStarFilterTime << "s)";

	OfferCacheDataNPtr offerRes = pick_out(resultSize, typedWeightMap, pref, createLog, createDetail);

	//gettimeofday( &tvEnd, NULL );
	//double linEnd = ((double)tvEnd.tv_sec*1000000 + (double)tvEnd.tv_usec);
	//double linPickOutTime = linEnd - linStarFilterEnd;
	//linPickOutTime = linPickOutTime/1000000;
	//createLog	<< "(" << linPickOutTime << "s)";

	//double linTime = linEnd - linStart;
	//linTime = linTime/1000000;
	//createLog	<< " total(" << linTime << "s)";

	//MCE_INFO( "[OfferCreate::create] userId=" << userId << createLog.str() );
	//createRes << "userId=" << userId << createLog.str() << " details[ " << createDetail.str() << " ]";
	return offerRes;
}
コード例 #23
0
ファイル: RoomPool.cpp プロジェクト: bradenwu/oce
IntSeq RoomPool::GetRoomMember(const MucRoomIdPtr& roomid){

  RoomMemberListPtr rmlptr;
  IntSeq ans;
  rmlptr = GetMemberList(roomid);
  if(rmlptr){
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
    ans = rmlptr->GetAllMembersSeq();
  }
  MCE_DEBUG("RoomPool::GetRoomMember --> roomname = " << roomid->roomname << " ANS.SIZE = " << ans.size());
  return ans;
}