|
@@ -35,8 +35,6 @@ import static com.tzld.piaoquan.recommend.server.service.flowpool.FlowPoolConsta
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class FlowPoolWithLevelRecallStrategyTomson extends AbstractFlowPoolWithLevelRecallStrategy {
|
|
|
- @ApolloJsonValue("${ifOneLevelRandom:true}")
|
|
|
- private boolean ifOneLevelRandom;
|
|
|
@Autowired
|
|
|
private FlowPoolConfigService flowPoolConfigService;
|
|
|
|
|
@@ -135,27 +133,16 @@ public class FlowPoolWithLevelRecallStrategyTomson extends AbstractFlowPoolWithL
|
|
|
videoFlowPoolMap_.put(NumberUtils.toLong(values[0], 0), values[1]);
|
|
|
}
|
|
|
Map<Long, Double> resultmap = null;
|
|
|
- if ("1".equals(level) && ifOneLevelRandom) {
|
|
|
- // 流量池一层改为全随机
|
|
|
- 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来保持插入顺序(如果需要的话)
|
|
|
- ));
|
|
|
- }
|
|
|
+ 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, new ArrayList<>(resultmap.keySet()));
|