yuqi1129 commented on code in PR #5020:
URL: https://github.com/apache/gravitino/pull/5020#discussion_r1800413212
##########
catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/HadoopCatalogOperations.java:
##########
@@ -742,4 +742,44 @@ private boolean checkSingleFile(Fileset fileset) {
fileset.name());
}
}
+
+ FileSystem getFileSystem(Path path, Map<String, String> config) throws
IOException {
+ String defaultFilesystemProvider =
+ (String)
+ propertiesMetadata
+ .catalogPropertiesMetadata()
+ .getOrDefault(config,
HadoopCatalogPropertiesMetadata.DEFAULT_FS);
+
+ Map<String, String> newConfig = Maps.newHashMap(config);
+ if (path == null) {
+ if (defaultFilesystemProvider != null) {
+ return getFileSystemByScheme(defaultFilesystemProvider, newConfig);
+ } else {
+ LOG.warn("The path and default filesystem provider are both null,
using local file system");
+ return getFileSystemByScheme(LOCAL_FILE_SCHEMA, newConfig);
+ }
+ }
+
+ // Path is not null;
+ if (path.toUri().getScheme() == null) {
+ LOG.warn(
+ "Can't get schema from path: {} and default filesystem provider are
both null, using"
+ + " local file system",
+ path);
+ return getFileSystemByScheme(LOCAL_FILE_SCHEMA, newConfig);
+ } else {
+ newConfig.put(DEFAULT_FS, path.toUri().toString());
+ return getFileSystemByScheme(path.toUri().getScheme(), newConfig);
+ }
+ }
Review Comment:
Yes, but If we want to log detail information about potential problems such
as:
```
LOG.warn("The path and default filesystem provider are both null,
using local file system");
LOG.warn(
"Can't get schema from path: {} and default filesystem provider is
null, using"
+ " local file system",
path);
```
this format may miss this information.
--
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]