|
@@ -4,6 +4,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.enums.RedisPrefixEnum;
|
|
|
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.thread.ThreadPoolFactory;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.util.*;
|
|
|
import com.tzld.piaoquan.ad.engine.service.feature.Feature;
|
|
|
import com.tzld.piaoquan.ad.engine.service.score.dto.AdPlatformCreativeDTO;
|
|
@@ -13,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.xm.Similarity;
|
|
|
|
|
@@ -21,23 +23,41 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class RankService680 extends RankStrategyXGBBasic {
|
|
|
|
|
|
+
|
|
|
private Map<String, double[]> bucketsMap = new HashMap<>();
|
|
|
|
|
|
private Map<String, Double> bucketsLen = new HashMap<>();
|
|
|
|
|
|
+ @Value("${similarity.concurrent: false}")
|
|
|
+ private boolean similarityConcurrent;
|
|
|
+
|
|
|
+ @ApolloJsonValue("${rank.score.weight.680:{}}")
|
|
|
+ private Map<String, Double> weightMap;
|
|
|
+
|
|
|
@Override
|
|
|
public List<AdRankItem> adItemRank(RankRecommendRequestParam request, ScoreParam scoreParam) {
|
|
|
|
|
|
+ Map<String, Double> weightParam = ObjUtil.nullOrDefault(weightMap, new HashMap<>());
|
|
|
+
|
|
|
Set<String> noApiAdVerIds = getNoApiAdVerIds();
|
|
|
|
|
|
long ts = System.currentTimeMillis() / 1000;
|
|
|
|
|
|
+ String brand = scoreParam.getRequestContext().getMachineinfoBrand();
|
|
|
+ if (StringUtils.isNotEmpty(brand)) {
|
|
|
+ scoreParam.getRequestContext().setMachineinfoBrand(brand + "-n");
|
|
|
+ }
|
|
|
+
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
// 特征处理
|
|
|
Feature feature = this.getFeature(scoreParam, request);
|
|
|
|
|
@@ -62,51 +82,123 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
Map<String, String> e2Feature = userFeature.getOrDefault("alg_mid_feature_share_tags", new HashMap<>());
|
|
|
|
|
|
Map<String, String> sceneFeatureMap = this.handleSceneFeature(ts);
|
|
|
+ long time1 = System.currentTimeMillis();
|
|
|
|
|
|
List<AdRankItem> adRankItems = new ArrayList<>(request.getAdIdList().size());
|
|
|
- for (AdPlatformCreativeDTO dto : request.getAdIdList()) {
|
|
|
- AdRankItem adRankItem = new AdRankItem();
|
|
|
- adRankItem.setAdId(dto.getCreativeId());
|
|
|
- adRankItem.setCreativeCode(dto.getCreativeCode());
|
|
|
- adRankItem.setAdVerId(dto.getAdVerId());
|
|
|
- adRankItem.setVideoId(request.getVideoId());
|
|
|
- adRankItem.setCpa(dto.getCpa());
|
|
|
- adRankItem.setId(dto.getAdId());
|
|
|
- adRankItem.setCampaignId(dto.getCampaignId());
|
|
|
- adRankItem.setCpm(ObjUtil.nullOrDefault(dto.getCpm(), 90).doubleValue());
|
|
|
+ Random random = new Random();
|
|
|
+ if (similarityConcurrent) {
|
|
|
+ for (AdPlatformCreativeDTO dto : request.getAdIdList()) {
|
|
|
+ AdRankItem adRankItem = new AdRankItem();
|
|
|
+ adRankItem.setAdId(dto.getCreativeId());
|
|
|
+ adRankItem.setCreativeCode(dto.getCreativeCode());
|
|
|
+ adRankItem.setAdVerId(dto.getAdVerId());
|
|
|
+ adRankItem.setVideoId(request.getVideoId());
|
|
|
+ adRankItem.setCpa(dto.getCpa());
|
|
|
+ adRankItem.setId(dto.getAdId());
|
|
|
+ adRankItem.setCampaignId(dto.getCampaignId());
|
|
|
+ adRankItem.setCpm(ObjUtil.nullOrDefault(dto.getCpm(), 90).doubleValue());
|
|
|
+ adRankItem.setRandom(random.nextInt(1000));
|
|
|
+ if (noApiAdVerIds.contains(dto.getAdVerId())) {
|
|
|
+ adRankItem.getExt().put("isApi", "0");
|
|
|
+ } else {
|
|
|
+ adRankItem.getExt().put("isApi", "1");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String cidStr = dto.getCreativeId().toString();
|
|
|
+ Map<String, String> cidFeatureMap = adRankItem.getFeatureMap();
|
|
|
+ Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
|
|
|
+ Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", new HashMap<>());
|
|
|
+
|
|
|
+ Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(dto.getAdVerId(), new HashMap<>());
|
|
|
+
|
|
|
+ Map<String, String> d1Feature = cidFeature.getOrDefault("alg_cid_feature_vid_cf", new HashMap<>());
|
|
|
+
|
|
|
+ this.handleB1Feature(b1Feature, cidFeatureMap, cidStr);
|
|
|
+
|
|
|
+ this.handleB2ToB5AndB8ToB9Feature(cidFeature, adVerFeature, cidFeatureMap);
|
|
|
+
|
|
|
+ this.handleB6ToB7Feature(cidFeature, cidFeatureMap);
|
|
|
|
|
|
- String cidStr = dto.getCreativeId().toString();
|
|
|
- Map<String, String> cidFeatureMap = new HashMap<>();
|
|
|
- Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
|
|
|
- Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", new HashMap<>());
|
|
|
+ this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
|
|
|
- Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(dto.getAdVerId(), new HashMap<>());
|
|
|
+ this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
|
|
|
- Map<String, String> d1Feature = cidFeature.getOrDefault("alg_cid_feature_vid_cf", new HashMap<>());
|
|
|
+ this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
|
|
|
- this.handleB1Feature(b1Feature, cidFeatureMap, cidStr);
|
|
|
+ // adRankItem.setFeatureMap(cidFeatureMap);
|
|
|
|
|
|
- this.handleB2ToB5AndB8ToB9Feature(cidFeature, adVerFeature, cidFeatureMap);
|
|
|
+ adRankItems.add(adRankItem);
|
|
|
|
|
|
- this.handleB6ToB7Feature(cidFeature, cidFeatureMap);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ CountDownLatch cdl = 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.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap());
|
|
|
+ this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap());
|
|
|
+ } finally {
|
|
|
+ cdl.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ cdl.await(200, TimeUnit.MILLISECONDS);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (AdPlatformCreativeDTO dto : request.getAdIdList()) {
|
|
|
+ AdRankItem adRankItem = new AdRankItem();
|
|
|
+ adRankItem.setAdId(dto.getCreativeId());
|
|
|
+ adRankItem.setCreativeCode(dto.getCreativeCode());
|
|
|
+ adRankItem.setAdVerId(dto.getAdVerId());
|
|
|
+ adRankItem.setVideoId(request.getVideoId());
|
|
|
+ adRankItem.setCpa(dto.getCpa());
|
|
|
+ adRankItem.setId(dto.getAdId());
|
|
|
+ adRankItem.setCampaignId(dto.getCampaignId());
|
|
|
+ adRankItem.setCpm(ObjUtil.nullOrDefault(dto.getCpm(), 90).doubleValue());
|
|
|
+ adRankItem.setRandom(random.nextInt(1000));
|
|
|
+
|
|
|
+ String cidStr = dto.getCreativeId().toString();
|
|
|
+ Map<String, String> cidFeatureMap = adRankItem.getFeatureMap();
|
|
|
+ Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
|
|
|
+ Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", new HashMap<>());
|
|
|
+
|
|
|
+ Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(dto.getAdVerId(), new HashMap<>());
|
|
|
|
|
|
- this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
+ Map<String, String> d1Feature = cidFeature.getOrDefault("alg_cid_feature_vid_cf", new HashMap<>());
|
|
|
|
|
|
- this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
+ this.handleB1Feature(b1Feature, cidFeatureMap, cidStr);
|
|
|
|
|
|
- this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
+ this.handleB2ToB5AndB8ToB9Feature(cidFeature, adVerFeature, cidFeatureMap);
|
|
|
|
|
|
- String title = b1Feature.getOrDefault("cidtitle", "");
|
|
|
- this.handleE1AndE2Feature(e1Feature, e2Feature, title, cidFeatureMap);
|
|
|
+ this.handleB6ToB7Feature(cidFeature, cidFeatureMap);
|
|
|
|
|
|
- this.handleD3AndB1Feature(d3Feature, title, cidFeatureMap);
|
|
|
+ this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
|
|
|
- adRankItem.setFeatureMap(cidFeatureMap);
|
|
|
+ this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
|
|
|
- adRankItems.add(adRankItem);
|
|
|
+ this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
|
|
|
+ String title = b1Feature.getOrDefault("cidtitle", "");
|
|
|
+ this.handleE1AndE2Feature(e1Feature, e2Feature, title, cidFeatureMap);
|
|
|
+ this.handleD3AndB1Feature(d3Feature, title, cidFeatureMap);
|
|
|
+
|
|
|
+ // adRankItem.setFeatureMap(cidFeatureMap);
|
|
|
+
|
|
|
+ adRankItems.add(adRankItem);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ long time2 = System.currentTimeMillis();
|
|
|
// 分桶
|
|
|
this.readBucketFile();
|
|
|
userFeatureMap = this.featureBucket(userFeatureMap);
|
|
@@ -116,18 +208,22 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
}
|
|
|
|
|
|
// 打分排序
|
|
|
- List<AdRankItem> result = ScorerUtils.getScorerPipeline(ScorerUtils.XGBOOST_SCORE_CONF)
|
|
|
- .scoring(sceneFeatureMap, userFeatureMap, adRankItems);
|
|
|
+ List<AdRankItem> result = ScorerUtils.getScorerPipeline(ScorerUtils.XGBOOST_SCORE_CONF_20240909).scoring(sceneFeatureMap, userFeatureMap, adRankItems);
|
|
|
+ long time3 = System.currentTimeMillis();
|
|
|
+
|
|
|
+ double cpmCoefficient = weightParam.getOrDefault("cpmCoefficient", 0.9);
|
|
|
+
|
|
|
for (AdRankItem item : result) {
|
|
|
item.setScore(item.getLrScore() * item.getCpa());
|
|
|
item.getScoreMap().put("cpa", item.getCpa());
|
|
|
item.getScoreMap().put("cpm", item.getCpm());
|
|
|
+ item.getScoreMap().put("cpmCoefficient", cpmCoefficient);
|
|
|
item.getFeatureMap().putAll(userFeatureMap);
|
|
|
item.getFeatureMap().putAll(sceneFeatureMap);
|
|
|
|
|
|
// 没有转化回传的广告主,使用后台配置的CPM
|
|
|
if (noApiAdVerIds.contains(item.getAdVerId())) {
|
|
|
- item.setScore(item.getCpm() / 1000);
|
|
|
+ item.setScore(item.getCpm() * cpmCoefficient / 1000);
|
|
|
}
|
|
|
|
|
|
for (Map.Entry<String, Map<String, String>> entry : videoFeature.entrySet()) {
|
|
@@ -157,6 +253,10 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ long time4 = System.currentTimeMillis();
|
|
|
+ log.info("cost={}, feature1={}, feature2={}, getScorerPipeline={}, loop={}",
|
|
|
+ time4 - start, time1 - start, time2 - time1, time3 - time2, time4 - time3);
|
|
|
+
|
|
|
result.sort(ComparatorUtil.equalsRandomComparator());
|
|
|
|
|
|
return result;
|
|
@@ -191,14 +291,7 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
Map<String, String> b9Feature = c1Feature.getOrDefault("alg_cid_feature_weChatVersion_action", new HashMap<>());
|
|
|
|
|
|
List<String> timeList = Arrays.asList("1h", "2h", "3h", "6h", "12h", "1d", "3d", "7d", "yesterday", "today");
|
|
|
- List<Tuple2<Map<String, String>, String>> featureList = Arrays.asList(
|
|
|
- new Tuple2<>(b2Feature, "b2"),
|
|
|
- new Tuple2<>(b3Feature, "b3"),
|
|
|
- new Tuple2<>(b4Feature, "b4"),
|
|
|
- new Tuple2<>(b5Feature, "b5"),
|
|
|
- new Tuple2<>(b8Feature, "b8"),
|
|
|
- new Tuple2<>(b9Feature, "b9")
|
|
|
- );
|
|
|
+ List<Tuple2<Map<String, String>, String>> featureList = Arrays.asList(new Tuple2<>(b2Feature, "b2"), new Tuple2<>(b3Feature, "b3"), new Tuple2<>(b4Feature, "b4"), new Tuple2<>(b5Feature, "b5"), new Tuple2<>(b8Feature, "b8"), new Tuple2<>(b9Feature, "b9"));
|
|
|
for (Tuple2<Map<String, String>, String> tuple2 : featureList) {
|
|
|
Map<String, String> feature = tuple2.f1;
|
|
|
String prefix = tuple2.f2;
|
|
@@ -227,10 +320,7 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
Map<String, String> b7Feature = c1Feature.getOrDefault("alg_cid_feature_hour_action", new HashMap<>());
|
|
|
|
|
|
List<String> timeList = Arrays.asList("7d", "14d");
|
|
|
- List<Tuple2<Map<String, String>, String>> featureList = Arrays.asList(
|
|
|
- new Tuple2<>(b6Feature, "b6"),
|
|
|
- new Tuple2<>(b7Feature, "b7")
|
|
|
- );
|
|
|
+ List<Tuple2<Map<String, String>, String>> featureList = Arrays.asList(new Tuple2<>(b6Feature, "b6"), new Tuple2<>(b7Feature, "b7"));
|
|
|
for (Tuple2<Map<String, String>, String> tuple2 : featureList) {
|
|
|
Map<String, String> feature = tuple2.f1;
|
|
|
String prefix = tuple2.f2;
|
|
@@ -260,15 +350,13 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
List<TupleMapEntry<Tuple5>> midActionList = new ArrayList<>();
|
|
|
if (c1Feature.containsKey("action")) {
|
|
|
String action = c1Feature.get("action");
|
|
|
- midActionList = Arrays.stream(action.split(","))
|
|
|
- .map(r -> {
|
|
|
+ midActionList = Arrays.stream(action.split(",")).map(r -> {
|
|
|
String[] rList = r.split(":");
|
|
|
Tuple5 tuple5 = new Tuple5(rList[1], rList[2], rList[3], rList[4], rList[5]);
|
|
|
return new TupleMapEntry<>(rList[0], tuple5);
|
|
|
})
|
|
|
// TODO 倒排
|
|
|
- .sorted((a, b) -> Integer.compare(Integer.parseInt(b.value.f1), Integer.parseInt(a.value.f1)))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ .sorted((a, b) -> Integer.compare(Integer.parseInt(b.value.f1), Integer.parseInt(a.value.f1))).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
double viewAll = midActionList.size();
|
|
@@ -310,24 +398,15 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
featureMap.put("actionstatic_income", String.valueOf(midActionStatic.getOrDefault("actionstatic_income_" + cid, 0.0)));
|
|
|
}
|
|
|
if (midActionStatic.containsKey("actionstatic_view_" + cid) && midActionStatic.containsKey("actionstatic_click_" + cid)) {
|
|
|
- double ctr = NumUtil.div(
|
|
|
- midActionStatic.getOrDefault("actionstatic_click_" + cid, 0.0),
|
|
|
- midActionStatic.getOrDefault("actionstatic_view_" + cid, 0.0)
|
|
|
- );
|
|
|
+ double ctr = NumUtil.div(midActionStatic.getOrDefault("actionstatic_click_" + cid, 0.0), midActionStatic.getOrDefault("actionstatic_view_" + cid, 0.0));
|
|
|
featureMap.put("actionstatic_ctr", String.valueOf(ctr));
|
|
|
}
|
|
|
if (midActionStatic.containsKey("actionstatic_view_" + cid) && midActionStatic.containsKey("actionstatic_conver_" + cid)) {
|
|
|
- double ctcvr = NumUtil.div(
|
|
|
- midActionStatic.getOrDefault("actionstatic_conver_" + cid, 0.0),
|
|
|
- midActionStatic.getOrDefault("actionstatic_view_" + cid, 0.0)
|
|
|
- );
|
|
|
+ double ctcvr = NumUtil.div(midActionStatic.getOrDefault("actionstatic_conver_" + cid, 0.0), midActionStatic.getOrDefault("actionstatic_view_" + cid, 0.0));
|
|
|
featureMap.put("actionstatic_ctcvr", String.valueOf(ctcvr));
|
|
|
}
|
|
|
if (midActionStatic.containsKey("actionstatic_conver_" + cid) && midActionStatic.containsKey("actionstatic_click_" + cid)) {
|
|
|
- double cvr = NumUtil.div(
|
|
|
- midActionStatic.getOrDefault("actionstatic_conver_" + cid, 0.0),
|
|
|
- midActionStatic.getOrDefault("actionstatic_click_" + cid, 0.0)
|
|
|
- );
|
|
|
+ double cvr = NumUtil.div(midActionStatic.getOrDefault("actionstatic_conver_" + cid, 0.0), midActionStatic.getOrDefault("actionstatic_click_" + cid, 0.0));
|
|
|
featureMap.put("actionstatic_cvr", String.valueOf(cvr));
|
|
|
}
|
|
|
}
|
|
@@ -382,10 +461,7 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<Tuple2<Map<String, String>, String>> tuple2List = Arrays.asList(
|
|
|
- new Tuple2<>(e1Feature, "e1"),
|
|
|
- new Tuple2<>(e2Feature, "e2")
|
|
|
- );
|
|
|
+ List<Tuple2<Map<String, String>, String>> tuple2List = Arrays.asList(new Tuple2<>(e1Feature, "e1"), new Tuple2<>(e2Feature, "e2"));
|
|
|
|
|
|
List<String> tagsFieldList = Arrays.asList("tags_3d", "tags_7d", "tags_14d");
|
|
|
for (Tuple2<Map<String, String>, String> tuple2 : tuple2List) {
|
|
@@ -457,9 +533,7 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
for (Map.Entry<String, String> entry : d2Feature.entrySet()) {
|
|
|
String key = entry.getKey();
|
|
|
String value = entry.getValue();
|
|
|
- Map<String, Double> valueMap = Arrays.stream(value.split(","))
|
|
|
- .map(r -> r.split(":"))
|
|
|
- .collect(Collectors.toMap(rList -> rList[0], rList -> Double.parseDouble(rList[2])));
|
|
|
+ Map<String, Double> valueMap = Arrays.stream(value.split(",")).map(r -> r.split(":")).collect(Collectors.toMap(rList -> rList[0], rList -> Double.parseDouble(rList[2])));
|
|
|
vidRankMaps.put(key, valueMap);
|
|
|
}
|
|
|
return vidRankMaps;
|
|
@@ -477,7 +551,7 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
return;
|
|
|
}
|
|
|
synchronized (this) {
|
|
|
- InputStream resourceStream = RankService680.class.getClassLoader().getResourceAsStream("20240718_ad_bucket_688.txt");
|
|
|
+ InputStream resourceStream = RankService687.class.getClassLoader().getResourceAsStream("20240718_ad_bucket_688.txt");
|
|
|
if (resourceStream != null) {
|
|
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceStream))) {
|
|
|
Map<String, double[]> bucketsMap = new HashMap<>();
|
|
@@ -492,9 +566,7 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
String key = rList[0];
|
|
|
double value1 = Double.parseDouble(rList[1]);
|
|
|
bucketsLen.put(key, value1);
|
|
|
- double[] value2 = Arrays.stream(rList[2].split(","))
|
|
|
- .mapToDouble(Double::valueOf)
|
|
|
- .toArray();
|
|
|
+ double[] value2 = Arrays.stream(rList[2].split(",")).mapToDouble(Double::valueOf).toArray();
|
|
|
bucketsMap.put(key, value2);
|
|
|
}
|
|
|
}
|
|
@@ -511,7 +583,7 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
}
|
|
|
|
|
|
private Map<String, String> featureBucket(Map<String, String> featureMap) {
|
|
|
- Map<String, String> newFeatureMap = new HashMap<>(featureMap.size());
|
|
|
+ Map<String, String> newFeatureMap = new ConcurrentHashMap<>(featureMap.size());
|
|
|
for (Map.Entry<String, String> entry : featureMap.entrySet()) {
|
|
|
String name = entry.getKey();
|
|
|
double score = Double.parseDouble(entry.getValue());
|
|
@@ -531,41 +603,4 @@ public class RankService680 extends RankStrategyXGBBasic {
|
|
|
return newFeatureMap;
|
|
|
}
|
|
|
|
|
|
- // public static class Tuple5 {
|
|
|
- // public String f1;
|
|
|
- // public String f2;
|
|
|
- // public String f3;
|
|
|
- // public String f4;
|
|
|
- // public String f5;
|
|
|
- //
|
|
|
- // public Tuple5(String f1, String f2, String f3, String f4, String f5) {
|
|
|
- // this.f1 = f1;
|
|
|
- // this.f2 = f2;
|
|
|
- // this.f3 = f3;
|
|
|
- // this.f4 = f4;
|
|
|
- // this.f5 = f5;
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // public static class TupleMapEntry<T> {
|
|
|
- // public String key;
|
|
|
- // public T value;
|
|
|
- //
|
|
|
- // public TupleMapEntry(String key, T value) {
|
|
|
- // this.key = key;
|
|
|
- // this.value = value;
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // public static class Tuple2<F1, F2> {
|
|
|
- // public F1 f1;
|
|
|
- //
|
|
|
- // public F2 f2;
|
|
|
- //
|
|
|
- // public Tuple2(F1 first, F2 name) {
|
|
|
- // this.f1 = first;
|
|
|
- // this.f2 = name;
|
|
|
- // }
|
|
|
- //
|
|
|
- // }
|
|
|
}
|