Authored by hugufei

配置添加阈值

@@ -13,6 +13,12 @@ public class RecallConfigService { @@ -13,6 +13,12 @@ public class RecallConfigService {
13 @Autowired 13 @Autowired
14 private RecallConfigServiceCommon recallConfigServiceCommon; 14 private RecallConfigServiceCommon recallConfigServiceCommon;
15 15
  16 + private int legallValue(int value, int min, int max) {
  17 + value = Math.min(value, max);
  18 + value = Math.max(value, min);
  19 + return value;
  20 + }
  21 +
16 /** 22 /**
17 * 获取推荐的品类品牌的配置 23 * 获取推荐的品类品牌的配置
18 * 24 *
@@ -20,7 +26,8 @@ public class RecallConfigService { @@ -20,7 +26,8 @@ public class RecallConfigService {
20 * @return 26 * @return
21 */ 27 */
22 public int getRecSortBrandCount(int pageId) { 28 public int getRecSortBrandCount(int pageId) {
23 - return recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.REC_S_B_COUNT, 12); 29 + int value = recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.REC_S_B_COUNT, 12);
  30 + return this.legallValue(value, 0, 30);
24 } 31 }
25 32
26 /** 33 /**
@@ -30,7 +37,8 @@ public class RecallConfigService { @@ -30,7 +37,8 @@ public class RecallConfigService {
30 * @return 37 * @return
31 */ 38 */
32 public int getVectorW2vSortBrandCount(int pageId) { 39 public int getVectorW2vSortBrandCount(int pageId) {
33 - return recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.VEC_W2V_S_B_COUNT, 12); 40 + int value = recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.VEC_W2V_S_B_COUNT, 12);
  41 + return this.legallValue(value, 0, 30);
34 } 42 }
35 43
36 /** 44 /**
@@ -40,7 +48,8 @@ public class RecallConfigService { @@ -40,7 +48,8 @@ public class RecallConfigService {
40 * @return 48 * @return
41 */ 49 */
42 public int getVectorRNNSortBrandCount(int pageId) { 50 public int getVectorRNNSortBrandCount(int pageId) {
43 - return recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.VEC_RNN_S_B_COUNT, 0); 51 + int value = recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.VEC_RNN_S_B_COUNT, 0);
  52 + return this.legallValue(value, 0, 30);
44 } 53 }
45 54
46 /** 55 /**
@@ -52,7 +61,8 @@ public class RecallConfigService { @@ -52,7 +61,8 @@ public class RecallConfigService {
52 */ 61 */
53 public int queryStrategyConfigSize(int pageId, StrategyEnum strategyEnum) { 62 public int queryStrategyConfigSize(int pageId, StrategyEnum strategyEnum) {
54 String configKey = getStrategyConfigKey(strategyEnum); 63 String configKey = getStrategyConfigKey(strategyEnum);
55 - return recallConfigServiceCommon.queryConfigSize(pageId, configKey, 0); 64 + int value = recallConfigServiceCommon.queryConfigSize(pageId, configKey, 0);
  65 + return this.legallValue(value, 0, 100);
56 } 66 }
57 67
58 /** 68 /**
@@ -65,9 +75,7 @@ public class RecallConfigService { @@ -65,9 +75,7 @@ public class RecallConfigService {
65 public int queryStrategyConfigInterval(int pageId, StrategyEnum strategyEnum) { 75 public int queryStrategyConfigInterval(int pageId, StrategyEnum strategyEnum) {
66 String configKey = getStrategyConfigKey(strategyEnum); 76 String configKey = getStrategyConfigKey(strategyEnum);
67 int interval = recallConfigServiceCommon.queryConfigInterval(pageId, configKey, 10); 77 int interval = recallConfigServiceCommon.queryConfigInterval(pageId, configKey, 10);
68 - interval = Math.max(interval, 2);  
69 - interval = Math.min(interval, 40);  
70 - return interval; 78 + return this.legallValue(interval, 2, 40);
71 } 79 }
72 80
73 private String getStrategyConfigKey(StrategyEnum strategyEnum) { 81 private String getStrategyConfigKey(StrategyEnum strategyEnum) {