Skip to content

Commit

Permalink
Refactor TableMapperRule (#30306)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Feb 26, 2024
1 parent 87e63ab commit 3d3aad4
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,9 @@ public TableNamesMapper getLogicTableMapper() {
return logicalTableMapper;
}

@Override
public TableNamesMapper getActualTableMapper() {
return new TableNamesMapper();
}

@Override
public TableNamesMapper getDistributedTableMapper() {
return getLogicTableMapper();
return logicalTableMapper;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,13 @@ public TableNamesMapper getLogicTableMapper() {
return logicalTableMapper;
}

@Override
public TableNamesMapper getActualTableMapper() {
return new TableNamesMapper();
}

@Override
public TableNamesMapper getDistributedTableMapper() {
return new TableNamesMapper();
}

@Override
public TableNamesMapper getEnhancedTableMapper() {
return getLogicTableMapper();
return logicalTableMapper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public TableNamesMapper getLogicTableMapper() {
return logicalTableMapper;
}

@Override
public TableNamesMapper getActualTableMapper() {
return new TableNamesMapper();
}

@Override
public TableNamesMapper getDistributedTableMapper() {
return new TableNamesMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public TableNamesMapper getActualTableMapper() {

@Override
public TableNamesMapper getDistributedTableMapper() {
return getLogicTableMapper();
return logicalTableMapper;
}

@Override
public TableNamesMapper getEnhancedTableMapper() {
return getLogicTableMapper();
return logicalTableMapper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public interface TableMapperRule {
*
* @return actual table mapper
*/
TableNamesMapper getActualTableMapper();
default TableNamesMapper getActualTableMapper() {
return new TableNamesMapper();
}

/**
* Get distributed table mapper.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.rule.identifier.type;
package org.apache.shardingsphere.infra.rule.identifier.type.table;

import org.apache.shardingsphere.infra.rule.identifier.type.table.TableNamesMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public TableNamesMapper getLogicTableMapper() {
return logicTableMapper;
}

@Override
public TableNamesMapper getActualTableMapper() {
return new TableNamesMapper();
}

@Override
public TableNamesMapper getDistributedTableMapper() {
return new TableNamesMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ private static Map<String, DataSource> getAggregatedDataSourceMap(final Map<Stri
public static Collection<String> getExcludedTables(final Collection<ShardingSphereRule> builtRules) {
Collection<String> result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (ShardingSphereRule each : builtRules) {
if (!(each instanceof TableMapperContainedRule)) {
continue;
if (each instanceof TableMapperContainedRule) {
result.addAll(((TableMapperContainedRule) each).getTableMapperRule().getDistributedTableMapper().getTableNames());
result.addAll(((TableMapperContainedRule) each).getTableMapperRule().getActualTableMapper().getTableNames());
}
result.addAll(((TableMapperContainedRule) each).getTableMapperRule().getDistributedTableMapper().getTableNames());
result.addAll(((TableMapperContainedRule) each).getTableMapperRule().getActualTableMapper().getTableNames());
}
return result;
}
Expand Down

0 comments on commit 3d3aad4

Please sign in to comment.