Skip to content

Commit

Permalink
Refactor TableRefreshUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Jan 25, 2025
1 parent d14c2e1 commit 22682d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public final class DropTablePushDownMetaDataRefresher implements PushDownMetaDat
public void refresh(final MetaDataManagerPersistService metaDataManagerPersistService, final ShardingSphereDatabase database, final Collection<String> logicDataSourceNames,
final String schemaName, final DatabaseType databaseType, final DropTableStatement sqlStatement, final ConfigurationProperties props) throws SQLException {
Collection<String> tableNames = sqlStatement.getTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList());
boolean isRuleRefreshRequired = TableRefreshUtils.isRuleRefreshRequired(database.getRuleMetaData(), schemaName, sqlStatement.getTables());
boolean needRefresh = TableRefreshUtils.isNeedRefresh(database.getRuleMetaData(), schemaName, sqlStatement.getTables());
metaDataManagerPersistService.dropTables(database.getName(), schemaName, tableNames);
for (SimpleTableSegment each : sqlStatement.getTables()) {
if (isRuleRefreshRequired && TableRefreshUtils.isSingleTable(each.getTableName().getIdentifier().getValue(), database)) {
if (needRefresh && TableRefreshUtils.isSingleTable(each.getTableName().getIdentifier().getValue(), database)) {
metaDataManagerPersistService.alterSingleRuleConfiguration(database.getName(), database.getRuleMetaData());
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static boolean isSingleTable(final String tableName, final ShardingSphere
*/
public static boolean isNeedRefresh(final RuleMetaData ruleMetaData, final String schemaName, final Collection<SimpleTableSegment> tableSegments) {
for (SimpleTableSegment each : tableSegments) {
if (isRuleRefreshRequired(ruleMetaData, schemaName, each.getTableName().getIdentifier().getValue())) {
if (isNeedRefresh(ruleMetaData, schemaName, each.getTableName().getIdentifier().getValue())) {
return true;
}
}
Expand Down

0 comments on commit 22682d4

Please sign in to comment.