hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r618347 [2/2] - in /hadoop/core/trunk: ./ src/contrib/hbase/conf/ src/contrib/hbase/src/java/org/apache/hadoop/hbase/ src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/ ...
Date Mon, 04 Feb 2008 17:54:38 GMT
Modified: hadoop/core/trunk/src/java/org/apache/hadoop/io/MapFile.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/io/MapFile.java?rev=618347&r1=618346&r2=618347&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/io/MapFile.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/io/MapFile.java Mon Feb  4 09:54:35 2008
@@ -246,12 +246,31 @@
     /** Construct a map reader for the named map using the named comparator.*/
     public Reader(FileSystem fs, String dirName, WritableComparator comparator, Configuration
conf)
       throws IOException {
+      this(fs, dirName, comparator, conf, true);
+    }
+    
+    /**
+     * Hook to allow subclasses to defer opening streams until further
+     * initialization is complete.
+     * @see #createDataFileReader(FileSystem, Path, Configuration)
+     */
+    protected Reader(FileSystem fs, String dirName,
+        WritableComparator comparator, Configuration conf, boolean open)
+      throws IOException {
+      
+      if (open) {
+        open(fs, dirName, comparator, conf);
+      }
+    }
+    
+    protected synchronized void open(FileSystem fs, String dirName,
+        WritableComparator comparator, Configuration conf) throws IOException {
       Path dir = new Path(dirName);
       Path dataFile = new Path(dir, DATA_FILE_NAME);
       Path indexFile = new Path(dir, INDEX_FILE_NAME);
 
       // open the data
-      this.data = new SequenceFile.Reader(fs, dataFile,  conf);
+      this.data = createDataFileReader(fs, dataFile, conf);
       this.firstPosition = data.getPosition();
 
       if (comparator == null)
@@ -261,6 +280,15 @@
 
       // open the index
       this.index = new SequenceFile.Reader(fs, indexFile, conf);
+    }
+
+    /**
+     * Override this method to specialize the type of
+     * {@link SequenceFile.Reader} returned.
+     */
+    protected SequenceFile.Reader createDataFileReader(FileSystem fs,
+        Path dataFile, Configuration conf) throws IOException {
+      return new SequenceFile.Reader(fs, dataFile,  conf);
     }
 
     private void readIndex() throws IOException {

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/io/SequenceFile.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/io/SequenceFile.java?rev=618347&r1=618346&r2=618347&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/io/SequenceFile.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/io/SequenceFile.java Mon Feb  4 09:54:35
2008
@@ -1391,11 +1391,20 @@
                    long length, Configuration conf, boolean tempReader) 
     throws IOException {
       this.file = file;
-      this.in = fs.open(file, bufferSize);
+      this.in = openFile(fs, file, bufferSize, length);
       this.conf = conf;
       seek(start);
       this.end = in.getPos() + length;
       init(tempReader);
+    }
+
+    /**
+     * Override this method to specialize the type of
+     * {@link FSDataInputStream} returned.
+     */
+    protected FSDataInputStream openFile(FileSystem fs, Path file,
+        int bufferSize, long length) throws IOException {
+      return fs.open(file, bufferSize);
     }
     
     private Decompressor getPooledOrNewDecompressor() {



Mime
View raw message