mirror of https://github.com/apache/lucene.git
LUCENE-9186: remove linefiledocs usage from BaseTokenStreamTestCase
This commit is contained in:
parent
4350efa932
commit
3bcc97c8eb
|
@ -45,7 +45,6 @@ import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.BytesRefBuilder;
|
import org.apache.lucene.util.BytesRefBuilder;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.IntsRef;
|
import org.apache.lucene.util.IntsRef;
|
||||||
import org.apache.lucene.util.LineFileDocs;
|
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.Rethrow;
|
import org.apache.lucene.util.Rethrow;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
@ -596,7 +595,6 @@ public abstract class BaseTokenStreamTestCase extends LuceneTestCase {
|
||||||
|
|
||||||
private static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean useCharFilter, boolean simple, boolean graphOffsetsAreCorrect, RandomIndexWriter iw) throws IOException {
|
private static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean useCharFilter, boolean simple, boolean graphOffsetsAreCorrect, RandomIndexWriter iw) throws IOException {
|
||||||
|
|
||||||
final LineFileDocs docs = new LineFileDocs(random);
|
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
Field field = null, currentField = null;
|
Field field = null, currentField = null;
|
||||||
StringReader bogus = new StringReader("");
|
StringReader bogus = new StringReader("");
|
||||||
|
@ -625,33 +623,8 @@ public abstract class BaseTokenStreamTestCase extends LuceneTestCase {
|
||||||
doc.add(currentField);
|
doc.add(currentField);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
String text;
|
String text = TestUtil.randomAnalysisString(random, maxWordLength, simple);
|
||||||
|
|
||||||
if (random.nextInt(10) == 7) {
|
|
||||||
// real data from linedocs
|
|
||||||
text = docs.nextDoc().get("body");
|
|
||||||
if (text.length() > maxWordLength) {
|
|
||||||
|
|
||||||
// Take a random slice from the text...:
|
|
||||||
int startPos = random.nextInt(text.length() - maxWordLength);
|
|
||||||
if (startPos > 0 && Character.isLowSurrogate(text.charAt(startPos))) {
|
|
||||||
// Take care not to split up a surrogate pair:
|
|
||||||
startPos--;
|
|
||||||
assert Character.isHighSurrogate(text.charAt(startPos));
|
|
||||||
}
|
|
||||||
int endPos = startPos + maxWordLength - 1;
|
|
||||||
if (Character.isHighSurrogate(text.charAt(endPos))) {
|
|
||||||
// Take care not to split up a surrogate pair:
|
|
||||||
endPos--;
|
|
||||||
}
|
|
||||||
text = text.substring(startPos, 1+endPos);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// synthetic
|
|
||||||
text = TestUtil.randomAnalysisString(random, maxWordLength, simple);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
checkAnalysisConsistency(random, a, useCharFilter, text, graphOffsetsAreCorrect, currentField);
|
checkAnalysisConsistency(random, a, useCharFilter, text, graphOffsetsAreCorrect, currentField);
|
||||||
|
@ -678,9 +651,6 @@ public abstract class BaseTokenStreamTestCase extends LuceneTestCase {
|
||||||
Rethrow.rethrow(t);
|
Rethrow.rethrow(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
IOUtils.closeWhileHandlingException(docs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String escape(String s) {
|
public static String escape(String s) {
|
||||||
|
|
Loading…
Reference in New Issue