package com.kidgrow.db.sharding; import org.apache.commons.lang.StringUtils; /** * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020
* * @Description: 按照字符串Hash求余确定分表
* @Project:
* @CreateDate: Created in 2020/2/4 16:05
* @Author: liuke */ public class HashModTableSuffix implements TableSuffix { private String hash; private static final int MOD = 100; public HashModTableSuffix(String hash) { if (StringUtils.isEmpty(hash)) { throw new IllegalArgumentException("hash should not be null or empty"); } this.hash = hash; } @Override public String getSuffix() { return String.format("_%d", hash.hashCode() / MOD); } }