import redis import random from models.cache import R from utils import filter_utils from configs import config_redis, config_algo, config_basic class pool_manager: def __init__(self, k, p, mid, scene='MP-FRONT',counts=10): self.k = k self.p = p self.mid = mid self.scene = scene self.counts = counts #前k个按rov分值排序,后面total-k个,按p的概率从测试池取值,1-p的概率从召回池取 def get_rov_data(self): res_all = [] res_recall = self._get_data_from_cache(config_redis.ROV_SERVICE_RECALL_VIDS, self.counts) res_pool = self._get_data_from_cache(config_redis.ROV_SERVICE_POOL_VIDS, self.counts) head_recall = 0 head_pool = 0 len_recall = len(res_recall) len_pool = len(res_pool) i = 0 item = None vid_from = None #按分排序取top k while(ires_pool[head_pool][1] and head_recall