lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r673371 - in /lucene/java/trunk/src: java/org/apache/lucene/index/CompoundFileReader.java java/org/apache/lucene/index/SegmentReader.java test/org/apache/lucene/index/TestFieldsReader.java
Date Wed, 02 Jul 2008 11:57:28 GMT
Author: mikemccand
Date: Wed Jul  2 04:57:27 2008
New Revision: 673371

URL: http://svn.apache.org/viewvc?rev=673371&view=rev
Log:
LUCENE-1322: remove unnecessary synchronization in CSIndexInput

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/CompoundFileReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/CompoundFileReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/CompoundFileReader.java?rev=673371&r1=673370&r2=673371&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/CompoundFileReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/CompoundFileReader.java Wed Jul  2
04:57:27 2008
@@ -218,11 +218,19 @@
         CSIndexInput(final IndexInput base, final long fileOffset, final long length, int
readBufferSize)
         {
             super(readBufferSize);
-            this.base = base;
+            this.base = (IndexInput)base.clone();
             this.fileOffset = fileOffset;
             this.length = length;
         }
-
+        
+        public Object clone() {
+          CSIndexInput clone = (CSIndexInput)super.clone();
+          clone.base = (IndexInput)base.clone();
+          clone.fileOffset = fileOffset;
+          clone.length = length;
+          return clone;
+        }
+        
         /** Expert: implements buffer refill.  Reads bytes from the current
          *  position in the input.
          * @param b the array to read bytes into
@@ -232,13 +240,11 @@
         protected void readInternal(byte[] b, int offset, int len)
         throws IOException
         {
-            synchronized (base) {
-              long start = getFilePointer();
-              if(start + len > length)
-                throw new IOException("read past EOF");
-              base.seek(fileOffset + start);
-              base.readBytes(b, offset, len, false);
-            }
+          long start = getFilePointer();
+          if(start + len > length)
+            throw new IOException("read past EOF");
+          base.seek(fileOffset + start);
+          base.readBytes(b, offset, len, false);
         }
 
         /** Expert: implements seek.  Sets current position in this file, where
@@ -248,7 +254,9 @@
         protected void seekInternal(long pos) {}
 
         /** Closes the stream to further operations. */
-        public void close() {}
+        public void close() throws IOException {
+          base.close();
+        }
 
         public long length() {
           return length;

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=673371&r1=673370&r2=673371&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Wed Jul  2 04:57:27
2008
@@ -296,7 +296,6 @@
       } else
         storeDir = null;
 
-      // No compound file exists - use the multi-file format
       fieldInfos = new FieldInfos(cfsDir, segment + ".fnm");
 
       final String fieldsSegment;

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=673371&r1=673370&r2=673371&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java Wed Jul  2 04:57:27
2008
@@ -367,6 +367,9 @@
     public void close() throws IOException {
       delegate.close();
     }
+    public Object clone() {
+      return new FaultyIndexInput((IndexInput) delegate.clone());
+    }
   }
 
   // LUCENE-1262



Mime
View raw message