Skip to content

Commit 2bfb228

Browse files
authored
HADOOP-17020. Improve RawFileSystem Performance (#2063)
Contributed by : Mehakmeet Singh Co-authored-by: Rajesh Balamohan Co-authored-by: Mehakmeet Singh
1 parent 5b1a56f commit 2bfb228

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
public class RawLocalFileSystem extends FileSystem {
6565
static final URI NAME = URI.create("file:///");
6666
private Path workingDir;
67+
private long defaultBlockSize;
6768
// Temporary workaround for HADOOP-9652.
6869
private static boolean useDeprecatedFileStatus = true;
6970

@@ -100,6 +101,7 @@ public File pathToFile(Path path) {
100101
public void initialize(URI uri, Configuration conf) throws IOException {
101102
super.initialize(uri, conf);
102103
setConf(conf);
104+
defaultBlockSize = getDefaultBlockSize(new Path(uri));
103105
}
104106

105107
/*******************************************************
@@ -518,7 +520,12 @@ public FileStatus[] listStatus(Path f) throws IOException {
518520
}
519521
return new FileStatus[] {
520522
new DeprecatedRawLocalFileStatus(localf,
521-
getDefaultBlockSize(f), this) };
523+
defaultBlockSize, this) };
524+
}
525+
526+
@Override
527+
public boolean exists(Path f) throws IOException {
528+
return pathToFile(f).exists();
522529
}
523530

524531
protected boolean mkOneDir(File p2f) throws IOException {
@@ -663,7 +670,7 @@ private FileStatus deprecatedGetFileStatus(Path f) throws IOException {
663670
File path = pathToFile(f);
664671
if (path.exists()) {
665672
return new DeprecatedRawLocalFileStatus(pathToFile(f),
666-
getDefaultBlockSize(f), this);
673+
defaultBlockSize, this);
667674
} else {
668675
throw new FileNotFoundException("File " + f + " does not exist");
669676
}
@@ -1051,7 +1058,7 @@ private FileStatus deprecatedGetFileLinkStatusInternal(final Path f)
10511058
private FileStatus getNativeFileLinkStatus(final Path f,
10521059
boolean dereference) throws IOException {
10531060
checkPath(f);
1054-
Stat stat = new Stat(f, getDefaultBlockSize(f), dereference, this);
1061+
Stat stat = new Stat(f, defaultBlockSize, dereference, this);
10551062
FileStatus status = stat.getFileStatus();
10561063
return status;
10571064
}

0 commit comments

Comments
 (0)