|  | @@ -1,6 +1,7 @@
 | 
	
		
			
				|  |  |  package com.tzld.piaoquan.ad.engine.service.score;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 | 
	
		
			
				|  |  | +import com.google.common.base.Stopwatch;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.ad.engine.commons.score.ScoreParam;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.ad.engine.commons.score.ScorerUtils;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.ad.engine.commons.util.*;
 | 
	
	
		
			
				|  | @@ -21,6 +22,7 @@ import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.io.InputStream;
 | 
	
		
			
				|  |  |  import java.io.InputStreamReader;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  | +import java.util.concurrent.TimeUnit;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Slf4j
 | 
	
	
		
			
				|  | @@ -44,6 +46,8 @@ public class RankService687 extends RankStrategyXGBBasic {
 | 
	
		
			
				|  |  |              scoreParam.getRequestContext().setMachineinfoBrand(brand + "-n");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        Stopwatch sw = Stopwatch.createStarted();
 | 
	
		
			
				|  |  | +        long start = System.currentTimeMillis();
 | 
	
		
			
				|  |  |          // 特征处理
 | 
	
		
			
				|  |  |          Feature feature = this.getFeature(scoreParam, request);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -68,6 +72,7 @@ public class RankService687 extends RankStrategyXGBBasic {
 | 
	
		
			
				|  |  |          Map<String, String> e2Feature = userFeature.getOrDefault("alg_mid_feature_share_tags", new HashMap<>());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Map<String, String> sceneFeatureMap = this.handleSceneFeature(ts);
 | 
	
		
			
				|  |  | +        long time1 = sw.stop().elapsed(TimeUnit.MILLISECONDS);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<AdRankItem> adRankItems = new ArrayList<>(request.getAdIdList().size());
 | 
	
		
			
				|  |  |          for (AdPlatformCreativeDTO dto : request.getAdIdList()) {
 | 
	
	
		
			
				|  | @@ -113,6 +118,7 @@ public class RankService687 extends RankStrategyXGBBasic {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        long time2 = sw.stop().elapsed(TimeUnit.MILLISECONDS);
 | 
	
		
			
				|  |  |          // 分桶
 | 
	
		
			
				|  |  |          this.readBucketFile();
 | 
	
		
			
				|  |  |          userFeatureMap = this.featureBucket(userFeatureMap);
 | 
	
	
		
			
				|  | @@ -121,9 +127,13 @@ public class RankService687 extends RankStrategyXGBBasic {
 | 
	
		
			
				|  |  |              adRankItem.setFeatureMap(this.featureBucket(featureMap));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          // 打分排序
 | 
	
		
			
				|  |  |          List<AdRankItem> result = ScorerUtils.getScorerPipeline(ScorerUtils.XGBOOST_SCORE_CONF_683)
 | 
	
		
			
				|  |  |                  .scoring(sceneFeatureMap, userFeatureMap, adRankItems);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        long time3 = sw.stop().elapsed(TimeUnit.MILLISECONDS);
 | 
	
		
			
				|  |  |          for (AdRankItem item : result) {
 | 
	
		
			
				|  |  |              item.setScore(item.getLrScore() * item.getCpa());
 | 
	
		
			
				|  |  |              item.getScoreMap().put("cpa", item.getCpa());
 | 
	
	
		
			
				|  | @@ -163,6 +173,10 @@ public class RankService687 extends RankStrategyXGBBasic {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        long time4 = sw.stop().elapsed(TimeUnit.MILLISECONDS);
 | 
	
		
			
				|  |  | +        log.info("cost={}, feature1={}, feature2={}, getScorerPipeline={}, loop={}",
 | 
	
		
			
				|  |  | +                System.currentTimeMillis() - start, time1, time2, time3, time4);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          result.sort(ComparatorUtil.equalsRandomComparator());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return result;
 |