lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1383911 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/store/ lucene/core/src/test/org/apache/lucene/store/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/store/
Date Wed, 12 Sep 2012 12:29:29 GMT
Author: rmuir
Date: Wed Sep 12 12:29:29 2012
New Revision: 1383911

URL: http://svn.apache.org/viewvc?rev=1383911&view=rev
Log:
LUCENE-4377: Remove IndexInput.copyBytes(IndexOutput, long)

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/IndexInput.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestCopyBytes.java
    lucene/dev/branches/branch_4x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Wed Sep 12 12:29:29 2012
@@ -89,6 +89,10 @@ API Changes
   not be overriden by subclasses: per-stream initialization should happen
   in reset().  (Robert Muir)
 
+* LUCENE-4377: Remove IndexInput.copyBytes(IndexOutput, long). 
+  Use DataOutput.copyBytes(DataInput, long) instead.
+  (Mike McCandless, Robert Muir)
+
 Bug Fixes
 
 * LUCENE-4297: BooleanScorer2 would multiply the coord() factor

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java
Wed Sep 12 12:29:29 2012
@@ -338,18 +338,6 @@ public abstract class BufferedIndexInput
     return toCopy;
   }
   
-  @Override
-  public void copyBytes(IndexOutput out, long numBytes) throws IOException {
-    assert numBytes >= 0: "numBytes=" + numBytes;
-
-    while (numBytes > 0) {
-      if (bufferLength == bufferPosition) {
-        refill();
-      }
-      numBytes -= flushBuffer(out, numBytes);
-    }
-  }
-  
   /**
    * Returns default buffer sizes for the given {@link IOContext}
    */

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java
Wed Sep 12 12:29:29 2012
@@ -197,7 +197,7 @@ public abstract class Directory implemen
     try {
       os = to.createOutput(dest, context);
       is = openInput(src, context);
-      is.copyBytes(os, is.length());
+      os.copyBytes(is, is.length());
     } catch (IOException ioe) {
       priorException = ioe;
     } finally {
@@ -327,22 +327,5 @@ public abstract class Directory implemen
     public long length() {
       return length;
     }
-    
-    @Override
-    public void copyBytes(IndexOutput out, long numBytes) throws IOException {
-      // Copy first whatever is in the buffer
-      numBytes -= flushBuffer(out, numBytes);
-      
-      // If there are more bytes left to copy, delegate the copy task to the
-      // base IndexInput, in case it can do an optimized copy.
-      if (numBytes > 0) {
-        long start = getFilePointer();
-        if (start + numBytes > length) {
-          throw new EOFException("read past EOF: " + this);
-        }
-        base.seek(fileOffset + start);
-        base.copyBytes(out, numBytes);
-      }
-    }
   }
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/IndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/IndexInput.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/IndexInput.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/IndexInput.java
Wed Sep 12 12:29:29 2012
@@ -66,30 +66,6 @@ public abstract class IndexInput extends
   /** The number of bytes in the file. */
   public abstract long length();
 
-  /**
-   * Copies <code>numBytes</code> bytes to the given {@link IndexOutput}.
-   * <p>
-   * <b>NOTE:</b> this method uses an intermediate buffer to copy the bytes.
-   * Consider overriding it in your implementation, if you can make a better,
-   * optimized copy.
-   * <p>
-   * <b>NOTE</b> ensure that there are enough bytes in the input to copy to
-   * output. Otherwise, different exceptions may be thrown, depending on the
-   * implementation.
-   */
-  public void copyBytes(IndexOutput out, long numBytes) throws IOException {
-    assert numBytes >= 0: "numBytes=" + numBytes;
-
-    byte copyBuf[] = new byte[BufferedIndexInput.BUFFER_SIZE];
-
-    while (numBytes > 0) {
-      final int toCopy = (int) (numBytes > copyBuf.length ? copyBuf.length : numBytes);
-      readBytes(copyBuf, 0, toCopy);
-      out.writeBytes(copyBuf, 0, toCopy);
-      numBytes -= toCopy;
-    }
-  }
-
   @Override
   public String toString() {
     return resourceDescription;

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
Wed Sep 12 12:29:29 2012
@@ -300,7 +300,7 @@ public class NRTCachingDirectory extends
       IndexInput in = null;
       try {
         in = cache.openInput(fileName, context);
-        in.copyBytes(out, in.length());
+        out.copyBytes(in, in.length());
       } finally {
         IOUtils.close(in, out);
       }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
Wed Sep 12 12:29:29 2012
@@ -106,27 +106,6 @@ public class RAMInputStream extends Inde
   }
 
   @Override
