瀏覽代碼

fix feature partition is null

jch 5 月之前
父節點
當前提交
c89648c4c7

+ 3 - 1
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV563.java

@@ -342,7 +342,9 @@ public class RankStrategy4RegionMergeModelV563 extends RankStrategy4RegionMergeM
 
         // 4 排序模型计算
         Map<String, String> sceneFeatureMap = new HashMap<>(0);
-        sceneFeatureMap.put("weightKey", partition.substring(partition.length() - 2));
+        if (null != partition && partition.length() > 2) {
+            sceneFeatureMap.put("weightKey", partition.substring(partition.length() - 2));
+        }
         List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_20241107.conf").scoring(sceneFeatureMap, userFeatureMap, rankItems);
         // 5 排序公式特征
         Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, "redis:vid_hasreturn_rov:");

+ 3 - 1
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelV564.java

@@ -342,7 +342,9 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
 
         // 4 排序模型计算
         Map<String, String> sceneFeatureMap = new HashMap<>(0);
-        sceneFeatureMap.put("weightKey", partition.substring(partition.length() - 2));
+        if (null != partition && partition.length() > 2) {
+            sceneFeatureMap.put("weightKey", partition.substring(partition.length() - 2));
+        }
         List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_20241119.conf").scoring(sceneFeatureMap, userFeatureMap, rankItems);
         // 5 排序公式特征
         Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, "redis:vid_hasreturn_rov:");

+ 1 - 1
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/score/VovH24WeightScorer.java

@@ -157,7 +157,7 @@ public class VovH24WeightScorer extends AbstractScorer {
 
         double vovScore = 0.0;
         Map<String, String> featureMap = item.getFeatureMap();
-        String weightKey = sceneFeatureMap.get("weightKey");
+        String weightKey = sceneFeatureMap.getOrDefault("weightKey", "");
         Map<String, Double> weightMap = model.getWeight(weightKey);
         if (MapUtils.isNotEmpty(featureMap) && MapUtils.isNotEmpty(weightMap)) {
             try {

+ 1 - 1
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/score/VovH24WeightV2Scorer.java

@@ -192,7 +192,7 @@ public class VovH24WeightV2Scorer extends AbstractScorer {
 
         double vovScore = 0.0;
         Map<String, String> featureMap = item.getFeatureMap();
-        String weightKey = sceneFeatureMap.get("weightKey");
+        String weightKey = sceneFeatureMap.getOrDefault("weightKey", "");
         Map<String, Double> weightMap = model.getWeight(weightKey);
         if (MapUtils.isNotEmpty(featureMap) && MapUtils.isNotEmpty(weightMap)) {
             try {