Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update from origin #160

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sharding-jdbc-doc/content/post/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public Collection<String> doBetweenSharding(final Collection<String> availableTa

下面是一个余2的算法的例子,当分片键的值除以2余数就是实际表的结尾。注意注释中提供了一些算法生成SQL的结果,参数`tableNames`集合中有两个参数`t_order_0`和`t_order_1`
```java
public final class ModuloDatabaseShardingAlgorithm implements SingleKeyDatabaseShardingAlgorithm<Integer> {
public final class ModuloTableShardingAlgorithm implements SingleKeyTableShardingAlgorithm<Integer> {

/**
* select * from t_order from t_order where order_id = 11
Expand Down Expand Up @@ -254,9 +254,9 @@ public Collection<String> doBetweenSharding(final Collection<String> availableTa
public Collection<String> doInSharding(final Collection<String> tableNames, final ShardingValue<Integer> shardingValue) {
Collection<String> result = new LinkedHashSet<>(tableNames.size());
for (Integer value : shardingValue.getValues()) {
for (String dataSourceName : tableNames) {
if (dataSourceName.endsWith(value % 2 + "")) {
result.add(dataSourceName);
for (String tableName : tableNames) {
if (tableName.endsWith(value % 2 + "")) {
result.add(tableName);
}
}
}
Expand Down