|
@@ -250,8 +250,8 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
long time2 = System.currentTimeMillis();
|
|
long time2 = System.currentTimeMillis();
|
|
|
- // feature3
|
|
|
|
|
- CountDownLatch cdl2 = new CountDownLatch(adRankItems.size() * 2);
|
|
|
|
|
|
|
+ // feature3 - 优化:合并两个任务为一个,减少线程调度开销
|
|
|
|
|
+ CountDownLatch cdl2 = new CountDownLatch(adRankItems.size());
|
|
|
for (AdRankItem item : adRankItems) {
|
|
for (AdRankItem item : adRankItems) {
|
|
|
String cidStr = String.valueOf(item.getAdId());
|
|
String cidStr = String.valueOf(item.getAdId());
|
|
|
Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
|
|
Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
|
|
@@ -260,12 +260,6 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
ThreadPoolFactory.defaultPool().submit(() -> {
|
|
ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
try {
|
|
try {
|
|
|
this.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap(), scoreParam);
|
|
this.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap(), scoreParam);
|
|
|
- } finally {
|
|
|
|
|
- cdl2.countDown();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
|
|
- try {
|
|
|
|
|
this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap(), scoreParam);
|
|
this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap(), scoreParam);
|
|
|
} finally {
|
|
} finally {
|
|
|
cdl2.countDown();
|
|
cdl2.countDown();
|
|
@@ -741,17 +735,10 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
} else {
|
|
} else {
|
|
|
// 优化:使用带缓存的 Word2Vec 相似度 (如果需要可进一步优化 word2vec)
|
|
// 优化:使用带缓存的 Word2Vec 相似度 (如果需要可进一步优化 word2vec)
|
|
|
// 这里暂时只优化 conceptSimilarity
|
|
// 这里暂时只优化 conceptSimilarity
|
|
|
- doubles = ExtractorUtils.funcC34567ForTags(tags, title);
|
|
|
|
|
if (optimizeSwitch) {
|
|
if (optimizeSwitch) {
|
|
|
- // 如果 funcC34567ForTags 内部也用了 conceptSimilarity,需要透传开关或使用 cached 版本
|
|
|
|
|
- // 由于 funcC34567ForTags 是静态方法,我们在方法内部判断?
|
|
|
|
|
- // 实际上 ExtractorUtils.funcC34567ForTags 内部调用了 Similarity.conceptSimilarity
|
|
|
|
|
- // 我们应该修改 ExtractorUtils 或者在这里替换实现
|
|
|
|
|
- // 简单起见,我们复制 funcC34567ForTags 的逻辑到这里并使用 cachedConceptSimilarity
|
|
|
|
|
- // 或者修改 ExtractorUtils.funcC34567ForTags 让他支持缓存?
|
|
|
|
|
- // 最好的办法是修改 ExtractorUtils.funcC34567ForTags
|
|
|
|
|
- // 但为了稳妥,我们调用新的 cached 方法
|
|
|
|
|
doubles = funcC34567ForTagsCached(tags, title);
|
|
doubles = funcC34567ForTagsCached(tags, title);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ doubles = ExtractorUtils.funcC34567ForTags(tags, title);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -915,7 +902,7 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Map<String, String> featureBucket(Map<String, String> featureMap) {
|
|
private Map<String, String> featureBucket(Map<String, String> featureMap) {
|
|
|
- Map<String, String> newFeatureMap = new ConcurrentHashMap<>(featureMap.size());
|
|
|
|
|
|
|
+ Map<String, String> newFeatureMap = new HashMap<>(featureMap.size());
|
|
|
for (Map.Entry<String, String> entry : featureMap.entrySet()) {
|
|
for (Map.Entry<String, String> entry : featureMap.entrySet()) {
|
|
|
try {
|
|
try {
|
|
|
String name = entry.getKey();
|
|
String name = entry.getKey();
|