|
@@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -394,6 +395,19 @@ public class RankService {
|
|
|
}
|
|
|
|
|
|
private RankResult mergeAndSort4Density(RankParam param, List<Video> rovRecallRank, List<Video> flowPoolRank) {
|
|
|
+ // 测试,添加数据
|
|
|
+// rovRecallRank.add(0, getTestVideo(1070462L, ""));
|
|
|
+// rovRecallRank.add(0, getTestVideo(1085062L, ""));
|
|
|
+// rovRecallRank.add(0, getTestVideo(1102552L, ""));
|
|
|
+// rovRecallRank.add(0, getTestVideo(1115929L, ""));
|
|
|
+//
|
|
|
+// flowPoolRank = new ArrayList<>();
|
|
|
+// flowPoolRank.add(getTestVideo(1263931L, "flow"));
|
|
|
+// flowPoolRank.add(getTestVideo(1284797L, "flow"));
|
|
|
+// flowPoolRank.add(getTestVideo(1289001L, "flow"));
|
|
|
+// flowPoolRank.add(getTestVideo(1331503L, "flow"));
|
|
|
+
|
|
|
+
|
|
|
if (CollectionUtils.isEmpty(rovRecallRank)) {
|
|
|
if (param.getSize() < flowPoolRank.size()) {
|
|
|
return new RankResult(flowPoolRank.subList(0, param.getSize()));
|
|
@@ -414,13 +428,15 @@ public class RankService {
|
|
|
if (!entry.getValue().containsKey(appType)){
|
|
|
continue;
|
|
|
}
|
|
|
- String str = (String) entry.getValue().get(appType);
|
|
|
- Map<String, Object> tmp = JSONUtils.fromJson(str,
|
|
|
- new TypeToken<Map<String, Object>>() {},
|
|
|
- Collections.emptyMap());
|
|
|
- if (tmp.containsKey("density") && tmp.get("density") instanceof Integer){
|
|
|
- densityRules.put(k, (Integer)tmp.get("density"));
|
|
|
+ JSONObject jb = (JSONObject) entry.getValue().get(appType);
|
|
|
+ try{
|
|
|
+ if (jb.containsKey("density") && jb.get("density") instanceof Integer){
|
|
|
+ densityRules.put(k, jb.getInteger("density"));
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("parse densityRules is wrong:", e);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
// 2 读取video的tags
|
|
@@ -487,4 +503,11 @@ public class RankService {
|
|
|
return new RankResult(resultWithDnsity);
|
|
|
}
|
|
|
|
|
|
+// public Video getTestVideo(Long id, String s){
|
|
|
+// Video a1 = new Video();
|
|
|
+// a1.setVideoId(id);
|
|
|
+// a1.setFlowPool(s);
|
|
|
+// return a1;
|
|
|
+// }
|
|
|
+
|
|
|
}
|