Authored by hugufei

代码优化

... ... @@ -50,7 +50,6 @@ public class QueryUserPersionalFactorBean {
UserPersonalFactorRspNew userFactorNew = userComponent.queryUserPersionalFactorNew(userRecallRequest.getUid(), userRecallRequest.getUdid(),pageFactor);
RECALL_NEW_LOGGER.info("queryUserPersionalFactorNew . cost is[{}]", System.currentTimeMillis() - begin);
//3、join获取最终的结果
begin = System.currentTimeMillis();
List<SortBrand> sortBrandList = this.getSortBrandListWithSort(pageFactor, userFactorNew);
List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(pageFactor, userFactorNew);
//4、构造UserPersonalFactorRspNew
... ... @@ -72,12 +71,17 @@ public class QueryUserPersionalFactorBean {
* @return
*/
private List<SortBrand> getSortBrandListWithSort(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactorNew){
//1、返回结果定义
List<SortBrand> results = new ArrayList<>();
//2、构造brand2MiSortIdsMap
List<PageBrandSorts> brandSortsList = pageFactor.getBrandSortsList();
Map<Integer,List<Integer>> brand2MiSortIdsMap = new HashMap<>(brandSortsList.size());
Map<Integer,List<Integer>> brand2MiSortIdsMap = new HashMap<>();
for (PageBrandSorts pageBrandSorts : brandSortsList) {
brand2MiSortIdsMap.put(pageBrandSorts.getBrandId(), pageBrandSorts.getMisorts());
}
List<SortBrand> results = new ArrayList<>();
//3、构建SortBrands
int maxJoinSortBrandCount = searchDynamicConfigService.searchPersionalNewStrategyMaxJoinSortBrandCount();
for (SortBrand sortBrand : userFactorNew.getSortBrandList()) {
if(!brand2MiSortIdsMap.containsKey(sortBrand.getBrandId())){
... ...
... ... @@ -39,9 +39,15 @@ class UserPersionalFactorComponent {
JSONObject result = serviceCaller.call(SERVICE_NAME, userPersionalFactorReq, JSONObject.class, timeOut);
JSONObject userPersonalFactorRspJSon = result.getJSONObject("data");
UserPersonalFactorRspNew rsp = JSON.toJavaObject(userPersonalFactorRspJSon, UserPersonalFactorRspNew.class);
if (rsp == null || rsp.getSortBrandList() == null || rsp.getSortPriceAreasList() == null) {
if (rsp == null) {
return new UserPersonalFactorRspNew();
}
if(rsp.getSortPriceAreasList()==null){
rsp.setSortPriceAreasList(new ArrayList<>());
}
if(rsp.getSortBrandList()==null){
rsp.setSortBrandList(new ArrayList<>());
}
return rsp;
} catch (Exception e) {
RECALL_NEW_LOGGER.error(e.getMessage(), e);
... ...
... ... @@ -10,9 +10,6 @@ public class CacheTimeConstants {
//通用召回的缓存
public static final int COMMON_RECALL_STRATEGY_CACHE_TIME = 10 * 60;//兜底的缓存
//品牌的缓存
public static final int BRAND_RECALL_STRATEGY_CACHE_TIME = 60 * 60;
//品类+品牌的缓存
public static final int SORT_BRAND_RECALL_STRATEGY_CACHE_TIME = 60 * 60;
... ...
... ... @@ -2,8 +2,6 @@ package com.yoho.search.recall.scene.constants;
public class RecallCommonConstants {
public static final int MAX_JOIN_BRANDID = 15;//截取【品牌的】数量-for召回
public static final int MAX_JOIN_SORT_BRAND = 20;//截取【品牌-品类】的数量-for排序
}
... ...
... ... @@ -12,8 +12,6 @@ public class SknCountConstants {
public static final int NEW_SHOP = 10;
public static final int ADD_FLOW = 10;
public static final int BRAND_RECALL_STRATEGY_SKN_COUNT = 4;
public static final int SORT_BRAND_RECALL_STRATEGY_SKN_COUNT = 4;
public static final int MAX_USER_RECALL_SKN_CACHE_COUNT = 100;
... ...