Authored by hugufei

add ABUserPartitionUtils

package com.yoho.search.recall.common;
import org.apache.commons.lang.StringUtils;
public class ABUserPartitionUtils {
public static boolean isAUser(int uid) {
int tail = uid % 1024;
return tail < 512 ? true : false;
}
public static boolean isAUser(String udid) {
if (StringUtils.isBlank(udid)) {
return false;
}
int tail = Math.abs(udid.hashCode() % 1024);
return tail < 512 ? true : false;
}
public static boolean isAUserComplete(int uid,String udid) {
if(uid>0){
return isAUser(uid);
}else{
return isAUser(udid);
}
}
}
... ...
package com.yoho.search.service.list;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.recall.common.ABUserPartitionUtils;
import com.yoho.search.recall.scene.SceneRecallProductListService;
import com.yoho.search.service.base.SearchDynamicConfigService;
import com.yoho.search.service.helper.SearchCommonHelper;
... ... @@ -28,11 +29,6 @@ public class ProductListSwitchService {
@Autowired
private FuzzySceneProductListService fuzzySceneProductListService;
private boolean isAUser(int uid) {
int tail = uid % 1024;
return tail < 512 ? true : false;
}
/**
* 普通商品列表入口
*
... ... @@ -68,7 +64,7 @@ public class ProductListSwitchService {
// 5个性化版本A/B 测试
int uid = searchCommonHelper.getUid(paramMap);
if(uid>0 && isAUser(uid)){
if(ABUserPartitionUtils.isAUser(uid)){
return defaultProductListService.productListForDefaultPersional(paramMap);
}
... ...