lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1442124 - /lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java
Date Mon, 04 Feb 2013 14:09:34 GMT
Author: rmuir
Date: Mon Feb  4 14:09:34 2013
New Revision: 1442124

URL: http://svn.apache.org/viewvc?rev=1442124&view=rev
Log:
fix nocommit

Modified:
    lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java

Modified: lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java?rev=1442124&r1=1442123&r2=1442124&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java
Mon Feb  4 14:09:34 2013
@@ -17,51 +17,59 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
-import java.util.Arrays;
 import java.util.Random;
 
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.store.MockDirectoryWrapper;
 import org.junit.Ignore;
 
 @Ignore("You must increase heap to > 2 G to run this")
-// nocommit: write this test in some other way (not indexinput/output)
 public class Test2BPagedBytes extends LuceneTestCase {
-/*
+
   public void test() throws Exception {
+    BaseDirectoryWrapper dir = newFSDirectory(_TestUtil.getTempDir("test2BPagedBytes"));
+    if (dir instanceof MockDirectoryWrapper) {
+      ((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
+    }
     PagedBytes pb = new PagedBytes(15);
-    PagedBytesDataOutput dataOutput = pb.getDataOutput();
+    IndexOutput dataOutput = dir.createOutput("foo", IOContext.DEFAULT);
     long netBytes = 0;
     long seed = random().nextLong();
     long lastFP = 0;
     Random r2 = new Random(seed);
     while(netBytes < 1.1*Integer.MAX_VALUE) {
-      int numBytes = _TestUtil.nextInt(r2, 1, 100000);
+      int numBytes = _TestUtil.nextInt(r2, 1, 32768);
       byte[] bytes = new byte[numBytes];
       r2.nextBytes(bytes);
       dataOutput.writeBytes(bytes, bytes.length);
-      long fp = dataOutput.getPosition();
+      long fp = dataOutput.getFilePointer();
       assert fp == lastFP + numBytes;
       lastFP = fp;
       netBytes += numBytes;
     }
-    pb.freeze(true);
+    dataOutput.close();
+    IndexInput input = dir.openInput("foo", IOContext.DEFAULT);
+    pb.copy(input, input.length());
+    input.close();
+    PagedBytes.Reader reader = pb.freeze(true);
 
-    PagedBytesDataInput dataInput = pb.getDataInput();
-    lastFP = 0;
     r2 = new Random(seed);
     netBytes = 0;
     while(netBytes < 1.1*Integer.MAX_VALUE) {
-      int numBytes = _TestUtil.nextInt(r2, 1, 100000);
+      int numBytes = _TestUtil.nextInt(r2, 1, 32768);
       byte[] bytes = new byte[numBytes];
       r2.nextBytes(bytes);
+      BytesRef expected = new BytesRef(bytes);
 
-      byte[] bytesIn = new byte[numBytes];
-      dataInput.readBytes(bytesIn, 0, numBytes);
-      assertTrue(Arrays.equals(bytes, bytesIn));
+      BytesRef actual = new BytesRef();
+      reader.fillSlice(actual, netBytes, numBytes);
+      assertEquals(expected, actual);
 
-      long fp = dataInput.getPosition();
-      assert fp == lastFP + numBytes;
-      lastFP = fp;
       netBytes += numBytes;
     }
-  } */
+    dir.close();
+  }
 }



Mime
View raw message