shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/TableMetaDataBuilder.java
/**
     * Load table metadata.
     *
     * @param tableNames table name collection
     * @param materials schema builder materials
     * @return table meta data map
     * @throws SQLException SQL exception
     */
Load table metadata.
@param tableNames table name collection
@param materials schema builder materials
@return table meta data map
@throws SQLException SQL exception
Load table metadata . @param tableNames table name collection @param materials schema builder materials @return table meta data map @throws SQLException SQL exception
@SuppressWarnings({"unchecked", "rawtypes"})
    public static Map<String, TableMetaData> load(final Collection<String> tableNames, final SchemaBuilderMaterials materials) throws SQLException {
        Map<String, TableMetaData> result = new LinkedHashMap<>();
        for (Entry<ShardingSphereRule, RuleBasedTableMetaDataBuilder> entry : OrderedSPIRegistry.getRegisteredServices(RuleBasedTableMetaDataBuilder.class, materials.getRules()).entrySet()) {
            if (entry.getKey() instanceof TableContainedRule) {
                TableContainedRule rule = (TableContainedRule) entry.getKey();
                RuleBasedTableMetaDataBuilder<TableContainedRule> builder = entry.getValue();
                Collection<String> needLoadTables = tableNames.stream().filter(each -> rule.getTables().contains(each)).filter(each -> !result.containsKey(each)).collect(Collectors.toList());
                if (!needLoadTables.isEmpty()) {
                    result.putAll(builder.load(needLoadTables, rule, materials));
                }
            }
        }
        return result;
    }
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static Map < String , TableMetaData > load ( final Collection < String > tableNames , final SchemaBuilderMaterials materials ) throws SQLException { Map < String , TableMetaData > result = new LinkedHashMap < > ( ) ; for ( Entry < ShardingSphereRule , RuleBasedTableMetaDataBuilder > entry : OrderedSPIRegistry . getRegisteredServices ( RuleBasedTableMetaDataBuilder . class , materials . getRules ( ) ) . entrySet ( ) ) { if ( entry . getKey ( ) instanceof TableContainedRule ) { TableContainedRule rule = ( TableContainedRule ) entry . getKey ( ) ; RuleBasedTableMetaDataBuilder < TableContainedRule > builder = entry . getValue ( ) ; Collection < String > needLoadTables = tableNames . stream ( ) . filter ( each -> rule . getTables ( ) . contains ( each ) ) . filter ( each -> ! result . containsKey ( each ) ) . collect ( Collectors . toList ( ) ) ; if ( ! needLoadTables . isEmpty ( ) ) { result . putAll ( builder . load ( needLoadTables , rule , materials ) ) ; } } } return result ; }
Load table metadata.
Load table metadata .