zjcnb commented on code in PR #20475:
URL: https://github.com/apache/shardingsphere/pull/20475#discussion_r955671417


##########
shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/DatabaseMetaDataPersistService.java:
##########
@@ -159,12 +168,27 @@ public Optional<ShardingSphereSchema> load(final String 
databaseName, final Stri
         ShardingSphereSchema schema = new ShardingSphereSchema();
         tables.forEach(each -> {
             String content = 
repository.get(DatabaseMetaDataNode.getTableMetaDataPath(databaseName, 
schemaName, each));
-            ShardingSphereTable table = new 
YamlTableSwapper().swapToObject(YamlEngine.unmarshal(content, 
YamlShardingSphereTable.class));
-            schema.put(each, table);
+            if (!StringUtils.isEmpty(content)) {
+                ShardingSphereTable table = new 
YamlTableSwapper().swapToObject(YamlEngine.unmarshal(content, 
YamlShardingSphereTable.class));
+                schema.put(each, table);
+            }
         });
         return Optional.of(schema);
     }
     
+    /**
+     * Load schemas.
+     *
+     * @param databaseName database name to be loaded
+     * @return Loaded schemas
+     */
+    public Map<String, ShardingSphereSchema> load(final String databaseName) {
+        Collection<String> schemas = 
repository.getChildrenKeys(DatabaseMetaDataNode.getMetaDataSchemasPath(databaseName));
+        Map<String, ShardingSphereSchema> result = new 
ConcurrentHashMap<>(schemas.size(), 1);
+        schemas.forEach(each -> result.put(each.toLowerCase(), 
load(databaseName, each).orElse(new ShardingSphereSchema())));

Review Comment:
   Ok, done.



-- 
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