Jelajahi Sumber

merge master

jch 3 bulan lalu
induk
melakukan
fd24540237
33 mengubah file dengan 14 tambahan dan 2531 penghapusan
  1. 0 1
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/RecommendService.java
  2. 7 188
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/RankService.java
  3. 1 153
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4RegionMergeModelBasic.java
  4. 6 135
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallService.java
  5. 0 101
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/CFRovnRecallStrategyV1.java
  6. 0 88
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/ContentBaseRecallStrategy.java
  7. 0 72
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/DahanRecallStrategy.java
  8. 0 83
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/FestivalRecallStrategyV1.java
  9. 0 25
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/FlowPoolLastDayTopRecallStrategy.java
  10. 0 38
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionHWithoutDupRecallStrategy.java
  11. 0 106
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV1_default.java
  12. 0 96
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV1_sort.java
  13. 0 67
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV2.java
  14. 0 68
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV2_sort.java
  15. 0 74
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV3.java
  16. 0 84
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV3_default.java
  17. 0 74
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV3_sort.java
  18. 0 66
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV4.java
  19. 0 67
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV5HighValue.java
  20. 0 93
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV6RootRov.java
  21. 0 65
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV7VovLongTermV1.java
  22. 0 65
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV7VovLongTermV2.java
  23. 0 65
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV7VovLongTermV3.java
  24. 0 65
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRealtimeRecallStrategyV7VovLongTermV4.java
  25. 0 35
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRelative48HDupRecallStrategy.java
  26. 0 35
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/RegionRelative48HRecallStrategy.java
  27. 0 73
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/ShareDeepRecallStrategy.java
  28. 0 73
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/ShareWidthRecallStrategy.java
  29. 0 23
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SimHotVideoRecallStrategy.java
  30. 0 237
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/TitleTagRecallStrategyV1.java
  31. 0 24
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/TopGoodPerformanceVideoRecallStrategy.java
  32. 0 4
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/xxl/NotUserUploadUserCacheJob.java
  33. 0 88
      recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/xxl/SyncFlowPoolRecentTopVideoJob.java

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

@@ -589,7 +589,6 @@ public class RecommendService {
         consumer.accept(Region24HRecallStrategy.PUSH_FORM);
         consumer.accept(RegionRelative24HRecallStrategy.PUSH_FORM);
         consumer.accept(RegionRelative24HDupRecallStrategy.PUSH_FORM);
-        consumer.accept(RegionHWithoutDupRecallStrategy.PUSH_FORM);
     }
 
 }

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

@@ -2,17 +2,13 @@ package com.tzld.piaoquan.recommend.server.service.rank;
 
 
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
-import com.tzld.piaoquan.recommend.feature.domain.video.base.RequestContext;
 import com.tzld.piaoquan.recommend.server.common.enums.AppTypeEnum;
-import com.tzld.piaoquan.recommend.server.model.MachineInfo;
 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.RecallResult;
 import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
-import com.tzld.piaoquan.recommend.server.service.score.ScoreParam;
 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 org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -20,7 +16,6 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
-import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -29,7 +24,7 @@ import java.util.stream.Collectors;
  */
 @Service
 @Slf4j
