lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1587685 - in /lucene/dev/trunk: ./ lucene/ lucene/core/ lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java
Date Tue, 15 Apr 2014 18:55:45 GMT
Author: mikemccand
Date: Tue Apr 15 18:55:44 2014
New Revision: 1587685

URL: http://svn.apache.org/r1587685
Log:
LUCENE-5604: switch these 'many terms' tests back to previous adversarial hash conflict case

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/lucene/   (props changed)
    lucene/dev/trunk/lucene/core/   (props changed)
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java?rev=1587685&r1=1587684&r2=1587685&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java
(original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java
Tue Apr 15 18:55:44 2014
@@ -25,11 +25,10 @@ import org.apache.lucene.document.Sorted
 import org.apache.lucene.store.BaseDirectoryWrapper;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.TimeUnits;
 import org.junit.Ignore;
-
 import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
 
 @TimeoutSuite(millis = 80 * TimeUnits.HOUR)
@@ -93,7 +92,6 @@ public class Test2BSortedDocValues exten
   }
   
   // indexes Integer.MAX_VALUE docs with a fixed binary field
-  // TODO: must use random.nextBytes (like Test2BTerms) to avoid BytesRefHash probing issues
   public void test2BOrds() throws Exception {
     BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BOrds"));
     if (dir instanceof MockDirectoryWrapper) {
@@ -118,7 +116,10 @@ public class Test2BSortedDocValues exten
     Random random = new Random(seed);
     
     for (int i = 0; i < Integer.MAX_VALUE; i++) {
-      random.nextBytes(bytes);
+      bytes[0] = (byte)(i >> 24);
+      bytes[1] = (byte)(i >> 16);
+      bytes[2] = (byte)(i >> 8);
+      bytes[3] = (byte) i;
       w.addDocument(doc);
       if (i % 100000 == 0) {
         System.out.println("indexed: " + i);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java?rev=1587685&r1=1587684&r2=1587685&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java Tue Apr
15 18:55:44 2014
@@ -44,7 +44,7 @@ import java.util.Random;
 @SuppressCodecs({ "SimpleText", "Memory", "Direct" })
 public class Test2BTerms extends LuceneTestCase {
 
-  private final static int TOKEN_LEN = 10;
+  private final static int TOKEN_LEN = 5;
 
   private final static BytesRef bytes = new BytesRef(TOKEN_LEN);
 
@@ -54,6 +54,7 @@ public class Test2BTerms extends LuceneT
     private int tokenCount;
     public final List<BytesRef> savedTerms = new ArrayList<>();
     private int nextSave;
+    private long termCounter;
     private final Random random;
 
     public MyTokenStream(Random random, int tokensPerDoc) {
@@ -67,10 +68,16 @@ public class Test2BTerms extends LuceneT
     
     @Override
     public boolean incrementToken() {
+      clearAttributes();
       if (tokenCount >= tokensPerDoc) {
         return false;
       }
-      random.nextBytes(bytes.bytes);
+      int shift = 32;
+      for(int i=0;i<5;i++) {
+        bytes.bytes[i] = (byte) ((termCounter >> shift) & 0xFF);
+        shift -= 8;
+      }
+      termCounter++;
       tokenCount++;
       if (--nextSave == 0) {
         savedTerms.add(BytesRef.deepCopyOf(bytes));



Mime
View raw message