8.8 — 添加功能队列

void VrBase::split_passthrough_video_queue(GRCSessionContext& sctx, 
        std::list<RidTmpInfo>& all_tmp_res, 
        int video_type) {
    std::string queue_config = "";
    std::string new_queue_config = "";
    if (video_type == VIDEO_TYPE_SHORT_VIDEO) {
        EXPERIMENT_GET_BY_SID(&sctx, "video_passthrough.shortvideo_queue", queue_config);
    } else if (video_type == VIDEO_TYPE_MICRO_VIDEO) {
        EXPERIMENT_GET_BY_SID(&sctx, "video_passthrough.microvideo_queue", queue_config);
        EXPERIMENT_GET_BY_SID(&sctx, "video_passthrough.microvideo_new_queue", new_queue_config);
    }
    
    GRCLOG(TRACE, &sctx) << "queue_config:" << queue_config;
    GRCLOG(TRACE, &sctx) << "vr passthrough before:" << _passthrough_res_map.size();
    get_passthrough_res_map(sctx, all_tmp_res, video_type, queue_config, _passthrough_res_map);
    GRCLOG(TRACE, &sctx) << "vr passthrough after:" << _passthrough_res_map.size();

    if (video_type == VIDEO_TYPE_MICRO_VIDEO && sctx._emgr.passthrough_queue_is_hit) {
        GRCLOG(TRACE, &sctx) << "new_queue_config:" << new_queue_config;
        GRCLOG(TRACE, &sctx) << "vr passthrough new before:" << _passthrough_res_map_new.size();

        get_passthrough_res_map(sctx, all_tmp_res, video_type, new_queue_config, _passthrough_res_map_new);
        GRCLOG(TRACE, &sctx) << "vr passthrough new after:" << _passthrough_res_map_new.size();
    }
}

void VrBase::get_passthrough_res_map(GRCSessionContext& sctx, 
        std::list<RidTmpInfo>& all_tmp_res, int video_type, std::string queue_config, 
        std::map<std::string, std::list<RidTmpInfo>>& _passthrough_map) {
    std::vector<std::string> resp_key_vec;
    StrategyUtil::split(queue_config, ",", resp_key_vec);
    std::string pass_log = "split_passthrough_result in cluster " + std::to_string(video_type) + ":";
    GRCLOG(TRACE, &sctx) << "vr _passthrough_map new before:" << _passthrough_map.size();

    for (auto iter = all_tmp_res.begin(); iter != all_tmp_res.end();) {
        GRCLOG(TRACE, &sctx) << "all tmp res key:" << iter->queue_key << ", cluster :" << video_type << " rid:" << iter->rid;
        std::string resp_key = iter->queue_key;
        auto find_iter =  std::find(resp_key_vec.begin(), resp_key_vec.end(), resp_key);
        if (resp_key.empty() || find_iter == resp_key_vec.end()) {
            GRCLOG(TRACE, &sctx) << "debug nid notsplit:" << iter->rid << ", cluster:" << video_type;
            ++iter;
            continue;
        } else {
            GRCLOG(TRACE, &sctx) << "debug nid split:" << iter->rid << ", cluster:" << video_type;
            auto pass_iter = _passthrough_map.find(resp_key);
            if (pass_iter == _passthrough_map.end()) {
                std::list<RidTmpInfo> queue_res;
                queue_res.push_back(*iter);
                _passthrough_map.insert(std::make_pair(resp_key, queue_res));

                GRCLOG(TRACE, &sctx) << "vr debug resp_key:" << resp_key << "vr debug passthrough size:" << queue_res.size();

                pass_log += "(" + std::to_string(iter->rid) + "," + std::to_string(iter->type) + ")";
                iter = all_tmp_res.erase(iter);
            } else {
                pass_iter->second.push_back(*iter);
                pass_log += "(" + std::to_string(iter->rid) + "," + std::to_string(iter->type) + ")";
                iter = all_tmp_res.erase(iter);
            }
        }
    }
    GRCLOG(NOTICE, &sctx) << pass_log;
}

猜你喜欢

转载自www.cnblogs.com/eilearn/p/11322012.html
8.8