丁云鹏 7 mesi fa
parent
commit
aa1e2ca108

+ 27 - 8
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/RankStrategyXGBAutoUpdateModel688.java

@@ -166,14 +166,33 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
                     Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", new HashMap<>());
                     String title = b1Feature.getOrDefault("cidtitle", "");
                     this.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap());
-                    this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap());
                 } finally {
                     cdl2.countDown();
                 }
             });
         }
         try {
-            cdl2.await(200, TimeUnit.MILLISECONDS);
+            cdl2.await(100, TimeUnit.MILLISECONDS);
+        } catch (Exception e) {
+            log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
+        }
+        long time31 = System.currentTimeMillis();
+        CountDownLatch cdl3 = new CountDownLatch(adRankItems.size());
+        for (AdRankItem item : adRankItems) {
+            ThreadPoolFactory.defaultPool().submit(() -> {
+                try {
+                    String cidStr = String.valueOf(item.getAdId());
+                    Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
+                    Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", new HashMap<>());
+                    String title = b1Feature.getOrDefault("cidtitle", "");
+                    this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap());
+                } finally {
+                    cdl3.countDown();
+                }
+            });
+        }
+        try {
+            cdl3.await(100, TimeUnit.MILLISECONDS);
         } catch (Exception e) {
             log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
         }
@@ -184,19 +203,19 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
         if (similarityConcurrent) {
             this.readBucketFile();
             userFeatureMap = this.featureBucket(userFeatureMap);
-            CountDownLatch cdl3 = new CountDownLatch(adRankItems.size());
+            CountDownLatch cdl4 = new CountDownLatch(adRankItems.size());
             for (AdRankItem adRankItem : adRankItems) {
                 ThreadPoolFactory.feature().submit(() -> {
                     try {
                         Map<String, String> featureMap = adRankItem.getFeatureMap();
                         adRankItem.setFeatureMap(this.featureBucket(featureMap));
                     } finally{
-                        cdl3.countDown();
+                        cdl4.countDown();
                     }
                 });
             }
             try {
-                cdl3.await(100, TimeUnit.MILLISECONDS);
+                cdl4.await(100, TimeUnit.MILLISECONDS);
             } catch (Exception e) {
                 log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
             }
@@ -255,10 +274,10 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
         }
 
         long time6 = System.currentTimeMillis();
-        log.info("cost={}, feature1={}, feature2={}, feature3={}, feature4={}, getScorerPipeline={}, " +
+        log.info("cost={}, feature1={}, feature2={}, feature31={}, feature32={}, feature4={}, getScorerPipeline={}, " +
                         "loop={}, adIdSize={}, adRankItemsSize={}",
-                time6 - start, time1 - start, time2 - time1, time3 - time2, time4 - time3, time5 - time4,
-                time6 - time5, request.getAdIdList().size(), adRankItems.size());
+                time6 - start, time1 - start, time2 - time1, time31 - time2, time3 - time31, time4 - time3,
+                time5 - time4, time6 - time5, request.getAdIdList().size(), adRankItems.size());
 
         result.sort(ComparatorUtil.equalsRandomComparator());