public static String getSplitTableName(String tableName, Object splitKeyVal, Integer subTableCount) {
if(splitKeyVal == null){
throw new RuntimeException("splitKeyVal is null.tableName:" +tableName);
}
long hashVal = splitKeyVal.toString().hashCode();
// 斐波那契(Fibonacci)散列
hashVal = ( hashVal * 2654435769L ) >> 28;
// 避免hashVal超出 MAX_VALUE = 0x7fffffff时变为负数,取绝对值
hashVal = Math.abs(hashVal) % subTableCount;
String hashTableName = tableName + "_" + hashVal;
if (logger.isDebugEnabled()) {
logger.debug("used hash mod algorithm. build {}'s subtable name: {}. ", tableName, hashTableName);
}
return hashTableName;
}