-public class RankService {
+public abstract class RankService {
     @Autowired
     @Qualifier("redisTemplate")
     public RedisTemplate<String, String> redisTemplate;
@@ -75,7 +70,7 @@ public class RankService {
             }
             return new RankResult(results);
         }
-        if (this.matchSpecialApp(param.getAppType())){
+        if (this.matchSpecialApp(param.getAppType())) {
             // 特殊app固定列表,只有一路召回,且不走排序。
             List<Video> results = new ArrayList<>(extractAndSort(param, RegionRealtimeRecallStrategyV5Hand.PUSH_FORM));
             removeDuplicate(results);
@@ -95,8 +90,6 @@ public class RankService {
         List<Video> rovRecallRank = mergeAndRankRovRecall(param);
         List<Video> flowPoolRank = mergeAndRankFlowPoolRecall(param);
 
-        rankFilter(param, rovRecallRank, flowPoolRank);
-
         removeDuplicate(param, rovRecallRank, flowPoolRank);
 
 
@@ -156,105 +149,8 @@ public class RankService {
 
     }
 
-    public void rankFilter(RankParam param, List<Video> rovRecallRank, List<Video> flowPoolRank) {
-    }
-
-    public List<Video> mergeAndRankRovRecall(RankParam param) {
-        // TODO ab test
-        // TODO 抽象成Strategy
-
-        return mergeAndRankRovRecallOld(param);
-    }
-
-    public List<Video> mergeAndRankRovRecallOld(RankParam param) {
-        List<Video> rovRecallRank = new ArrayList<>();
-        rovRecallRank.addAll(extractAndSort(param, RegionHRecallStrategy.PUSH_FORM));
-        rovRecallRank.addAll(extractAndSort(param, RegionHDupRecallStrategy.PUSH_FORM));
-        rovRecallRank.addAll(extractAndSort(param, Region24HRecallStrategy.PUSH_FORM));
-        rovRecallRank.addAll(extractAndSort(param, RegionRelative24HRecallStrategy.PUSH_FORM));
-        rovRecallRank.addAll(extractAndSort(param, RegionRelative24HDupRecallStrategy.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) {
-            sizeReturn = this.regionRecallReturnSize.get(abCode).getOrDefault("result_size", sizeReturn);
-        }
+    public abstract List<Video> mergeAndRankRovRecall(RankParam param);
 
-        if (param.getAbCode().equals("60054")
-                || param.getAbCode().equals("60068")
-                || param.getAbCode().equals("60081")
-                || param.getAbCode().equals("60084")
-                || param.getAbCode().equals("60087")
-                || param.getAbCode().equals("60088")
-                || param.getAbCode().equals("60089")
-                || param.getAbCode().equals("60090")
-                || param.getAbCode().equals("60091")
-                || param.getAbCode().equals("60092")
-                || param.getAbCode().equals("60093")
-                || param.getAbCode().equals("60094")
-                || param.getAbCode().equals("60095")
-                || param.getAbCode().equals("60096")
-                || param.getAbCode().equals("60097")
-                || param.getAbCode().equals("60098")
-                || param.getAbCode().equals("60111")
-                || param.getAbCode().equals("60103")
-                || param.getAbCode().equals("60104")
-                || param.getAbCode().equals("60110")
-                || param.getAbCode().equals("60150")
-        ) {
-            // 地域召回要做截取,再做融合排序
-            removeDuplicate(rovRecallRank);
-            rovRecallRank = rovRecallRank.size() <= sizeReturn
-                    ? rovRecallRank
-                    : rovRecallRank.subList(0, sizeReturn);
-
-
-            // 补充不分地域小时数据
-            rovRecallRank.addAll(extractAndSort(param, RegionHWithoutDupRecallStrategy.PUSH_FORM));
-            // merge sim recall 和 return recall
-            rovRecallRank.addAll(extractAndSort(param, SimHotVideoRecallStrategy.PUSH_FORM));
-            rovRecallRank.addAll(extractAndSort(param, ReturnVideoRecallStrategy.PUSH_FORM));
-            if (param.getAbCode().equals("60150")) {
-                rovRecallRank.addAll(extractAndSort(param, ShareDeepRecallStrategy.PUSH_FORM));
-                rovRecallRank.addAll(extractAndSort(param, ShareWidthRecallStrategy.PUSH_FORM));
-            }
-            removeDuplicate(rovRecallRank);
-
-            // 融合排序
-            List<String> videoIdKeys = rovRecallRank.stream()
-                    .map(t -> param.getRankKeyPrefix() + t.getVideoId())
-                    .collect(Collectors.toList());
-            List<String> videoScores = redisTemplate.opsForValue().multiGet(videoIdKeys);
-            if (CollectionUtils.isNotEmpty(videoScores)
-                    && videoScores.size() == rovRecallRank.size()) {
-                for (int i = 0; i < videoScores.size(); i++) {
-                    rovRecallRank.get(i).setSortScore(NumberUtils.toDouble(videoScores.get(i), 0.0));
-                }
-                Collections.sort(rovRecallRank, Comparator.comparingDouble(o -> -o.getSortScore()));
-            }
-        } else {
-            rovRecallRank.addAll(extractAndSort(param, SimHotVideoRecallStrategy.PUSH_FORM));
-            rovRecallRank.addAll(extractAndSort(param, ReturnVideoRecallStrategy.PUSH_FORM));
-            removeDuplicate(rovRecallRank);
-
-            // 融合排序
-            List<String> videoIdKeys = rovRecallRank.stream()
-                    .map(t -> param.getRankKeyPrefix() + t.getVideoId())
-                    .collect(Collectors.toList());
-            List<String> videoScores = redisTemplate.opsForValue().multiGet(videoIdKeys);
-            if (CollectionUtils.isNotEmpty(videoScores)
-                    && videoScores.size() == rovRecallRank.size()) {
-                for (int i = 0; i < videoScores.size(); i++) {
-                    rovRecallRank.get(i).setSortScore(NumberUtils.toDouble(videoScores.get(i), 0.0));
-                }
-                rovRecallRank.sort(Comparator.comparingDouble(o -> -o.getSortScore()));
-            }
-        }
-        return rovRecallRank;
-    }
 
     public void removeDuplicate(List<Video> rovRecallRank) {
         if (CollectionUtils.isNotEmpty(rovRecallRank)) {
@@ -271,38 +167,6 @@ public class RankService {
         }
     }
 
-    protected ScoreParam convert(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-
-        scoreParam.setMid(param.getMid());
-
-        // TODO hardcode 为了兼容写入逻辑
-        RequestContext context = new RequestContext();
-        context.setApptype(param.getAppType() + "");
-
-        // TODO 地域转换
-        context.setRegion(param.getProvince());
-        context.setCity(param.getCity());
-
-        Calendar calendar = Calendar.getInstance();
-        context.setWeek((calendar.get(Calendar.DAY_OF_WEEK) + 6) % 7 + "");
-        context.setDay(new SimpleDateFormat("yyyyMMdd").format(calendar.getTime()));
-        context.setHour(new SimpleDateFormat("HH").format(calendar.getTime()));
-
-        MachineInfo machineInfo = param.getMachineInfo();
-        if (machineInfo != null) {
-            context.setMachineinfo_brand(machineInfo.getBrand());
-            context.setMachineinfo_model(machineInfo.getModel());
-            context.setMachineinfo_platform(machineInfo.getPlatform());
-            context.setMachineinfo_sdkversion(machineInfo.getSdkVersion());
-            context.setMachineinfo_system(machineInfo.getSystem());
-            context.setMachineinfo_wechatversion(machineInfo.getWechatVersion());
-        }
-
-        scoreParam.setRequestContext(context);
-        return scoreParam;
-    }
-
     public List<Video> mergeAndRankFlowPoolRecall(RankParam param) {
         List<Video> quickFlowPoolVideos = extractAndSort(param, FlowPoolConstants.QUICK_PUSH_FORM);
         if (CollectionUtils.isNotEmpty(quickFlowPoolVideos)) {
@@ -373,60 +237,15 @@ public class RankService {
         }
     }
 
-    public RankResult mergeAndSort(RankParam param, List<Video> rovRecallRank, List<Video> flowPoolRank) {
-        if (CollectionUtils.isEmpty(rovRecallRank)) {
-            if (param.getSize() < flowPoolRank.size()) {
-                return new RankResult(flowPoolRank.subList(0, param.getSize()));
-            } else {
-                return new RankResult(flowPoolRank);
-            }
-        }
-
-        List<Video> result = new ArrayList<>();
-        for (int i = 0; i < param.getTopK() && i < rovRecallRank.size(); i++) {
-            result.add(rovRecallRank.get(i));
-        }
-
-        double flowPoolP = getFlowPoolP(param);
-        int flowPoolIndex = 0;
-        int rovPoolIndex = param.getTopK();
-
-        for (int i = 0; i < param.getSize() - param.getTopK(); i++) {
-            double rand = RandomUtils.nextDouble(0, 1);
-            if (rand < flowPoolP) {
-                if (flowPoolIndex < flowPoolRank.size()) {
-                    result.add(flowPoolRank.get(flowPoolIndex++));
-                } else {
-                    break;
-                }
-            } else {
-                if (rovPoolIndex < rovRecallRank.size()) {
-                    result.add(rovRecallRank.get(rovPoolIndex++));
-                } else {
-                    break;
-                }
-            }
-        }
-        if (rovPoolIndex >= rovRecallRank.size()) {
-            for (int i = flowPoolIndex; i < flowPoolRank.size() && result.size() < param.getSize(); i++) {
-                result.add(flowPoolRank.get(i));
-            }
-        }
-        if (flowPoolIndex >= flowPoolRank.size()) {
-            for (int i = rovPoolIndex; i < rovRecallRank.size() && result.size() < param.getSize(); i++) {
-                result.add(rovRecallRank.get(i));
-            }
-        }
-        return new RankResult(result);
-    }
+    public abstract RankResult mergeAndSort(RankParam param, List<Video> rovRecallRank, List<Video> flowPoolRank);
 
-    private boolean matchSpecialApp(int appId){
+    private boolean matchSpecialApp(int appId) {
         Set<Integer> notSpecialApp = new HashSet<>(Arrays.asList(0, 4, 5));
-        if (notSpecialApp.contains(appId)){
+        if (notSpecialApp.contains(appId)) {
             // vlog 票圈视频 内容精选 不允许走特殊列表,即使配置了也无效。
             return false;
         }
-        if (specialAppVid != null && specialAppVid.getOrDefault("app", new ArrayList<>()).contains((long) appId)){
+        if (specialAppVid != null && specialAppVid.getOrDefault("app", new ArrayList<>()).contains((long) appId)) {
             log.info("This request hits a special logic in matchSpecialApp with appId={}", appId);
             return true;
         }

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

@@ -33,9 +33,7 @@ import java.util.stream.Collectors;
  */
 @Service
 @Slf4j
-public class RankStrategy4RegionMergeModelBasic extends RankService {
-    @ApolloJsonValue("${rank.score.merge.weight:}")
-    private Map<String, Double> mergeWeight;
+public abstract class RankStrategy4RegionMergeModelBasic extends RankService {
     @ApolloJsonValue("${RankStrategy4DensityFilterV2:}")
     private Map<String, Map<String, Map<String, String>>> filterRules = new HashMap<>();
     String CLASS_NAME = this.getClass().getSimpleName();
@@ -52,74 +50,6 @@ public class RankStrategy4RegionMergeModelBasic extends RankService {
         }
     }
 
-    @Override
-    public List<Video> mergeAndRankRovRecall(RankParam param) {
-        List<Video> result = new ArrayList<>();
-        return result;
-    }
-
-    public double calNewVideoScore(Map<String, String> itemBasicMap) {
-        double existenceDays = Double.valueOf(itemBasicMap.getOrDefault("existence_days", "30"));
-        if (existenceDays > 5) {
-            return 0.0;
-        }
-        double score = 1.0 / (existenceDays + 10.0);
-        return score;
-    }
-
-    public double calTrendScore(List<Double> data) {
-        double sum = 0.0;
-        int size = data.size();
-        for (int i = 0; i < size - 4; ++i) {
-            sum += data.get(i) - data.get(i + 4);
-        }
-        if (sum * 10 > 0.6) {
-            sum = 0.6;
-        } else {
-            sum = sum * 10;
-        }
-        if (sum > 0) {
-            // 为了打断点
-            sum = sum;
-        }
-        return sum;
-    }
-    public Double calScoreWeightNoTimeDecay(List<Double> data) {
-        Double up = 0.0;
-        Double down = 0.0;
-        for (int i = 0; i < data.size(); ++i) {
-            up += 1.0 * data.get(i);
-            down += 1.0;
-        }
-        return down > 1E-8 ? up / down : 0.0;
-    }
-
-    public List<Double> getRateData(List<Double> ups, List<Double> downs, Double up, Double down) {
-        List<Double> data = new LinkedList<>();
-        for (int i = 0; i < ups.size(); ++i) {
-            if (ExtractorUtils.isDoubleEqualToZero(downs.get(i) + down)) {
-                data.add(0.0);
-            } else {
-                data.add(
-                        (ups.get(i) + up) / (downs.get(i) + down)
-                );
-            }
-        }
-        return data;
-    }
-
-    public List<Double> getStaticData(Map<String, Map<String, Double>> itemRealMap,
-                                      List<String> datehours, String key) {
-        List<Double> views = new LinkedList<>();
-        Map<String, Double> tmp = itemRealMap.getOrDefault(key, new HashMap<>());
-        for (String dh : datehours) {
-            views.add(tmp.getOrDefault(dh, 0.0D) +
-                    (views.isEmpty() ? 0.0 : views.get(views.size() - 1))
-            );
-        }
-        return views;
-    }
-
     public List<RankItem> model(List<Video> videos, RankParam param,
                                 List<String> rtFeaPart) {
         List<RankItem> result = new ArrayList<>();
@@ -261,45 +191,6 @@ public class RankStrategy4RegionMergeModelBasic extends RankService {
         return new RankResult(resultWithDensity);
     }
 
-    public void getVideoFeatureFromRedis(List<RankItem> items){
-        List<Long> videoIds = CommonCollectionUtils.toListDistinct(items, RankItem::getVideoId);
-        List<String> videoKeys = videoIds.stream().map(r -> "item_rt_fea_1hrootall_" + r)
-                .collect(Collectors.toList());
-        List<String> videoRtFeatures = this.redisTemplate.opsForValue().multiGet(videoKeys);
-        int j = 0;
-        if (videoRtFeatures != null) {
-            for (RankItem item : items) {
-                String vF = videoRtFeatures.get(j);
-                ++j;
-                if (vF == null) {
-                    continue;
-                }
-                Map<String, String> vfMap = new HashMap<>();
-                Map<String, Map<String, Double>> vfMapNew = new HashMap<>();
-                try {
-                    vfMap = JSONUtils.fromJson(vF, new TypeToken<Map<String, String>>() {
-                    }, vfMap);
-                    for (Map.Entry<String, String> entry : vfMap.entrySet()) {
-                        String value = entry.getValue();
-                        if (value == null) {
-                            continue;
-                        }
-                        String[] var1 = value.split(",");
-                        Map<String, Double> tmp = new HashMap<>();
-                        for (String var2 : var1) {
-                            String[] var3 = var2.split(":");
-                            tmp.put(var3[0], Double.valueOf(var3[1]));
-                        }
-                        vfMapNew.put(entry.getKey(), tmp);
-                    }
-                    item.setItemRealTimeRootFeature(vfMapNew);
-                } catch (Exception e) {
-                    log.error(String.format("parse video item_rt_fea_1hrootall_ json is wrong in {} with {}", this.CLASS_NAME, e));
-                }
-            }
-        }
-    }
-
     public Map<String, Map<String, String>> getVideoRedisFeature(List<String> vids, String redisKeyPrefix){
         List<String> keys = vids.stream().map(r -> redisKeyPrefix + r).collect(Collectors.toList());
         List<String> key2Values = this.redisTemplate.opsForValue().multiGet(keys);
@@ -402,47 +293,4 @@ public class RankStrategy4RegionMergeModelBasic extends RankService {
         }
     }
 
-
-    public static void main(String[] args) {
-
-    }
-
-    List<Double> help(String s, String date, Integer h) {
-        Map<String, Double> maps = Arrays.stream(s.split(",")).map(pair -> pair.split(":"))
-                .collect(Collectors.toMap(
-                        arr -> arr[0],
-                        arr -> Double.valueOf(arr[1])
-                ));
-        List<String> datehours = new LinkedList<>(); // 时间是倒叙的
-        List<Double> result = new ArrayList<>();
-        for (int i = 0; i < h; ++i) {
-            Double d = (result.isEmpty() ? 0.0 : result.get(result.size() - 1));
-            result.add(d + maps.getOrDefault(date, 0D));
-            datehours.add(date);
-            date = ExtractorUtils.subtractHours(date, 1);
-        }
-        return result;
-    }
-    public double calVovScore(RankItem item, Map<String, Map<String, String>> vid2VovFeatureMap){
-        String id = item.getVideoId() + "";
-        Map<String, String> featureMap = vid2VovFeatureMap.getOrDefault(id, new HashMap<>());
-        double numerator = 0D;
-        final Set<String> ups = new HashSet<>(Arrays.asList(
-                "1_vovh0分子", "2_vovh1分子", "3_vovh2分子", "4_vovh3分子", "7_vovh6分子", "13_vovh12分子", "25_vovh24分子", "2_vovd1分子"
-        ));
-        for (String key: ups){
-            numerator += Double.parseDouble(featureMap.getOrDefault(key, "0"));
-        }
-        double denominator = 0D;
-        final Set<String> downs = new HashSet<>(Arrays.asList(
-                "1_vovh分母", "2_vovh分母", "3_vovh分母", "4_vovh分母", "7_vovh分母", "13_vovh分母", "25_vovh分母", "2_vovd分母"
-        ));
-        for (String key: downs){
-            denominator += Double.parseDouble(featureMap.getOrDefault(key, "0"));
-        }
-        item.getScoresMap().put("numerator", numerator);
-        item.getScoresMap().put("denominator", denominator);
-        return denominator != 0.0? numerator / denominator: 0.0;
-    }
-
 }

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

@@ -121,50 +121,15 @@ public class RecallService implements ApplicationContextAware {
             return strategies;
         }
         switch (abCode) {
-            case "60122": // 537
-            case "60124": // 546
-            case "60125": // 547
-            case "60126": // 548
-            case "60116": // 566
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV2.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV3.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV4.class.getSimpleName()));
-                strategies.addAll(getRegionRecallStrategy(param));
-                break;
-            case "60120": // 576
-            case "60123": // 541
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV2.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV3.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV4.class.getSimpleName()));
-                break;
-
-            case "60656": // 656
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.addAll(getRegionRecallStrategy(param));
-                break;
-            case "60118": // 568
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV4.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.addAll(getRegionRecallStrategy(param));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                break;
-            case "60107": // 553
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.addAll(getRegionRecallStrategy(param));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV7VovLongTermV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV7VovLongTermV2.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV7VovLongTermV3.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV7VovLongTermV4.class.getSimpleName()));
-                break;
+//            60112  562
+//            60113  563
+//            60114  564
+//            60117  567
+//            60119  569
+//            60121  536
             case "60121": // 536
-            case "60105": // 551
-            case "60106": // 552
             case "60112": // 562
             case "60114": // 564
-            case "60115": // 565
             case "60119": // 569
                 strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
                 strategies.addAll(getRegionRecallStrategy(param));
@@ -189,100 +154,6 @@ public class RecallService implements ApplicationContextAware {
                 strategies.add(strategyMap.get(FlowPoolWithLevelScoreRecallStrategy.class.getSimpleName()));
             }
         }
-
-        //3:通过“abcode”控制“召回子策略”
-        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 "60111": // 561
-            case "60068":
-            case "60092":
-            case "60094":
-            case "60097": // 523
-            case "60098": // 533
-            case "60101": // 排序str实验
-            case "60102": // 通过更改param中的配置实现使用不同数据源 data66 rule68 + 无排序模块
-            case "60103": // 增加地域1小时扩量,通过配置实现
-            case "60120": // 576
-                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                break;
-            case "60122": // 537
-            case "60124": // 546
-            case "60125": // 547
-            case "60123": // 541
-            case "60126": // 548
-            case "60116": // 566
-            case "60656": // 656
-            case "60104": // 去掉sim的对比实验
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                break;
-            case "60121": // 536
-            case "60105": // 551
-            case "60106": // 552
-            case "60107": // 553
-            case "60112": // 562
-            case "60113": // 563
-            case "60114": // 564
-            case "60115": // 565
-            case "60117": // 567
-            case "60118": // 568
-            case "60119": // 569
-                break;
-            case "60110": // 新内容的召回(流量池的Top内容)
-                strategies.add(strategyMap.get(TopGoodPerformanceVideoRecallStrategy.class.getSimpleName()));
-                if (!hitUserBlacklist || !isInBlacklist) {
-                    strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
-                }
-                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                break;
-            case "60130":
-            case "60131":
-            case "60132":
-                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
-                break;
-            case "60150": // 645
-                strategies.add(strategyMap.get(ShareWidthRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ShareDeepRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
-                break;
-            case "60151": // 650
-                strategies.add(strategyMap.get(ContentBaseRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
-                break;
-            case "60654":
-                strategies.add(strategyMap.get(CFRovnRecallStrategyV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
-            case "60655":
-                strategies.add(strategyMap.get(CFRovnRecallStrategyV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV2_sort.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV3.class.getSimpleName()));
-                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV4.class.getSimpleName()));
-                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
-            default:
-                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                break;
-        }
-
         return strategies;
     }
 

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

@@ -1,101 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.google.common.reflect.TypeToken;
-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.util.JSONUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @author zhangbo
- */
-@Component
-@Slf4j
-public class CFRovnRecallStrategyV1 implements RecallStrategy {
-    private final String CLASS_NAME = this.getClass().getSimpleName();
-    @Autowired
-    private RegionFilterService filterService;
-    @Autowired
-    @Qualifier("redisTemplate")
-    public RedisTemplate<String, String> redisTemplate;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        long t0 = System.currentTimeMillis();
-        List<Video> result = new ArrayList<>();
-        // 1 获取头部vid,请求redis得到tag。
-        Long headVid = param.getVideoId();
-        String key1 = "redis:cf_rovn_vid:" + headVid;
-        String value1 = redisTemplate.opsForValue().get(key1);
-        if (value1 == null || value1.isEmpty()){
-            return result;
-        }
-        Map<String, String> vfMap = new HashMap<>();
-        vfMap = JSONUtils.fromJson(value1, new TypeToken<Map<String, String>>() {}, vfMap);
-        List<Long> vids = new ArrayList<>();
-        List<Double> scores = new ArrayList<>();
-        try{
-            vids = Arrays.stream(vfMap.getOrDefault("videoid_arr", "").split(","))
-                    .filter(s -> !s.trim().isEmpty() && s.matches("-?\\d+"))
-                    .map(Long::valueOf).collect(Collectors.toList());
-            scores = Arrays.stream(vfMap.getOrDefault("score_arr", "").split(","))
-                    .map(Double::valueOf).collect(Collectors.toList());
-        }catch(Exception e){
-            log.error(String.format("json parse is wrong in {}, key={}, error={}", CLASS_NAME, value1, e));
-            vids = new ArrayList<>();
-            scores = new ArrayList<>();
-        }
-        if (vids.size() != scores.size() || vids.isEmpty()){
-            return result;
-        }
-        Map<Long, Double> vid2Score = new HashMap<>(vids.size());
-        for (int i = 0; i < vids.size(); ++i){
-            Long id = vids.get(i);
-            if (id.equals(headVid)){
-                continue;
-            }
-            Double score = scores.get(i);
-            vid2Score.put(id, score);
-        }
-
-        FilterParam filterParam = FilterParamFactory.create(param, vids);
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(vid2Score.getOrDefault(vid, 0.0D));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-
-        // 5 内部日志打印
-
-        // 6 返回结果
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-
-    public static final String PUSH_FORM = "recall_strategy_cf_rovn";
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,88 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.alibaba.fastjson.JSONObject;
-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 org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Component
-public class ContentBaseRecallStrategy implements RecallStrategy {
-
-    public static final String PUSH_FORM = "content_base_recall_strategy";
-
-    private static final String VIDEO_2_TAG_REDIS_KEY = "content:base:video:tags:";
-
-    @Value("${recommend.content.base.recall.strategy.limit:50}")
-    private Integer limit;
-    @Resource
-    private RegionFilterService filterService;
-    @Resource
-    private RedisTemplate<String, String> redisTemplate;
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-        Long videoId = param.getVideoId();
-        Map<String, String> param4Model = new HashMap<>(1);
-        String redisKey = VIDEO_2_TAG_REDIS_KEY + videoId;
-        String tags = redisTemplate.opsForValue().get(redisKey);
-        try {
-            String tagStr = JSONObject.parseObject(tags).getString("tags");
-            param4Model.put("tags", tagStr);
-        } catch (Exception e) {
-            return Collections.emptyList();
-        }
-        // 2 通过model拿到召回list
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("content_base_recall.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i = 1; i < results.size(); ++i) {
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v : result) {
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream()
-                    // 按照 rovScore 倒序排序
-                    .sorted(Comparator.comparing(vid -> videoMap.getOrDefault(vid, 0.0)).reversed())
-                    .limit(limit).forEach(vid -> {
-                        Video video = new Video();
-                        video.setVideoId(vid);
-                        video.setAbCode(param.getAbCode());
-                        video.setRovScore(videoMap.get(vid));
-                        video.setPushFrom(pushFrom());
-                        videosResult.add(video);
-                    });
-        }
-        return videosResult;
-    }
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-
-}

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

@@ -1,72 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.google.common.collect.Lists;
-import com.google.common.reflect.TypeToken;
-import com.tzld.piaoquan.recommend.server.model.Video;
-import com.tzld.piaoquan.recommend.server.service.filter.FilterResult;
-import com.tzld.piaoquan.recommend.server.service.recall.FilterParamFactory;
-import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
-import com.tzld.piaoquan.recommend.server.util.DateUtils;
-import com.tzld.piaoquan.recommend.server.util.JSONUtils;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.MapUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.math.NumberUtils;
-import org.springframework.data.redis.core.ZSetOperations;
-import org.springframework.stereotype.Service;
-
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-/**
- * 不区分地域小时(不做离线去重)
- *
- * @author dyp
- */
-@Service
-public class DahanRecallStrategy extends AbstractRegionRecallStrategy {
-    public static final String PUSH_FORM = "dahan_recall";
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-        List<Video> results = new ArrayList<>();
-
-        List<Long> ss = new ArrayList<>(Arrays.asList(10409992L, 10436156L, 18160019L, 18247521L, 18254840L));
-        ss.stream().forEach(vid -> {
-            Video video = new Video();
-            video.setVideoId(vid);
-            video.setAbCode(param.getAbCode());
-            video.setRovScore(Math.random());
-            video.setPushFrom(pushFrom());
-            video.setLastVideoKey("zhangbo");
-            results.add(video);
-        });
-
-
-
-        Collections.sort(results, Comparator.comparingDouble(o -> -o.getRovScore()));
-
-        return results;
-    }
-    @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;
-    }
-}

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

@@ -1,83 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.alibaba.fastjson.JSONObject;
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Component
-public class FestivalRecallStrategyV1 implements RecallStrategy {
-
-    public static final String PUSH_FORM = "recall_strategy_festival";
-
-    @Value("${yearly_festival_recall_time_range:}")
-    private String yearlyFestivalTimeRange;
-    @Autowired
-    private RegionFilterService filterService;
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-
-        // 1 获取省份key 放入参数map中
-        String provinceCn = param.getProvince();
-        if (provinceCn == null) {
-            provinceCn = "中国";
-        } else {
-            provinceCn = provinceCn.replaceAll("省$", "");
-        }
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("region_province", provinceCn);
-        param4Model.put("yearly_festival_time_range", yearlyFestivalTimeRange);
-        // 2 通过model拿到召回list
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_score_config_festival.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i = 1; i < results.size(); ++i) {
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v : result) {
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        Collections.sort(videosResult, Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-
-}

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

@@ -1,25 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.tzld.piaoquan.recommend.server.common.base.Constant;
-import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
-import org.springframework.stereotype.Service;
-
-/**
- * @author sunxy
- */
-@Service
-@Deprecated
-public class FlowPoolLastDayTopRecallStrategy extends AbstractNewContentVideoRecallStrategy {
-
-    public static final String PUSH_FORM = "flow_pool_top_video_recall";
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-    @Override
-    public String recallKey(RecallParam param) {
-        return Constant.VIDEO_PERFORMANCE_DATA_REDIS_KEY + PUSH_FORM;
-    }
-}

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

@@ -1,38 +0,0 @@
-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;
-    }
-}

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

@@ -1,106 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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 org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Component
-public class RegionRealtimeRecallStrategyV1_default implements RecallStrategy {
-    private final String CLASS_NAME = this.getClass().getSimpleName();
-    @Autowired
-    private RegionFilterService filterService;
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-        long t0 = System.currentTimeMillis();
-        // 1 获取省份key 放入参数map中
-        String provinceCn = param.getProvince();
-        if (provinceCn == null) {
-            // provinceCn = "中国";
-            return new ArrayList<>();
-        } else {
-            provinceCn = provinceCn.replaceAll("省$", "");
-        }
-        final Set<String> provinceCns = new HashSet<>(Arrays.asList(
-                "北京", "天津", "河北", "山西", "内蒙古", "辽宁", "吉林",
-                "黑龙江", "上海", "江苏", "浙江", "安徽", "福建", "江西",
-                "山东", "河南", "湖北", "湖南", "广东", "广西", "海南",
-                "重庆", "四川", "贵州", "云南", "西藏", "陕西", "甘肃",
-                "青海", "宁夏", "新疆", "台湾", "香港", "澳门", "中国"
-        ));
-        if (!provinceCns.contains(provinceCn)) {
-            return new ArrayList<>();
-        }
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("region_province", provinceCn);
-        // 2 通过model拿到召回list
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v1.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i = 1; i < results.size(); ++i) {
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v : result) {
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        long t1 = System.currentTimeMillis();
-        // 3 召回内部过滤
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        List<Long> videosResultId = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-                videosResultId.add(vid);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-
-    public static final String PUSH_FORM = "recall_strategy_region_1h";
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-
-    public static List<List<Long>> groupKeys(Map<Long, Double> videoMap, int groupSize) {
-        List<List<Long>> result = new ArrayList<>();
-        List<Long> keys = new ArrayList<>(videoMap.keySet());
-
-        int size = keys.size();
-        for (int i = 0; i < size; i += groupSize) {
-            int endIndex = Math.min(i + groupSize, size);
-            List<Long> group = keys.subList(i, endIndex);
-            result.add(group);
-        }
-
-        return result;
-    }
-
-}

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

@@ -1,96 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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 org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Component
-public class RegionRealtimeRecallStrategyV1_sort implements RecallStrategy {
-    private final String CLASS_NAME = this.getClass().getSimpleName();
-    @Autowired
-    private RegionFilterService filterService;
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-        long t0 = System.currentTimeMillis();
-        // 1 获取省份key 放入参数map中
-        String provinceCn = param.getProvince();
-        if (provinceCn == null) {
-            provinceCn = "中国";
-        } else {
-            provinceCn = provinceCn.replaceAll("省$", "");
-        }
-        Map<String, String> param4Model = new HashMap<>(2);
-        param4Model.put("region_province", provinceCn);
-        param4Model.put("sort", "1");
-        // 2 通过model拿到召回list
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v1_vov.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i = 1; i < results.size(); ++i) {
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v : result) {
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        long t1 = System.currentTimeMillis();
-        // 3 召回内部过滤
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        List<Long> videosResultId = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-                videosResultId.add(vid);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-
-    public static final String PUSH_FORM = "recall_strategy_region_1h";
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-
-    public static List<List<Long>> groupKeys(Map<Long, Double> videoMap, int groupSize) {
-        List<List<Long>> result = new ArrayList<>();
-        List<Long> keys = new ArrayList<>(videoMap.keySet());
-
-        int size = keys.size();
-        for (int i = 0; i < size; i += groupSize) {
-            int endIndex = Math.min(i + groupSize, size);
-            List<Long> group = keys.subList(i, endIndex);
-            result.add(group);
-        }
-
-        return result;
-    }
-
-}

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

@@ -1,67 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV2 implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-
-        // 2 通过model拿到召回list
-        Map<String, String> param4Model = new HashMap<>(0);
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v2.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        Collections.sort(videosResult, Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_noregion_24h";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,68 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV2_sort implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-
-        // 2 通过model拿到召回list
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("sort", "1");
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v2.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        Collections.sort(videosResult, Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_noregion_24h";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,74 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.alibaba.fastjson.JSONObject;
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV3 implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        // 1 获取省份key 放入参数map中
-        String provinceCn = param.getProvince();
-        if (provinceCn == null){
-            provinceCn = "中国";
-        }else{
-            provinceCn = provinceCn.replaceAll("省$", "");
-        }
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("region_province", provinceCn);
-        // 2 通过model拿到召回list
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v3.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_region_24h";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,84 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV3_default implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        // 1 获取省份key 放入参数map中
-        String provinceCn = param.getProvince();
-        if (provinceCn == null){
-            provinceCn = "中国";
-            return new ArrayList<>();
-        }else{
-            provinceCn = provinceCn.replaceAll("省$", "");
-        }
-        final Set<String> provinceCns = new HashSet<>(Arrays.asList(
-                "北京", "天津", "河北", "山西", "内蒙古", "辽宁", "吉林",
-                "黑龙江", "上海", "江苏", "浙江", "安徽", "福建", "江西",
-                "山东", "河南", "湖北", "湖南", "广东", "广西", "海南",
-                "重庆", "四川", "贵州", "云南", "西藏", "陕西", "甘肃",
-                "青海", "宁夏", "新疆", "台湾", "香港", "澳门", "中国"
-        ));
-        if (!provinceCns.contains(provinceCn)){
-            return new ArrayList<>();
-        }
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("region_province", provinceCn);
-        // 2 通过model拿到召回list
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v1.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_region_24h";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,74 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV3_sort implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        // 1 获取省份key 放入参数map中
-        String provinceCn = param.getProvince();
-        if (provinceCn == null){
-            provinceCn = "中国";
-        }else{
-            provinceCn = provinceCn.replaceAll("省$", "");
-        }
-        Map<String, String> param4Model = new HashMap<>(2);
-        param4Model.put("region_province", provinceCn);
-        param4Model.put("sort", "1");
-        // 2 通过model拿到召回list
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v3.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_region_24h";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,66 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV4 implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        // 2 通过model拿到召回list
-        Map<String, String> param4Model = new HashMap<>(0);
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v4.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_rovn_7d";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,67 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo feeds_recall_config_region_v5_highvalue
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV5HighValue implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-
-        // 2 通过model拿到召回list
-        Map<String, String> param4Model = new HashMap<>(0);
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v5_highvalue.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_highvalue";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,93 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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 org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo
- */
-@Component
-public class RegionRealtimeRecallStrategyV6RootRov implements RecallStrategy {
-    private final String CLASS_NAME = this.getClass().getSimpleName();
-    @Autowired
-    private RegionFilterService filterService;
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-        long t0 = System.currentTimeMillis();
-        // 1 获取省份key 放入参数map中
-        String provinceCn = param.getProvince();
-        if (provinceCn == null) {
-            provinceCn = "中国";
-        } else {
-            provinceCn = provinceCn.replaceAll("省$", "");
-        }
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("region_province", provinceCn);
-        // 2 通过model拿到召回list
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v6_rootrov.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i = 1; i < results.size(); ++i) {
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v : result) {
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        long t1 = System.currentTimeMillis();
-        // 3 召回内部过滤
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-
-    public static final String PUSH_FORM = "recall_strategy_root_rov";
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-
-    public static List<List<Long>> groupKeys(Map<Long, Double> videoMap, int groupSize) {
-        List<List<Long>> result = new ArrayList<>();
-        List<Long> keys = new ArrayList<>(videoMap.keySet());
-
-        int size = keys.size();
-        for (int i = 0; i < size; i += groupSize) {
-            int endIndex = Math.min(i + groupSize, size);
-            List<Long> group = keys.subList(i, endIndex);
-            result.add(group);
-        }
-
-        return result;
-    }
-
-}

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

@@ -1,65 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo feeds_recall_config_region_v5_highvalue
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV7VovLongTermV1 implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("t_2_8", "50");
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v7_vov_longterm.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_vov_longterm_v1";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,65 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo feeds_recall_config_region_v5_highvalue
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV7VovLongTermV2 implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("t_9_36", "50");
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v7_vov_longterm.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_vov_longterm_v2";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,65 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo feeds_recall_config_region_v5_highvalue
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV7VovLongTermV3 implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("t_37_90", "50");
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v7_vov_longterm.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_vov_longterm_v3";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,65 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author zhangbo feeds_recall_config_region_v5_highvalue
- */
-@Slf4j
-@Component
-public class RegionRealtimeRecallStrategyV7VovLongTermV4 implements RecallStrategy {
-    @Autowired
-    protected RegionFilterService filterService;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("t_91_365", "50");
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_recall_config_region_v7_vov_longterm.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i=1; i<results.size(); ++i){
-            result.addAll(results.get(i));
-        }
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        for (Pair<Long, Double> v: result){
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setRovScore(videoMap.get(vid));
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-        videosResult.sort(Comparator.comparingDouble(o -> -o.getRovScore()));
-        return videosResult;
-    }
-    public static final String PUSH_FORM = "recall_strategy_vov_longterm_v4";
-    @Override
-    public String pushFrom(){
-        return PUSH_FORM;
-    }
-
-}

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

@@ -1,35 +0,0 @@
-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;
-
-/**
- * 分地域24h
- *
- * @author dyp
- */
-@Service
-public class RegionRelative48HDupRecallStrategy extends AbstractRegionRecallStrategy {
-    public static final String PUSH_FORM = "rov_recall_48h_dup";
-
-    @Override
-    protected String recordKey(RecallParam param) {
-        return String.format("recall:last:record:region:dup3:48h:%s:%s", param.getAppType(), param.getMid());
-    }
-
-    @Override
-    protected String poolKey(RecallParam param, String now_dt, int h) {
-        return String.format("recall:item:score:region:dup3:48h:%s:%s:%s:%s:%s", StringUtils.isBlank(param.getRegionCode()) ? -1 : param.getRegionCode(), param.getDataKey(), param.getRuleKey(), now_dt, h);
-    }
-
-    @Override
-    protected String lastVideoKey(RecallParam param) {
-        return String.format("recall:last:item:region:dup3:48h:%s:%s", param.getAppType(), param.getMid());
-    }
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-}

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

@@ -1,35 +0,0 @@
-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;
-
-/**
- * 分地域24h
- *
- * @author dyp
- */
-@Service
-public class RegionRelative48HRecallStrategy extends AbstractRegionRecallStrategy {
-    public static final String PUSH_FORM = "recall_pool_48h";
-
-    @Override
-    protected String recordKey(RecallParam param) {
-        return String.format("recall:last:record:region:dup2:48h:%s:%s", param.getAppType(), param.getMid());
-    }
-
-    @Override
-    protected String poolKey(RecallParam param, String now_dt, int h) {
-        return String.format("recall:item:score:region:dup2:48h:%s:%s:%s:%s:%s", StringUtils.isBlank(param.getRegionCode()) ? -1 : param.getRegionCode(), param.getDataKey(), param.getRuleKey(), now_dt, h);
-    }
-
-    @Override
-    protected String lastVideoKey(RecallParam param) {
-        return String.format("recall:last:item:region:dup2:48h:%s:%s", param.getAppType(), param.getMid());
-    }
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-}

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

@@ -1,73 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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 org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author sunxy
- */
-@Component
-public class ShareDeepRecallStrategy implements RecallStrategy {
-
-    @Value("${ShareDeepRecallStrategyRecallNumber:500}")
-    private String shareDeepRecallStrategyRecallNumber;
-    @Value("${ShareDeepRecallStrategyRecallNumberAfterFilter:20}")
-    private String shareDeepRecallStrategyRecallNumberAfterFilter;
-
-    public static final String PUSH_FORM = "share_deep_recall_strategy";
-
-    @Autowired
-    private RegionFilterService filterService;
-
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("limit", shareDeepRecallStrategyRecallNumber);
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_score_config_share_deep.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i = 1; i < results.size(); ++i) {
-            result.addAll(results.get(i));
-        }
-        for (Pair<Long, Double> v : result) {
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream()
-                    .sorted(Comparator.comparingDouble(vid -> videoMap.getOrDefault(vid, 0.0)).reversed())
-                    .limit(Integer.parseInt(shareDeepRecallStrategyRecallNumberAfterFilter)).forEach(vid -> {
-                        Video video = new Video();
-                        video.setVideoId(vid);
-                        video.setAbCode(param.getAbCode());
-                        video.setPushFrom(pushFrom());
-                        videosResult.add(video);
-                    });
-        }
-        return videosResult;
-    }
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-}

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

@@ -1,73 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-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 org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @author sunxy
- */
-@Component
-public class ShareWidthRecallStrategy implements RecallStrategy {
-
-    @Value("${ShareDeepRecallStrategyRecallNumber:500}")
-    private String shareDeepRecallStrategyRecallNumber;
-    @Value("${ShareDeepRecallStrategyRecallNumberAfterFilter:20}")
-    private String shareDeepRecallStrategyRecallNumberAfterFilter;
-
-    public static final String PUSH_FORM = "share_width_recall_strategy";
-
-    @Autowired
-    private RegionFilterService filterService;
-
-
-    @Override
-    public List<Video> recall(RecallParam param) {
-        Map<String, String> param4Model = new HashMap<>(1);
-        param4Model.put("limit", shareDeepRecallStrategyRecallNumber);
-        ScorerPipeline4Recall pipeline = ScorerUtils.getScorerPipeline4Recall("feeds_score_config_share_width.conf");
-        List<List<Pair<Long, Double>>> results = pipeline.recall(param4Model);
-        Map<Long, Double> videoMap = new LinkedHashMap<>();
-        List<Pair<Long, Double>> result = results.get(0);
-        for (int i = 1; i < results.size(); ++i) {
-            result.addAll(results.get(i));
-        }
-        for (Pair<Long, Double> v : result) {
-            videoMap.put(v.getLeft(), v.getRight());
-        }
-        FilterParam filterParam = FilterParamFactory.create(param, Lists.newArrayList(videoMap.keySet()));
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream()
-                    .sorted(Comparator.comparingDouble(vid -> videoMap.getOrDefault(vid, 0.0)).reversed())
-                    .limit(Integer.parseInt(shareDeepRecallStrategyRecallNumberAfterFilter)).forEach(vid -> {
-                        Video video = new Video();
-                        video.setVideoId(vid);
-                        video.setAbCode(param.getAbCode());
-                        video.setPushFrom(pushFrom());
-                        videosResult.add(video);
-                    });
-        }
-        return videosResult;
-    }
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-}

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

@@ -1,23 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
-import org.springframework.stereotype.Service;
-
-/**
- * @author dyp
- */
-@Service
-public class SimHotVideoRecallStrategy extends AbstractVideoRecallStrategy {
-
-    public static final String PUSH_FORM = "sim_hot_vid_recall";
-
-    @Override
-    String recallKey(RecallParam param) {
-        return String.format("sim_hot_%s", param.getVideoId());
-    }
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-}

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

@@ -1,237 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.google.common.reflect.TypeToken;
-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.util.JSONUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @author zhangbo
- */
-@Component
-@Slf4j
-public class TitleTagRecallStrategyV1 implements RecallStrategy {
-    private final String CLASS_NAME = this.getClass().getSimpleName();
-    @Autowired
-    private RegionFilterService filterService;
-    @Autowired
-    @Qualifier("redisTemplate")
-    public RedisTemplate<String, String> redisTemplate;
-    @Override
-    public List<Video> recall(RecallParam param) {
-        long t0 = System.currentTimeMillis();
-        List<Video> result = new ArrayList<>();
-        // 1 获取头部vid,请求redis得到tag。
-        Long headVid = param.getVideoId();
-        String key1 = "redis:vid_title_tags:" + headVid;
-        String value1 = redisTemplate.opsForValue().get(key1);
-        if (value1 == null || value1.isEmpty()){
-            return result;
-        }
-        Map<String, String> vfMap = new HashMap<>();
-        vfMap = JSONUtils.fromJson(value1, new TypeToken<Map<String, String>>() {}, vfMap);
-        String tags = vfMap.getOrDefault("tags","");
-        if (tags.isEmpty()){
-            return result;
-        }
-        String title = vfMap.getOrDefault("title","");
-        // 2 通过tags请求redis,得到list。
-        List<String> key2 = Arrays.stream(tags.split(",")).map(r -> "redis:tag2vids:"+r).collect(Collectors.toList());
-        List<String> value2 = redisTemplate.opsForValue().multiGet(key2);
-        if (value2 == null || value2.isEmpty()){
-            return result;
-        }
-        // 3 合并多个tag的结果。
-        Map<Long, VideoTmp> vid2Info = new HashMap<>();
-        for (String v2: value2){
-            if (v2 == null || v2.isEmpty()){
-                continue;
-            }
-            vfMap = new HashMap<>();
-            vfMap = JSONUtils.fromJson(v2, new TypeToken<Map<String, String>>() {}, vfMap);
-            List<Long> vids = new ArrayList<>();
-            List<Double> scores = new ArrayList<>();
-            try{
-                vids = Arrays.stream(vfMap.getOrDefault("videoid_arr", "").split(","))
-                        .filter(s -> !s.trim().isEmpty() && s.matches("-?\\d+"))
-                        .map(Long::valueOf).limit(20).collect(Collectors.toList());
-                scores = Arrays.stream(vfMap.getOrDefault("score_arr", "").split(","))
-                        .map(Double::valueOf).limit(20).collect(Collectors.toList());
-            }catch(Exception e){
-                log.error(String.format("json parse is wrong in {}, key={}, error={}", CLASS_NAME, v2, e));
-                vids = new ArrayList<>();
-                scores = new ArrayList<>();
-            }
-            if (vids.size() != scores.size() || vids.isEmpty()){
-                continue;
-            }
-            for (int i = 0; i < vids.size(); ++i){
-                Long id = vids.get(i);
-                if (id.equals(headVid)){
-                    continue;
-                }
-                Double score = scores.get(i);
-                if (vid2Info.containsKey(id)){
-                    VideoTmp videoTmp = vid2Info.get(id);
-                    videoTmp.cnt += 1;
-                    videoTmp.score += score;
-                    vid2Info.put(id, videoTmp);
-                }else{
-                    VideoTmp videoTmp = new VideoTmp();
-                    videoTmp.id = id;
-                    videoTmp.cnt = 1;
-                    videoTmp.score = score;
-                    vid2Info.put(id, videoTmp);
-                }
-            }
-        }
-        if (vid2Info.isEmpty()){
-            return result;
-        }
-
-        List<Map.Entry<Long, VideoTmp>> entries = new ArrayList<>(vid2Info.entrySet());
-        entries.sort(new Comparator<Map.Entry<Long, VideoTmp>>() {
-            @Override
-            public int compare(Map.Entry<Long, VideoTmp> o1, Map.Entry<Long, VideoTmp> o2) {
-                // 先比较cnt,如果cnt相同则比较score,如果score也相同则比较id
-                int cmpCnt = Integer.compare(o2.getValue().cnt, o1.getValue().cnt); // 从大到小
-                if (cmpCnt != 0) {
-                    return cmpCnt;
-                }
-                int cmpScore = Double.compare(o2.getValue().score, o1.getValue().score); // 从大到小
-                if (cmpScore != 0) {
-                    return cmpScore;
-                }
-                return Long.compare(o2.getKey(), o1.getKey()); // 从大到小
-            }
-        });
-        // 现在entries是按照cnt、score、id从大到小排序的,提取key到List<Long>
-        List<Long> sortedKeys = new ArrayList<>();
-        for (Map.Entry<Long, VideoTmp> entry : entries) {
-            sortedKeys.add(entry.getKey());
-        }
-
-        // 4 集体走title匹配过滤,推荐过滤。
-        List<Long> deleteKey = new ArrayList<>();
-        if (!title.isEmpty()){
-            List<String> key3 = sortedKeys.stream().map(r -> "redis:vid_title_tags:"+r).collect(Collectors.toList());
-            List<String> value3 = redisTemplate.opsForValue().multiGet(key3);
-            if (value3 != null && !value3.isEmpty()){
-                int j = 0;
-                for (String v3 : value3){
-                    vfMap = new HashMap<>();
-                    vfMap = JSONUtils.fromJson(v3, new TypeToken<Map<String, String>>() {}, vfMap);
-                    String titleTmp = vfMap.getOrDefault("title","");
-                    if (!titleTmp.isEmpty() && calculateStringSimilarity(title, titleTmp) >= 0.9){
-                        deleteKey.add(sortedKeys.get(j));
-                    }
-                    j++;
-                }
-            }
-        }
-        sortedKeys.removeIf(deleteKey::contains);
-        if (sortedKeys.isEmpty()){
-            return result;
-        }
-
-        FilterParam filterParam = FilterParamFactory.create(param, sortedKeys);
-        FilterResult filterResult = filterService.filter(filterParam);
-        List<Video> videosResult = new ArrayList<>();
-        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                double score = 0.0;
-                if (vid2Info.containsKey(vid)){
-                    VideoTmp videoTmp = vid2Info.get(vid);
-                    score = videoTmp.score / videoTmp.cnt;
-                }
-                video.setRovScore(score);
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
-        }
-
-        // 5 内部日志打印
-
-        // 6 返回结果
-        return videosResult;
-    }
-
-    public static final String PUSH_FORM = "recall_strategy_title_tag";
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-    static class VideoTmp{
-        Long id;
-        Integer cnt;
-        Double score;
-    }
-
-    public static int calculateLevenshteinDistance(String s1, String s2) {
-        if (s1 == null || s2 == null) {
-            throw new IllegalArgumentException("Strings must not be null");
-        }
-
-        int len0 = s1.length() + 1;
-        int len1 = s2.length() + 1;
-
-        // 创建一个二维数组来保存已经计算过的子问题的解
-        int[][] dp = new int[len0][len1];
-
-        // 初始化第一行和第一列
-        for (int i = 0; i < len0; i++) {
-            dp[i][0] = i;
-        }
-        for (int j = 0; j < len1; j++) {
-            dp[0][j] = j;
-        }
-
-        // 动态规划计算Levenshtein距离
-        for (int i = 1; i < len0; i++) {
-            for (int j = 1; j < len1; j++) {
-                int cost = (s1.charAt(i - 1) == s2.charAt(j - 1)) ? 0 : 1;
-                dp[i][j] = Math.min(
-                        Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1),
-                        dp[i - 1][j - 1] + cost
-                );
-            }
-        }
-
-        return dp[len0 - 1][len1 - 1];
-    }
-
-    // 计算字符串匹配度(0到1之间)
-    public static double calculateStringSimilarity(String s1, String s2) {
-        int distance = calculateLevenshteinDistance(s1, s2);
-        int maxLength = Math.max(s1.length(), s2.length());
-        // 如果maxLength为0,则两个字符串都是空的,返回1表示完全匹配
-        return maxLength == 0 ? 1.0 : 1.0 - ((double) distance / maxLength);
-    }
-
-    public static void main(String[] args) {
-        String s1 = "老年人都来看看那";
-        String s2 = "老年人都来看看";
-        double score = calculateStringSimilarity(s1, s2);
-        System.out.println(score);
-    }
-
-}

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

@@ -1,24 +0,0 @@
-package com.tzld.piaoquan.recommend.server.service.recall.strategy;
-
-import com.tzld.piaoquan.recommend.server.common.base.Constant;
-import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
-import org.springframework.stereotype.Service;
-
-/**
- * @author sunxy
- */
-@Service
-public class TopGoodPerformanceVideoRecallStrategy extends AbstractNewContentVideoRecallStrategy {
-
-    public static final String PUSH_FORM = "top_good_performance_video_recall";
-
-    @Override
-    public String pushFrom() {
-        return PUSH_FORM;
-    }
-
-    @Override
-    protected String recallKey(RecallParam param) {
-        return Constant.VIDEO_PERFORMANCE_DATA_REDIS_KEY + PUSH_FORM;
-    }
-}

+ 0 - 4
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/xxl/NotUserUploadUserCacheJob.java

@@ -1,12 +1,8 @@
 package com.tzld.piaoquan.recommend.server.xxl;
 
-import com.alibaba.fastjson.JSONObject;
 import com.aliyun.odps.data.Record;
-import com.tzld.piaoquan.recommend.server.common.base.Constant;
 import com.tzld.piaoquan.recommend.server.service.filter.strategy.VideoSourceTypeStrategy;
 import com.tzld.piaoquan.recommend.server.service.odps.ODPSManager;
-import com.tzld.piaoquan.recommend.server.service.recall.strategy.FlowPoolLastDayTopRecallStrategy;
-import com.tzld.piaoquan.recommend.server.service.recall.strategy.TopGoodPerformanceVideoRecallStrategy;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.xxl.job.core.log.XxlJobLogger;

+ 0 - 88
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/xxl/SyncFlowPoolRecentTopVideoJob.java

@@ -1,88 +0,0 @@
-package com.tzld.piaoquan.recommend.server.xxl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.aliyun.odps.data.Record;
-import com.tzld.piaoquan.recommend.server.common.base.Constant;
-import com.tzld.piaoquan.recommend.server.service.odps.ODPSManager;
-import com.tzld.piaoquan.recommend.server.service.recall.strategy.FlowPoolLastDayTopRecallStrategy;
-import com.tzld.piaoquan.recommend.server.service.recall.strategy.TopGoodPerformanceVideoRecallStrategy;
-import com.xxl.job.core.biz.model.ReturnT;
-import com.xxl.job.core.handler.annotation.XxlJob;
-import com.xxl.job.core.log.XxlJobLogger;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-
-/**
- * @author sunxy
- */
-@Component
-@Slf4j
-public class SyncFlowPoolRecentTopVideoJob {
-
-    @Autowired
-    private ODPSManager odpsManager;
-
-    @Autowired
-    private RedisTemplate<String, String> redisTemplate;
-
-    @XxlJob("syncFlowPoolRecentTopVideo")
-    public ReturnT<String> syncFlowPoolRecentTopVideo(String params) {
-        // 执行 ODPS Sql,获取数据
-        List<Long> videoIds = queryTopVideoIdsByLast6Hour(200);
-        if (CollectionUtils.isEmpty(videoIds)) {
-            XxlJobLogger.log("syncFlowPoolRecentTopVideo, videoIds is empty");
-            return ReturnT.SUCCESS;
-        }
-        XxlJobLogger.log("syncFlowPoolRecentTopVideo, videoIds:{}", videoIds);
-        // 将数据写入 Redis
-        redisTemplate.opsForValue().set(Constant.VIDEO_PERFORMANCE_DATA_REDIS_KEY + FlowPoolLastDayTopRecallStrategy.PUSH_FORM,
-                JSONObject.toJSONString(videoIds), 2, TimeUnit.HOURS);
-        return ReturnT.SUCCESS;
-    }
-
-    private List<Long> queryTopVideoIdsByLast6Hour(Integer topNum) {
-        String sql = "SELECT videoid FROM loghubods.flow_pool_video_info_per_hour " +
-                "WHERE dt = '" + odpsManager.getNowHour() + "' " +
-                "ORDER BY 12hour_return_cnt DESC LIMIT " + topNum + ";";
-        List<Record> records = odpsManager.query(sql);
-        if (records == null || records.size() == 0) {
-            return null;
-        }
-        return records.stream().map(record -> record.getBigint(0)).collect(Collectors.toList());
-    }
-
-    @XxlJob("syncGoodPerformanceVideo")
-    public ReturnT<String> syncGoodPerformanceVideo(String params) {
-        // 执行 ODPS Sql,获取数据
-        List<Long> videoIds = queryGoodPerformanceVideo(100);
-        if (CollectionUtils.isEmpty(videoIds)) {
-            XxlJobLogger.log("syncGoodPerformanceVideo, videoIds is empty");
-            return ReturnT.SUCCESS;
-        }
-        XxlJobLogger.log("syncGoodPerformanceVideo, videoIds:{}", videoIds);
-        // 将数据写入 Redis
-        redisTemplate.opsForValue().set(Constant.VIDEO_PERFORMANCE_DATA_REDIS_KEY + TopGoodPerformanceVideoRecallStrategy.PUSH_FORM,
-                JSONObject.toJSONString(videoIds), 2, TimeUnit.HOURS);
-        return ReturnT.SUCCESS;
-    }
-
-    private List<Long> queryGoodPerformanceVideo(int limit) {
-        String sql = "SELECT videoid FROM loghubods.long_period_good_performance_video " +
-                "WHERE dt = '" + odpsManager.getNowHour() + "' " +
-                "ORDER BY rov DESC LIMIT " + limit + ";";
-        List<Record> records = odpsManager.query(sql);
-        if (records == null || records.size() == 0) {
-            return null;
-        }
-        return records.stream().map(record -> record.getBigint(0)).collect(Collectors.toList());
-    }
-
-
-}