com.github.javaclub.cdl.client.matrix.rule.SuffixParse Maven / Gradle / Ivy
package com.github.javaclub.cdl.client.matrix.rule;
public class SuffixParse {
public static String getTableSuffix(int tableNum, int indexBits) {
if (indexBits == 1) {
return String.valueOf(tableNum);
} else if (indexBits == 2) {
if (tableNum < 10) {
return "0" + tableNum;
} else {
return String.valueOf(tableNum);
}
} else if (indexBits == 3) {
if (tableNum < 10) {
return "00" + tableNum;
} else if (tableNum > 10 && tableNum < 100) {
return "0" + tableNum;
} else {
return String.valueOf(tableNum);
}
} else if (indexBits == 4) {
if (tableNum < 10) {
return "000" + tableNum;
} else if (tableNum > 10 && tableNum < 100) {
return "00" + tableNum;
} else if (tableNum > 100 && tableNum < 1000) {
return "0" + tableNum;
} else {
return String.valueOf(tableNum);
}
}
throw new RuntimeException("too many sharding table");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy