提交 481585be authored 作者: Thomas Mueller's avatar Thomas Mueller

File system: getting the file name from a path is now faster.

上级 f2ccfd17
...@@ -280,7 +280,7 @@ public abstract class FileSystem { ...@@ -280,7 +280,7 @@ public abstract class FileSystem {
* @param name the directory and file name * @param name the directory and file name
* @return just the file name * @return just the file name
*/ */
public abstract String getFileName(String name) throws SQLException; public abstract String getFileName(String name);
/** /**
* Check if a file starts with a given prefix. * Check if a file starts with a given prefix.
......
...@@ -359,19 +359,9 @@ public class FileSystemDisk extends FileSystem { ...@@ -359,19 +359,9 @@ public class FileSystemDisk extends FileSystem {
} }
} }
public String getFileName(String name) throws SQLException { public String getFileName(String name) {
name = translateFileName(name); name = translateFileName(name);
String separator = SysProperties.FILE_SEPARATOR; return new File(name).getName();
String path = getParent(name);
if (!path.endsWith(separator)) {
path += separator;
}
String fullFileName = normalize(name);
if (!fullFileName.startsWith(path)) {
Message.throwInternalError("file utils error: " + fullFileName + " does not start with " + path);
}
String fileName = fullFileName.substring(path.length());
return fileName;
} }
public boolean fileStartsWith(String fileName, String prefix) { public boolean fileStartsWith(String fileName, String prefix) {
......
...@@ -99,7 +99,7 @@ public class FileSystemSplit extends FileSystem { ...@@ -99,7 +99,7 @@ public class FileSystemSplit extends FileSystem {
return FileSystem.PREFIX_SPLIT + getFileSystem(fileName).getAbsolutePath(fileName); return FileSystem.PREFIX_SPLIT + getFileSystem(fileName).getAbsolutePath(fileName);
} }
public String getFileName(String name) throws SQLException { public String getFileName(String name) {
name = translateFileName(name); name = translateFileName(name);
return getFileSystem(name).getFileName(name); return getFileSystem(name).getFileName(name);
} }
......
...@@ -120,7 +120,7 @@ public class FileSystemDebug extends FileSystem { ...@@ -120,7 +120,7 @@ public class FileSystemDebug extends FileSystem {
return PREFIX + FileSystem.getInstance(fileName).getAbsolutePath(fileName); return PREFIX + FileSystem.getInstance(fileName).getAbsolutePath(fileName);
} }
public String getFileName(String name) throws SQLException { public String getFileName(String name) {
name = translateFileName(name); name = translateFileName(name);
trace("getFileName", name); trace("getFileName", name);
return FileSystem.getInstance(name).getFileName(name); return FileSystem.getInstance(name).getFileName(name);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论