Ver código fonte

ADD:ShareDeepAndSort Recall Rank

sunxy 11 meses atrás
pai
commit
e3a06c7aa3

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

@@ -56,13 +56,15 @@ public class ShareDeepRecallStrategy implements RecallStrategy {
         FilterResult filterResult = filterService.filter(filterParam);
         List<Video> videosResult = new ArrayList<>();
         if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().limit(Integer.parseInt(shareDeepRecallStrategyRecallNumberAfterFilter)).forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
+            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;
     }

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

@@ -56,13 +56,15 @@ public class ShareWidthRecallStrategy implements RecallStrategy {
         FilterResult filterResult = filterService.filter(filterParam);
         List<Video> videosResult = new ArrayList<>();
         if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().limit(Integer.parseInt(shareDeepRecallStrategyRecallNumberAfterFilter)).forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
+            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;
     }