Author: cutting Date: Wed Nov 14 15:36:06 2007 New Revision: 595135 URL: http://svn.apache.org/viewvc?rev=595135&view=rev Log: Merge -r 595130:595131 from trunk to 0.15 branch. Fixes: HADOOP-2172.
Modified: lucene/hadoop/branches/branch-0.15/CHANGES.txt lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java Modified: lucene/hadoop/branches/branch-0.15/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/branches/branch-0.15/CHANGES.txt?rev=595135&r1=595134&r2=595135&view=diff ============================================================================== --- lucene/hadoop/branches/branch-0.15/CHANGES.txt (original) +++ lucene/hadoop/branches/branch-0.15/CHANGES.txt Wed Nov 14 15:36:06 2007 @@ -20,6 +20,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/branches/branch-0.15/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java URL: http://svn.apache.org/viewvc/lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java?rev=595135&r1=595134&r2=595135&view=diff ============================================================================== --- lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java (original) +++ lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java Wed Nov 14 15:36:06 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 {