|
@@ -28,6 +28,9 @@ public class VideoAdThompsonScorerV2 {
|
|
//redis:vid_cid_action:{$vid}_{$cid}
|
|
//redis:vid_cid_action:{$vid}_{$cid}
|
|
private String redisVideoCreativeStatisticsPrefix="redis:vid_cid_action:";
|
|
private String redisVideoCreativeStatisticsPrefix="redis:vid_cid_action:";
|
|
|
|
|
|
|
|
+ private String rediCidActionKeyV1 = "redis:cid_action_v1:";
|
|
|
|
+ private String rediCidVidActionKeyV1 = "redis:vid_cid_action_v1:";
|
|
|
|
+
|
|
private Map<String,Double> exp663Param=new HashMap<>();
|
|
private Map<String,Double> exp663Param=new HashMap<>();
|
|
private Map<String,Double> exp664Param=new HashMap<>();
|
|
private Map<String,Double> exp664Param=new HashMap<>();
|
|
private Map<String,Double> exp665Param=new HashMap<>();
|
|
private Map<String,Double> exp665Param=new HashMap<>();
|
|
@@ -248,8 +251,8 @@ public class VideoAdThompsonScorerV2 {
|
|
|
|
|
|
|
|
|
|
public List<AdRankItem> thompsonScorerByExp669(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
public List<AdRankItem> thompsonScorerByExp669(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
- Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(redisCreativeStatisticsPrefix, adIdList);
|
|
|
|
- Map<Long, CreativeStatistic> videoCreativeStatisticsMap = this.batchFindCreativeRedisCache(redisVideoCreativeStatisticsPrefix + param.getVideoId() + "_", adIdList);
|
|
|
|
|
|
+ Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(rediCidActionKeyV1, adIdList);
|
|
|
|
+ Map<Long, CreativeStatistic> videoCreativeStatisticsMap = this.batchFindCreativeRedisCache(rediCidVidActionKeyV1 + param.getVideoId() + "_", adIdList);
|
|
Double creativeExpSum = this.sumCreativeStatisticExp(creativeStatisticsMap.values());
|
|
Double creativeExpSum = this.sumCreativeStatisticExp(creativeStatisticsMap.values());
|
|
Double videoCreativeExpSum = this.sumCreativeStatisticExp(videoCreativeStatisticsMap.values());
|
|
Double videoCreativeExpSum = this.sumCreativeStatisticExp(videoCreativeStatisticsMap.values());
|
|
|
|
|
|
@@ -266,8 +269,8 @@ public class VideoAdThompsonScorerV2 {
|
|
}
|
|
}
|
|
|
|
|
|
public List<AdRankItem> thompsonScorerByExp670(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
public List<AdRankItem> thompsonScorerByExp670(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
- Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(redisCreativeStatisticsPrefix, adIdList);
|
|
|
|
- Map<Long, CreativeStatistic> videoCreativeStatisticsMap = this.batchFindCreativeRedisCache(redisVideoCreativeStatisticsPrefix + param.getVideoId() + "_", adIdList);
|
|
|
|
|
|
+ Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(rediCidActionKeyV1, adIdList);
|
|
|
|
+ Map<Long, CreativeStatistic> videoCreativeStatisticsMap = this.batchFindCreativeRedisCache(rediCidVidActionKeyV1 + param.getVideoId() + "_", adIdList);
|
|
|
|
|
|
List<AdRankItem> result = new ArrayList<>(adIdList.size());
|
|
List<AdRankItem> result = new ArrayList<>(adIdList.size());
|
|
this.calcScore(result, adIdList, 0.0, 0.0, 0.0, creativeStatisticsMap, videoCreativeStatisticsMap, exp670Param);
|
|
this.calcScore(result, adIdList, 0.0, 0.0, 0.0, creativeStatisticsMap, videoCreativeStatisticsMap, exp670Param);
|
|
@@ -310,13 +313,19 @@ public class VideoAdThompsonScorerV2 {
|
|
|
|
|
|
private Map<Long, CreativeStatistic> batchFindCreativeRedisCache(String keyPrefix, List<AdPlatformCreativeDTO> adIdList) {
|
|
private Map<Long, CreativeStatistic> batchFindCreativeRedisCache(String keyPrefix, List<AdPlatformCreativeDTO> adIdList) {
|
|
Map<Long, CreativeStatistic> resultMap = new HashMap<>();
|
|
Map<Long, CreativeStatistic> resultMap = new HashMap<>();
|
|
- for (AdPlatformCreativeDTO dto : adIdList) {
|
|
|
|
- String redisKey = keyPrefix + dto.getCreativeId();
|
|
|
|
- String value = redisHelper.get(redisKey);
|
|
|
|
|
|
+ List<String> redisKeys = adIdList.stream()
|
|
|
|
+ .map(dto -> keyPrefix + dto.getCreativeId())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<String> values = redisHelper.getValues(redisKeys);
|
|
|
|
+ for (int i = 0; i < adIdList.size(); i++) {
|
|
|
|
+ Long cid = adIdList.get(i).getCreativeId();
|
|
|
|
+ String value = values.get(i);
|
|
if (StringUtils.isNotBlank(value)) {
|
|
if (StringUtils.isNotBlank(value)) {
|
|
- resultMap.put(dto.getCreativeId(), gson.fromJson(value, CreativeStatistic.class));
|
|
|
|
|
|
+ resultMap.put(cid, gson.fromJson(value, CreativeStatistic.class));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
|
|
|