You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by cu...@apache.org on 2006/03/02 21:16:52 UTC
svn commit: r382499 - in /lucene/java/trunk/src:
java/org/apache/lucene/store/BufferedIndexOutput.java
test/org/apache/lucene/index/TestCompoundFile.java
Author: cutting
Date: Thu Mar 2 12:16:49 2006
New Revision: 382499
URL: http://svn.apache.org/viewcvs?rev=382499&view=rev
Log:
Patch for LUCENE-511.
Modified:
lucene/java/trunk/src/java/org/apache/lucene/store/BufferedIndexOutput.java
lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java
Modified: lucene/java/trunk/src/java/org/apache/lucene/store/BufferedIndexOutput.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/store/BufferedIndexOutput.java?rev=382499&r1=382498&r2=382499&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/BufferedIndexOutput.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/BufferedIndexOutput.java Thu Mar 2 12:16:49 2006
@@ -58,6 +58,7 @@
flush();
// and write data at once
flushBuffer(b, length);
+ bufferStart += length;
} else {
// we fill/flush the buffer (until the input is written)
int pos = 0; // position in the input data
Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java?rev=382499&r1=382498&r2=382499&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java Thu Mar 2 12:16:49 2006
@@ -622,4 +622,26 @@
is.close();
cr.close();
}
+
+ /** This test that writes larger than the size of the buffer output
+ * will correctly increment the file pointer.
+ */
+ public void testLargeWrites() throws IOException {
+ IndexOutput os = dir.createOutput("testBufferStart.txt");
+
+ byte[] largeBuf = new byte[2048];
+ for (int i=0; i<largeBuf.length; i++) {
+ largeBuf[i] = (byte) (Math.random() * 256);
+ }
+
+ long currentPos = os.getFilePointer();
+ os.writeBytes(largeBuf, largeBuf.length);
+
+ try {
+ assertEquals(currentPos + largeBuf.length, os.getFilePointer());
+ } finally {
+ os.close();
+ }
+
+ }
}