-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move PartialSQLRouteExecutor logic to TablelessRouteEngine to handle …
…tableless sql route (#33820) * Move PartialSQLRouteExecutor logic to TablelessRouteEngine to handle tableless sql route * Remove useless spi file
- Loading branch information
1 parent
67c768c
commit 68a0ace
Showing
17 changed files
with
275 additions
and
559 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
36 changes: 0 additions & 36 deletions
36
...e/src/main/java/org/apache/shardingsphere/infra/route/engine/SQLRouteExecutorDecider.java
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...va/org/apache/shardingsphere/infra/route/engine/dialect/MySQLSQLRouteExecutorDecider.java
This file was deleted.
Oops, something went wrong.
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
50 changes: 50 additions & 0 deletions
50
...a/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactory.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,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
|
||
package org.apache.shardingsphere.infra.route.engine.tableless; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; | ||
import org.apache.shardingsphere.infra.route.engine.tableless.type.broadcast.DataSourceBroadcastRouteEngine; | ||
import org.apache.shardingsphere.infra.route.engine.tableless.type.ignore.IgnoreRouteEngine; | ||
import org.apache.shardingsphere.infra.session.query.QueryContext; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowTableStatusStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowTablesStatement; | ||
|
||
/** | ||
* Tableless route engine factory. | ||
*/ | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class TablelessRouteEngineFactory { | ||
|
||
/** | ||
* Create new instance of route engine. | ||
* | ||
* @param queryContext query context | ||
* @return created instance | ||
*/ | ||
public static TablelessRouteEngine newInstance(final QueryContext queryContext) { | ||
SQLStatementContext sqlStatementContext = queryContext.getSqlStatementContext(); | ||
SQLStatement sqlStatement = sqlStatementContext.getSqlStatement(); | ||
if (sqlStatement instanceof ShowTablesStatement || sqlStatement instanceof ShowTableStatusStatement) { | ||
return new DataSourceBroadcastRouteEngine(); | ||
} | ||
return new IgnoreRouteEngine(); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ava/org/apache/shardingsphere/infra/route/engine/tableless/router/TablelessSQLRouter.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,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
|
||
package org.apache.shardingsphere.infra.route.engine.tableless.router; | ||
|
||
import org.apache.shardingsphere.infra.binder.context.extractor.SQLStatementContextExtractor; | ||
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; | ||
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; | ||
import org.apache.shardingsphere.infra.route.context.RouteContext; | ||
import org.apache.shardingsphere.infra.route.engine.tableless.TablelessRouteEngineFactory; | ||
import org.apache.shardingsphere.infra.session.query.QueryContext; | ||
|
||
/** | ||
* Tableless sql router. | ||
*/ | ||
public final class TablelessSQLRouter { | ||
|
||
/** | ||
* Route. | ||
* | ||
* @param queryContext query context | ||
* @param globalRuleMetaData global rule meta data | ||
* @param database sharding sphere database | ||
* @param routeContext route context | ||
* @return route context | ||
*/ | ||
public RouteContext route(final QueryContext queryContext, final RuleMetaData globalRuleMetaData, final ShardingSphereDatabase database, final RouteContext routeContext) { | ||
if (routeContext.getRouteUnits().isEmpty() && SQLStatementContextExtractor.getTableNames(database, queryContext.getSqlStatementContext()).isEmpty()) { | ||
return TablelessRouteEngineFactory.newInstance(queryContext).route(globalRuleMetaData, database); | ||
} | ||
return routeContext; | ||
} | ||
} |
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
Oops, something went wrong.