|
@@ -1,6 +1,7 @@
|
|
|
package com.tzld.piaoquan.recommend.server.service.recall;
|
|
|
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
+import com.tzld.piaoquan.recommend.server.model.Video;
|
|
|
import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -40,10 +41,10 @@ public class RecallService implements ApplicationContextAware {
|
|
|
public RecallResult recall(RecallParam param) {
|
|
|
List<RecallStrategy> strategies = getRecallStrategy(param);
|
|
|
CountDownLatch cdl = new CountDownLatch(strategies.size());
|
|
|
- List<Future<List<RecallResult.RecallData>>> recallResultFutures = new ArrayList<>(strategies.size());
|
|
|
+ List<Future<List<Video>>> recallResultFutures = new ArrayList<>(strategies.size());
|
|
|
for (RecallStrategy strategy : strategies) {
|
|
|
- Future<List<RecallResult.RecallData>> future = pool.submit(() -> {
|
|
|
- List<RecallResult.RecallData> result = strategy.recall(param);
|
|
|
+ Future<List<Video>> future = pool.submit(() -> {
|
|
|
+ List<Video> result = strategy.recall(param);
|
|
|
cdl.countDown();
|
|
|
return result;
|
|
|
});
|
|
@@ -62,9 +63,9 @@ public class RecallService implements ApplicationContextAware {
|
|
|
return merge(recallResultFutures, param);
|
|
|
}
|
|
|
|
|
|
- private RecallResult merge(List<Future<List<RecallResult.RecallData>>> recallResultFutures, RecallParam param) {
|
|
|
- List<List<RecallResult.RecallData>> results = new ArrayList<>();
|
|
|
- for (Future<List<RecallResult.RecallData>> f : recallResultFutures) {
|
|
|
+ private RecallResult merge(List<Future<List<Video>>> recallResultFutures, RecallParam param) {
|
|
|
+ List<List<Video>> results = new ArrayList<>();
|
|
|
+ for (Future<List<Video>> f : recallResultFutures) {
|
|
|
try {
|
|
|
results.add(f.get());
|
|
|
} catch (Exception e) {
|
|
@@ -75,23 +76,23 @@ public class RecallService implements ApplicationContextAware {
|
|
|
|
|
|
|
|
|
Set<Long> videoIds = new HashSet<>();
|
|
|
- List<RecallResult.RecallData> datas = new ArrayList<>();
|
|
|
+ List<Video> datas = new ArrayList<>();
|
|
|
if (param.getAbCode().equals("60054")
|
|
|
|| param.getAbCode().equals("60068")
|
|
|
|| param.getAbCode().equals("60081")
|
|
|
|| param.getAbCode().equals("60084")) {
|
|
|
if (results.size() >= 2) {
|
|
|
- List<RecallResult.RecallData> region_recall = results.get(0);
|
|
|
+ List<Video> region_recall = results.get(0);
|
|
|
if (CollectionUtils.isNotEmpty(region_recall)) {
|
|
|
- for (RecallResult.RecallData data : region_recall) {
|
|
|
+ for (Video data : region_recall) {
|
|
|
if (!videoIds.contains(data.getVideoId())) {
|
|
|
datas.add(data);
|
|
|
videoIds.add(data.getVideoId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<RecallResult.RecallData> simRecall = null;
|
|
|
- List<RecallResult.RecallData> returnRecall = null;
|
|
|
+ List<Video> simRecall = null;
|
|
|
+ List<Video> returnRecall = null;
|
|
|
if (param.getAppType().equals("18") || param.getAppType().equals("19")) {
|
|
|
simRecall = results.get(1);
|
|
|
} else {
|
|
@@ -104,7 +105,7 @@ public class RecallService implements ApplicationContextAware {
|
|
|
}
|
|
|
|
|
|
if (simRecall != null && CollectionUtils.isNotEmpty(simRecall)) {
|
|
|
- for (RecallResult.RecallData data : simRecall) {
|
|
|
+ for (Video data : simRecall) {
|
|
|
if (!videoIds.contains(data.getVideoId())) {
|
|
|
datas.add(data);
|
|
|
videoIds.add(data.getVideoId());
|
|
@@ -113,7 +114,7 @@ public class RecallService implements ApplicationContextAware {
|
|
|
}
|
|
|
|
|
|
if (returnRecall != null && CollectionUtils.isNotEmpty(returnRecall)) {
|
|
|
- for (RecallResult.RecallData data : returnRecall) {
|
|
|
+ for (Video data : returnRecall) {
|
|
|
if (!videoIds.contains(data.getVideoId())) {
|
|
|
datas.add(data);
|
|
|
videoIds.add(data.getVideoId());
|