Author: cutting Date: Wed Nov 14 15:33:52 2007 New Revision: 595131 URL: http://svn.apache.org/viewvc?rev=595131&view=rev Log: HADOOP-2172. Restore performance of random access to local files.
Modified: lucene/hadoop/trunk/CHANGES.txt lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java Modified: lucene/hadoop/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=595131&r1=595130&r2=595131&view=diff ============================================================================== --- lucene/hadoop/trunk/CHANGES.txt (original) +++ lucene/hadoop/trunk/CHANGES.txt Wed Nov 14 15:33:52 2007 @@ -120,6 +120,11 @@ FSCopyFilesMapper.close which led to a NPE since the reporter isn't valid in the close method. (Chris Douglas via acmurthy) + HADOOP-2172. Restore performance of random access to local files + by caching positions of local input streams, avoiding a system + call. (cutting) + + Release 0.15.0 - 2007-11-2 INCOMPATIBLE CHANGES Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java?rev=595131&r1=595130&r2=595131&view=diff ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java Wed Nov 14 15:33:52 2007 @@ -68,6 +68,7 @@ *******************************************************/ class LocalFSFileInputStream extends FSInputStream { FileInputStream fis; + private long position; public LocalFSFileInputStream(Path f) throws IOException { this.fis = new FileInputStream(pathToFile(f)); @@ -75,10 +76,11 @@ public void seek(long pos) throws IOException { fis.getChannel().position(pos); + this.position = pos; } public long getPos() throws IOException { - return fis.getChannel().position(); + return this.position; } public boolean seekToNewSource(long targetPos) throws IOException { @@ -94,7 +96,11 @@ public int read() throws IOException { try { - return fis.read(); + int value = fis.read(); + if (value >= 0) { + this.position++; + } + return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } @@ -102,7 +108,11 @@ public int read(byte[] b, int off, int len) throws IOException { try { - return fis.read(b, off, len); + int value = fis.read(b, off, len); + if (value > 0) { + this.position += value; + } + return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } @@ -118,7 +128,13 @@ } } - public long skip(long n) throws IOException { return fis.skip(n); } + public long skip(long n) throws IOException { + long value = fis.skip(n); + if (value > 0) { + this.position += value; + } + return value; + } } public FSDataInputStream open(Path f, int bufferSize) throws IOException {