-  public void copyBytes(IndexOutput out, long numBytes) throws IOException {
-    assert numBytes >= 0: "numBytes=" + numBytes;
-    
-    long left = numBytes;
-    while (left > 0) {
-      if (bufferPosition == bufferLength) {
-        ++currentBufferIndex;
-        switchCurrentBuffer(true);
-      }
-      
-      final int bytesInBuffer = bufferLength - bufferPosition;
-      final int toCopy = (int) (bytesInBuffer < left ? bytesInBuffer : left);
-      out.writeBytes(currentBuffer, bufferPosition, toCopy);
-      bufferPosition += toCopy;
-      left -= toCopy;
-    }
-    
-    assert left == 0: "Insufficient bytes to copy: numBytes=" + numBytes + " copied=" + (numBytes
- left);
-  }
-  
-  @Override
   public long getFilePointer() {
     return currentBufferIndex < 0 ? 0 : bufferStart + bufferPosition;
   }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/RAMOutputStream.java
Wed Sep 12 12:29:29 2012
@@ -178,27 +178,5 @@ public class RAMOutputStream extends Ind
   /** Returns byte usage of all buffers. */
   public long sizeInBytes() {
     return (long) file.numBuffers() * (long) BUFFER_SIZE;
-  }
-  
-  @Override
-  public void copyBytes(DataInput input, long numBytes) throws IOException {
-    assert numBytes >= 0: "numBytes=" + numBytes;
-
-    while (numBytes > 0) {
-      if (bufferPosition == bufferLength) {
-        currentBufferIndex++;
-        switchCurrentBuffer();
-      }
-
-      int toCopy = currentBuffer.length - bufferPosition;
-      if (numBytes < toCopy) {
-        toCopy = (int) numBytes;
-      }
-      input.readBytes(currentBuffer, bufferPosition, toCopy, false);
-      numBytes -= toCopy;
-      bufferPosition += toCopy;
-    }
-
-  }
-  
+  }  
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
Wed Sep 12 12:29:29 2012
@@ -213,12 +213,5 @@ public class SimpleFSDirectory extends F
     boolean isFDValid() throws IOException {
       return file.getFD().valid();
     }
-    
-    @Override
-    public void copyBytes(IndexOutput out, long numBytes) throws IOException {
-      numBytes -= flushBuffer(out, numBytes);
-      // If out is FSIndexOutput, the copy will be optimized
-      out.copyBytes(this, numBytes);
-    }
   }
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestCopyBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestCopyBytes.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestCopyBytes.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestCopyBytes.java
Wed Sep 12 12:29:29 2012
@@ -121,7 +121,7 @@ public class TestCopyBytes extends Lucen
     IndexInput input = d.openInput("data", IOContext.DEFAULT);
     IndexOutput outputHeader = d.createOutput("header", IOContext.DEFAULT);
     // copy our 100-byte header
-    input.copyBytes(outputHeader, 100);
+    outputHeader.copyBytes(input, 100);
     outputHeader.close();
     
     // now make N copies of the remaining bytes
@@ -163,7 +163,7 @@ public class TestCopyBytes extends Lucen
     @Override
     public void run() {
       try {
-        src.copyBytes(dst, src.length()-100);
+        dst.copyBytes(src, src.length()-100);
         dst.close();
       } catch (IOException ex) {
         throw new RuntimeException(ex);

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java?rev=1383911&r1=1383910&r2=1383911&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java
Wed Sep 12 12:29:29 2012
@@ -119,12 +119,6 @@ public class MockIndexInputWrapper exten
   }
 
   @Override
-  public void copyBytes(IndexOutput out, long numBytes) throws IOException {
-    ensureOpen();
-    delegate.copyBytes(out, numBytes);
-  }
-
-  @Override
   public void readBytes(byte[] b, int offset, int len, boolean useBuffer)
       throws IOException {
     ensureOpen();



Mime
View raw message