丁云鹏 1 anno fa
parent
commit
d7138c04cb

+ 5 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/model/RecommendParam.java

@@ -21,6 +21,11 @@ public class RecommendParam {
     private String abCode;
     private String ruleKey;
     private String dataKey;
+    
+    // hardcode   兼容旧服务的518实验
+    private String hDataKey;
+    private String hRuleKey;
+
     private int flowPoolId;
     private String flowPoolAbtestGroup;
     private String rankKeyPrefix;

+ 9 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/RecommendService.java

@@ -243,6 +243,10 @@ public class RecommendService {
                     param.setAbCode(entry.getValue().get("ab_code"));
                     param.setRuleKey(entry.getValue().get("rule_key"));
                     param.setDataKey(entry.getValue().get("data_key"));
+
+                    param.setHDataKey(entry.getValue().get("h_data_key"));
+                    param.setHRuleKey(entry.getValue().get("h_rule_key"));
+
                     param.setRankKeyPrefix(StringUtils.isNotBlank(entry.getValue().get("rank_key_prefix"))
                             ? entry.getValue().get("rank_key_prefix")
                             : "rank:score1:");
@@ -391,6 +395,10 @@ public class RecommendService {
 
         recallParam.setRuleKey(param.getRuleKey());
         recallParam.setDataKey(param.getDataKey());
+        recallParam.setHRuleKey(param.getHRuleKey());
+        recallParam.setHDataKey(param.getHDataKey());
+
+
         recallParam.setMid(param.getMid());
         recallParam.setSize(param.getSize());
         recallParam.setUid(param.getUid());
@@ -511,6 +519,7 @@ public class RecommendService {
         consumer.accept(Region24HRecallStrategy.PUSH_FORM);
         consumer.accept(RegionRelative24HRecallStrategy.PUSH_FORM);
         consumer.accept(RegionRelative24HDupRecallStrategy.PUSH_FORM);
+        consumer.accept(RegionHWithoutDupRecallStrategy.PUSH_FORM);
     }
 
 }

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

@@ -2,7 +2,6 @@ package com.tzld.piaoquan.recommend.server.service.rank;
 
 
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
-import com.google.common.reflect.TypeToken;
 import com.tzld.piaoquan.recommend.feature.domain.video.base.ItemFeature;
 import com.tzld.piaoquan.recommend.feature.domain.video.base.RequestContext;
 import com.tzld.piaoquan.recommend.feature.domain.video.base.UserFeature;
@@ -12,21 +11,15 @@ import com.tzld.piaoquan.recommend.server.model.MachineInfo;
 import com.tzld.piaoquan.recommend.server.model.Video;
 import com.tzld.piaoquan.recommend.server.remote.FeatureRemoteService;
 import com.tzld.piaoquan.recommend.server.service.flowpool.FlowPoolConstants;
-import com.tzld.piaoquan.recommend.server.service.rank.extractor.RankExtractorFeature;
-import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorDensity;
 import com.tzld.piaoquan.recommend.server.service.recall.RecallResult;
 import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
 import com.tzld.piaoquan.recommend.server.service.score.ScoreParam;
 import com.tzld.piaoquan.recommend.server.service.score.ScorerUtils;
 import com.tzld.piaoquan.recommend.server.util.CommonCollectionUtils;
-import com.tzld.piaoquan.recommend.server.util.JSONUtils;
-import lombok.Getter;
-import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.math.NumberUtils;
-import com.alibaba.fastjson.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -89,13 +82,15 @@ public class RankService {
     public List<Video> mergeAndRankRovRecall(RankParam param) {
         // TODO ab test
         // TODO 抽象成Strategy
-        boolean hitTest = newRankSwitch
-                || CommonCollectionUtils.contains(param.getAbExpCodes(), newRankAbExpCode);
-        if (hitTest) {
-            return mergeAndRankRovRecallNew(param);
-        } else {
-            return mergeAndRankRovRecallOld(param);
-        }
+//        boolean hitTest = newRankSwitch
+//                || CommonCollectionUtils.contains(param.getAbExpCodes(), newRankAbExpCode);
+//        if (hitTest) {
+//            return mergeAndRankRovRecallNew(param);
+//        } else {
+//            return mergeAndRankRovRecallOld(param);
+//        }
+        // 研发重写了代码,直接走新逻辑
+        return mergeAndRankRovRecallOld(param);
     }
 
     public List<Video> mergeAndRankRovRecallOld(RankParam param) {
@@ -105,13 +100,14 @@ public class RankService {
         rovRecallRank.addAll(extractAndSort(param, Region24HRecallStrategy.PUSH_FORM));
         rovRecallRank.addAll(extractAndSort(param, RegionRelative24HRecallStrategy.PUSH_FORM));
         rovRecallRank.addAll(extractAndSort(param, RegionRelative24HDupRecallStrategy.PUSH_FORM));
+        rovRecallRank.addAll(extractAndSort(param, RegionHWithoutDupRecallStrategy.PUSH_FORM));
 
         // @zhangbo 增加不同召回子策略的返回数量-阿波罗:region.recall.return.size
         String abCode = param.getAbCode();
         int sizeReturn = param.getSize();
         if (abCode != null && this.regionRecallReturnSize != null &&
                 this.regionRecallReturnSize.containsKey(abCode) &&
-                this.regionRecallReturnSize.get(abCode) != null ){
+                this.regionRecallReturnSize.get(abCode) != null) {
             sizeReturn = this.regionRecallReturnSize.get(abCode).getOrDefault("result_size", sizeReturn);
         }
 

+ 5 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallParam.java

@@ -15,6 +15,11 @@ public class RecallParam {
     private int appType;
     private String dataKey;
     private String ruleKey;
+
+    // hardcode   兼容旧服务的518实验
+    private String hDataKey;
+    private String hRuleKey;
+
     private String abCode;
     private int size;
     private String flowPoolAbtestGroup;

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

@@ -5,8 +5,6 @@ import com.tzld.piaoquan.recommend.server.common.enums.AppTypeEnum;
 import com.tzld.piaoquan.recommend.server.model.Video;
 import com.tzld.piaoquan.recommend.server.service.flowpool.FlowPoolConstants;
 import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
-import com.tzld.piaoquan.recommend.server.util.CommonCollectionUtils;
-import com.tzld.piaoquan.recommend.server.util.JSONUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeansException;
@@ -107,16 +105,20 @@ public class RecallService implements ApplicationContextAware {
 
         //3:通过“abcode”控制“召回子策略”
         String abCode = param.getAbCode();
-        if (abCode == null){
+        if (abCode == null) {
             // todo 做兜底吗?
             ;
-        }else{
-            switch (abCode){
+        } else {
+            switch (abCode) {
+                case "60096":
+                    strategies.add(strategyMap.get(RegionHWithoutDupRecallStrategy.class.getSimpleName()));
+                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                    break;
                 case "60106":
                 case "60068":
                 case "60092":
                 case "60094":
-                case "60096":
                 case "60097":
                 case "60098":
                 case "60101": // 排序str实验

+ 1 - 1
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionHDupRecallStrategy.java

@@ -5,7 +5,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 /**
- * 分地域
+ * 不区分地域小时
  *
  * @author dyp
  */

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

@@ -0,0 +1,38 @@
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
+
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+/**
+ * 不区分地域小时(不做离线去重)
+ *
+ * @author dyp
+ */
+@Service
+public class RegionHWithoutDupRecallStrategy extends AbstractRegionRecallStrategy {
+    public static final String PUSH_FORM = "rov_recall_h_h_without_dup";
+    public static final String LAST_VIDEO_KEY_FORMAT = "recall:last:item:h:%s:%s";
+
+    @Override
+    protected String recordKey(RecallParam param) {
+        return String.format("recall:last:record:h:%s:%s", param.getAppType(), param.getMid());
+    }
+
+    @Override
+    protected String poolKey(RecallParam param, String now_dt, int h) {
+        // hard code  因为生产任务,会给region填充默认值-1
+        return String.format("recall:item:score:h:%s:%s:%s:%s",
+                param.getDataKey(), param.getRuleKey(), now_dt, h);
+    }
+
+    @Override
+    protected String lastVideoKey(RecallParam param) {
+        return String.format(LAST_VIDEO_KEY_FORMAT, param.getAppType(), param.getMid());
+    }
+
+    @Override
+    public String pushFrom() {
+        return PUSH_FORM;
+    }
+}