Forráskód Böngészése

Merge branch 'feature/zhangbo_rank' of algorithm/recommend-server into master

zhangbo 1 éve
szülő
commit
cae95b76a2

+ 4 - 5
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/RankRouter.java

@@ -49,17 +49,14 @@ public class RankRouter {
         }
         switch (abCode) {
             case "60097":
-            case "60121": // 536
+            case "60111": // 561
+            case "60112": // 562
                 return rankStrategy4Density.rank(param);
             case "60106":
                 return rankStrategy4Rankv2Model.rank(param);
             case "60101":
                 return rankStrategy4RankModel.rank(param);
             case "60098":
-            case "60111": // 561
-                return rankStrategy4RegionMergeModelV561.rank(param);
-            case "60112": // 562
-                return rankStrategy4RegionMergeModelV562.rank(param);
             case "60113":
             case "60114":
             case "60115":
@@ -70,6 +67,8 @@ public class RankRouter {
                 return rankStrategyFlowThompsonModel.rank(param);
             case "60120": // 576
                 return rankStrategy4RegionMerge.rank(param);
+            case "60121": // 536
+                return rankStrategy4RegionMergeModelV536.rank(param);
             case "60122": // 537
                 return rankStrategy4RegionMergeModelV2.rank(param);
             case "60123": // 541

+ 4 - 4
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/RankService.java

@@ -138,7 +138,8 @@ public class RankService {
                 || param.getAbCode().equals("60095")
                 || param.getAbCode().equals("60096")
                 || param.getAbCode().equals("60097")
-                || param.getAbCode().equals("60121")
+                || param.getAbCode().equals("60111")
+                || param.getAbCode().equals("60112")
                 || param.getAbCode().equals("60098")
                 || param.getAbCode().equals("60103")
                 || param.getAbCode().equals("60104")
@@ -165,9 +166,8 @@ public class RankService {
             // merge sim recall 和 return recall
             rovRecallRank.addAll(extractAndSort(param, SimHotVideoRecallStrategy.PUSH_FORM));
             rovRecallRank.addAll(extractAndSort(param, ReturnVideoRecallStrategy.PUSH_FORM));
-            if (param.getAbCode().equals("60110")) {
-                rovRecallRank.addAll(extractAndSort(param, FlowPoolLastDayTopRecallStrategy.PUSH_FORM));
-                rovRecallRank.addAll(extractAndSort(param, TopGoodPerformanceVideoRecallStrategy.PUSH_FORM));
+            if (param.getAbCode().equals("60112")) {
+                rovRecallRank.addAll(extractAndSort(param, RegionRealtimeRecallStrategyV5Hand.PUSH_FORM));
             }
             removeDuplicate(rovRecallRank);
 

+ 6 - 5
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallService.java

@@ -110,7 +110,6 @@ public class RecallService implements ApplicationContextAware {
                     break;
                 case "60120": // 576
                 case "60123": // 541
-                case "60112": // 562
                     strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
                     strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV2.class.getSimpleName()));
                     strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV3.class.getSimpleName()));
@@ -120,7 +119,7 @@ public class RecallService implements ApplicationContextAware {
                     strategies.addAll(getRegionRecallStrategy(param));
             }
             //2:通过“流量池标记”控制“流量池召回子策略” 其中有9组会走EXPERIMENTAL_FLOW_SET_LEVEL 有1组会走EXPERIMENTAL_FLOW_SET_LEVEL_SCORE
-            if ("60111".equals(abCode) || "60112".equals(abCode)){
+            if ("60111".equals(abCode)){
                 int lastDigit = param.getLastDigit();
                 String lastDigitAB = lastDigitAbcode != null? lastDigitAbcode.getOrDefault(lastDigit, "default"): "default";
                 switch (lastDigitAB){
@@ -181,8 +180,6 @@ public class RecallService implements ApplicationContextAware {
             // todo 做兜底吗?
         } else {
             switch (abCode) {
-
-
                 case "60113":
                 case "60114":
                 case "60115":
@@ -211,13 +208,17 @@ public class RecallService implements ApplicationContextAware {
                     strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
                     strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
                     break;
+                case "60112": // 562
+                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                    strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV5Hand.class.getSimpleName()));
+                    break;
                 case "60121": // 536
                 case "60122": // 537
                 case "60124": // 546
                 case "60125": // 547
                 case "60123": // 541
                 case "60126": // 548
-                case "60112": // 562
                     strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
                     strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
                     strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));

+ 65 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV5Hand.java

@@ -0,0 +1,65 @@
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
+
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
+import com.google.common.collect.Lists;
+import com.tzld.piaoquan.recommend.server.model.Video;
+import com.tzld.piaoquan.recommend.server.service.filter.FilterParam;
+import com.tzld.piaoquan.recommend.server.service.filter.FilterResult;
+import com.tzld.piaoquan.recommend.server.service.filter.RegionFilterService;
+import com.tzld.piaoquan.recommend.server.service.recall.FilterParamFactory;
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import com.tzld.piaoquan.recommend.server.service.recall.RecallStrategy;
+import com.tzld.piaoquan.recommend.server.service.score.ScorerUtils;
+import com.tzld.piaoquan.recommend.server.service.score4recall.ScorerPipeline4Recall;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+/**
+ * @author zhangbo
+ */
+@Slf4j
+@Component
+public class RegionRealtimeRecallStrategyV5Hand implements RecallStrategy {
+    @ApolloJsonValue("${alg.recall.hand.videos:[]}")
+    private List<Long> handVideos;
+    @Autowired
+    protected RegionFilterService filterService;
+    @Override
+    public List<Video> recall(RecallParam param) {
+        List<Long> vids = handVideos != null ? handVideos : new ArrayList<>();
+        List<Video> videosResult = new ArrayList<>();
+        if (vids.isEmpty()){
+            return videosResult;
+        }
+        FilterParam filterParam = FilterParamFactory.create(param, vids);
+        filterParam.setForceTruncation(10000);
+        filterParam.setConcurrent(true);
+        filterParam.setNotUsePreView(false);
+        FilterResult filterResult = filterService.filter(filterParam);
+        if (filterResult == null || filterResult.getVideoIds().isEmpty()){
+            return videosResult;
+        }
+        filterResult.getVideoIds().forEach(vid -> {
+            Video video = new Video();
+            video.setVideoId(vid);
+            video.setAbCode(param.getAbCode());
+            video.setRovScore(RandomUtils.nextFloat(0, 1));
+            video.setPushFrom(pushFrom());
+            videosResult.add(video);
+        });
+        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
+        return videosResult;
+    }
+    public static final String PUSH_FORM = "recall_strategy_hand";
+    @Override
+    public String pushFrom(){
+        return PUSH_FORM;
+    }
+
+}