lucene4/RandomInts-oe.patch
2020-08-19 14:23:46 +08:00

383 lines
21 KiB
Diff

diff -urN lucene-4.10.4/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java lucene-4.10.4.new/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java
--- lucene-4.10.4/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java 2014-02-19 13:42:17.000000000 +0000
+++ lucene-4.10.4.new/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java 2020-06-09 01:50:25.176680050 +0000
@@ -26,7 +26,7 @@
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
public abstract class AbstractTestCompressionMode extends LuceneTestCase {
@@ -45,7 +45,7 @@
static byte[] randomArray(int length, int max) {
final byte[] arr = new byte[length];
for (int i = 0; i < arr.length; ++i) {
- arr[i] = (byte) RandomInts.randomIntBetween(random(), 0, max);
+ arr[i] = (byte) RandomNumbers.randomIntBetween(random(), 0, max);
}
return arr;
}
@@ -130,7 +130,7 @@
}
public void testIncompressible() throws IOException {
- final byte[] decompressed = new byte[RandomInts.randomIntBetween(random(), 20, 256)];
+ final byte[] decompressed = new byte[RandomNumbers.randomIntBetween(random(), 20, 256)];
for (int i = 0; i < decompressed.length; ++i) {
decompressed[i] = (byte) i;
}
diff -urN lucene-4.10.4/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestLZ4CompressionMode.java lucene-4.10.4.new/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestLZ4CompressionMode.java
--- lucene-4.10.4/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestLZ4CompressionMode.java 2014-03-31 12:29:44.000000000 +0000
+++ lucene-4.10.4.new/core/src/test/org/apache/lucene/codecs/compressing/AbstractTestLZ4CompressionMode.java 2020-06-09 01:50:25.172679991 +0000
@@ -20,7 +20,7 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
public abstract class AbstractTestLZ4CompressionMode extends AbstractTestCompressionMode {
@@ -88,7 +88,7 @@
public void testLongMatchs() throws IOException {
// match length >= 20
- final byte[] decompressed = new byte[RandomInts.randomIntBetween(random(), 300, 1024)];
+ final byte[] decompressed = new byte[RandomNumbers.randomIntBetween(random(), 300, 1024)];
for (int i = 0; i < decompressed.length; ++i) {
decompressed[i] = (byte) i;
}
@@ -97,10 +97,10 @@
public void testLongLiterals() throws IOException {
// long literals (length >= 16) which are not the last literals
- final byte[] decompressed = randomArray(RandomInts.randomIntBetween(random(), 400, 1024), 256);
+ final byte[] decompressed = randomArray(RandomNumbers.randomIntBetween(random(), 400, 1024), 256);
final int matchRef = random().nextInt(30);
- final int matchOff = RandomInts.randomIntBetween(random(), decompressed.length - 40, decompressed.length - 20);
- final int matchLength = RandomInts.randomIntBetween(random(), 4, 10);
+ final int matchOff = RandomNumbers.randomIntBetween(random(), decompressed.length - 40, decompressed.length - 20);
+ final int matchLength = RandomNumbers.randomIntBetween(random(), 4, 10);
System.arraycopy(decompressed, matchRef, decompressed, matchOff, matchLength);
test(decompressed);
}
diff -urN lucene-4.10.4/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java lucene-4.10.4.new/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
--- lucene-4.10.4/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java 2014-09-19 13:24:09.000000000 +0000
+++ lucene-4.10.4.new/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java 2020-06-09 01:50:25.176680050 +0000
@@ -34,7 +34,7 @@
import org.junit.Test;
import com.carrotsearch.randomizedtesting.annotations.Repeat;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
@Repeat(iterations=5) // give it a chance to test various compression modes with different chunk sizes
public class TestCompressingStoredFieldsFormat extends BaseStoredFieldsFormatTestCase {
@@ -52,7 +52,7 @@
((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
}
IndexWriterConfig iwConf = newIndexWriterConfig(new MockAnalyzer(random()));
- iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
+ iwConf.setMaxBufferedDocs(RandomNumbers.randomIntBetween(random(), 2, 30));
iwConf.setCodec(CompressingCodec.randomInstance(random()));
// disable CFS because this test checks file names
iwConf.setMergePolicy(newLogMergePolicy(false));
diff -urN lucene-4.10.4/core/src/test/org/apache/lucene/codecs/lucene41/TestForUtil.java lucene-4.10.4.new/core/src/test/org/apache/lucene/codecs/lucene41/TestForUtil.java
--- lucene-4.10.4/core/src/test/org/apache/lucene/codecs/lucene41/TestForUtil.java 2012-10-12 02:00:19.000000000 +0000
+++ lucene-4.10.4.new/core/src/test/org/apache/lucene/codecs/lucene41/TestForUtil.java 2020-06-09 01:50:25.172679991 +0000
@@ -32,24 +32,24 @@
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.packed.PackedInts;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
public class TestForUtil extends LuceneTestCase {
public void testEncodeDecode() throws IOException {
- final int iterations = RandomInts.randomIntBetween(random(), 1, 1000);
+ final int iterations = RandomNumbers.randomIntBetween(random(), 1, 1000);
final float acceptableOverheadRatio = random().nextFloat();
final int[] values = new int[(iterations - 1) * BLOCK_SIZE + ForUtil.MAX_DATA_SIZE];
for (int i = 0; i < iterations; ++i) {
final int bpv = random().nextInt(32);
if (bpv == 0) {
- final int value = RandomInts.randomIntBetween(random(), 0, Integer.MAX_VALUE);
+ final int value = RandomNumbers.randomIntBetween(random(), 0, Integer.MAX_VALUE);
for (int j = 0; j < BLOCK_SIZE; ++j) {
values[i * BLOCK_SIZE + j] = value;
}
} else {
for (int j = 0; j < BLOCK_SIZE; ++j) {
- values[i * BLOCK_SIZE + j] = RandomInts.randomIntBetween(random(),
+ values[i * BLOCK_SIZE + j] = RandomNumbers.randomIntBetween(random(),
0, (int) PackedInts.maxValue(bpv));
}
}
diff -urN lucene-4.10.4/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java lucene-4.10.4.new/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java
--- lucene-4.10.4/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java 2014-04-05 10:09:42.000000000 +0000
+++ lucene-4.10.4.new/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java 2020-06-09 01:50:25.176680050 +0000
@@ -31,7 +31,7 @@
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
/**
* This test creates an index with one segment that is a little larger than 4GB.
@@ -64,7 +64,7 @@
ft.setIndexed(false);
ft.setStored(true);
ft.freeze();
- final int valueLength = RandomInts.randomIntBetween(random(), 1 << 13, 1 << 20);
+ final int valueLength = RandomNumbers.randomIntBetween(random(), 1 << 13, 1 << 20);
final byte[] value = new byte[valueLength];
for (int i = 0; i < valueLength; ++i) {
// random so that even compressing codecs can't compress it
diff -urN lucene-4.10.4/core/src/test/org/apache/lucene/util/automaton/TestOperations.java lucene-4.10.4.new/core/src/test/org/apache/lucene/util/automaton/TestOperations.java
--- lucene-4.10.4/core/src/test/org/apache/lucene/util/automaton/TestOperations.java 2014-11-04 22:29:27.000000000 +0000
+++ lucene-4.10.4.new/core/src/test/org/apache/lucene/util/automaton/TestOperations.java 2020-06-09 01:50:25.176680050 +0000
@@ -22,7 +22,7 @@
import org.apache.lucene.util.*;
import org.apache.lucene.util.fst.Util;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
import static org.apache.lucene.util.automaton.Operations.DEFAULT_MAX_DETERMINIZED_STATES;
@@ -30,7 +30,7 @@
/** Test string union. */
public void testStringUnion() {
List<BytesRef> strings = new ArrayList<>();
- for (int i = RandomInts.randomIntBetween(random(), 0, 1000); --i >= 0;) {
+ for (int i = RandomNumbers.randomIntBetween(random(), 0, 1000); --i >= 0;) {
strings.add(new BytesRef(TestUtil.randomUnicodeString(random())));
}
diff -urN lucene-4.10.4/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java lucene-4.10.4.new/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java
--- lucene-4.10.4/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java 2014-07-01 14:59:52.000000000 +0000
+++ lucene-4.10.4.new/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java 2020-06-09 01:50:25.180680109 +0000
@@ -43,7 +43,7 @@
import org.apache.lucene.util.packed.PackedInts.Reader;
import org.junit.Ignore;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
@Slow
public class TestPackedInts extends LuceneTestCase {
@@ -51,7 +51,7 @@
public void testByteCount() {
final int iters = atLeast(3);
for (int i = 0; i < iters; ++i) {
- final int valueCount = RandomInts.randomIntBetween(random(), 1, Integer.MAX_VALUE);
+ final int valueCount = RandomNumbers.randomIntBetween(random(), 1, Integer.MAX_VALUE);
for (PackedInts.Format format : PackedInts.Format.values()) {
for (int bpv = 1; bpv <= 64; ++bpv) {
final long byteCount = format.byteCount(PackedInts.VERSION_CURRENT, valueCount, bpv);
@@ -208,7 +208,7 @@
public void testEndPointer() throws IOException {
final Directory dir = newDirectory();
- final int valueCount = RandomInts.randomIntBetween(random(), 1, 1000);
+ final int valueCount = RandomNumbers.randomIntBetween(random(), 1, 1000);
final IndexOutput out = dir.createOutput("tests.bin", newIOContext(random()));
for (int i = 0; i < valueCount; ++i) {
out.writeLong(0);
@@ -226,7 +226,7 @@
// test iterator
in.seek(0L);
- final PackedInts.ReaderIterator it = PackedInts.getReaderIteratorNoHeader(in, format, version, valueCount, bpv, RandomInts.randomIntBetween(random(), 1, 1<<16));
+ final PackedInts.ReaderIterator it = PackedInts.getReaderIteratorNoHeader(in, format, version, valueCount, bpv, RandomNumbers.randomIntBetween(random(), 1, 1<<16));
for (int i = 0; i < valueCount; ++i) {
it.next();
}
@@ -983,9 +983,9 @@
}
public void testPackedLongValues() {
- final long[] arr = new long[RandomInts.randomIntBetween(random(), 1, 1000000)];
+ final long[] arr = new long[RandomNumbers.randomIntBetween(random(), 1, 1000000)];
float[] ratioOptions = new float[]{PackedInts.DEFAULT, PackedInts.COMPACT, PackedInts.FAST};
- for (int bpv : new int[]{0, 1, 63, 64, RandomInts.randomIntBetween(random(), 2, 62)}) {
+ for (int bpv : new int[]{0, 1, 63, 64, RandomNumbers.randomIntBetween(random(), 2, 62)}) {
for (DataType dataType : Arrays.asList(DataType.DELTA_PACKED)) {
final int pageSize = 1 << TestUtil.nextInt(random(), 6, 20);
float acceptableOverheadRatio = ratioOptions[TestUtil.nextInt(random(), 0, ratioOptions.length - 1)];
@@ -1068,7 +1068,7 @@
final int[] bitsPerValues = new int[longs.length];
final boolean[] skip = new boolean[longs.length];
for (int i = 0; i < longs.length; ++i) {
- final int bpv = RandomInts.randomIntBetween(random(), 1, 64);
+ final int bpv = RandomNumbers.randomIntBetween(random(), 1, 64);
bitsPerValues[i] = random().nextBoolean() ? bpv : TestUtil.nextInt(random(), bpv, 64);
if (bpv == 64) {
longs[i] = random().nextLong();
diff -urN lucene-4.10.4/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java lucene-4.10.4.new/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java
--- lucene-4.10.4/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java 2014-08-14 09:15:35.000000000 +0000
+++ lucene-4.10.4.new/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java 2020-06-09 01:50:25.180680109 +0000
@@ -39,7 +39,7 @@
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.packed.PackedInts;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
@SuppressCodecs("Lucene3x")
public class TestDocValuesFieldSources extends LuceneTestCase {
@@ -81,7 +81,7 @@
f.setBytesValue(new BytesRef((String) vals[i]));
break;
case NUMERIC:
- final int bitsPerValue = RandomInts.randomIntBetween(random(), 1, 31); // keep it an int
+ final int bitsPerValue = RandomNumbers.randomIntBetween(random(), 1, 31); // keep it an int
vals[i] = (long) random().nextInt((int) PackedInts.maxValue(bitsPerValue));
f.setLongValue((Long) vals[i]);
break;
diff -urN lucene-4.10.4/test-framework/src/java/org/apache/lucene/codecs/compressing/CompressingCodec.java lucene-4.10.4.new/test-framework/src/java/org/apache/lucene/codecs/compressing/CompressingCodec.java
--- lucene-4.10.4/test-framework/src/java/org/apache/lucene/codecs/compressing/CompressingCodec.java 2014-08-14 16:15:33.000000000 +0000
+++ lucene-4.10.4.new/test-framework/src/java/org/apache/lucene/codecs/compressing/CompressingCodec.java 2020-06-09 01:50:25.180680109 +0000
@@ -25,7 +25,7 @@
import org.apache.lucene.codecs.compressing.dummy.DummyCompressingCodec;
import org.apache.lucene.codecs.lucene410.Lucene410Codec;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
/**
* A codec that uses {@link CompressingStoredFieldsFormat} for its stored
@@ -56,14 +56,14 @@
* suffix
*/
public static CompressingCodec randomInstance(Random random) {
- return randomInstance(random, RandomInts.randomIntBetween(random, 1, 500), false);
+ return randomInstance(random, RandomNumbers.randomIntBetween(random, 1, 500), false);
}
/**
* Creates a random {@link CompressingCodec} that is using a segment suffix
*/
public static CompressingCodec randomInstance(Random random, boolean withSegmentSuffix) {
- return randomInstance(random, RandomInts.randomIntBetween(random, 1, 500), withSegmentSuffix);
+ return randomInstance(random, RandomNumbers.randomIntBetween(random, 1, 500), withSegmentSuffix);
}
private final CompressingStoredFieldsFormat storedFieldsFormat;
diff -urN lucene-4.10.4/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java lucene-4.10.4.new/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java
--- lucene-4.10.4/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java 2014-08-14 16:15:33.000000000 +0000
+++ lucene-4.10.4.new/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java 2020-06-09 01:50:25.184680168 +0000
@@ -59,7 +59,7 @@
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.TestUtil;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
/**
@@ -330,7 +330,7 @@
public void testReadSkip() throws IOException {
Directory dir = newDirectory();
IndexWriterConfig iwConf = newIndexWriterConfig(new MockAnalyzer(random()));
- iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
+ iwConf.setMaxBufferedDocs(RandomNumbers.randomIntBetween(random(), 2, 30));
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
FieldType ft = new FieldType();
@@ -383,7 +383,7 @@
public void testEmptyDocs() throws IOException {
Directory dir = newDirectory();
IndexWriterConfig iwConf = newIndexWriterConfig(new MockAnalyzer(random()));
- iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
+ iwConf.setMaxBufferedDocs(RandomNumbers.randomIntBetween(random(), 2, 30));
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
// make sure that the fact that documents might be empty is not a problem
@@ -408,7 +408,7 @@
public void testConcurrentReads() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwConf = newIndexWriterConfig(new MockAnalyzer(random()));
- iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
+ iwConf.setMaxBufferedDocs(RandomNumbers.randomIntBetween(random(), 2, 30));
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
// make sure the readers are properly cloned
@@ -496,15 +496,15 @@
}
Directory dir = newDirectory();
IndexWriterConfig iwConf = newIndexWriterConfig(new MockAnalyzer(random()));
- iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
+ iwConf.setMaxBufferedDocs(RandomNumbers.randomIntBetween(random(), 2, 30));
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
final int docCount = atLeast(200);
final byte[][][] data = new byte [docCount][][];
for (int i = 0; i < docCount; ++i) {
final int fieldCount = rarely()
- ? RandomInts.randomIntBetween(random(), 1, 500)
- : RandomInts.randomIntBetween(random(), 1, 5);
+ ? RandomNumbers.randomIntBetween(random(), 1, 500)
+ : RandomNumbers.randomIntBetween(random(), 1, 5);
data[i] = new byte[fieldCount][];
for (int j = 0; j < fieldCount; ++j) {
final int length = rarely()
@@ -589,7 +589,7 @@
// so if we get NRTCachingDir+SimpleText, we make massive stored fields and OOM (LUCENE-4484)
Directory dir = new MockDirectoryWrapper(random(), new MMapDirectory(createTempDir("testBigDocuments")));
IndexWriterConfig iwConf = newIndexWriterConfig(new MockAnalyzer(random()));
- iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
+ iwConf.setMaxBufferedDocs(RandomNumbers.randomIntBetween(random(), 2, 30));
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
if (dir instanceof MockDirectoryWrapper) {
@@ -609,12 +609,12 @@
onlyStored.setIndexed(false);
final Field smallField = new Field("fld", randomByteArray(random().nextInt(10), 256), onlyStored);
- final int numFields = RandomInts.randomIntBetween(random(), 500000, 1000000);
+ final int numFields = RandomNumbers.randomIntBetween(random(), 500000, 1000000);
for (int i = 0; i < numFields; ++i) {
bigDoc1.add(smallField);
}
- final Field bigField = new Field("fld", randomByteArray(RandomInts.randomIntBetween(random(), 1000000, 5000000), 2), onlyStored);
+ final Field bigField = new Field("fld", randomByteArray(RandomNumbers.randomIntBetween(random(), 1000000, 5000000), 2), onlyStored);
bigDoc2.add(bigField);
final int numDocs = atLeast(5);
diff -urN lucene-4.10.4/test-framework/src/java/org/apache/lucene/util/TestUtil.java lucene-4.10.4.new/test-framework/src/java/org/apache/lucene/util/TestUtil.java
--- lucene-4.10.4/test-framework/src/java/org/apache/lucene/util/TestUtil.java 2014-08-14 16:15:33.000000000 +0000
+++ lucene-4.10.4.new/test-framework/src/java/org/apache/lucene/util/TestUtil.java 2020-06-09 01:50:25.188680226 +0000
@@ -88,7 +88,7 @@
import org.apache.lucene.store.Directory;
import org.junit.Assert;
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
/**
@@ -243,7 +243,7 @@
/** start and end are BOTH inclusive */
public static int nextInt(Random r, int start, int end) {
- return RandomInts.randomIntBetween(r, start, end);
+ return RandomNumbers.randomIntBetween(r, start, end);
}
/** start and end are BOTH inclusive */
@@ -384,7 +384,7 @@
final StringBuilder regexp = new StringBuilder(maxLength);
for (int i = nextInt(r, 0, maxLength); i > 0; i--) {
if (r.nextBoolean()) {
- regexp.append((char) RandomInts.randomIntBetween(r, 'a', 'z'));
+ regexp.append((char) RandomNumbers.randomIntBetween(r, 'a', 'z'));
} else {
regexp.append(RandomPicks.randomFrom(r, ops));
}