mirror of https://github.com/apache/lucene.git
LUCENE-2764: switch existing tests to per-field API
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1036583 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
90323ccff5
commit
58f7005a8e
|
@ -133,7 +133,6 @@ public class CreateIndexTask extends PerfTask {
|
|||
|
||||
final String defaultCodec = config.get("default.codec", null);
|
||||
if (defaultCodec != null) {
|
||||
CodecProvider.setDefaultCodec(defaultCodec);
|
||||
CodecProvider.getDefault().setDefaultFieldCodec(defaultCodec);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.lucene.index.codecs.standard.StandardCodec;
|
|||
public class CodecProvider {
|
||||
private SegmentInfosWriter infosWriter = new DefaultSegmentInfosWriter();
|
||||
private SegmentInfosReader infosReader = new DefaultSegmentInfosReader();
|
||||
private String defaultFieldCodec = defaultCodec;
|
||||
private String defaultFieldCodec = "Standard";
|
||||
private final Map<String, String> perFieldMap = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
@ -47,7 +47,6 @@ public class CodecProvider {
|
|||
|
||||
private final Set<String> knownExtensions = new HashSet<String>();
|
||||
|
||||
private static String defaultCodec = "Standard";
|
||||
|
||||
public final static String[] CORE_CODECS = new String[] {"Standard", "Pulsing", "PreFlex", "SimpleText"};
|
||||
|
||||
|
@ -102,15 +101,6 @@ public class CodecProvider {
|
|||
public static CodecProvider getDefault() {
|
||||
return defaultCodecs;
|
||||
}
|
||||
|
||||
/** Used for testing. @lucene.internal */
|
||||
public synchronized static void setDefaultCodec(String s) {
|
||||
defaultCodec = s;
|
||||
}
|
||||
/** Used for testing. @lucene.internal */
|
||||
public synchronized static String getDefaultCodec() {
|
||||
return defaultCodec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link Codec} for a given field. Not that setting a fields code is
|
||||
|
@ -175,6 +165,5 @@ class DefaultCodecProvider extends CodecProvider {
|
|||
register(new PreFlexCodec());
|
||||
register(new PulsingCodec(1));
|
||||
register(new SimpleTextCodec());
|
||||
setDefaultFieldCodec(CodecProvider.getDefaultCodec());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Random;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.codecs.CodecProvider;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
@ -84,7 +83,7 @@ public class RandomIndexWriter implements Closeable {
|
|||
flushAt = _TestUtil.nextInt(r, 10, 1000);
|
||||
if (LuceneTestCase.VERBOSE) {
|
||||
System.out.println("RIW config=" + w.getConfig());
|
||||
System.out.println("codec default=" + CodecProvider.getDefaultCodec());
|
||||
System.out.println("codec default=" + w.getConfig().getCodecProvider().getDefaultFieldCodec());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public class Test2BTerms extends LuceneTestCase {
|
|||
@Ignore("Takes ~4 hours to run on a fast machine!! And requires that you don't use PreFlex codec.")
|
||||
public void test2BTerms() throws IOException {
|
||||
|
||||
if ("PreFlex".equals(CodecProvider.getDefaultCodec())) {
|
||||
if ("PreFlex".equals(CodecProvider.getDefault().getDefaultFieldCodec())) {
|
||||
throw new RuntimeException("thist test cannot run with PreFlex codec");
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TestLazyProxSkipping extends LuceneTestCase {
|
|||
int numDocs = 500;
|
||||
|
||||
Directory directory = new SeekCountingDirectory(new RAMDirectory());
|
||||
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, true, false)).setMaxBufferedDocs(10));
|
||||
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, true, false)).setMaxBufferedDocs(10));
|
||||
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
|
||||
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
|
@ -120,7 +120,7 @@ public class TestLazyProxSkipping extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testLazySkipping() throws IOException {
|
||||
assumeFalse("This test cannot run with SimpleText codec", CodecProvider.getDefaultCodec().equals("SimpleText"));
|
||||
assumeFalse("This test cannot run with SimpleText codec", CodecProvider.getDefault().getFieldCodec(this.field).equals("SimpleText"));
|
||||
// test whether only the minimum amount of seeks()
|
||||
// are performed
|
||||
performTest(5);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TestPrefixRandom extends LuceneTestCase {
|
|||
|
||||
// we generate aweful prefixes: good for testing.
|
||||
// but for preflex codec, the test can be very slow, so use less iterations.
|
||||
String codec = CodecProvider.getDefaultCodec();
|
||||
final String codec = CodecProvider.getDefault().getFieldCodec("field");
|
||||
int num = codec.equals("PreFlex") ? 200 * RANDOM_MULTIPLIER : 2000 * RANDOM_MULTIPLIER;
|
||||
for (int i = 0; i < num; i++) {
|
||||
field.setValue(_TestUtil.randomUnicodeString(random, 10));
|
||||
|
|
|
@ -58,7 +58,6 @@ public class TestRegexpRandom2 extends LuceneTestCase {
|
|||
RandomIndexWriter writer = new RandomIndexWriter(random, dir,
|
||||
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.KEYWORD, false))
|
||||
.setMaxBufferedDocs(_TestUtil.nextInt(random, 50, 1000)));
|
||||
|
||||
Document doc = new Document();
|
||||
Field field = newField("field", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
|
||||
doc.add(field);
|
||||
|
@ -135,8 +134,7 @@ public class TestRegexpRandom2 extends LuceneTestCase {
|
|||
public void testRegexps() throws Exception {
|
||||
// we generate aweful regexps: good for testing.
|
||||
// but for preflex codec, the test can be very slow, so use less iterations.
|
||||
String codec = CodecProvider.getDefaultCodec();
|
||||
int num = codec.equals("PreFlex") ? 100 * RANDOM_MULTIPLIER : 1000 * RANDOM_MULTIPLIER;
|
||||
int num = CodecProvider.getDefault().getFieldCodec("field").equals("PreFlex") ? 100 * RANDOM_MULTIPLIER : 1000 * RANDOM_MULTIPLIER;
|
||||
for (int i = 0; i < num; i++) {
|
||||
String reg = AutomatonTestUtil.randomRegexp(random);
|
||||
assertSame(reg);
|
||||
|
|
|
@ -215,7 +215,7 @@ public abstract class LuceneTestCase extends Assert {
|
|||
static Codec installTestCodecs() {
|
||||
final CodecProvider cp = CodecProvider.getDefault();
|
||||
|
||||
savedDefaultCodec = CodecProvider.getDefaultCodec();
|
||||
savedDefaultCodec = cp.getDefaultFieldCodec();
|
||||
String codec = TEST_CODEC;
|
||||
|
||||
final boolean codecHasParam;
|
||||
|
@ -235,7 +235,6 @@ public abstract class LuceneTestCase extends Assert {
|
|||
}
|
||||
}
|
||||
|
||||
CodecProvider.setDefaultCodec(codec);
|
||||
cp.setDefaultFieldCodec(codec);
|
||||
|
||||
if (codec.equals("PreFlex")) {
|
||||
|
@ -268,7 +267,6 @@ public abstract class LuceneTestCase extends Assert {
|
|||
cp.unregister(cp.lookup("MockFixedIntBlock"));
|
||||
cp.unregister(cp.lookup("MockVariableIntBlock"));
|
||||
swapCodec(new PulsingCodec(1));
|
||||
CodecProvider.setDefaultCodec(savedDefaultCodec);
|
||||
cp.setDefaultFieldCodec(savedDefaultCodec);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue