|
|
@@ -22,6 +22,8 @@ public class ModelUserLayerDataHelper {
|
|
|
private static final String redisKey = "ad:engine:strategy:model_ctcvr_calibration_v1";
|
|
|
private static final String keyFormat = "%s:%s:%s:%s:%s:%s:%s";
|
|
|
private static final String SUM = "sum";
|
|
|
+ /** 曝光大于该阈值才使用当前层校准,否则回退下一层 */
|
|
|
+ private static final double MIN_CALIBRATION_EXPOSURE = 5000d;
|
|
|
|
|
|
private volatile static Map<String, String> dataMap = Collections.emptyMap();
|
|
|
|
|
|
@@ -46,6 +48,7 @@ public class ModelUserLayerDataHelper {
|
|
|
/**
|
|
|
* 按粒度回退取校准数据,并返回命中的校准层:
|
|
|
* l1=agent+customer 粒度,l2=profession 粒度,l3=layer 粒度。
|
|
|
+ * 当前层曝光必须大于 {@link #MIN_CALIBRATION_EXPOSURE},否则回退下一层。
|
|
|
* key/value 均以 ':' 分隔;
|
|
|
* value: exposure_cnt:conversion_cnt:pred_conversion_cnt:real_ctcvr:pred_ctcvr:copc
|
|
|
*/
|
|
|
@@ -62,21 +65,21 @@ public class ModelUserLayerDataHelper {
|
|
|
|
|
|
String key = String.format(keyFormat, model, landingPageType, targetingConversion, layer, profession, agentId, customerId);
|
|
|
CalibrationData data = parseValue(dataMap.get(key));
|
|
|
- if (data != null) {
|
|
|
+ if (isExposureEnough(data)) {
|
|
|
data.setLayer("l1");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
key = String.format(keyFormat, model, landingPageType, targetingConversion, layer, profession, SUM, SUM);
|
|
|
data = parseValue(dataMap.get(key));
|
|
|
- if (data != null) {
|
|
|
+ if (isExposureEnough(data)) {
|
|
|
data.setLayer("l2");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
key = String.format(keyFormat, model, landingPageType, targetingConversion, layer, SUM, SUM, SUM);
|
|
|
data = parseValue(dataMap.get(key));
|
|
|
- if (data != null) {
|
|
|
+ if (isExposureEnough(data)) {
|
|
|
data.setLayer("l3");
|
|
|
return data;
|
|
|
}
|
|
|
@@ -84,6 +87,10 @@ public class ModelUserLayerDataHelper {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private static boolean isExposureEnough(CalibrationData data) {
|
|
|
+ return data != null && data.getExposureCnt() != null && data.getExposureCnt() > MIN_CALIBRATION_EXPOSURE;
|
|
|
+ }
|
|
|
+
|
|
|
private static CalibrationData parseValue(String value) {
|
|
|
if (value == null || value.trim().isEmpty()) {
|
|
|
return null;
|