Authored by hugufei

拆包

Showing 13 changed files with 179 additions and 199 deletions
package com.yoho.search.recall.scene.request;
package com.yoho.search.recall.scene;
import com.yoho.search.recall.scene.models.RecallParams;
import com.yoho.search.recall.scene.models.RecallRequest;
import com.yoho.search.recall.scene.builder.request.BrandRecallRequestBuilder;
import com.yoho.search.recall.scene.builder.request.CommonRecallRequestBuilder;
import com.yoho.search.recall.scene.builder.request.SortPriceRecallRequestBuilder;
import com.yoho.search.recall.scene.builder.response.RecallResponseBatchBuilder;
import com.yoho.search.recall.scene.builder.response.RecallSknResultBuilder;
import com.yoho.search.recall.scene.component.BatchRecallComponent;
import com.yoho.search.recall.scene.models.*;
import com.yoho.search.recall.scene.persional.PersionalFactor;
import com.yoho.search.recall.scene.request.BrandRecallRequestBuilder;
import com.yoho.search.recall.scene.request.CommonRecallRequestBuilder;
import com.yoho.search.recall.scene.request.SortPriceRecallRequestBuilder;
import com.yoho.search.recall.scene.persional.RecallPersionalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -13,22 +16,54 @@ import java.util.ArrayList;
import java.util.List;
@Component
public class BatchRequestsBuilder {
public class RecallService {
@Autowired
private RecallPersionalService recallPersionalService;
@Autowired
private BatchRecallComponent bacthRecallComponent;
@Autowired
private RecallResponseBatchBuilder recallResponseBatchBuilder;
@Autowired
private RecallSknResultBuilder recallSknResultBuilder;
@Autowired
private CommonRecallRequestBuilder commonRequestBuilder;
@Autowired
private BrandRecallRequestBuilder brandRequestBuilder;
@Autowired
private SortPriceRecallRequestBuilder sortPriceRequestBuilder;
public RecallSknResult getRecallSknResult(RecallSknParams recallSknParams){
RecallSknResult recallSknResult = this.doRecall(recallSknParams);
return recallSknResult;
}
/**
* 召回入口
* @param param
* @return
*/
private RecallSknResult doRecall(RecallSknParams param) {
//1、获取个性化因子
PersionalFactor persionalFactor = recallPersionalService.queryPersionalFactor(param);
//2、构造请求
List<RecallRequest> batchRequests = this.buildBatchRequests(param, persionalFactor);
//3、批量召回
List<CacheRecallRequestResponse> requestResponses = bacthRecallComponent.batchRecallAndCache(batchRequests);
//4、获取skn列表[去重]
RecallResponseBatch recallResponseBatch = recallResponseBatchBuilder.buildRecallResponseBatch(requestResponses);
//5、构造真实结果[排序,截取skn]
RecallSknResult recallSknResult = recallSknResultBuilder.builderRecallResult(recallResponseBatch, param, persionalFactor);
return recallSknResult;
}
/**
* 批量请求构造器
* 批量构造请求
* @param param
* @param persionalFactor
* @return
*/
public List<RecallRequest> buildBatchRequests(RecallParams param,PersionalFactor persionalFactor) {
public List<RecallRequest> buildBatchRequests(RecallSknParams param, PersionalFactor persionalFactor) {
//1、构造召回请求
List<RecallRequest> allRequests = new ArrayList<>();
//2、构造非个性化的请求
... ...
package com.yoho.search.recall.scene;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.CollectionUtils;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
... ... @@ -9,13 +10,7 @@ import com.yoho.search.models.SearchApiResult;
import com.yoho.search.recall.scene.component.*;
import com.yoho.search.recall.scene.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.models.*;
import com.yoho.search.recall.scene.models.CacheRecallRequestResponse;
import com.yoho.search.recall.scene.persional.PersionalFactor;
import com.yoho.search.recall.scene.persional.RecallPersionalService;
import com.yoho.search.recall.scene.request.BatchRequestsBuilder;
import com.yoho.search.recall.scene.request.BatchResponseBuilder;
import com.yoho.search.recall.scene.request.RecallParamsBuilder;
import com.yoho.search.recall.scene.request.RecallResultBuilder;
import com.yoho.search.recall.scene.builder.request.RecallParamsBuilder;
import com.yoho.search.service.base.SearchCommonService;
import com.yoho.search.service.base.index.ProductIndexBaseService;
import com.yoho.search.service.helper.SearchCommonHelper;
... ... @@ -40,16 +35,6 @@ public class SceneRecallService {
@Autowired
private RecallParamsBuilder recallParamsBuilder;
@Autowired
private RecallPersionalService recallPersionalService;
@Autowired
private BatchRequestsBuilder batchRequestsBuilder;
@Autowired
private BatchRecallComponent bacthRecallComponent;
@Autowired
private BatchResponseBuilder batchResponseBuilder;
@Autowired
private RecallResultBuilder recallResultBuilder;
@Autowired
private SearchCommonHelper searchCommonHelper;
@Autowired
private ProductIndexBaseService productIndexBaseService;
... ... @@ -57,6 +42,9 @@ public class SceneRecallService {
private SearchCommonService searchCommonService;
@Autowired
private BacthSknInfoComponent bacthSknInfoComponent;
@Autowired
private RecallService recallService;
public SearchApiResult sceneRecall(Map<String, String> paramMap) {
try {
... ... @@ -67,19 +55,17 @@ public class SceneRecallService {
return new SearchApiResult().setCode(400).setMessage("分页参数不合法");
}
//2、构造召回相关参数
RecallParams recallParams = recallParamsBuilder.buildRecallParams(paramMap);
//3、获取个性化因子
PersionalFactor persionalFactor = recallPersionalService.queryPersionalFactor(recallParams);
//4、执行召回
RecallResult recallResult = this.doRecall(recallParams, persionalFactor);
//5、根据召回结果查询商品信息
List<Map<String, Object>> productList = this.queryProductList(recallParams,recallResult);
RecallSknParams recallSknParams = recallParamsBuilder.buildRecallParams(paramMap);
//3、执行召回
RecallSknResult recallSknResult = recallService.getRecallSknResult(recallSknParams);
//4、根据召回结果查询商品信息
List<Map<String, Object>> productList = this.queryProductList(recallSknParams, recallSknResult,page,pageSize);
//6、构造返回结果
JSONObject dataMap = new JSONObject();
dataMap.put("total", recallResult.getTotal());
dataMap.put("page", recallParams.getPage());
dataMap.put("page_size", recallParams.getPageSize());
dataMap.put("page_total", searchCommonHelper.getTotalPage(recallResult.getTotal(), recallParams.getPageSize()));
dataMap.put("total", recallSknResult.getTotal());
dataMap.put("page", page);
dataMap.put("page_size", recallSknParams.getPageSize());
dataMap.put("page_total", searchCommonHelper.getTotalPage(recallSknResult.getTotal(), recallSknParams.getPageSize()));
dataMap.put("product_list", productList);
return new SearchApiResult().setData(dataMap);
} catch (Exception e) {
... ... @@ -88,46 +74,31 @@ public class SceneRecallService {
}
}
/**
* 召回入口
*
* @param param
* @param persionalFactor
* @return
*/
private RecallResult doRecall(RecallParams param, PersionalFactor persionalFactor) {
//1、构造请求
List<RecallRequest> batchRequests = batchRequestsBuilder.buildBatchRequests(param, persionalFactor);
//2、批量召回
List<CacheRecallRequestResponse> requestResponses = bacthRecallComponent.batchRecallAndCache(batchRequests);
//3、获取skn列表[去重]
RecallResponseBatch recallResponseBatch = batchResponseBuilder.buildRecallResponseBatch(requestResponses);
//4、构造真实结果[排序,截取skn]
RecallResult recallResult = recallResultBuilder.builderRecallResult(recallResponseBatch, param, persionalFactor);
return recallResult;
}
private List<Map<String, Object>> queryProductList(RecallParams recallParams,RecallResult recallResult) {
//1、
List<Integer> productSkns = recallResult.getSknList();
if (productSkns != null && !productSkns.isEmpty()) {
private List<Map<String, Object>> queryProductList(RecallSknParams recallSknParams, RecallSknResult recallSknResult,int page,int pageSize) {
//1、判断当前页码是否在召回的页码里
int recallTotalPage = recallSknResult.getRecallTotalPage();
//2、在召回结果中则直接根据skn去查询
if(page<=recallTotalPage){
List<Integer> productSkns = CollectionUtils.safeSubList(recallSknResult.getSknList(),(page-1)*pageSize,page*pageSize);
return bacthSknInfoComponent.queryProductListBySkn(productSkns,productSkns.size());
}else{
return this.queryProductByFilterSkn(recallResult.getNotProductSkn(),recallResult.getRealPage(),recallParams.getPageSize());
}
//3、过滤召回的skn,修改真实页码,执行查询
int realPage = page - recallTotalPage;
return this.queryProductByFilterSkn(recallSknResult.getSknList(), realPage, pageSize);
}
/**
* 过滤掉已召回的skn,并按人气排序
* @param notProductSkns
* @param page
* @param realPage
* @param pageSize
* @return
*/
private List<Map<String, Object>> queryProductByFilterSkn(List<Integer> notProductSkns,int page,int pageSize){
private List<Map<String, Object>> queryProductByFilterSkn(List<Integer> notProductSkns,int realPage,int pageSize){
SearchParam searchParam = new SearchParam();
//设置分页参数
searchParam.setOffset((page-1)*pageSize);
searchParam.setOffset((realPage-1)*pageSize);
searchParam.setSize(pageSize);
//设置filter
... ... @@ -147,8 +118,4 @@ public class SceneRecallService {
return productIndexBaseService.getProductListWithPricePlan(searchResult.getResultList());
}
}
... ...
package com.yoho.search.recall.scene.request;
package com.yoho.search.recall.scene.builder.request;
import com.yoho.search.recall.scene.constants.SknCountConstants;
import com.yoho.search.recall.scene.models.ParamQueryFilter;
... ... @@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.List;
@Component
public class BrandRecallRequestBuilder extends BaseRecallRequest{
public class BrandRecallRequestBuilder{
/**
* 按偏好品牌批量召回
... ... @@ -52,8 +52,8 @@ public class BrandRecallRequestBuilder extends BaseRecallRequest{
* @return
*/
private RecallRequest buildBrandHeatValueRequest(ParamQueryFilter paramQueryFilter, Integer brandId, int size) {
BrandHeatValueStrategy strage = new BrandHeatValueStrategy(brandId, size);
return this.buildRecallRequest(paramQueryFilter, strage);
BrandHeatValueStrategy strategy = new BrandHeatValueStrategy(brandId, size);
return new RecallRequest(paramQueryFilter, strategy);
}
/**
... ... @@ -66,7 +66,7 @@ public class BrandRecallRequestBuilder extends BaseRecallRequest{
*/
private RecallRequest buildBrandNewShelveRequest(ParamQueryFilter paramQueryFilter, Integer brandId, int size) {
BrandNewShelveStrategy strage = new BrandNewShelveStrategy(brandId, size);
return this.buildRecallRequest(paramQueryFilter, strage);
return new RecallRequest(paramQueryFilter, strage);
}
/**
... ... @@ -79,7 +79,7 @@ public class BrandRecallRequestBuilder extends BaseRecallRequest{
*/
private RecallRequest buildBrandNewReducePriceRequest(ParamQueryFilter paramQueryFilter, Integer brandId, int size) {
BrandReducePriceStrategy strage = new BrandReducePriceStrategy(brandId, size);
return this.buildRecallRequest(paramQueryFilter, strage);
return new RecallRequest(paramQueryFilter, strage);
}
/**
... ... @@ -92,7 +92,7 @@ public class BrandRecallRequestBuilder extends BaseRecallRequest{
*/
private RecallRequest buildBrandNewPromotionRequest(ParamQueryFilter paramQueryFilter, Integer brandId, int size) {
BrandPromotionStrategy strage = new BrandPromotionStrategy(brandId, size);
return this.buildRecallRequest(paramQueryFilter, strage);
return new RecallRequest(paramQueryFilter, strage);
}
}
... ...
package com.yoho.search.recall.scene.request;
package com.yoho.search.recall.scene.builder.request;
import com.yoho.search.recall.scene.constants.SknCountConstants;
... ... @@ -11,7 +11,7 @@ import java.util.ArrayList;
import java.util.List;
@Component
public class CommonRecallRequestBuilder extends BaseRecallRequest {
public class CommonRecallRequestBuilder{
/**
* 批量召回业务需求
... ... @@ -45,8 +45,8 @@ public class CommonRecallRequestBuilder extends BaseRecallRequest {
* @return
*/
private RecallRequest buildCommonRequest(ParamQueryFilter paramQueryFilter, int size) {
CommonHeatValueStrategy strage = new CommonHeatValueStrategy(size);
return this.buildRecallRequest(paramQueryFilter, strage);
CommonHeatValueStrategy strategy = new CommonHeatValueStrategy(size);
return new RecallRequest(paramQueryFilter, strategy);
}
/**
... ... @@ -58,8 +58,8 @@ public class CommonRecallRequestBuilder extends BaseRecallRequest {
* @return
*/
private RecallRequest buildFirstSknRequest(ParamQueryFilter paramQueryFilter, List<String> firstProductSkns, int size) {
CommonFirstSknStrategy strage = new CommonFirstSknStrategy(size, firstProductSkns);
return this.buildRecallRequest(paramQueryFilter, strage);
CommonFirstSknStrategy strategy = new CommonFirstSknStrategy(size, firstProductSkns);
return new RecallRequest(paramQueryFilter, strategy);
}
/**
... ... @@ -70,8 +70,8 @@ public class CommonRecallRequestBuilder extends BaseRecallRequest {
* @return
*/
private RecallRequest buildDirectTrainRequest(ParamQueryFilter paramQueryFilter, int size) {
CommonDirectTrainStrategy strage = new CommonDirectTrainStrategy(size);
return this.buildRecallRequest(paramQueryFilter, strage);
CommonDirectTrainStrategy strategy = new CommonDirectTrainStrategy(size);
return new RecallRequest(paramQueryFilter, strategy);
}
/**
... ... @@ -82,8 +82,8 @@ public class CommonRecallRequestBuilder extends BaseRecallRequest {
* @return
*/
private RecallRequest buildNewShopRequest(ParamQueryFilter paramQueryFilter, int size) {
CommonNewShopStrategy strage = new CommonNewShopStrategy(size);
return this.buildRecallRequest(paramQueryFilter, strage);
CommonNewShopStrategy strategy = new CommonNewShopStrategy(size);
return new RecallRequest(paramQueryFilter, strategy);
}
/**
... ... @@ -94,8 +94,8 @@ public class CommonRecallRequestBuilder extends BaseRecallRequest {
* @return
*/
private RecallRequest buildAddFlowRequest(ParamQueryFilter paramQueryFilter, int size) {
CommonAddFlowStrategy strage = new CommonAddFlowStrategy(size);
return this.buildRecallRequest(paramQueryFilter, strage);
CommonAddFlowStrategy strategy = new CommonAddFlowStrategy(size);
return new RecallRequest(paramQueryFilter, strategy);
}
}
... ...
package com.yoho.search.recall.scene.request;
package com.yoho.search.recall.scene.builder.request;
import com.yoho.search.recall.scene.models.ParamQueryFilter;
import com.yoho.search.recall.scene.models.RecallParams;
import com.yoho.search.recall.scene.models.RecallSknParams;
import com.yoho.search.recall.sort.helper.RecallServiceHelper;
import com.yoho.search.service.helper.SearchServiceHelper;
import org.apache.commons.collections.MapUtils;
... ... @@ -21,14 +21,13 @@ public class RecallParamsBuilder {
@Autowired
private RecallServiceHelper recallServiceHelper;
public RecallParams buildRecallParams(Map<String, String> paramMap) throws Exception {
public RecallSknParams buildRecallParams(Map<String, String> paramMap) throws Exception {
//1、获取链接中的query和filter参数
QueryBuilder query = searchServiceHelepr.constructQueryBuilder(paramMap);
BoolQueryBuilder filter = searchServiceHelepr.constructFilterBuilder(paramMap, null);
ParamQueryFilter queryFilter = new ParamQueryFilter(query,filter);
//2、获取分页参数
int page = MapUtils.getIntValue(paramMap, "page", 1);
int pageSize = MapUtils.getIntValue(paramMap, "viewNum", 10);
//3、获取firstSkn参数
... ... @@ -38,6 +37,6 @@ public class RecallParamsBuilder {
int uid = MapUtils.getIntValue(paramMap, "uid", 1);
String udid = MapUtils.getString(paramMap, "udid", "");
return new RecallParams(queryFilter,page,pageSize, firstProductSkns , uid, udid);
return new RecallSknParams(queryFilter,pageSize, firstProductSkns , uid, udid);
}
}
... ...
package com.yoho.search.recall.scene.request;
package com.yoho.search.recall.scene.builder.request;
import com.yoho.search.recall.scene.constants.SknCountConstants;
import com.yoho.search.recall.scene.models.ParamQueryFilter;
... ... @@ -11,7 +11,7 @@ import java.util.ArrayList;
import java.util.List;
@Component
public class SortPriceRecallRequestBuilder extends BaseRecallRequest{
public class SortPriceRecallRequestBuilder{
/**
* 基于用户的品类价格带召回
... ... @@ -28,9 +28,8 @@ public class SortPriceRecallRequestBuilder extends BaseRecallRequest{
}
private RecallRequest buildSortPriceRecallRequest(ParamQueryFilter paramQueryFilter, PersionalFactor.SortPriceArea sortPriceArea, int size){
SortPriceStrategy strage = new SortPriceStrategy(sortPriceArea,size);
return this.buildRecallRequest(paramQueryFilter,strage);
SortPriceStrategy strategy = new SortPriceStrategy(sortPriceArea,size);
return new RecallRequest(paramQueryFilter, strategy);
}
}
... ...
package com.yoho.search.recall.scene.request;
package com.yoho.search.recall.scene.builder.response;
import com.yoho.search.recall.scene.models.RecallRequest;
import com.yoho.search.recall.scene.models.CacheRecallRequestResponse;
... ... @@ -13,7 +13,7 @@ import java.util.List;
import java.util.Map;
@Component
public class BatchResponseBuilder {
public class RecallResponseBatchBuilder {
/**
* 召回结果构造器
... ...
package com.yoho.search.recall.scene.request;
package com.yoho.search.recall.scene.builder.response;
import com.yoho.search.base.utils.CollectionUtils;
import com.yoho.search.recall.scene.models.RecallParams;
import com.yoho.search.recall.scene.models.RecallSknParams;
import com.yoho.search.recall.scene.models.RecallResponseBatch;
import com.yoho.search.recall.scene.models.RecallResult;
import com.yoho.search.recall.scene.models.RecallSknResult;
import com.yoho.search.recall.scene.persional.PersionalFactor;
import com.yoho.search.recall.scene.strategy.StrategyNameEnum;
import com.yoho.search.service.base.ProductListSortKey;
... ... @@ -17,16 +17,14 @@ import java.util.Comparator;
import java.util.List;
@Component
public class RecallResultBuilder {
public class RecallSknResultBuilder {
@Autowired
private ProductListSortService productListSortService;
public RecallResult builderRecallResult(RecallResponseBatch recallResponseBatch, RecallParams param, PersionalFactor persionalFactor){
public RecallSknResult builderRecallResult(RecallResponseBatch recallResponseBatch, RecallSknParams param, PersionalFactor persionalFactor){
//1、构造结果中的分页信息
final long total = recallResponseBatch.getTotal();
final int page = param.getPage();
final int pageSize = param.getPageSize();
//2、获取召回结果中的最大整数页码
List<RecallResponseBatch.SknResult> sknResultList = recallResponseBatch.getSknList();
... ... @@ -55,33 +53,24 @@ public class RecallResultBuilder {
});
//TODO 6、处理直通车
//7、截取整数页
int recallMaxPage = (sknResultList.size() / pageSize);
if (recallMaxPage == 0) {
recallMaxPage = 1;
int pageSize = param.getPageSize();
int recallTotalPage = (sknResultList.size() / pageSize);
if (recallTotalPage == 0) {
recallTotalPage = 1;
}
if (recallMaxPage > 5) {
recallMaxPage = 5;
if (recallTotalPage > 5) {
recallTotalPage = 5;
}
sknResultList = CollectionUtils.safeSubList(sknResultList,0,recallMaxPage * pageSize);
final long recallTotal = sknResultList.size();
//8、判断当前页码是否在召回结果中
int realPage;
List<Integer> sknList = null;
List<Integer> notProductSkn = null;
sknResultList = CollectionUtils.safeSubList(sknResultList,0,recallTotalPage * param.getPageSize());
if(page > recallMaxPage) {
realPage = page - recallMaxPage;
notProductSkn = this.getSknList(sknResultList);//notProductKlsn
}else{
realPage = page;
sknList = this.getSknList(CollectionUtils.safeSubList(sknResultList,(page-1)*pageSize,page *pageSize));
}
return new RecallResult(total,recallTotal,recallMaxPage,realPage,sknList,notProductSkn);
//8、构造返回结果
List<Integer> sknList = this.getSknList(sknResultList);
int recallTotal = sknResultList.size();
return new RecallSknResult(total,recallTotal,recallTotalPage,sknList);
}
private void doCalScore(List<RecallResponseBatch.SknResult> sknResultList,PersionalFactor persionalFactor) {
String userFactor = persionalFactor.getUserFactor();
for (RecallResponseBatch.SknResult sknResult : sknResultList) {
... ...
package com.yoho.search.recall.scene.models;
import java.util.List;
public class RecallResult {
private final long total;
private final long recallTotal;
private final long recallPageTotal;
private final int realPage;
private final List<Integer> sknList;//查询的页码在召回的范围内,则返回这些skn
private final List<Integer> notProductSkn;//查询的页码不在召回的范围内,则返回全部召回的skn,外层过滤这些skn
public RecallResult(long total,long recallTotal,long recallPageTotal, int realPage,List<Integer> sknList,List<Integer> notProductSkn) {
this.total = total;
this.recallTotal = recallTotal;
this.recallPageTotal = recallPageTotal;
this.realPage = realPage;
this.sknList = sknList;
this.notProductSkn = notProductSkn;
}
public long getTotal() {
return total;
}
public long getRecallTotal() {
return recallTotal;
}
public long getRecallPageTotal() {
return recallPageTotal;
}
public int getRealPage() {
return realPage;
}
public List<Integer> getSknList() {
return sknList;
}
public List<Integer> getNotProductSkn() {
return notProductSkn;
}
}
... ... @@ -2,19 +2,17 @@ package com.yoho.search.recall.scene.models;
import java.util.List;
public class RecallParams {
public class RecallSknParams {
private final ParamQueryFilter paramQueryFilter;
private final int page;
private final int pageSize;
private final List<String> firstProductSkns;
private final int uid;
private final String udid;
public RecallParams(ParamQueryFilter paramQueryFilter,int page, int pageSize,List<String> firstProductSkns, int uid, String udid) {
public RecallSknParams(ParamQueryFilter paramQueryFilter, int pageSize, List<String> firstProductSkns, int uid, String udid) {
this.paramQueryFilter = paramQueryFilter;
this.firstProductSkns = firstProductSkns;
this.page = page;
this.pageSize = pageSize;
this.uid = uid;
this.udid = udid;
... ... @@ -24,10 +22,6 @@ public class RecallParams {
return paramQueryFilter;
}
public int getPage() {
return page;
}
public int getPageSize() {
return pageSize;
}
... ...
package com.yoho.search.recall.scene.models;
import java.io.Serializable;
import java.util.List;
public class RecallSknResult implements Serializable{
private static final long serialVersionUID = -5692239509936546967L;
private long total;
private int recallTotal;
private int recallTotalPage;
private List<Integer> sknList;
public RecallSknResult() {
}
public RecallSknResult(long total, int recallTotal, int recallTotalPage, List<Integer> sknList) {
this.total = total;
this.recallTotal = recallTotal;
this.recallTotalPage = recallTotalPage;
this.sknList = sknList;
}
public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
public int getRecallTotal() {
return recallTotal;
}
public void setRecallTotal(int recallTotal) {
this.recallTotal = recallTotal;
}
public int getRecallTotalPage() {
return recallTotalPage;
}
public void setRecallTotalPage(int recallTotalPage) {
this.recallTotalPage = recallTotalPage;
}
public List<Integer> getSknList() {
return sknList;
}
public void setSknList(List<Integer> sknList) {
this.sknList = sknList;
}
}
... ...
package com.yoho.search.recall.scene.persional;
import com.yoho.search.recall.scene.models.ParamQueryFilter;
import com.yoho.search.recall.scene.models.RecallParams;
import com.yoho.search.recall.scene.models.RecallSknParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -23,15 +22,15 @@ public class RecallPersionalService {
/**
* 获取个性化因子
*
* @param recallParams
* @param recallSknParams
* @return
*/
public PersionalFactor queryPersionalFactor(RecallParams recallParams) {
public PersionalFactor queryPersionalFactor(RecallSknParams recallSknParams) {
try {
//1、获取页面上的个性化因子
PersionalFactor pageFactor = pageComponent.queryPagePersionalFactor(recallParams.getParamQueryFilter());
PersionalFactor pageFactor = pageComponent.queryPagePersionalFactor(recallSknParams.getParamQueryFilter());
//2、获取用户的个性化因子
PersionalFactor userFactor = userComponent.queryUserPersionalFactor(recallParams.getUid(), recallParams.getUdid());
PersionalFactor userFactor = userComponent.queryUserPersionalFactor(recallSknParams.getUid(), recallSknParams.getUdid());
//3、join获取最终的结果
List<Integer> brandIds = this.innerJoin(pageFactor.getBrandIds(),userFactor.getBrandIds(),10);
List<PersionalFactor.SortPriceArea> sortPriceAreas = this.innerJoin(pageFactor.getSortPriceAreas(),userFactor.getSortPriceAreas(),5);
... ...
package com.yoho.search.recall.scene.request;
import com.yoho.search.recall.scene.models.ParamQueryFilter;
import com.yoho.search.recall.scene.models.RecallRequest;
import com.yoho.search.recall.scene.strategy.IStrategy;
public abstract class BaseRecallRequest {
protected RecallRequest buildRecallRequest(ParamQueryFilter paramQueryFilter, IStrategy strategy) {
return new RecallRequest(paramQueryFilter, strategy);
}
}