|
@@ -41,7 +41,7 @@ public class FlowPoolService {
|
|
|
LAO_HAO_KAN_VIDEO.getCode(), ZUI_JING_QI.getCode(), PIAO_QUAN_VIDEO_PLUS.getCode(), JOURNEY.getCode()};
|
|
|
|
|
|
|
|
|
- public Map<Long, Integer> getLocalDistributeCountWithLevel(Map<Long, String> videoFlowPoolMap) {
|
|
|
+ public Map<Long, Integer> getDistributeCountWithLevel(Map<Long, String> videoFlowPoolMap) {
|
|
|
if (MapUtils.isEmpty(videoFlowPoolMap)) {
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
@@ -56,29 +56,22 @@ public class FlowPoolService {
|
|
|
e -> e.getKey(),
|
|
|
e -> e.getValue()
|
|
|
));
|
|
|
- asyncDelLocalDistributeCountWithLevel(dirties);
|
|
|
+ asyncDelDistributeCountWithLevel(dirties);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private Map<Long, Integer> getDistributeCount(Map<Long, String> videoFlowPoolMap) {
|
|
|
- // 为了保证有序
|
|
|
- List<Map.Entry<Long, String>> entries =
|
|
|
- videoFlowPoolMap.entrySet().stream().sorted().collect(Collectors.toList());
|
|
|
+ public void updateDistributeCountWithLevel(List<Video> videos) {
|
|
|
+ if (CollectionUtils.isEmpty(videos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, String> removeMap = updateDistributeCount(videos);
|
|
|
|
|
|
- List<String> keys = entries.stream()
|
|
|
- .map(v -> String.format(localDistributeCountFormat, v.getKey(), v.getValue()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- List<Integer> counts = redisTemplate.opsForValue().multiGet(keys);
|
|
|
+ asyncDelDistributeCountWithLevel(removeMap);
|
|
|
|
|
|
- Map<Long, Integer> result = new HashMap<>();
|
|
|
- for (int i = 0; i < entries.size(); i++) {
|
|
|
- result.put(entries.get(i).getKey(), counts.get(i));
|
|
|
- }
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
- private void asyncDelLocalDistributeCountWithLevel(Map<Long, String> videoFlowPoolMap) {
|
|
|
+ private void asyncDelDistributeCountWithLevel(Map<Long, String> videoFlowPoolMap) {
|
|
|
if (MapUtils.isEmpty(videoFlowPoolMap)) {
|
|
|
return;
|
|
|
}
|
|
@@ -101,7 +94,7 @@ public class FlowPoolService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public Map<Long, Integer> getLocalDistributeCountWithLevelScore(Map<Long, String> videoFlowPoolMap) {
|
|
|
+ public Map<Long, Integer> getDistributeCountWithLevelScore(Map<Long, String> videoFlowPoolMap) {
|
|
|
if (MapUtils.isEmpty(videoFlowPoolMap)) {
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
@@ -114,12 +107,21 @@ public class FlowPoolService {
|
|
|
e -> e.getKey(),
|
|
|
e -> e.getValue()
|
|
|
));
|
|
|
- asyncDelLocalDistributeCountWithLevelScore(dirties);
|
|
|
+ asyncLocalDistributeCountWithLevelScore(dirties);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private void asyncDelLocalDistributeCountWithLevelScore(Map<Long, String> videoFlowPoolMap) {
|
|
|
+ public void updateDistributeCountWithLevelScore(List<Video> videos) {
|
|
|
+ if (CollectionUtils.isEmpty(videos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, String> removeMap = updateDistributeCount(videos);
|
|
|
+
|
|
|
+ asyncLocalDistributeCountWithLevelScore(removeMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void asyncLocalDistributeCountWithLevelScore(Map<Long, String> videoFlowPoolMap) {
|
|
|
if (MapUtils.isEmpty(videoFlowPoolMap)) {
|
|
|
return;
|
|
|
}
|
|
@@ -142,7 +144,7 @@ public class FlowPoolService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public Map<Long, Integer> getLocalDistributeCountWithScore(Map<Long, String> videoFlowPoolMap) {
|
|
|
+ public Map<Long, Integer> getDistributeCountWithScore(Map<Long, String> videoFlowPoolMap) {
|
|
|
if (MapUtils.isEmpty(videoFlowPoolMap)) {
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
@@ -154,12 +156,19 @@ public class FlowPoolService {
|
|
|
e -> e.getKey(),
|
|
|
e -> e.getValue()
|
|
|
));
|
|
|
- asyncDelLocalDistributeCountWithScore(dirties);
|
|
|
-
|
|
|
+ asyncDelDistributeCountWithScore(dirties);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private void asyncDelLocalDistributeCountWithScore(Map<Long, String> videoFlowPoolMap) {
|
|
|
+ public void updateDistributeCountWithScore(List<Video> videos) {
|
|
|
+ if (CollectionUtils.isEmpty(videos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, String> removeMap = updateDistributeCount(videos);
|
|
|
+ asyncDelDistributeCountWithScore(removeMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void asyncDelDistributeCountWithScore(Map<Long, String> videoFlowPoolMap) {
|
|
|
if (MapUtils.isEmpty(videoFlowPoolMap)) {
|
|
|
return;
|
|
|
}
|
|
@@ -182,14 +191,21 @@ public class FlowPoolService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public void updateLocalDistributeCountWithLevel(List<Video> videos) {
|
|
|
- if (CollectionUtils.isEmpty(videos)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Map<Long, String> removeMap = updateDistributeCount(videos);
|
|
|
+ private Map<Long, Integer> getDistributeCount(Map<Long, String> videoFlowPoolMap) {
|
|
|
+ // 为了保证有序
|
|
|
+ List<Map.Entry<Long, String>> entries =
|
|
|
+ videoFlowPoolMap.entrySet().stream().sorted().collect(Collectors.toList());
|
|
|
|
|
|
- asyncDelLocalDistributeCountWithLevel(removeMap);
|
|
|
+ List<String> keys = entries.stream()
|
|
|
+ .map(v -> String.format(localDistributeCountFormat, v.getKey(), v.getValue()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<Integer> counts = redisTemplate.opsForValue().multiGet(keys);
|
|
|
|
|
|
+ Map<Long, Integer> result = new HashMap<>();
|
|
|
+ for (int i = 0; i < entries.size(); i++) {
|
|
|
+ result.put(entries.get(i).getKey(), counts.get(i));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
private Map<Long, String> updateDistributeCount(List<Video> videos) {
|
|
@@ -203,22 +219,4 @@ public class FlowPoolService {
|
|
|
});
|
|
|
return removeMap;
|
|
|
}
|
|
|
-
|
|
|
- public void updateLocalDistributeCountWithLevelScore(List<Video> videos) {
|
|
|
- if (CollectionUtils.isEmpty(videos)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Map<Long, String> removeMap = updateDistributeCount(videos);
|
|
|
-
|
|
|
- asyncDelLocalDistributeCountWithLevelScore(removeMap);
|
|
|
- }
|
|
|
-
|
|
|
- public void updateLocalDistributeCount(List<Video> videos) {
|
|
|
- if (CollectionUtils.isEmpty(videos)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Map<Long, String> removeMap = updateDistributeCount(videos);
|
|
|
-
|
|
|
- asyncDelLocalDistributeCountWithScore(removeMap);
|
|
|
- }
|
|
|
}
|