Apache Lucene open-source search software
Adding -noverify and a little bit nicer output to TestFSTs. These are debugging/analysis utils that are not used anywhere, so I commit them without the patch.
Dawid Weissea6655a126e4
diff --git a/lucene/src/test/org/apache/lucene/util/automaton/fst/TestFSTs.java b/lucene/src/test/org/apache/lucene/util/automaton/fst/TestFSTs.javaindex 5f6c589a764..7e909a3f52e 100644--- a/lucene/src/test/org/apache/lucene/util/automaton/fst/TestFSTs.java+++ b/lucene/src/test/org/apache/lucene/util/automaton/fst/TestFSTs.java@@ -25,16 +25,7 @@ import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.io.Writer;-import java.util.ArrayList;-import java.util.Arrays;-import java.util.Collections;-import java.util.HashMap;-import java.util.HashSet;-import java.util.Iterator;-import java.util.List;-import java.util.Map;-import java.util.Random;-import java.util.Set;+import java.util.*;import org.apache.lucene.analysis.MockAnalyzer;import org.apache.lucene.document.Document;@@ -1098,7 +1089,7 @@ public class TestFSTs extends LuceneTestCase {protected abstract T getOutput(IntsRef input, int ord) throws IOException;- public void run(int limit) throws IOException {+ public void run(int limit, boolean verify) throws IOException {BufferedReader is = new BufferedReader(new InputStreamReader(new FileInputStream(wordsFileIn), "UTF-8"), 65536);try {final IntsRef intsRef = new IntsRef(10);@@ -1115,7 +1106,9 @@ public class TestFSTs extends LuceneTestCase {ord++;if (ord % 500000 == 0) {- System.out.println(((System.currentTimeMillis()-tStart)/1000.0) + "s: " + ord + "...");+ System.out.println(+ String.format(Locale.ENGLISH,+ "%6.2fs: %9d...", ((System.currentTimeMillis() - tStart) / 1000.0), ord));}if (ord >= limit) {break;@@ -1144,6 +1137,10 @@ public class TestFSTs extends LuceneTestCase {System.out.println("Saved FST to fst.bin.");+ if (!verify) {+ System.exit(0);+ }+System.out.println("\nNow verify...");is.close();@@ -1194,6 +1191,7 @@ public class TestFSTs extends LuceneTestCase {int inputMode = 0; // utf8boolean storeOrds = false;boolean storeDocFreqs = false;+ boolean verify = true;while(idx < args.length) {if (args[idx].equals("-prune")) {prune = Integer.valueOf(args[1+idx]);@@ -1215,6 +1213,9 @@ public class TestFSTs extends LuceneTestCase {if (args[idx].equals("-ords")) {storeOrds = true;}+ if (args[idx].equals("-noverify")) {+ verify = false;+ }idx++;}@@ -1235,7 +1236,7 @@ public class TestFSTs extends LuceneTestCase {return new PairOutputs.Pair<Long,Long>(o1.get(ord),o2.get(_TestUtil.nextInt(rand, 1, 5000)));}- }.run(limit);+ }.run(limit, verify);} else if (storeOrds) {// Store only ordsfinal PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton(true);@@ -1244,7 +1245,7 @@ public class TestFSTs extends LuceneTestCase {public Long getOutput(IntsRef input, int ord) {return outputs.get(ord);}- }.run(limit);+ }.run(limit, verify);} else if (storeDocFreqs) {// Store only docFreqfinal PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton(false);@@ -1257,7 +1258,7 @@ public class TestFSTs extends LuceneTestCase {}return outputs.get(_TestUtil.nextInt(rand, 1, 5000));}- }.run(limit);+ }.run(limit, verify);} else {// Store nothingfinal NoOutputs outputs = NoOutputs.getSingleton();@@ -1267,7 +1268,7 @@ public class TestFSTs extends LuceneTestCase {public Object getOutput(IntsRef input, int ord) {return NO_OUTPUT;}- }.run(limit);+ }.run(limit, verify);}}