Misakami commented on issue #24311:
URL: 
https://github.com/apache/shardingsphere/issues/24311#issuecomment-1441470624

   I fixed it simply.
   code version  shardingsphere-sharding-core 3.0 
   
   ShardingSchemaMetaDataDecorator.java
   
   I modify the getLogicTableMetaDataMap
   `    private Map<String, Collection<TableMetaData>> 
getLogicTableMetaDataMap(final SchemaMetaData schemaMetaData, final 
ShardingRule rule) {
           Map<String, Collection<TableMetaData>> result = new 
LinkedHashMap<>();
           for (TableMetaData each : schemaMetaData.getTables()) {
               List<TableRule> tableRules = 
rule.findTableRulesByActualTable(each.getName());
               if (tableRules.isEmpty()) {
                   String logicTableName = each.getName();
                   Collection<TableMetaData> tableMetaDataList = 
result.computeIfAbsent(logicTableName, key -> new LinkedList<>());
                   tableMetaDataList.add(decorate(each, rule));
               } else {
                   tableRules.forEach(tableRule -> {
                       Collection<TableMetaData> tableMetaDataList =
                               
result.computeIfAbsent(tableRule.getLogicTable(), key -> new LinkedList<>());
                       tableMetaDataList.add(createTableMetaData(rule, 
tableRule, each));
                   });
               }
           }
           return result;
       }`
   ShardingRule.java
   I added a new method
   `    /**
        * Find table rules via actual table name.
        *
        * @param actualTableName actual table name
        * @return rule
        */
       public List<TableRule> findTableRulesByActualTable(final String 
actualTableName) {
           return tableRules.values()
                   .stream()
                   .filter(each -> each.isExisted(actualTableName))
                   .collect(Collectors.toList());
       }
       `
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to