Showing
11 changed files
with
429 additions
and
58 deletions
@@ -113,7 +113,10 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us | @@ -113,7 +113,10 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us | ||
113 | //5、处理基于RNN向量生成的品类品牌的召回 | 113 | //5、处理基于RNN向量生成的品类品牌的召回 |
114 | CompletableFuture<List<RecallRequestResponse>> vectorRnnSortBrandCompletableFuture = this.doRecallVectorRnnSortBrand(userRecallRequest, userPersonalFactor); | 114 | CompletableFuture<List<RecallRequestResponse>> vectorRnnSortBrandCompletableFuture = this.doRecallVectorRnnSortBrand(userRecallRequest, userPersonalFactor); |
115 | 115 | ||
116 | - //6、构造最终返回结果投入额 | 116 | + //6、处理基于RNN向量生成的品类品牌的召回 |
117 | + CompletableFuture<List<RecallRequestResponse>> configSortBrandCompletableFuture = this.doRecallConfigSortBrand(userRecallRequest, userPersonalFactor); | ||
118 | + | ||
119 | + //7、构造最终返回结果投入额 | ||
117 | List<RecallRequestResponse> batchRequestResults = new ArrayList<>(); | 120 | List<RecallRequestResponse> batchRequestResults = new ArrayList<>(); |
118 | 121 | ||
119 | batchRequestResults.addAll(this.getResultFromCompletableFuture(sknListCompletableFuture));//按skn召回放在第一个,不然merger的时候可能会无序 | 122 | batchRequestResults.addAll(this.getResultFromCompletableFuture(sknListCompletableFuture));//按skn召回放在第一个,不然merger的时候可能会无序 |
@@ -121,6 +124,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us | @@ -121,6 +124,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us | ||
121 | batchRequestResults.addAll(this.getResultFromCompletableFuture(realTimeSortBrandCompletableFuture)); | 124 | batchRequestResults.addAll(this.getResultFromCompletableFuture(realTimeSortBrandCompletableFuture)); |
122 | batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorW2vSortBrandCompletableFuture)); | 125 | batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorW2vSortBrandCompletableFuture)); |
123 | batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorRnnSortBrandCompletableFuture)); | 126 | batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorRnnSortBrandCompletableFuture)); |
127 | + batchRequestResults.addAll(this.getResultFromCompletableFuture(configSortBrandCompletableFuture)); | ||
124 | 128 | ||
125 | //9、日志打印 | 129 | //9、日志打印 |
126 | if (userRecallRequest.openDetailLog()) { | 130 | if (userRecallRequest.openDetailLog()) { |
@@ -207,7 +211,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us | @@ -207,7 +211,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us | ||
207 | long begin = System.currentTimeMillis(); | 211 | long begin = System.currentTimeMillis(); |
208 | List<RecallRequest> vectorRnnSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest, userPersonalFactor.getVectorRnnSortBrandList(), SortBrandType.VEC_RNN_SORT_BRAND); | 212 | List<RecallRequest> vectorRnnSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest, userPersonalFactor.getVectorRnnSortBrandList(), SortBrandType.VEC_RNN_SORT_BRAND); |
209 | List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vectorRnnSortBrandRequests); | 213 | List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vectorRnnSortBrandRequests); |
210 | - RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.5]-doRecallVectorRnnSortBrand,requestCount is [{}], cost is [{}]", vectorRnnSortBrandRequests.size(), System.currentTimeMillis() - begin); | 214 | + RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.4]-doRecallVectorRnnSortBrand,requestCount is [{}], cost is [{}]", vectorRnnSortBrandRequests.size(), System.currentTimeMillis() - begin); |
211 | return vecSortBrandRequestsResponses; | 215 | return vecSortBrandRequestsResponses; |
212 | }, recallExecutorService); | 216 | }, recallExecutorService); |
213 | } | 217 | } |
@@ -224,9 +228,26 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us | @@ -224,9 +228,26 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us | ||
224 | long begin = System.currentTimeMillis(); | 228 | long begin = System.currentTimeMillis(); |
225 | List<RecallRequest> vectorW2vSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest, userPersonalFactor.getVectorW2vSortBrandList(), SortBrandType.VEC_W2V_SORT_BRAND); | 229 | List<RecallRequest> vectorW2vSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest, userPersonalFactor.getVectorW2vSortBrandList(), SortBrandType.VEC_W2V_SORT_BRAND); |
226 | List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vectorW2vSortBrandRequests); | 230 | List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vectorW2vSortBrandRequests); |
227 | - RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.6]-doRecallVectorW2vSortBrand,requestCount is [{}], cost is [{}]", vectorW2vSortBrandRequests.size(), System.currentTimeMillis() - begin); | 231 | + RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.5]-doRecallVectorW2vSortBrand,requestCount is [{}], cost is [{}]", vectorW2vSortBrandRequests.size(), System.currentTimeMillis() - begin); |
228 | return vecSortBrandRequestsResponses; | 232 | return vecSortBrandRequestsResponses; |
229 | }, recallExecutorService); | 233 | }, recallExecutorService); |
230 | } | 234 | } |
231 | 235 | ||
236 | + /** | ||
237 | + * 执行配置的【品牌+品类】的召回 | ||
238 | + * | ||
239 | + * @param userRecallRequest | ||
240 | + * @param userPersonalFactor | ||
241 | + * @return | ||
242 | + */ | ||
243 | + private CompletableFuture<List<RecallRequestResponse>> doRecallConfigSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) { | ||
244 | + return CompletableFuture.supplyAsync(() -> { | ||
245 | + long begin = System.currentTimeMillis(); | ||
246 | + List<RecallRequest> configSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest, userPersonalFactor.getConfigSortBrandList(), SortBrandType.CONFIG_SORT_BRAND); | ||
247 | + List<RecallRequestResponse> configBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(configSortBrandRequests); | ||
248 | + RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.6]-doRecallConfigSortBrand,requestCount is [{}], cost is [{}]", configSortBrandRequests.size(), System.currentTimeMillis() - begin); | ||
249 | + return configBrandRequestsResponses; | ||
250 | + }, recallExecutorService); | ||
251 | + } | ||
252 | + | ||
232 | } | 253 | } |
@@ -3,6 +3,7 @@ package com.yoho.search.recall.beans.persional; | @@ -3,6 +3,7 @@ package com.yoho.search.recall.beans.persional; | ||
3 | import com.yoho.search.core.personalized.models.SortBrand; | 3 | import com.yoho.search.core.personalized.models.SortBrand; |
4 | import com.yoho.search.core.personalized.models.SortPriceAreas; | 4 | import com.yoho.search.core.personalized.models.SortPriceAreas; |
5 | import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; | 5 | import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; |
6 | +import com.yoho.search.recall.beans.strategy.SortBrandType; | ||
6 | import com.yoho.search.recall.beans.vector.SortBrandVectorComponent; | 7 | import com.yoho.search.recall.beans.vector.SortBrandVectorComponent; |
7 | import com.yoho.search.recall.config.RecallConfigService; | 8 | import com.yoho.search.recall.config.RecallConfigService; |
8 | import com.yoho.search.recall.models.personal.PagePersonalFactor; | 9 | import com.yoho.search.recall.models.personal.PagePersonalFactor; |
@@ -93,28 +94,31 @@ public class QueryUserPersionalFactorBean { | @@ -93,28 +94,31 @@ public class QueryUserPersionalFactorBean { | ||
93 | pageSortBrandKeys.add(pageSortBrand.key()); | 94 | pageSortBrandKeys.add(pageSortBrand.key()); |
94 | } | 95 | } |
95 | //4、构造实时【品类+品牌】 | 96 | //4、构造实时【品类+品牌】 |
96 | - int recSortBrandCount = recallConfigService.getRecSortBrandCount(pageId); | 97 | + int recSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.REC_SORT_BRAND, 12); |
97 | List<SortBrand> realTimeSortBrandList = this.getSortBrandListWithSort(pageSortBrandKeys, filterSortBrandKeys, userFactor.getRealTimeSortBrandList(), recSortBrandCount); | 98 | List<SortBrand> realTimeSortBrandList = this.getSortBrandListWithSort(pageSortBrandKeys, filterSortBrandKeys, userFactor.getRealTimeSortBrandList(), recSortBrandCount); |
98 | //realTimeSortBrandList = Arrays.asList(new SortBrand(63,28)); | 99 | //realTimeSortBrandList = Arrays.asList(new SortBrand(63,28)); |
99 | for (SortBrand existSortBrand : realTimeSortBrandList) { | 100 | for (SortBrand existSortBrand : realTimeSortBrandList) { |
100 | filterSortBrandKeys.add(existSortBrand.key()); | 101 | filterSortBrandKeys.add(existSortBrand.key()); |
101 | } | 102 | } |
102 | //5、构造基于RNN向量的【品牌+品牌】,去除实时的品类和品牌 | 103 | //5、构造基于RNN向量的【品牌+品牌】,去除实时的品类和品牌 |
103 | - int vectorRNNSortBrandCount = recallConfigService.getVectorRNNSortBrandCount(pageId); | 104 | + int vectorRNNSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.VEC_RNN_SORT_BRAND, 0); |
104 | List<SortBrand> vectorRnnSortBrandList = sortBrandVectorComponent.queryVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVector(), userFactor.getSortBrandVector(), true, vectorRNNSortBrandCount); | 105 | List<SortBrand> vectorRnnSortBrandList = sortBrandVectorComponent.queryVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVector(), userFactor.getSortBrandVector(), true, vectorRNNSortBrandCount); |
105 | //vectorRnnSortBrandList = Arrays.asList(new SortBrand(59,199)); | 106 | //vectorRnnSortBrandList = Arrays.asList(new SortBrand(59,199)); |
106 | for (SortBrand existSortBrand : vectorRnnSortBrandList) { | 107 | for (SortBrand existSortBrand : vectorRnnSortBrandList) { |
107 | filterSortBrandKeys.add(existSortBrand.key()); | 108 | filterSortBrandKeys.add(existSortBrand.key()); |
108 | } | 109 | } |
109 | //6、构造基于W2V向量的【品牌+品牌】,去除实时的品类和品牌 | 110 | //6、构造基于W2V向量的【品牌+品牌】,去除实时的品类和品牌 |
110 | - int vecW2vSortBrandCount = recallConfigService.getVectorW2vSortBrandCount(pageId); | 111 | + int vecW2vSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.VEC_W2V_SORT_BRAND, 12); |
111 | List<SortBrand> vectorW2vSortBrandList = sortBrandVectorComponent.queryVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVectorW2v(), userFactor.getSortBrandVectorW2v(), false, vecW2vSortBrandCount); | 112 | List<SortBrand> vectorW2vSortBrandList = sortBrandVectorComponent.queryVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVectorW2v(), userFactor.getSortBrandVectorW2v(), false, vecW2vSortBrandCount); |
112 | //vectorW2vSortBrandList = Arrays.asList(new SortBrand(266,105)); | 113 | //vectorW2vSortBrandList = Arrays.asList(new SortBrand(266,105)); |
113 | for (SortBrand existSortBrand : vectorW2vSortBrandList) { | 114 | for (SortBrand existSortBrand : vectorW2vSortBrandList) { |
114 | filterSortBrandKeys.add(existSortBrand.key()); | 115 | filterSortBrandKeys.add(existSortBrand.key()); |
115 | } | 116 | } |
116 | - //7、返回最终结果 | ||
117 | - return new UserPersonalFactor(recommendSknList, realTimeSimilarSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList); | 117 | + //7、构造基于配置的【品牌+品牌】,去除其他类型的品类和品牌 |
118 | + int configSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.CONFIG_SORT_BRAND, 0); | ||
119 | + List<SortBrand> configSortBrandList = recallConfigService.queryConfigSortBrandList(pageFactor, filterSortBrandKeys, configSortBrandCount); | ||
120 | + //8、返回最终结果 | ||
121 | + return new UserPersonalFactor(recommendSknList, realTimeSimilarSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList, configSortBrandList); | ||
118 | } | 122 | } |
119 | 123 | ||
120 | private List<SortBrand> getSortBrandListWithSort(Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, List<SortBrand> userSortBrands, int maxCount) { | 124 | private List<SortBrand> getSortBrandListWithSort(Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, List<SortBrand> userSortBrands, int maxCount) { |
@@ -6,5 +6,6 @@ package com.yoho.search.recall.beans.strategy; | @@ -6,5 +6,6 @@ package com.yoho.search.recall.beans.strategy; | ||
6 | public enum SortBrandType { | 6 | public enum SortBrandType { |
7 | REC_SORT_BRAND, | 7 | REC_SORT_BRAND, |
8 | VEC_RNN_SORT_BRAND, | 8 | VEC_RNN_SORT_BRAND, |
9 | - VEC_W2V_SORT_BRAND | 9 | + VEC_W2V_SORT_BRAND, |
10 | + CONFIG_SORT_BRAND | ||
10 | } | 11 | } |
@@ -30,8 +30,15 @@ public enum StrategyEnum { | @@ -30,8 +30,15 @@ public enum StrategyEnum { | ||
30 | VEC_W2V_S_B_HEAT_VALUE(65),//向量预测的品牌+品类的人气值 | 30 | VEC_W2V_S_B_HEAT_VALUE(65),//向量预测的品牌+品类的人气值 |
31 | VEC_W2V_S_B_RANDOM(64),//向量预测的品牌+品类的随机 | 31 | VEC_W2V_S_B_RANDOM(64),//向量预测的品牌+品类的随机 |
32 | 32 | ||
33 | - COMMON_CTR_VALUE(2),//页面兜底召回-包含个性化【随机200取40】 | ||
34 | - COMMON_HEAT_VALUE(1),//页面兜底召回-包含个性化【随机200取40】 | 33 | + CONFIG_S_B_NEW(59),//配置的品牌+品类的新品 |
34 | + CONFIG_S_B_PROMOTION(58),//配置的品牌+品类的新开促销 | ||
35 | + CONFIG_S_B_REDUCE_PRICE(57),//配置的品牌+品类的最新降价 | ||
36 | + CONFIG_S_B_CTR_VALUE(56),//配置的品牌+品类的转化率 | ||
37 | + CONFIG_S_B_HEAT_VALUE(55),//配置的的品牌+品类的人气值 | ||
38 | + CONFIG_S_B_RANDOM(54),//配置的的品牌+品类的随机 | ||
39 | + | ||
40 | + COMMON_CTR_VALUE(2),//页面兜底召回 | ||
41 | + COMMON_HEAT_VALUE(1),//页面兜底召回 | ||
35 | 42 | ||
36 | DEFAULT_HEAT_VALUE(-1),//第四部分做A/B测试 | 43 | DEFAULT_HEAT_VALUE(-1),//第四部分做A/B测试 |
37 | DEFAULT_CTR_VALUE(-2);//第四部分做A/B测试 | 44 | DEFAULT_CTR_VALUE(-2);//第四部分做A/B测试 |
@@ -44,6 +44,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | @@ -44,6 +44,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | ||
44 | return StrategyEnum.VEC_RNN_S_B_HEAT_VALUE; | 44 | return StrategyEnum.VEC_RNN_S_B_HEAT_VALUE; |
45 | case VEC_W2V_SORT_BRAND: | 45 | case VEC_W2V_SORT_BRAND: |
46 | return StrategyEnum.VEC_W2V_S_B_HEAT_VALUE; | 46 | return StrategyEnum.VEC_W2V_S_B_HEAT_VALUE; |
47 | + case CONFIG_SORT_BRAND: | ||
48 | + return StrategyEnum.CONFIG_S_B_HEAT_VALUE; | ||
47 | default: | 49 | default: |
48 | return null; | 50 | return null; |
49 | } | 51 | } |
@@ -57,6 +59,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | @@ -57,6 +59,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | ||
57 | return StrategyEnum.VEC_RNN_S_B_CTR_VALUE; | 59 | return StrategyEnum.VEC_RNN_S_B_CTR_VALUE; |
58 | case VEC_W2V_SORT_BRAND: | 60 | case VEC_W2V_SORT_BRAND: |
59 | return StrategyEnum.VEC_W2V_S_B_CTR_VALUE; | 61 | return StrategyEnum.VEC_W2V_S_B_CTR_VALUE; |
62 | + case CONFIG_SORT_BRAND: | ||
63 | + return StrategyEnum.CONFIG_S_B_CTR_VALUE; | ||
60 | default: | 64 | default: |
61 | return null; | 65 | return null; |
62 | } | 66 | } |
@@ -70,6 +74,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | @@ -70,6 +74,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | ||
70 | return StrategyEnum.VEC_RNN_S_B_NEW; | 74 | return StrategyEnum.VEC_RNN_S_B_NEW; |
71 | case VEC_W2V_SORT_BRAND: | 75 | case VEC_W2V_SORT_BRAND: |
72 | return StrategyEnum.VEC_W2V_S_B_NEW; | 76 | return StrategyEnum.VEC_W2V_S_B_NEW; |
77 | + case CONFIG_SORT_BRAND: | ||
78 | + return StrategyEnum.CONFIG_S_B_NEW; | ||
73 | default: | 79 | default: |
74 | return null; | 80 | return null; |
75 | } | 81 | } |
@@ -83,6 +89,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | @@ -83,6 +89,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | ||
83 | return StrategyEnum.VEC_RNN_S_B_PROMOTION; | 89 | return StrategyEnum.VEC_RNN_S_B_PROMOTION; |
84 | case VEC_W2V_SORT_BRAND: | 90 | case VEC_W2V_SORT_BRAND: |
85 | return StrategyEnum.VEC_W2V_S_B_PROMOTION; | 91 | return StrategyEnum.VEC_W2V_S_B_PROMOTION; |
92 | + case CONFIG_SORT_BRAND: | ||
93 | + return StrategyEnum.CONFIG_S_B_PROMOTION; | ||
86 | default: | 94 | default: |
87 | return null; | 95 | return null; |
88 | } | 96 | } |
@@ -97,6 +105,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | @@ -97,6 +105,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | ||
97 | return StrategyEnum.VEC_RNN_S_B_REDUCE_PRICE; | 105 | return StrategyEnum.VEC_RNN_S_B_REDUCE_PRICE; |
98 | case VEC_W2V_SORT_BRAND: | 106 | case VEC_W2V_SORT_BRAND: |
99 | return StrategyEnum.VEC_W2V_S_B_REDUCE_PRICE; | 107 | return StrategyEnum.VEC_W2V_S_B_REDUCE_PRICE; |
108 | + case CONFIG_SORT_BRAND: | ||
109 | + return StrategyEnum.CONFIG_S_B_REDUCE_PRICE; | ||
100 | default: | 110 | default: |
101 | return null; | 111 | return null; |
102 | } | 112 | } |
@@ -110,6 +120,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | @@ -110,6 +120,8 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { | ||
110 | return StrategyEnum.VEC_RNN_S_B_RANDOM; | 120 | return StrategyEnum.VEC_RNN_S_B_RANDOM; |
111 | case VEC_W2V_SORT_BRAND: | 121 | case VEC_W2V_SORT_BRAND: |
112 | return StrategyEnum.VEC_W2V_S_B_RANDOM; | 122 | return StrategyEnum.VEC_W2V_S_B_RANDOM; |
123 | + case CONFIG_SORT_BRAND: | ||
124 | + return StrategyEnum.CONFIG_S_B_PROMOTION; | ||
113 | default: | 125 | default: |
114 | return null; | 126 | return null; |
115 | } | 127 | } |
1 | +package com.yoho.search.recall.config; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.yoho.search.dal.model.CsRecallConfigCommon; | ||
5 | +import com.yoho.search.service.base.index.CsRecallConfigCommonIndexBaseService; | ||
6 | +import org.apache.commons.lang.StringUtils; | ||
7 | +import org.slf4j.Logger; | ||
8 | +import org.slf4j.LoggerFactory; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.stereotype.Component; | ||
11 | + | ||
12 | +import javax.annotation.PostConstruct; | ||
13 | +import java.util.HashMap; | ||
14 | +import java.util.List; | ||
15 | +import java.util.Map; | ||
16 | +import java.util.concurrent.Executors; | ||
17 | +import java.util.concurrent.ScheduledExecutorService; | ||
18 | +import java.util.concurrent.TimeUnit; | ||
19 | + | ||
20 | +@Component | ||
21 | +class RecallConfigCommonService { | ||
22 | + | ||
23 | + private static final Logger logger = LoggerFactory.getLogger(RecallConfigCommonService.class); | ||
24 | + | ||
25 | + @Autowired | ||
26 | + private CsRecallConfigCommonIndexBaseService csRecallConfigCommonIndexBaseService; | ||
27 | + | ||
28 | + private ScheduledExecutorService schedule = Executors.newSingleThreadScheduledExecutor(); | ||
29 | + | ||
30 | + private Map<String, Map<Integer, RecallSizeInterval>> typePageConfigCache = new HashMap<>(); | ||
31 | + | ||
32 | + @PostConstruct | ||
33 | + void init() { | ||
34 | + schedule.scheduleAtFixedRate(() -> loadConfig(), 0, 1, TimeUnit.MINUTES); | ||
35 | + } | ||
36 | + | ||
37 | + private void loadConfig() { | ||
38 | + try { | ||
39 | + List<CsRecallConfigCommon> configList = csRecallConfigCommonIndexBaseService.queryAll(); | ||
40 | + Map<String, Map<Integer, RecallSizeInterval>> temp = new HashMap<>(); | ||
41 | + for (CsRecallConfigCommon csRecallConfigCommon : configList) { | ||
42 | + Map<Integer, RecallSizeInterval> pageConfigs = temp.get(csRecallConfigCommon.getConfigType()); | ||
43 | + if (pageConfigs == null) { | ||
44 | + pageConfigs = new HashMap<>(); | ||
45 | + temp.put(csRecallConfigCommon.getConfigType(), pageConfigs); | ||
46 | + } | ||
47 | + int size = csRecallConfigCommon.getSize(); | ||
48 | + int interval = csRecallConfigCommon.getInterval(); | ||
49 | + pageConfigs.put(csRecallConfigCommon.getConfigPage(), new RecallSizeInterval(size, interval)); | ||
50 | + } | ||
51 | + typePageConfigCache = temp; | ||
52 | + System.out.println(JSON.toJSONString(typePageConfigCache)); | ||
53 | + } catch (Exception e) { | ||
54 | + logger.error(e.getMessage(), e); | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + private RecallSizeInterval queryCommonConfig(String configKey, int configPage) { | ||
59 | + Map<Integer, RecallSizeInterval> pageConfigMap = typePageConfigCache.get(configKey); | ||
60 | + if (pageConfigMap == null) { | ||
61 | + return null; | ||
62 | + } | ||
63 | + RecallSizeInterval pageConfig = pageConfigMap.get(configPage); | ||
64 | + if (pageConfig == null) { | ||
65 | + pageConfig = pageConfigMap.get(RecallConfigConstants.DEFAULT_PAGE_ID); | ||
66 | + } | ||
67 | + if (pageConfigMap == null) { | ||
68 | + return null; | ||
69 | + } else { | ||
70 | + return pageConfig; | ||
71 | + } | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * 获取配置的大小 | ||
76 | + * | ||
77 | + * @param pageId | ||
78 | + * @param configKey | ||
79 | + * @param defaultSize | ||
80 | + * @return | ||
81 | + */ | ||
82 | + public int queryConfigSize(int pageId, String configKey, int defaultSize) { | ||
83 | + if (StringUtils.isBlank(configKey)) { | ||
84 | + return defaultSize; | ||
85 | + } | ||
86 | + RecallSizeInterval config = queryCommonConfig(configKey, pageId); | ||
87 | + return config == null ? defaultSize : config.getSize(); | ||
88 | + } | ||
89 | + | ||
90 | + /** | ||
91 | + * 获取配置的间隔 | ||
92 | + * | ||
93 | + * @param pageId | ||
94 | + * @param configKey | ||
95 | + * @param defaultInterval | ||
96 | + * @return | ||
97 | + */ | ||
98 | + public int queryConfigInterval(int pageId, String configKey, int defaultInterval) { | ||
99 | + if (StringUtils.isBlank(configKey)) { | ||
100 | + return defaultInterval; | ||
101 | + } | ||
102 | + RecallSizeInterval config = queryCommonConfig(configKey, pageId); | ||
103 | + return config == null ? defaultInterval : config.getInterval(); | ||
104 | + } | ||
105 | + | ||
106 | +} |
@@ -12,13 +12,12 @@ public class RecallConfigConstants { | @@ -12,13 +12,12 @@ public class RecallConfigConstants { | ||
12 | public static final String RT_SIM_SKN = "RT_SIM_SKN"; | 12 | public static final String RT_SIM_SKN = "RT_SIM_SKN"; |
13 | public static final String ADD_FLOW = "ADD_FLOW"; | 13 | public static final String ADD_FLOW = "ADD_FLOW"; |
14 | public static final String NEW_SHOP = "NEW_SHOP"; | 14 | public static final String NEW_SHOP = "NEW_SHOP"; |
15 | - public static final String REC_S_B_COUNT = "REC_S_B_COUNT"; | ||
16 | - public static final String VEC_RNN_S_B_COUNT = "VEC_RNN_S_B_COUNT"; | ||
17 | - public static final String VEC_W2V_S_B_COUNT = "VEC_W2V_S_B_COUNT"; | ||
18 | 15 | ||
19 | public static final String REC_SORT_BRAND = "REC_SORT_BRAND"; | 16 | public static final String REC_SORT_BRAND = "REC_SORT_BRAND"; |
20 | public static final String VEC_RNN_SORT_BRAND = "VEC_RNN_SORT_BRAND"; | 17 | public static final String VEC_RNN_SORT_BRAND = "VEC_RNN_SORT_BRAND"; |
21 | public static final String VEC_W2V_SORT_BRAND = "VEC_W2V_SORT_BRAND"; | 18 | public static final String VEC_W2V_SORT_BRAND = "VEC_W2V_SORT_BRAND"; |
19 | + public static final String CONFIG_SORT_BRAND = "CONFIG_SORT_BRAND"; | ||
20 | + | ||
22 | public static final String RECALL_SKN_COUNT_SORT = "SORT"; | 21 | public static final String RECALL_SKN_COUNT_SORT = "SORT"; |
23 | public static final String RECALL_SKN_COUNT_BRAND = "BRAND"; | 22 | public static final String RECALL_SKN_COUNT_BRAND = "BRAND"; |
24 | 23 |
1 | +package com.yoho.search.recall.config; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.yoho.search.core.personalized.models.SortBrand; | ||
5 | +import com.yoho.search.dal.model.CsRecallConfigProduct; | ||
6 | +import com.yoho.search.service.base.index.CsRecallConfigProductIndexBaseService; | ||
7 | +import org.slf4j.Logger; | ||
8 | +import org.slf4j.LoggerFactory; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.stereotype.Component; | ||
11 | + | ||
12 | +import javax.annotation.PostConstruct; | ||
13 | +import java.util.HashMap; | ||
14 | +import java.util.List; | ||
15 | +import java.util.Map; | ||
16 | +import java.util.concurrent.Executors; | ||
17 | +import java.util.concurrent.ScheduledExecutorService; | ||
18 | +import java.util.concurrent.TimeUnit; | ||
19 | + | ||
20 | +@Component | ||
21 | +class RecallConfigProductService { | ||
22 | + | ||
23 | + private static final Logger logger = LoggerFactory.getLogger(RecallConfigProductService.class); | ||
24 | + | ||
25 | + @Autowired | ||
26 | + private CsRecallConfigProductIndexBaseService csRecallConfigProductIndexBaseService; | ||
27 | + | ||
28 | + private Map<String, Map<Integer, RecallSknCount>> typePageConfigCache = new HashMap<>(); | ||
29 | + | ||
30 | + private ScheduledExecutorService schedule = Executors.newSingleThreadScheduledExecutor(); | ||
31 | + | ||
32 | + @PostConstruct | ||
33 | + void init() { | ||
34 | + schedule.scheduleAtFixedRate(() -> loadRecallSknCountConfig(), 0, 1, TimeUnit.MINUTES); | ||
35 | + } | ||
36 | + | ||
37 | + private void loadRecallSknCountConfig() { | ||
38 | + try { | ||
39 | + Map<String, Map<Integer, RecallSknCount>> tempTypePageConfigCache = new HashMap<>(); | ||
40 | + List<CsRecallConfigProduct> configList = csRecallConfigProductIndexBaseService.queryAll(); | ||
41 | + for (CsRecallConfigProduct productConfig : configList) { | ||
42 | + String configType = productConfig.getConfigType(); | ||
43 | + int configTypeId = productConfig.getConfigTypeId(); | ||
44 | + int pageId = productConfig.getConfigPage(); | ||
45 | + String configKey = this.buildConfiKey(configType,configTypeId); | ||
46 | + int configStatus = productConfig.getConfigStatus(); | ||
47 | + if(configStatus==1){ | ||
48 | + this.addElement(configKey,pageId,this.genProductCountConfig(productConfig),tempTypePageConfigCache); | ||
49 | + } | ||
50 | + } | ||
51 | + typePageConfigCache = tempTypePageConfigCache; | ||
52 | + System.out.println(JSON.toJSONString(typePageConfigCache)); | ||
53 | + } catch (Exception e) { | ||
54 | + logger.error(e.getMessage(), e); | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + private String buildConfiKey(String configType, int configTypeId) { | ||
59 | + if (configType.equalsIgnoreCase(RecallConfigConstants.RECALL_SKN_COUNT_SORT)) { | ||
60 | + return this.buildSortCacheKey(configTypeId); | ||
61 | + } else if (configType.equalsIgnoreCase(RecallConfigConstants.RECALL_SKN_COUNT_BRAND)) { | ||
62 | + return this.buildBrandCacheKey(configTypeId); | ||
63 | + } else { | ||
64 | + return this.buildSortBrandCacheKey(configType, new SortBrand()); | ||
65 | + } | ||
66 | + } | ||
67 | + | ||
68 | + private String buildSortCacheKey(int middleSortId) { | ||
69 | + return RecallConfigConstants.RECALL_SKN_COUNT_SORT + "_" + middleSortId; | ||
70 | + } | ||
71 | + | ||
72 | + private String buildBrandCacheKey(int brandId) { | ||
73 | + return RecallConfigConstants.RECALL_SKN_COUNT_BRAND + "_" + brandId; | ||
74 | + } | ||
75 | + | ||
76 | + private String buildSortBrandCacheKey(String sortBrandType, SortBrand sortBrand) { | ||
77 | + return sortBrandType + "_" + sortBrand.key(); | ||
78 | + } | ||
79 | + | ||
80 | + private void addElement(String configKey, int pageId, RecallSknCount recallSknCount, Map<String, Map<Integer, RecallSknCount>> map) { | ||
81 | + if (!map.containsKey(configKey)) { | ||
82 | + map.put(configKey, new HashMap<>()); | ||
83 | + } | ||
84 | + map.get(configKey).put(pageId, recallSknCount); | ||
85 | + } | ||
86 | + | ||
87 | + private RecallSknCount genProductCountConfig(CsRecallConfigProduct configProduct) { | ||
88 | + int newShelve = configProduct.getNewShelve(); | ||
89 | + int promotion = configProduct.getPromotion(); | ||
90 | + int reducePrice = configProduct.getReducePrice(); | ||
91 | + int ctrValue = configProduct.getCtrValue(); | ||
92 | + int heatValue = configProduct.getHeatValue(); | ||
93 | + int random = configProduct.getRandom(); | ||
94 | + return genProductCountConfig(newShelve, promotion, reducePrice, ctrValue, heatValue, random); | ||
95 | + } | ||
96 | + | ||
97 | + private RecallSknCount genProductCountConfig(int newShelve, int promotion, int reducePrice, int ctrValue, int heatValue, int random) { | ||
98 | + RecallSknCount recallSknCount = new RecallSknCount(); | ||
99 | + recallSknCount.setNewShelve(newShelve); | ||
100 | + recallSknCount.setPromotion(promotion); | ||
101 | + recallSknCount.setReducePrice(reducePrice); | ||
102 | + recallSknCount.setCtrValue(ctrValue); | ||
103 | + recallSknCount.setHeatValue(heatValue); | ||
104 | + recallSknCount.setRandom(random); | ||
105 | + return recallSknCount; | ||
106 | + } | ||
107 | + | ||
108 | + private RecallSknCount genProductCountConfigByCompare(RecallSknCount recallSknCount1, RecallSknCount recallSknCount2) { | ||
109 | + int newShelve = Math.min(recallSknCount1.getNewShelve(), recallSknCount2.getNewShelve()); | ||
110 | + int promotion = Math.min(recallSknCount1.getPromotion(), recallSknCount2.getPromotion()); | ||
111 | + int reducePrice = Math.min(recallSknCount1.getReducePrice(), recallSknCount2.getReducePrice()); | ||
112 | + int ctrValue = Math.min(recallSknCount1.getCtrValue(), recallSknCount2.getCtrValue()); | ||
113 | + int heatValue = Math.min(recallSknCount1.getHeatValue(), recallSknCount2.getHeatValue()); | ||
114 | + int random = Math.min(recallSknCount1.getHeatValue(), recallSknCount2.getHeatValue()); | ||
115 | + return genProductCountConfig(newShelve, promotion, reducePrice, ctrValue, heatValue, random); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * 按页面+品类+品牌获取商品的召回数量 | ||
120 | + * | ||
121 | + * @param pageId | ||
122 | + * @param sortBrand | ||
123 | + * @return | ||
124 | + */ | ||
125 | + public RecallSknCount queryRecallSknCount(int pageId, String sortBrandType, SortBrand sortBrand) { | ||
126 | + RecallSknCount sortConfig = this.queryConfigBySort(pageId, sortBrand.getMisort()); | ||
127 | + RecallSknCount brandConfig = this.queryConfigByBrand(pageId, sortBrand.getBrandId()); | ||
128 | + if (sortConfig != null && sortConfig != null) { | ||
129 | + return genProductCountConfigByCompare(sortConfig, brandConfig); | ||
130 | + } | ||
131 | + if (sortConfig != null) { | ||
132 | + return sortConfig; | ||
133 | + } | ||
134 | + if (brandConfig != null) { | ||
135 | + return brandConfig; | ||
136 | + } | ||
137 | + RecallSknCount pageConfig = this.queryConfigByPage(pageId, sortBrandType, sortBrand); | ||
138 | + if (pageConfig != null) { | ||
139 | + return pageConfig; | ||
140 | + } | ||
141 | + pageConfig = this.queryConfigByPage(pageId, sortBrandType, new SortBrand());//使用默认的值替代 | ||
142 | + if (pageConfig != null) { | ||
143 | + return pageConfig; | ||
144 | + } | ||
145 | + return genProductCountConfig(6, 3, 6, 6, 6, 0); | ||
146 | + } | ||
147 | + | ||
148 | + /** | ||
149 | + * 查询中分类在页面上的召回配置,没有则取pageId=0的数据 | ||
150 | + * @param pageId | ||
151 | + * @param middleSortId | ||
152 | + * @return | ||
153 | + */ | ||
154 | + private RecallSknCount queryConfigBySort(int pageId, int middleSortId) { | ||
155 | + String sortKey = this.buildSortCacheKey(middleSortId); | ||
156 | + return this.getRecallSknCount(sortKey, pageId); | ||
157 | + } | ||
158 | + | ||
159 | + /** | ||
160 | + * 查询品牌在页面上的召回配置,没有则取pageId=0的数据 | ||
161 | + * @param pageId | ||
162 | + * @param brandId | ||
163 | + * @return | ||
164 | + */ | ||
165 | + private RecallSknCount queryConfigByBrand(int pageId, int brandId) { | ||
166 | + String brandKey = this.buildBrandCacheKey(brandId); | ||
167 | + return this.getRecallSknCount(brandKey, pageId); | ||
168 | + } | ||
169 | + | ||
170 | + /** | ||
171 | + * 查询【品类*品牌】在页面上的召回配置,没有则取pageId=0的数据 | ||
172 | + * @param pageId | ||
173 | + * @param sortBrandType | ||
174 | + * @param sortBrand | ||
175 | + * @return | ||
176 | + */ | ||
177 | + private RecallSknCount queryConfigByPage(int pageId, String sortBrandType, SortBrand sortBrand) { | ||
178 | + String sortBrandKey = this.buildSortBrandCacheKey(sortBrandType, sortBrand); | ||
179 | + return this.getRecallSknCount(sortBrandKey, pageId); | ||
180 | + } | ||
181 | + | ||
182 | + private RecallSknCount getRecallSknCount(String key, int pageId) { | ||
183 | + Map<Integer, RecallSknCount> pageConfig = typePageConfigCache.get(key); | ||
184 | + if (pageConfig == null) { | ||
185 | + return null; | ||
186 | + } | ||
187 | + RecallSknCount sknCount = pageConfig.get(pageId); | ||
188 | + if (sknCount == null) { | ||
189 | + sknCount = pageConfig.get(RecallConfigConstants.DEFAULT_PAGE_ID); | ||
190 | + } | ||
191 | + return sknCount; | ||
192 | + } | ||
193 | + | ||
194 | +} |
1 | package com.yoho.search.recall.config; | 1 | package com.yoho.search.recall.config; |
2 | 2 | ||
3 | +import com.yoho.search.base.utils.CollectionUtils; | ||
3 | import com.yoho.search.core.personalized.models.SortBrand; | 4 | import com.yoho.search.core.personalized.models.SortBrand; |
4 | import com.yoho.search.recall.beans.strategy.SortBrandType; | 5 | import com.yoho.search.recall.beans.strategy.SortBrandType; |
5 | import com.yoho.search.recall.beans.strategy.StrategyEnum; | 6 | import com.yoho.search.recall.beans.strategy.StrategyEnum; |
7 | +import com.yoho.search.recall.models.personal.PagePersonalFactor; | ||
6 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
7 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
8 | -import sun.applet.Main; | 10 | + |
11 | +import java.util.ArrayList; | ||
12 | +import java.util.Collections; | ||
13 | +import java.util.List; | ||
14 | +import java.util.Set; | ||
9 | 15 | ||
10 | @Service | 16 | @Service |
11 | public class RecallConfigService { | 17 | public class RecallConfigService { |
12 | @Autowired | 18 | @Autowired |
13 | - private RecallConfigServiceProduct recallConfigServiceProduct; | 19 | + private RecallConfigProductService recallConfigProductService; |
20 | + @Autowired | ||
21 | + private RecallConfigCommonService recallConfigCommonService; | ||
14 | @Autowired | 22 | @Autowired |
15 | - private RecallConfigServiceCommon recallConfigServiceCommon; | 23 | + private RecallConfigSortBrandService recallConfigSortBrandService; |
16 | 24 | ||
17 | private static int legallValue(int value, int min, int max) { | 25 | private static int legallValue(int value, int min, int max) { |
18 | value = Math.min(value, max); | 26 | value = Math.min(value, max); |
@@ -21,39 +29,6 @@ public class RecallConfigService { | @@ -21,39 +29,6 @@ public class RecallConfigService { | ||
21 | } | 29 | } |
22 | 30 | ||
23 | /** | 31 | /** |
24 | - * 获取推荐的品类品牌的配置 | ||
25 | - * | ||
26 | - * @param pageId | ||
27 | - * @return | ||
28 | - */ | ||
29 | - public int getRecSortBrandCount(int pageId) { | ||
30 | - int value = recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.REC_S_B_COUNT, 12); | ||
31 | - return this.legallValue(value, 0, 30); | ||
32 | - } | ||
33 | - | ||
34 | - /** | ||
35 | - * 获取W2v预测的品类品牌的数量 | ||
36 | - * | ||
37 | - * @param pageId | ||
38 | - * @return | ||
39 | - */ | ||
40 | - public int getVectorW2vSortBrandCount(int pageId) { | ||
41 | - int value = recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.VEC_W2V_S_B_COUNT, 12); | ||
42 | - return this.legallValue(value, 0, 30); | ||
43 | - } | ||
44 | - | ||
45 | - /** | ||
46 | - * 获取RNN预测的品类品牌的数量 | ||
47 | - * | ||
48 | - * @param pageId | ||
49 | - * @return | ||
50 | - */ | ||
51 | - public int getVectorRNNSortBrandCount(int pageId) { | ||
52 | - int value = recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.VEC_RNN_S_B_COUNT, 0); | ||
53 | - return this.legallValue(value, 0, 30); | ||
54 | - } | ||
55 | - | ||
56 | - /** | ||
57 | * 获取某些策略的召回数量 | 32 | * 获取某些策略的召回数量 |
58 | * | 33 | * |
59 | * @param pageId | 34 | * @param pageId |
@@ -62,7 +37,7 @@ public class RecallConfigService { | @@ -62,7 +37,7 @@ public class RecallConfigService { | ||
62 | */ | 37 | */ |
63 | public int queryStrategyConfigSize(int pageId, StrategyEnum strategyEnum) { | 38 | public int queryStrategyConfigSize(int pageId, StrategyEnum strategyEnum) { |
64 | String configKey = getStrategyConfigKey(strategyEnum); | 39 | String configKey = getStrategyConfigKey(strategyEnum); |
65 | - int value = recallConfigServiceCommon.queryConfigSize(pageId, configKey, 0); | 40 | + int value = recallConfigCommonService.queryConfigSize(pageId, configKey, 0); |
66 | return this.legallValue(value, 0, 100); | 41 | return this.legallValue(value, 0, 100); |
67 | } | 42 | } |
68 | 43 | ||
@@ -75,7 +50,7 @@ public class RecallConfigService { | @@ -75,7 +50,7 @@ public class RecallConfigService { | ||
75 | */ | 50 | */ |
76 | public int queryStrategyConfigInterval(int pageId, StrategyEnum strategyEnum) { | 51 | public int queryStrategyConfigInterval(int pageId, StrategyEnum strategyEnum) { |
77 | String configKey = getStrategyConfigKey(strategyEnum); | 52 | String configKey = getStrategyConfigKey(strategyEnum); |
78 | - int interval = recallConfigServiceCommon.queryConfigInterval(pageId, configKey, 10); | 53 | + int interval = recallConfigCommonService.queryConfigInterval(pageId, configKey, 10); |
79 | return this.legallValue(interval, 2, 40); | 54 | return this.legallValue(interval, 2, 40); |
80 | } | 55 | } |
81 | 56 | ||
@@ -99,15 +74,27 @@ public class RecallConfigService { | @@ -99,15 +74,27 @@ public class RecallConfigService { | ||
99 | } | 74 | } |
100 | 75 | ||
101 | /** | 76 | /** |
102 | - * 获取品类品牌的召回数量 | 77 | + * 获取推荐的【品类*品牌】的数量 |
78 | + * | ||
79 | + * @param pageId | ||
80 | + * @return | ||
81 | + */ | ||
82 | + public int querySortBrandConfigCount(int pageId, SortBrandType sortBrandType, int defaultSize) { | ||
83 | + String sortBrandConfigKey = this.getSortBrandConfigKey(sortBrandType); | ||
84 | + int value = recallConfigCommonService.queryConfigSize(pageId, sortBrandConfigKey, defaultSize); | ||
85 | + return this.legallValue(value, 0, 30); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * 获取【品类*品牌】下的的商品的召回数量 | ||
103 | * | 90 | * |
104 | * @param pageId | 91 | * @param pageId |
105 | * @param sortBrand | 92 | * @param sortBrand |
106 | * @return | 93 | * @return |
107 | */ | 94 | */ |
108 | public RecallSknCount queryRecallSknCount(int pageId, SortBrandType sortBrandType, SortBrand sortBrand) { | 95 | public RecallSknCount queryRecallSknCount(int pageId, SortBrandType sortBrandType, SortBrand sortBrand) { |
109 | - String sortBrandTypeKey = this.getStrategyConfiKey(sortBrandType); | ||
110 | - RecallSknCount recallSknCount = recallConfigServiceProduct.queryRecallSknCount(pageId, sortBrandTypeKey, sortBrand); | 96 | + String sortBrandConfigKey = this.getSortBrandConfigKey(sortBrandType); |
97 | + RecallSknCount recallSknCount = recallConfigProductService.queryRecallSknCount(pageId, sortBrandConfigKey, sortBrand); | ||
111 | if (recallSknCount == null) { | 98 | if (recallSknCount == null) { |
112 | return null; | 99 | return null; |
113 | } | 100 | } |
@@ -120,7 +107,7 @@ public class RecallConfigService { | @@ -120,7 +107,7 @@ public class RecallConfigService { | ||
120 | return recallSknCount; | 107 | return recallSknCount; |
121 | } | 108 | } |
122 | 109 | ||
123 | - private String getStrategyConfiKey(SortBrandType sortBrandType) { | 110 | + private String getSortBrandConfigKey(SortBrandType sortBrandType) { |
124 | if (sortBrandType.equals(SortBrandType.REC_SORT_BRAND)) { | 111 | if (sortBrandType.equals(SortBrandType.REC_SORT_BRAND)) { |
125 | return RecallConfigConstants.REC_SORT_BRAND; | 112 | return RecallConfigConstants.REC_SORT_BRAND; |
126 | } | 113 | } |
@@ -130,11 +117,27 @@ public class RecallConfigService { | @@ -130,11 +117,27 @@ public class RecallConfigService { | ||
130 | if (sortBrandType.equals(SortBrandType.VEC_W2V_SORT_BRAND)) { | 117 | if (sortBrandType.equals(SortBrandType.VEC_W2V_SORT_BRAND)) { |
131 | return RecallConfigConstants.VEC_W2V_SORT_BRAND; | 118 | return RecallConfigConstants.VEC_W2V_SORT_BRAND; |
132 | } | 119 | } |
120 | + if (sortBrandType.equals(SortBrandType.CONFIG_SORT_BRAND)) { | ||
121 | + return RecallConfigConstants.CONFIG_SORT_BRAND; | ||
122 | + } | ||
133 | return null; | 123 | return null; |
134 | } | 124 | } |
135 | 125 | ||
126 | + /** | ||
127 | + * 随机获取configSortBrandCount数量 | ||
128 | + * @param pageFactor | ||
129 | + * @param filterSortBrandKeys | ||
130 | + * @param configSortBrandCount | ||
131 | + * @return | ||
132 | + */ | ||
133 | + public List<SortBrand> queryConfigSortBrandList(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, int configSortBrandCount) { | ||
134 | + List<SortBrand> pageConfigSortBrands = recallConfigSortBrandService.queryConfigSortBrand(pageFactor,filterSortBrandKeys); | ||
135 | + Collections.shuffle(pageConfigSortBrands); | ||
136 | + return CollectionUtils.safeSubList(pageConfigSortBrands,0,configSortBrandCount); | ||
137 | + } | ||
138 | + | ||
136 | public static void main(String[] args) { | 139 | public static void main(String[] args) { |
137 | - System.out.println(legallValue(-1,0,30)); | 140 | + System.out.println(legallValue(-1, 0, 30)); |
138 | } | 141 | } |
139 | 142 | ||
140 | 143 |
1 | +package com.yoho.search.recall.config; | ||
2 | + | ||
3 | +import com.yoho.search.core.personalized.models.SortBrand; | ||
4 | +import com.yoho.search.recall.models.personal.PagePersonalFactor; | ||
5 | +import org.springframework.stereotype.Component; | ||
6 | + | ||
7 | +import java.util.*; | ||
8 | + | ||
9 | +@Component | ||
10 | +class RecallConfigSortBrandService { | ||
11 | + | ||
12 | + private Map<String,SortBrand> allConfigSortBrand = new HashMap<>(); | ||
13 | + | ||
14 | + public List<SortBrand> queryConfigSortBrand(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys) { | ||
15 | + return new ArrayList<>(); | ||
16 | + //pageFactor.getSortBrandList(); | ||
17 | + } | ||
18 | +} |
@@ -15,6 +15,7 @@ public class UserPersonalFactor { | @@ -15,6 +15,7 @@ public class UserPersonalFactor { | ||
15 | private List<SortBrand> realTimeSortBrandList; | 15 | private List<SortBrand> realTimeSortBrandList; |
16 | private List<SortBrand> vectorRnnSortBrandList; | 16 | private List<SortBrand> vectorRnnSortBrandList; |
17 | private List<SortBrand> vectorW2vSortBrandList; | 17 | private List<SortBrand> vectorW2vSortBrandList; |
18 | + private List<SortBrand> configSortBrandList; | ||
18 | 19 | ||
19 | public UserPersonalFactor() { | 20 | public UserPersonalFactor() { |
20 | this.recommendSknList = new ArrayList<>(); | 21 | this.recommendSknList = new ArrayList<>(); |
@@ -24,9 +25,10 @@ public class UserPersonalFactor { | @@ -24,9 +25,10 @@ public class UserPersonalFactor { | ||
24 | this.realTimeSortBrandList = new ArrayList<>(); | 25 | this.realTimeSortBrandList = new ArrayList<>(); |
25 | this.vectorRnnSortBrandList = new ArrayList<>(); | 26 | this.vectorRnnSortBrandList = new ArrayList<>(); |
26 | this.vectorW2vSortBrandList = new ArrayList<>(); | 27 | this.vectorW2vSortBrandList = new ArrayList<>(); |
28 | + this.configSortBrandList = new ArrayList<>(); | ||
27 | } | 29 | } |
28 | 30 | ||
29 | - public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList) { | 31 | + public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList,List<SortBrand> configSortBrandList) { |
30 | this.recommendSknList = recommendSknList; | 32 | this.recommendSknList = recommendSknList; |
31 | this.realTimeSimilarSknList = realTimeSimilarSknList; | 33 | this.realTimeSimilarSknList = realTimeSimilarSknList; |
32 | this.sortPriceAreasList = sortPriceAreasList; | 34 | this.sortPriceAreasList = sortPriceAreasList; |
@@ -34,6 +36,7 @@ public class UserPersonalFactor { | @@ -34,6 +36,7 @@ public class UserPersonalFactor { | ||
34 | this.realTimeSortBrandList = realTimeSortBrandList; | 36 | this.realTimeSortBrandList = realTimeSortBrandList; |
35 | this.vectorRnnSortBrandList = vectorRnnSortBrandList; | 37 | this.vectorRnnSortBrandList = vectorRnnSortBrandList; |
36 | this.vectorW2vSortBrandList = vectorW2vSortBrandList; | 38 | this.vectorW2vSortBrandList = vectorW2vSortBrandList; |
39 | + this.configSortBrandList = configSortBrandList; | ||
37 | } | 40 | } |
38 | 41 | ||
39 | public List<Integer> getRecommendSknList() { | 42 | public List<Integer> getRecommendSknList() { |
@@ -60,4 +63,7 @@ public class UserPersonalFactor { | @@ -60,4 +63,7 @@ public class UserPersonalFactor { | ||
60 | return vectorW2vSortBrandList; | 63 | return vectorW2vSortBrandList; |
61 | } | 64 | } |
62 | 65 | ||
66 | + public List<SortBrand> getConfigSortBrandList() { | ||
67 | + return configSortBrandList; | ||
68 | + } | ||
63 | } | 69 | } |
-
Please register or login to post a comment