lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r995376 - in /lucene/dev/trunk/lucene/src: java/org/apache/lucene/store/FSDirectory.java test/org/apache/lucene/index/TestIndexWriter.java
Date Thu, 09 Sep 2010 10:50:15 GMT
Author: rmuir
Date: Thu Sep  9 10:50:15 2010
New Revision: 995376

URL: http://svn.apache.org/viewvc?rev=995376&view=rev
Log:
FSDirectory.copyBytes isn't safe for SimpleFSDirectory

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FSDirectory.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FSDirectory.java?rev=995376&r1=995375&r2=995376&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/FSDirectory.java Thu Sep  9 10:50:15
2010
@@ -22,7 +22,6 @@ import java.io.FileNotFoundException;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
@@ -33,7 +32,6 @@ import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.Future;
 
-import org.apache.lucene.store.SimpleFSDirectory.SimpleFSIndexInput;
 import org.apache.lucene.util.ThreadInterruptedException;
 import org.apache.lucene.util.Constants;
 
@@ -468,46 +466,6 @@ public abstract class FSDirectory extend
     public void flushBuffer(byte[] b, int offset, int size) throws IOException {
       file.write(b, offset, size);
     }
-
-    @Override
-    public void copyBytes(DataInput input, long numBytes) throws IOException {
-      // Optimized copy only if the number of bytes to copy is larger than the
-      // buffer size, and the given IndexInput supports FileChannel copying.
-      // NOTE: the below check relies on NIOIndexInput extending Simple. If that
-      // changes in the future, we should change the check as well.
-      if (numBytes <= BUFFER_SIZE || !(input instanceof SimpleFSIndexInput)) {
-        super.copyBytes(input, numBytes);
-        return;
-      }
-
-      SimpleFSIndexInput fsInput = (SimpleFSIndexInput) input;
-
-      // flush any bytes in the input's buffer.
-      numBytes -= fsInput.flushBuffer(this, numBytes);
-      
-      // flush any bytes in the buffer
-      flush();
-      
-      // do the optimized copy
-      FileChannel in = fsInput.file.getChannel();
-
-      // Necessary because BufferedIndexInput does lazy seeking:
-      in.position(fsInput.getFilePointer());
-
-      FileChannel out = file.getChannel();
-      long pos = out.position();
-      long writeTo = numBytes + pos;
-      while (pos < writeTo) {
-        pos += out.transferFrom(in, pos, Math.min(CHANNEL_CHUNK_SIZE, writeTo - pos));
-      }
-      // transferFrom does not change the position of the channel. Need to change it manually
-      out.position(pos);
-      
-      // corrects the position in super (BufferedIndexOutput), so that calls
-      // to getFilePointer will return the correct pointer.
-      // Perhaps a specific method is better?
-      super.seek(out.position());
-    }
     
     @Override
     public void close() throws IOException {

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=995376&r1=995375&r2=995376&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java Thu Sep
 9 10:50:15 2010
@@ -5134,8 +5134,7 @@ public class TestIndexWriter extends Luc
   }
 
   public void testRandomStoredFields() throws IOException {
-    File index = _TestUtil.getTempDir("lucenerandfields");
-    Directory dir = FSDirectory.open(index);
+    Directory dir = newDirectory(random);
     Random rand = random;
     RandomIndexWriter w = new RandomIndexWriter(rand, dir, newIndexWriterConfig(rand, TEST_VERSION_CURRENT,
new MockAnalyzer()).setMaxBufferedDocs(_TestUtil.nextInt(rand, 5, 20)));
     //w.w.setInfoStream(System.out);
@@ -5221,7 +5220,6 @@ public class TestIndexWriter extends Luc
     }
     w.close();
     dir.close();
-    _TestUtil.rmDir(index);
   }
 
   private static class FailTwiceDuringMerge extends MockDirectoryWrapper.Failure {



Mime
View raw message