|
@@ -1,5 +1,6 @@
|
|
|
package com.tzld.piaoquan.recommend.server.service.filter.strategy;
|
|
|
|
|
|
+import com.google.common.base.Stopwatch;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.hash.Hashing;
|
|
|
import com.tzld.piaoquan.recommend.server.common.enums.AppTypeEnum;
|
|
@@ -33,7 +34,7 @@ public class AllowListStrategy implements FilterStrategy {
|
|
|
@Override
|
|
|
// TODO 未找到优化方法 暂时保留原代码
|
|
|
public List<Long> filter(FilterParam param) {
|
|
|
-
|
|
|
+ Stopwatch stopwatch = Stopwatch.createStarted();
|
|
|
if (param == null
|
|
|
|| CollectionUtils.isEmpty(param.getVideoIds())) {
|
|
|
return Collections.emptyList();
|
|
@@ -66,6 +67,7 @@ public class AllowListStrategy implements FilterStrategy {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ log.info("AllowListStrategy cost {} ms", stopwatch.elapsed().toMillis());
|
|
|
if (CollectionUtils.isEmpty(retainVideoIds)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
@@ -81,14 +83,14 @@ public class AllowListStrategy implements FilterStrategy {
|
|
|
int newIdx = Math.abs(Hashing.murmur3_32().hashLong(videoId).asInt()) % 100;
|
|
|
String newPrefix = VIDEO_ALLOW_LIST_BITMAP_KEY_SET_PREFIX + newIdx;
|
|
|
Boolean result = redisTemplate.opsForSet().isMember(newPrefix, String.valueOf(videoId));
|
|
|
- // 兼容旧 key
|
|
|
- if (Objects.equals(1, mvalCompatible) && !result) {
|
|
|
- int idx = Math.abs(Hashing.murmur3_32().hashLong(videoId).asInt()) % 10;
|
|
|
- result = redisTemplate.opsForValue().getBit(VIDEO_ALLOW_LIST_BITMAP_KEY_PREFIX + idx, videoId);
|
|
|
- }
|
|
|
- if (Objects.equals(1, mvalCompatible) && !result) {
|
|
|
- result = redisTemplate.opsForValue().getBit(VIDEO_ALLOW_LIST_BITMAP_KEY, videoId);
|
|
|
- }
|
|
|
+// // 兼容旧 key apollo配置0 所以删除
|
|
|
+// if (Objects.equals(1, mvalCompatible) && !result) {
|
|
|
+// int idx = Math.abs(Hashing.murmur3_32().hashLong(videoId).asInt()) % 10;
|
|
|
+// result = redisTemplate.opsForValue().getBit(VIDEO_ALLOW_LIST_BITMAP_KEY_PREFIX + idx, videoId);
|
|
|
+// }
|
|
|
+// if (Objects.equals(1, mvalCompatible) && !result) {
|
|
|
+// result = redisTemplate.opsForValue().getBit(VIDEO_ALLOW_LIST_BITMAP_KEY, videoId);
|
|
|
+// }
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
log.error("isMemberOfVideoAllowList error {}", videoId, e);
|