|
@@ -1,6 +1,5 @@
|
|
package com.tzld.longarticle.recommend.server.service.filter;
|
|
package com.tzld.longarticle.recommend.server.service.filter;
|
|
|
|
|
|
-import com.google.common.collect.Lists;
|
|
|
|
import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
|
|
import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
|
|
import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
|
|
import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
|
|
import com.tzld.longarticle.recommend.server.service.filter.strategy.CategoryStrategy;
|
|
import com.tzld.longarticle.recommend.server.service.filter.strategy.CategoryStrategy;
|
|
@@ -24,19 +23,19 @@ public class FilterService {
|
|
private final ExecutorService pool = ThreadPoolFactory.filterPool();
|
|
private final ExecutorService pool = ThreadPoolFactory.filterPool();
|
|
|
|
|
|
public FilterResult filter(FilterParam param) {
|
|
public FilterResult filter(FilterParam param) {
|
|
- List<Long> videoIds = contentFilter(param);
|
|
|
|
|
|
+ List<String> contentIds = contentFilter(param);
|
|
|
|
|
|
- return new FilterResult(videoIds);
|
|
|
|
|
|
+ return new FilterResult(contentIds);
|
|
}
|
|
}
|
|
|
|
|
|
- private List<Long> contentFilter(FilterParam param) {
|
|
|
|
|
|
+ private List<String> contentFilter(FilterParam param) {
|
|
|
|
|
|
List<FilterStrategy> strategies = getStrategies(param);
|
|
List<FilterStrategy> strategies = getStrategies(param);
|
|
CountDownLatch cdl = new CountDownLatch(strategies.size());
|
|
CountDownLatch cdl = new CountDownLatch(strategies.size());
|
|
- List<Future<List<Long>>> futures = new ArrayList<>();
|
|
|
|
|
|
+ List<Future<List<String>>> futures = new ArrayList<>();
|
|
for (final FilterStrategy strategy : strategies) {
|
|
for (final FilterStrategy strategy : strategies) {
|
|
- Future<List<Long>> future = pool.submit(() -> {
|
|
|
|
- List<Long> result = strategy.filter(param);
|
|
|
|
|
|
+ Future<List<String>> future = pool.submit(() -> {
|
|
|
|
+ List<String> result = strategy.filter(param);
|
|
cdl.countDown();
|
|
cdl.countDown();
|
|
return result;
|
|
return result;
|
|
});
|
|
});
|
|
@@ -49,8 +48,8 @@ public class FilterService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- List<List<Long>> contentIds = new ArrayList<>();
|
|
|
|
- for (Future<List<Long>> f : futures) {
|
|
|
|
|
|
+ List<List<String>> contentIds = new ArrayList<>();
|
|
|
|
+ for (Future<List<String>> f : futures) {
|
|
try {
|
|
try {
|
|
contentIds.add(f.get());
|
|
contentIds.add(f.get());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -60,7 +59,7 @@ public class FilterService {
|
|
if (CollectionUtils.isEmpty(contentIds)) {
|
|
if (CollectionUtils.isEmpty(contentIds)) {
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
}
|
|
}
|
|
-// List<Long> result = Lists.newArrayList(param.getContents());
|
|
|
|
|
|
+// List<String> result = Lists.newArrayList(param.getContents());
|
|
// for (int i = 0; i < contentIds.size(); ++i) {
|
|
// for (int i = 0; i < contentIds.size(); ++i) {
|
|
// result.retainAll(contentIds.get(i));
|
|
// result.retainAll(contentIds.get(i));
|
|
// }
|
|
// }
|