Apache Solr open-source search software
LUCENE-5604: switch these 'many terms' tests back to previous adversarial hash conflict case
Michael McCandless9c2de17be096
diff --git a/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java b/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.javaindex 56584c986fc..c1b99572e86 100644--- a/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java+++ b/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java@@ -25,11 +25,10 @@ import org.apache.lucene.document.SortedDocValuesField;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 extends LuceneTestCase {}// indexes Integer.MAX_VALUE docs with a fixed binary field- // TODO: must use random.nextBytes (like Test2BTerms) to avoid BytesRefHash probing issuespublic void test2BOrds() throws Exception {BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BOrds"));if (dir instanceof MockDirectoryWrapper) {@@ -118,7 +116,10 @@ public class Test2BSortedDocValues extends LuceneTestCase {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);diff --git a/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java b/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.javaindex e528fcfb4e5..508cbabbead 100644--- a/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java+++ b/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java@@ -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 LuceneTestCase {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 LuceneTestCase {@Overridepublic 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));