Authored by hugufei

fix mapUtils

package com.yoho.search.common.utils;
import java.util.List;
import java.util.Map;
public class MapSizeUtils {
public static <K, V> int getMapElementCount(Map<K, V> map) {
if (map == null) {
return 0;
}
return map.size();
}
public static <K, V> int getMapElementListCount(Map<K, List<V>> map) {
if (map == null) {
return 0;
}
int count = 0;
for (List<V> list : map.values()) {
count += list == null ? 0 : list.size();
}
return count;
}
public static <K1, K2, V> int getMapElementMapCount(Map<K1, Map<K2, V>> map) {
if (map == null) {
return 0;
}
int count = 0;
for (Map<K2, V> mapValue : map.values()) {
count += mapValue == null ? 0 : mapValue.size();
}
return count;
}
}
... ...
package com.yoho.search.recall.config;
import com.yoho.search.common.utils.MapSizeUtils;
import com.yoho.search.dal.model.CsRecallConfigCommon;
import com.yoho.search.service.base.index.CsRecallConfigCommonIndexBaseService;
import org.apache.commons.lang.StringUtils;
... ... @@ -51,7 +52,7 @@ class RecallConfigCommonService {
tempCache.get(configKey).put(pageId, configSizeInterval);
}
recallConfigCommonCache = tempCache;
RECALL_NEW_LOGGER.info("loadRecallConfigCommonCache success,recallConfigCommonCache size is[{}]", recallConfigCommonCache.size());
RECALL_NEW_LOGGER.info("loadRecallConfigCommonCache success,recallConfigCommonCache size is[{}]", MapSizeUtils.getMapElementMapCount(recallConfigCommonCache));
} catch (Exception e) {
RECALL_NEW_LOGGER.error("loadRecallConfigCommonCache error,exception is:" + e.getMessage(), e);
}
... ...
package com.yoho.search.recall.config;
import com.yoho.search.common.utils.MapSizeUtils;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.dal.model.CsRecallConfigProduct;
import com.yoho.search.service.base.index.CsRecallConfigProductIndexBaseService;
... ... @@ -56,7 +57,7 @@ class RecallConfigProductService {
tempCache.get(configKey).put(pageId, configSknCount);
}
recallSknCountConfigCache = tempCache;
RECALL_NEW_LOGGER.info("loadRecallSknCountConfigCache success,recallSknCountConfigCache size is[{}]", recallSknCountConfigCache.size());
RECALL_NEW_LOGGER.info("loadRecallSknCountConfigCache success,recallSknCountConfigCache size is[{}]", MapSizeUtils.getMapElementMapCount(recallSknCountConfigCache));
} catch (Exception e) {
RECALL_NEW_LOGGER.error("loadRecallSknCountConfigCache error,exception is:" + e.getMessage(), e);
}
... ...