|
@@ -125,31 +125,43 @@ public class FlowPoolWithLevelRecallStrategyTomson extends AbstractFlowPoolWithL
|
|
|
videoFlowPoolMap.put(values[0], values[1]);
|
|
|
videoFlowPoolMap_.put(NumberUtils.toLong(values[0], 0), values[1]);
|
|
|
}
|
|
|
- ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_tomson.conf");
|
|
|
- List<List<Pair<Long, Double>>> results = pipeline.recall(videoFlowPoolMap);
|
|
|
- List<Pair<Long, Double>> result = results.get(0);
|
|
|
- Map<Long, Double> resultmap = result.stream()
|
|
|
+ Map<Long, Double> resultmap = null;
|
|
|
+ if ("1".equals(level)){
|
|
|
+ // 流量池一层改为全随机
|
|
|
+ int limitSize = 60;
|
|
|
+ List<Long> keyList = new ArrayList<>(videoFlowPoolMap_.keySet());
|
|
|
+ Collections.shuffle(keyList);
|
|
|
+ resultmap = keyList.stream().limit(limitSize).collect(Collectors.toMap(
|
|
|
+ key -> key,
|
|
|
+ key -> Math.random()
|
|
|
+ ));
|
|
|
+ }else{
|
|
|
+ ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_tomson.conf");
|
|
|
+ List<List<Pair<Long, Double>>> results = pipeline.recall(videoFlowPoolMap);
|
|
|
+ List<Pair<Long, Double>> result = results.get(0);
|
|
|
+ resultmap = result.stream()
|
|
|
.collect(Collectors.toMap(
|
|
|
Pair::getLeft, // 键是Pair的left值
|
|
|
Pair::getRight, // 值是Pair的right值
|
|
|
(existingValue, newValue) -> existingValue, // 如果键冲突,选择保留现有的值(或者你可以根据需要定义其他合并策略)
|
|
|
LinkedHashMap::new // 使用LinkedHashMap来保持插入顺序(如果需要的话)
|
|
|
));
|
|
|
+ }
|
|
|
+
|
|
|
// 3 召回内部过滤
|
|
|
- FilterParam filterParam = FilterParamFactory.create(param, result.stream()
|
|
|
- .map(Pair::getLeft)
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ FilterParam filterParam = FilterParamFactory.create(param, new ArrayList<>(resultmap.keySet()));
|
|
|
filterParam.setForceTruncation(10000);
|
|
|
filterParam.setConcurrent(true);
|
|
|
filterParam.setNotUsePreView(false);
|
|
|
FilterResult filterResult = filterService.filter(filterParam);
|
|
|
List<Video> videosResult = new ArrayList<>();
|
|
|
if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
|
|
|
+ Map<Long, Double> finalResultmap = resultmap;
|
|
|
filterResult.getVideoIds().forEach(vid -> {
|
|
|
Video recallData = new Video();
|
|
|
recallData.setVideoId(vid);
|
|
|
recallData.setAbCode(param.getAbCode());
|
|
|
- recallData.setRovScore(resultmap.getOrDefault(vid, 0.0));
|
|
|
+ recallData.setRovScore(finalResultmap.getOrDefault(vid, 0.0));
|
|
|
recallData.setPushFrom(pushFrom());
|
|
|
recallData.setFlowPool(videoFlowPoolMap_.get(vid));
|
|
|
recallData.setFlowPoolAbtestGroup(param.getFlowPoolAbtestGroup());
|