Skip to content

Commit

Permalink
Add AdvancedDistSQLUpdateExecutor (#32665)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Aug 24, 2024
1 parent 657ba7a commit fd43e0b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.distsql.handler.engine.update;

import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;

/**
* Advanced DistSQL update executor.
*
* @param <T> type of DistSQL statement
*/
@SingletonSPI
public interface AdvancedDistSQLUpdateExecutor<T extends DistSQLStatement> extends DistSQLUpdateExecutor<T> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ private void executeRuleDefinitionUpdate() throws SQLException {

@SuppressWarnings({"rawtypes", "unchecked"})
private void executeNormalUpdate() throws SQLException {
DistSQLUpdateExecutor executor = TypedSPILoader.getService(DistSQLUpdateExecutor.class, sqlStatement.getClass());
Optional<AdvancedDistSQLUpdateExecutor> advancedExecutor = TypedSPILoader.findService(AdvancedDistSQLUpdateExecutor.class, sqlStatement.getClass());
DistSQLUpdateExecutor executor = advancedExecutor.isPresent() ? advancedExecutor.get() : TypedSPILoader.getService(DistSQLUpdateExecutor.class, sqlStatement.getClass());
ShardingSphereDatabase database = null == databaseName ? null : contextManager.getDatabase(databaseName);
new DistSQLExecutorAwareSetter(executor).set(contextManager, database, null, sqlStatement);
new DistSQLExecutorRequiredChecker(executor).check(sqlStatement, contextManager, database);
Expand Down

0 comments on commit fd43e0b

Please sign in to comment.