Performance enhancement, seek plus readFully while using LocalFileSystem is much more performant.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/36bf75be Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/36bf75be Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/36bf75be Branch: refs/heads/0.2-dev Commit: 36bf75bee14823cd91f998e4dbcf749f7b26bfe4 Parents: 95581f9 Author: Aaron McCurry <[email protected]> Authored: Wed Feb 27 08:47:44 2013 -0500 Committer: Aaron McCurry <[email protected]> Committed: Wed Feb 27 08:47:44 2013 -0500 ---------------------------------------------------------------------- .../org/apache/blur/store/hdfs/HdfsDirectory.java | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/36bf75be/src/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java ---------------------------------------------------------------------- diff --git a/src/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java b/src/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java index 1c398f1..18de3e7 100644 --- a/src/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java +++ b/src/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java @@ -97,7 +97,7 @@ public class HdfsDirectory extends Directory { private FSDataInputStream inputStream; private boolean isClone; - public HdfsIndexInput(String name, FileSystem fileSystem, Path filePath) throws IOException { + public HdfsIndexInput(FileSystem fileSystem, Path filePath) throws IOException { super(filePath.toString()); inputStream = fileSystem.open(filePath); FileStatus fileStatus = fileSystem.getFileStatus(filePath); @@ -116,7 +116,10 @@ public class HdfsDirectory extends Directory { @Override protected void readInternal(byte[] b, int offset, int length) throws IOException { - inputStream.readFully(getFilePointer(), b, offset, length); + synchronized (inputStream) { + inputStream.seek(getFilePointer()); + inputStream.readFully(b, offset, length); + } } @Override @@ -172,7 +175,7 @@ public class HdfsDirectory extends Directory { throw new FileNotFoundException("File [" + name + "] not found."); } Path filePath = getPath(name); - return new HdfsIndexInput(name, fileSystem, filePath); + return new HdfsIndexInput(fileSystem, filePath); } @Override
