Forráskód Böngészése

修改排序 以便于param排序覆盖

gufengshou1 1 éve
szülő
commit
a10d4b1362

+ 7 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/container/PredictPidContainer.java

@@ -59,6 +59,8 @@ public class PredictPidContainer {
     OSS client;
 
     private static ConcurrentHashMap<String,Double>  lambdaCache=new ConcurrentHashMap<>();
+
+    private static ConcurrentHashMap<String,Double>  latestThresholdCache=new ConcurrentHashMap<>();
     private Date cacheDate;
 
     @PostConstruct
@@ -103,6 +105,7 @@ public class PredictPidContainer {
                     Double lambdaNew=lambdaCache.getOrDefault(group,0d)+
                             kp*Double.parseDouble(cols[1])+ki*Double.parseDouble(cols[2])+kd*Double.parseDouble(cols[3]);
                     lambdaCache.put(group,lambdaNew);
+                    latestThresholdCache.put(group,Double.parseDouble(cols[4].trim()));
                 }catch (Exception e){
                     e.printStackTrace();
                 }
@@ -132,7 +135,6 @@ public class PredictPidContainer {
             OSSObject object=client.getObject(bucketName,lambdaFileName);
             if(object==null) return;
             if(cacheDate!=null&& !cacheDate.before(object.getObjectMetadata().getLastModified())) return;
-//            if(cacheDate!=null&& cacheDate.after(object.getObjectMetadata().getLastModified())) return;
             StringBuilder builder=new StringBuilder();
             InputStream is=object.getObjectContent();
             InputStreamReader isr=new InputStreamReader(is);
@@ -152,4 +154,8 @@ public class PredictPidContainer {
     public static Double getPidLambda(String group){
         return lambdaCache.getOrDefault(group,0d);
     }
+
+    public static Double getLatestThreshold(String group){
+        return latestThresholdCache.getOrDefault(group,0d);
+    }
 }

+ 11 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/ScoreV2ThresholdPredictModel.java

@@ -36,6 +36,8 @@ public class ScoreV2ThresholdPredictModel extends ThresholdPredictModel {
 
     @Value("${ad.predict.threshold:1}")
     private double threshold;
+    @Value("${ad.model.pid.type:0.0}")
+    private double pidType;
 
     @Override
     String initName() {
@@ -94,8 +96,15 @@ public class ScoreV2ThresholdPredictModel extends ThresholdPredictModel {
         );
         int adPredict;
         //加入pid逻辑
-        realThreshold=realThreshold+ PredictPidContainer.getPidLambda(
-                scoreParam.getExtraParam().getOrDefault("predict_test_id","default")+"_"+modelParam.getAppType());
+        if(pidType>0){
+            realThreshold=realThreshold+ PredictPidContainer.getPidLambda(
+                    scoreParam.getExtraParam().getOrDefault("predict_test_id","default")+"_"+modelParam.getAppType());
+        }else {
+            realThreshold=PredictPidContainer.getLatestThreshold(
+                    scoreParam.getExtraParam().getOrDefault("predict_test_id","default")+"_"+modelParam.getAppType());
+        }
+
+
         if (maxItem != null && maxItem.getScore() < realThreshold) {
             // If final score is below threshold, do not show the ad
             adPredict = 1;