-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
128 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...dbc-core/src/main/java/io/shardingjdbc/core/routing/type/none/NoneTableRoutingEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 1999-2015 dangdang.com. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* </p> | ||
*/ | ||
|
||
package io.shardingjdbc.core.routing.type.none; | ||
|
||
import com.google.common.base.Preconditions; | ||
import io.shardingjdbc.core.parsing.parser.sql.SQLStatement; | ||
import io.shardingjdbc.core.parsing.parser.token.IndexToken; | ||
import io.shardingjdbc.core.routing.type.RoutingEngine; | ||
import io.shardingjdbc.core.routing.type.RoutingResult; | ||
import io.shardingjdbc.core.routing.type.simple.SimpleRoutingEngine; | ||
import io.shardingjdbc.core.rule.ShardingRule; | ||
import io.shardingjdbc.core.rule.TableRule; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* None table routing engine. | ||
* | ||
* @author caohao | ||
*/ | ||
@RequiredArgsConstructor | ||
public final class NoneTableRoutingEngine implements RoutingEngine { | ||
|
||
private final ShardingRule shardingRule; | ||
|
||
private final List<Object> parameters; | ||
|
||
private final SQLStatement sqlStatement; | ||
|
||
@Override | ||
public RoutingResult route() { | ||
return new SimpleRoutingEngine(shardingRule, parameters, getLogicTableName(), sqlStatement).route(); | ||
} | ||
|
||
private String getLogicTableName() { | ||
Preconditions.checkState(sqlStatement.getSqlTokens().size() == 1); | ||
IndexToken indexToken = (IndexToken) sqlStatement.getSqlTokens().get(0); | ||
String indexName = indexToken.getIndexName(); | ||
String logicTableName = ""; | ||
for (TableRule each : shardingRule.getTableRules()) { | ||
if (indexName.equals(each.getLogicIndex())) { | ||
logicTableName = each.getLogicTable(); | ||
} | ||
} | ||
return logicTableName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
sharding-jdbc-core/src/test/resources/integrate/dataset/sharding/tbl/expect/index/tbl.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<dataset> | ||
<t_log /> | ||
</dataset> |
12 changes: 12 additions & 0 deletions
12
...jdbc-core/src/test/resources/integrate/dataset/sharding/tbl/expect/index/tbl_sharding.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<dataset> | ||
<t_order_0 /> | ||
<t_order_1 /> | ||
<t_order_2 /> | ||
<t_order_3 /> | ||
<t_order_4 /> | ||
<t_order_5 /> | ||
<t_order_6 /> | ||
<t_order_7 /> | ||
<t_order_8 /> | ||
<t_order_9 /> | ||
</dataset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters