|
@@ -40,60 +40,7 @@ public class RankService {
|
|
|
private FeatureRemoteService featureRemoteService;
|
|
|
|
|
|
|
|
|
- // LR scores
|
|
|
- public RankResult rank(RecommendRequest recommendRequest,
|
|
|
- RankParam param,
|
|
|
- RequestContext requestContext,
|
|
|
- RecallResult recallResult,
|
|
|
- UserFeature userFeature,
|
|
|
- List<RankItem> videoRankFeatures,
|
|
|
- Config config) {
|
|
|
- if (param == null
|
|
|
- || param.getRecallResult() == null
|
|
|
- || CollectionUtils.isEmpty(param.getRecallResult().getData())) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- if (param.isSpecialRecommend()) {
|
|
|
- Optional<RecallResult.RecallData> data = param.getRecallResult().getData().stream()
|
|
|
- .filter(d -> d.getPushFrom().equals(SpecialRecallStrategy.PUSH_FROM))
|
|
|
- .findFirst();
|
|
|
- if (data.isPresent()
|
|
|
- && data.get() != null) {
|
|
|
- return new RankResult(data.get().getVideos());
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- ScorerPipeline scorerPipeline = ScorerUtils.getScorerPipeline(config);
|
|
|
- // TODO merge 后返回待排序的video list
|
|
|
- List<Video> recallVideos = recallResult.mergeRecallVideos();
|
|
|
-
|
|
|
- // TODO 转化成rankitem
|
|
|
- // convert List<Video> to List<RankItem>
|
|
|
- List<RankItem> rovRecallRank = scorerPipeline.scoring(requestContext, param, userFeature, videoRankFeatures);
|
|
|
-
|
|
|
- log.info("mergeAndRankRovRecall rovRecallRank={}", JSONUtils.toJson(rovRecallRank));
|
|
|
- List<Video> flowPoolRank = mergeAndRankFlowPoolRecall(param);
|
|
|
- log.info("mergeAndRankFlowPoolRecall flowPoolRank={}", JSONUtils.toJson(flowPoolRank));
|
|
|
-
|
|
|
- //TODO
|
|
|
- removeDuplicate(param, recallVideos, flowPoolRank);
|
|
|
- // convert List<RankItem> to List<Video>
|
|
|
-
|
|
|
- log.info("removeDuplicate rovRecallRank={}, flowPoolRank={}",
|
|
|
- JSONUtils.toJson(rovRecallRank),
|
|
|
- JSONUtils.toJson(flowPoolRank));
|
|
|
-
|
|
|
- // 融合排序
|
|
|
- //TODO need to repair
|
|
|
- return mergeAndSort(param, recallVideos, flowPoolRank);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public RankResult rank(RankParam param) {
|
|
|
-
|
|
|
-
|
|
|
if (param == null
|
|
|
|| param.getRecallResult() == null
|
|
|
|| CollectionUtils.isEmpty(param.getRecallResult().getData())) {
|
|
@@ -193,7 +140,6 @@ public class RankService {
|
|
|
return rovRecallRank;
|
|
|
}
|
|
|
|
|
|
-<<<<<<< HEAD
|
|
|
private void removeDuplicate(List<Video> rovRecallRank) {
|
|
|
if (CollectionUtils.isNotEmpty(rovRecallRank)) {
|
|
|
Set<Long> videoIds = new HashSet<>();
|
|
@@ -207,7 +153,7 @@ public class RankService {
|
|
|
videoIds.add(v.getVideoId());
|
|
|
}
|
|
|
}
|
|
|
-=======
|
|
|
+ }
|
|
|
private List<Video> mergeAndRankRovRecallNew(RankParam param) {
|
|
|
UserFeature userFeature = featureRemoteService.getUserFeature(param.getUid());
|
|
|
List<Video> recallVideos = param.getRecallResult().mergeRecallVideos();
|
|
@@ -236,7 +182,6 @@ public class RankService {
|
|
|
v.setSortScore(i.getScore());
|
|
|
return v;
|
|
|
});
|
|
|
->>>>>>> 9c18d0c (reco process)
|
|
|
}
|
|
|
|
|
|
private List<Video> mergeAndRankFlowPoolRecall(RankParam param) {
|