LUCENE-3327: fix AIOOBE in test case when verbose is true

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1148968 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-07-20 23:07:38 +00:00
parent 3822c0e4cc
commit 82d74a2e86
2 changed files with 16 additions and 5 deletions

View File

@ -559,6 +559,11 @@ Optimizations
greatly reduce RAM required during building, and CPU consumed, at
the cost of a somewhat larger FST. (Mike McCandless)
Test Cases
* LUCENE-3327: Fix AIOOBE when TestFSTs is run with
-Dtests.verbose=true (James Dyer via Mike McCandless)
======================= Lucene 3.3.0 =======================
Changes in backwards compatibility policy

View File

@ -830,7 +830,7 @@ public class TestFSTs extends LuceneTestCase {
final IntsRef prefix = ent.getKey();
final CountMinOutput<T> cmo = ent.getValue();
if (VERBOSE) {
System.out.println(" term=" + inputToString(inputMode, prefix) + " count=" + cmo.count + " isLeaf=" + cmo.isLeaf + " output=" + outputs.outputToString(cmo.output) + " isFinal=" + cmo.isFinal);
System.out.println(" term prefix=" + inputToString(inputMode, prefix, false) + " count=" + cmo.count + " isLeaf=" + cmo.isLeaf + " output=" + outputs.outputToString(cmo.output) + " isFinal=" + cmo.isFinal);
}
final boolean keep;
if (prune1 > 0) {
@ -897,7 +897,7 @@ public class TestFSTs extends LuceneTestCase {
IntsRefFSTEnum.InputOutput<T> current;
while((current = fstEnum.next()) != null) {
if (VERBOSE) {
System.out.println(" fstEnum.next term=" + inputToString(inputMode, current.input) + " output=" + outputs.outputToString(current.output));
System.out.println(" fstEnum.next prefix=" + inputToString(inputMode, current.input, false) + " output=" + outputs.outputToString(current.output));
}
final CountMinOutput cmo = prefixes.get(current.input);
assertNotNull(cmo);
@ -920,7 +920,7 @@ public class TestFSTs extends LuceneTestCase {
final CountMinOutput<T> cmo = ent.getValue();
final T output = run(fst, ent.getKey(), stopNode);
if (VERBOSE) {
System.out.println("TEST: verify term=" + inputToString(inputMode, ent.getKey()) + " output=" + outputs.outputToString(cmo.output));
System.out.println("TEST: verify prefix=" + inputToString(inputMode, ent.getKey(), false) + " output=" + outputs.outputToString(cmo.output));
}
// if (cmo.isFinal && !cmo.isLeaf) {
if (cmo.isFinal) {
@ -982,9 +982,15 @@ public class TestFSTs extends LuceneTestCase {
public void testBigSet() throws IOException {
testRandomWords(_TestUtil.nextInt(random, 50000, 60000), 1);
}
private static String inputToString(int inputMode, IntsRef term) {
if (inputMode == 0) {
return inputToString(inputMode, term, true);
}
private static String inputToString(int inputMode, IntsRef term, boolean isValidUnicode) {
if (!isValidUnicode) {
return term.toString();
} else if (inputMode == 0) {
// utf8
return toBytesRef(term).utf8ToString() + " " + term;
} else {