mirror of https://github.com/apache/lucene.git
LUCENE-3489: generalize UseNoMemoryExpensiveCodec to SuppressCodecs
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1337538 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e3f6f47ac9
commit
23c1ebced2
|
@ -20,13 +20,13 @@ package org.apache.lucene.collation;
|
|||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.CollationTestBase;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestCollationKeyAnalyzer extends CollationTestBase {
|
||||
// the sort order of Ø versus U depends on the version of the rules being used
|
||||
// for the inherited root locale: Ø's order isnt specified in Locale.US since
|
||||
|
@ -43,12 +43,6 @@ public class TestCollationKeyAnalyzer extends CollationTestBase {
|
|||
private BytesRef firstRangeEnd = new BytesRef(collator.getCollationKey(firstRangeEndOriginal).toByteArray());
|
||||
private BytesRef secondRangeBeginning = new BytesRef(collator.getCollationKey(secondRangeBeginningOriginal).toByteArray());
|
||||
private BytesRef secondRangeEnd = new BytesRef(collator.getCollationKey(secondRangeEndOriginal).toByteArray());
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
assumeFalse("preflex format only supports UTF-8 encoded bytes", "Lucene3x".equals(Codec.getDefault().getName()));
|
||||
}
|
||||
|
||||
public void testFarsiRangeFilterCollating() throws Exception {
|
||||
testFarsiRangeFilterCollating
|
||||
|
|
|
@ -24,10 +24,11 @@ import org.apache.lucene.analysis.Analyzer;
|
|||
import org.apache.lucene.analysis.CollationTestBase;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestICUCollationKeyAnalyzer extends CollationTestBase {
|
||||
|
||||
private Collator collator = Collator.getInstance(new Locale("fa"));
|
||||
|
@ -42,12 +43,6 @@ public class TestICUCollationKeyAnalyzer extends CollationTestBase {
|
|||
private BytesRef secondRangeEnd = new BytesRef
|
||||
(collator.getCollationKey(secondRangeEndOriginal).toByteArray());
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
assumeFalse("preflex format only supports UTF-8 encoded bytes", "Lucene3x".equals(Codec.getDefault().getName()));
|
||||
}
|
||||
|
||||
public void testFarsiRangeFilterCollating() throws Exception {
|
||||
testFarsiRangeFilterCollating(analyzer, firstRangeBeginning, firstRangeEnd,
|
||||
secondRangeBeginning, secondRangeEnd);
|
||||
|
|
|
@ -30,13 +30,13 @@ import org.apache.lucene.index.FieldInfo.IndexOptions;
|
|||
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
/**
|
||||
* Test indexes ~82M docs with 26 terms each, so you get > Integer.MAX_VALUE terms/docs pairs
|
||||
* @lucene.experimental
|
||||
*/
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class Test2BPostings extends LuceneTestCase {
|
||||
|
||||
@Nightly
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.lucene.index;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.util.*;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.store.*;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.analysis.*;
|
||||
|
@ -45,7 +46,7 @@ import org.junit.Ignore;
|
|||
//
|
||||
// java -server -Xmx8g -d64 -cp .:lib/junit-4.10.jar:./build/classes/test:./build/classes/test-framework:./build/classes/java -Dlucene.version=4.0-dev -Dtests.directory=MMapDirectory -DtempDir=build -ea org.junit.runner.JUnitCore org.apache.lucene.index.Test2BTerms
|
||||
//
|
||||
@LuceneTestCase.UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class Test2BTerms extends LuceneTestCase {
|
||||
|
||||
private final static int TOKEN_LEN = 10;
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.lucene.index;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
|
@ -30,15 +29,14 @@ import org.apache.lucene.search.TopDocs;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
/**
|
||||
* Test indexing and searching some byte[] terms
|
||||
*/
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestBinaryTerms extends LuceneTestCase {
|
||||
public void testBinary() throws IOException {
|
||||
assumeFalse("PreFlex codec cannot work with binary terms!",
|
||||
Codec.getDefault().getName().equals("Lucene3x"));
|
||||
|
||||
public void testBinary() throws IOException {
|
||||
Directory dir = newDirectory();
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
|
||||
BytesRef bytes = new BytesRef(2);
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
|||
import java.util.Random;
|
||||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.TextField;
|
||||
|
@ -33,28 +32,21 @@ import org.apache.lucene.store.MockDirectoryWrapper;
|
|||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LineFileDocs;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.junit.Before;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// TODO: what is the problem with SimpleText
|
||||
@SuppressCodecs({ "SimpleText", "Lucene3x" })
|
||||
public class TestCustomNorms extends LuceneTestCase {
|
||||
final String floatTestField = "normsTestFloat";
|
||||
final String exceptionTestField = "normsTestExcp";
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
assumeFalse("cannot work with preflex codec", Codec.getDefault().getName()
|
||||
.equals("Lucene3x"));
|
||||
assumeFalse("cannot work with simple text codec", Codec.getDefault()
|
||||
.getName().equals("SimpleText"));
|
||||
|
||||
}
|
||||
|
||||
public void testFloatNorms() throws IOException {
|
||||
|
||||
MockDirectoryWrapper dir = newDirectory();
|
||||
// TODO: what is the checkindex problem?
|
||||
dir.setCheckIndexOnClose(false); // can't set sim to checkindex yet
|
||||
IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT,
|
||||
new MockAnalyzer(random()));
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.apache.lucene.index;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
|
@ -25,14 +24,14 @@ import org.apache.lucene.store.Directory;
|
|||
import org.apache.lucene.util.FixedBitSet;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
/**
|
||||
* Tests the Terms.docCount statistic
|
||||
*/
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestDocCount extends LuceneTestCase {
|
||||
public void testSimple() throws Exception {
|
||||
assumeFalse("PreFlex codec does not support docCount statistic!",
|
||||
"Lucene3x".equals(Codec.getDefault().getName()));
|
||||
Directory dir = newDirectory();
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
|
||||
int numDocs = atLeast(100);
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.*;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.ByteDocValuesField;
|
||||
import org.apache.lucene.document.DerefBytesDocValuesField;
|
||||
import org.apache.lucene.document.Document;
|
||||
|
@ -48,6 +47,7 @@ import org.apache.lucene.util.BytesRefHash;
|
|||
import org.apache.lucene.util.FixedBitSet;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.junit.Before;
|
||||
|
||||
/**
|
||||
|
@ -55,17 +55,12 @@ import org.junit.Before;
|
|||
* Tests DocValues integration into IndexWriter & Codecs
|
||||
*
|
||||
*/
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestDocValuesIndexing extends LuceneTestCase {
|
||||
/*
|
||||
* - add test for multi segment case with deletes
|
||||
* - add multithreaded tests / integrate into stress indexing?
|
||||
*/
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
assumeFalse("cannot work with preflex codec", Codec.getDefault().getName().equals("Lucene3x"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple test case to show how to use the API
|
||||
|
|
|
@ -70,7 +70,7 @@ public class TestDuelingCodecs extends LuceneTestCase {
|
|||
// so this would make assertEquals complicated.
|
||||
|
||||
leftCodec = Codec.forName("SimpleText");
|
||||
rightCodec = new RandomCodec(random(), false);
|
||||
rightCodec = new RandomCodec(random(), null);
|
||||
leftDir = newDirectory();
|
||||
rightDir = newDirectory();
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ import org.apache.lucene.search.DocIdSetIterator;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util.FixedBitSet;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestLongPostings extends LuceneTestCase {
|
||||
|
||||
// Produces a realistic unicode random string that
|
||||
|
|
|
@ -22,20 +22,18 @@ import java.util.Set;
|
|||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.codecs.lucene3x.PreFlexRWCodec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.junit.Assume;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestMixedCodecs extends LuceneTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
|
||||
Assume.assumeTrue(!(Codec.getDefault() instanceof PreFlexRWCodec));
|
||||
|
||||
final int NUM_DOCS = atLeast(1000);
|
||||
|
||||
final Directory dir = newDirectory();
|
||||
|
|
|
@ -22,13 +22,13 @@ import java.util.concurrent.ExecutorService;
|
|||
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
// TODO
|
||||
// - mix in forceMerge, addIndexes
|
||||
// - randomoly mix in non-congruent docs
|
||||
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestNRTThreads extends ThreadedIndexingAndSearchingTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
|
|||
import org.apache.lucene.search.similarities.Similarity;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LineFileDocs;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
|
@ -39,7 +39,7 @@ import org.apache.lucene.util._TestUtil;
|
|||
* Test that norms info is preserved during index life - including
|
||||
* separate norms, addDocument, addIndexes, forceMerge.
|
||||
*/
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestNorms extends LuceneTestCase {
|
||||
final String byteTestField = "normsTestByte";
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ import org.apache.lucene.store.Directory;
|
|||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LineFileDocs;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.util.automaton.Automaton;
|
||||
import org.apache.lucene.util.automaton.BasicAutomata;
|
||||
import org.apache.lucene.util.automaton.CompiledAutomaton;
|
||||
import org.apache.lucene.util.automaton.DaciukMihovAutomatonBuilder;
|
||||
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestTermsEnum extends LuceneTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.EnumSet;
|
|||
import java.util.Random;
|
||||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.ByteDocValuesField;
|
||||
import org.apache.lucene.document.DerefBytesDocValuesField;
|
||||
import org.apache.lucene.document.Document;
|
||||
|
@ -42,14 +41,10 @@ import org.apache.lucene.store.ByteArrayDataOutput;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.junit.Before;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestTypePromotion extends LuceneTestCase {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
assumeFalse("cannot work with preflex codec", Codec.getDefault().getName().equals("Lucene3x"));
|
||||
}
|
||||
|
||||
private static EnumSet<Type> INTEGERS = EnumSet.of(Type.VAR_INTS,
|
||||
Type.FIXED_INTS_16, Type.FIXED_INTS_32,
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.lucene.search;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FloatDocValuesField;
|
||||
|
@ -36,6 +35,7 @@ import org.apache.lucene.search.similarities.Similarity;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
|
||||
/**
|
||||
* Tests the use of indexdocvalues in scoring.
|
||||
|
@ -43,13 +43,11 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
* In the example, a docvalues field is used as a per-document boost (separate from the norm)
|
||||
* @lucene.experimental
|
||||
*/
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestDocValuesScoring extends LuceneTestCase {
|
||||
private static final float SCORE_EPSILON = 0.001f; /* for comparing floats */
|
||||
|
||||
public void testSimple() throws Exception {
|
||||
assumeFalse("PreFlex codec cannot work with DocValues!",
|
||||
"Lucene3x".equals(Codec.getDefault().getName()));
|
||||
|
||||
public void testSimple() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
|
||||
Document doc = new Document();
|
||||
|
|
|
@ -40,10 +40,10 @@ import org.apache.lucene.store.Directory;
|
|||
import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.lucene.store.NRTCachingDirectory;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util.ThreadInterruptedException;
|
||||
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestNRTManager extends ThreadedIndexingAndSearchingTestCase {
|
||||
|
||||
private final ThreadLocal<Long> lastGens = new ThreadLocal<Long>();
|
||||
|
|
|
@ -27,10 +27,10 @@ import org.apache.lucene.index.IndexReader;
|
|||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestSearchWithThreads extends LuceneTestCase {
|
||||
int NUM_DOCS;
|
||||
final int NUM_SEARCH_THREADS = 5;
|
||||
|
|
|
@ -39,11 +39,11 @@ import org.apache.lucene.index.Term;
|
|||
import org.apache.lucene.index.ThreadedIndexingAndSearchingTestCase;
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util.NamedThreadFactory;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestSearcherManager extends ThreadedIndexingAndSearchingTestCase {
|
||||
|
||||
boolean warmCalled;
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.lucene.index.MultiReader;
|
|||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
// TODO
|
||||
|
@ -41,7 +41,7 @@ import org.apache.lucene.util._TestUtil;
|
|||
// - test pulling docs in 2nd round trip...
|
||||
// - filter too
|
||||
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestShardSearching extends ShardSearchingTestBase {
|
||||
|
||||
private static class PreviousSearchState {
|
||||
|
|
|
@ -54,7 +54,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
import org.apache.lucene.util.IntsRef;
|
||||
import org.apache.lucene.util.LineFileDocs;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.UseNoMemoryExpensiveCodec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util.UnicodeUtil;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.util.fst.BytesRefFSTEnum.InputOutput;
|
||||
|
@ -62,7 +62,7 @@ import org.apache.lucene.util.fst.FST.Arc;
|
|||
import org.apache.lucene.util.fst.FST.BytesReader;
|
||||
import org.apache.lucene.util.fst.PairOutputs.Pair;
|
||||
|
||||
@UseNoMemoryExpensiveCodec
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestFSTs extends LuceneTestCase {
|
||||
|
||||
private MockDirectoryWrapper dir;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.apache.lucene.codecs.lucene40.Lucene40Codec;
|
||||
|
@ -56,6 +57,8 @@ public class RandomCodec extends Lucene40Codec {
|
|||
// otherwise DWPT's .toString() calls that iterate over the map can
|
||||
// cause concurrentmodificationexception if indexwriter's infostream is on
|
||||
private Map<String,PostingsFormat> previousMappings = Collections.synchronizedMap(new HashMap<String,PostingsFormat>());
|
||||
/** set of codec names to avoid */
|
||||
private final Set<String> avoidCodecs;
|
||||
private final int perFieldSeed;
|
||||
|
||||
@Override
|
||||
|
@ -74,31 +77,36 @@ public class RandomCodec extends Lucene40Codec {
|
|||
return codec;
|
||||
}
|
||||
|
||||
public RandomCodec(Random random, boolean useNoMemoryExpensiveCodec) {
|
||||
public RandomCodec(Random random, Set<String> avoidCodecs) {
|
||||
this.avoidCodecs = avoidCodecs;
|
||||
this.perFieldSeed = random.nextInt();
|
||||
// TODO: make it possible to specify min/max iterms per
|
||||
// block via CL:
|
||||
int minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
|
||||
int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
|
||||
formats.add(new Lucene40PostingsFormat(minItemsPerBlock, maxItemsPerBlock));
|
||||
add(new Lucene40PostingsFormat(minItemsPerBlock, maxItemsPerBlock));
|
||||
// TODO: make it possible to specify min/max iterms per
|
||||
// block via CL:
|
||||
minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
|
||||
maxItemsPerBlock = 2*(Math.max(1, minItemsPerBlock-1)) + random.nextInt(100);
|
||||
formats.add(new Pulsing40PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock));
|
||||
formats.add(new MockSepPostingsFormat());
|
||||
formats.add(new MockFixedIntBlockPostingsFormat(_TestUtil.nextInt(random, 1, 2000)));
|
||||
formats.add(new MockVariableIntBlockPostingsFormat( _TestUtil.nextInt(random, 1, 127)));
|
||||
formats.add(new MockRandomPostingsFormat(random));
|
||||
formats.add(new NestedPulsingPostingsFormat());
|
||||
formats.add(new Lucene40WithOrds());
|
||||
if (!useNoMemoryExpensiveCodec) {
|
||||
formats.add(new SimpleTextPostingsFormat());
|
||||
formats.add(new MemoryPostingsFormat(random.nextBoolean()));
|
||||
}
|
||||
add(new Pulsing40PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock));
|
||||
add(new MockSepPostingsFormat());
|
||||
add(new MockFixedIntBlockPostingsFormat(_TestUtil.nextInt(random, 1, 2000)));
|
||||
add(new MockVariableIntBlockPostingsFormat( _TestUtil.nextInt(random, 1, 127)));
|
||||
add(new MockRandomPostingsFormat(random));
|
||||
add(new NestedPulsingPostingsFormat());
|
||||
add(new Lucene40WithOrds());
|
||||
add(new SimpleTextPostingsFormat());
|
||||
add(new MemoryPostingsFormat(random.nextBoolean()));
|
||||
Collections.shuffle(formats, random);
|
||||
}
|
||||
|
||||
private final void add(PostingsFormat p) {
|
||||
if (avoidCodecs == null || !avoidCodecs.contains(p.getName())) {
|
||||
formats.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + ": " + previousMappings.toString();
|
||||
|
|
|
@ -404,30 +404,33 @@ public abstract class LuceneTestCase extends Assert {
|
|||
}
|
||||
|
||||
Class<?> targetClass = RandomizedContext.current().getTargetClass();
|
||||
LuceneTestCase.useNoMemoryExpensiveCodec =
|
||||
targetClass.isAnnotationPresent(UseNoMemoryExpensiveCodec.class);
|
||||
if (useNoMemoryExpensiveCodec) {
|
||||
System.err.println("NOTE: Using no memory expensive codecs (Memory, SimpleText) for " +
|
||||
targetClass.getSimpleName() + ".");
|
||||
if (targetClass.isAnnotationPresent(SuppressCodecs.class)) {
|
||||
SuppressCodecs a = targetClass.getAnnotation(SuppressCodecs.class);
|
||||
avoidCodecs = new HashSet<String>(Arrays.asList(a.value()));
|
||||
System.err.println("NOTE: Suppressing codecs " + Arrays.toString(a.value())
|
||||
+ " for " + targetClass.getSimpleName() + ".");
|
||||
} else {
|
||||
avoidCodecs = null;
|
||||
}
|
||||
|
||||
|
||||
PREFLEX_IMPERSONATION_IS_ACTIVE = false;
|
||||
savedCodec = Codec.getDefault();
|
||||
final Codec codec;
|
||||
int randomVal = random().nextInt(10);
|
||||
|
||||
if ("Lucene3x".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal < 2)) { // preflex-only setup
|
||||
if ("Lucene3x".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal < 2 && !shouldAvoidCodec("Lucene3x"))) { // preflex-only setup
|
||||
codec = Codec.forName("Lucene3x");
|
||||
assert (codec instanceof PreFlexRWCodec) : "fix your classpath to have tests-framework.jar before lucene-core.jar";
|
||||
PREFLEX_IMPERSONATION_IS_ACTIVE = true;
|
||||
} else if ("SimpleText".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 9 && !useNoMemoryExpensiveCodec)) {
|
||||
} else if ("SimpleText".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 9 && !shouldAvoidCodec("SimpleText"))) {
|
||||
codec = new SimpleTextCodec();
|
||||
} else if ("Appending".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 8)) {
|
||||
} else if ("Appending".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 8 && !shouldAvoidCodec("Appending"))) {
|
||||
codec = new AppendingCodec();
|
||||
} else if (!"random".equals(TEST_CODEC)) {
|
||||
codec = Codec.forName(TEST_CODEC);
|
||||
} else if ("random".equals(TEST_POSTINGSFORMAT)) {
|
||||
codec = new RandomCodec(random(), useNoMemoryExpensiveCodec);
|
||||
codec = new RandomCodec(random(), avoidCodecs);
|
||||
} else {
|
||||
codec = new Lucene40Codec() {
|
||||
private final PostingsFormat format = PostingsFormat.forName(TEST_POSTINGSFORMAT);
|
||||
|
@ -719,11 +722,11 @@ public abstract class LuceneTestCase extends Assert {
|
|||
|
||||
savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount();
|
||||
|
||||
if (useNoMemoryExpensiveCodec) {
|
||||
if (avoidCodecs != null) {
|
||||
String defFormat = _TestUtil.getPostingsFormat("thisCodeMakesAbsolutelyNoSenseCanWeDeleteIt");
|
||||
if ("SimpleText".equals(defFormat) || "Memory".equals(defFormat)) {
|
||||
if (avoidCodecs.contains(defFormat)) {
|
||||
assumeTrue("NOTE: A test method in " + getClass().getSimpleName()
|
||||
+ " was ignored, as it uses too much memory with " + defFormat + ".", false);
|
||||
+ " was ignored, as it is not allowed to use " + defFormat + ".", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1648,7 +1651,11 @@ public abstract class LuceneTestCase extends Assert {
|
|||
}
|
||||
|
||||
// initialized by the TestRunner
|
||||
static boolean useNoMemoryExpensiveCodec;
|
||||
static HashSet<String> avoidCodecs;
|
||||
|
||||
static boolean shouldAvoidCodec(String codec) {
|
||||
return avoidCodecs != null && avoidCodecs.contains(codec);
|
||||
}
|
||||
|
||||
private String name = "<unknown>";
|
||||
|
||||
|
@ -1698,7 +1705,9 @@ public abstract class LuceneTestCase extends Assert {
|
|||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface UseNoMemoryExpensiveCodec {}
|
||||
public @interface SuppressCodecs {
|
||||
String[] value();
|
||||
}
|
||||
|
||||
protected static boolean defaultCodecSupportsDocValues() {
|
||||
return !Codec.getDefault().getName().equals("Lucene3x");
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.FileOutputStream;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
@ -33,11 +33,11 @@ import com.ibm.icu.util.ULocale;
|
|||
/**
|
||||
* Tests {@link ICUCollationField} with TermQueries, RangeQueries, and sort order.
|
||||
*/
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestICUCollationField extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
assumeFalse("preflex format only supports UTF-8 encoded bytes", "Lucene3x".equals(Codec.getDefault().getName()));
|
||||
String home = setupSolrHome();
|
||||
initCore("solrconfig.xml","schema.xml", home);
|
||||
// add some docs
|
||||
|
|
|
@ -17,17 +17,17 @@ package org.apache.solr.schema;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
* Tests expert options of {@link ICUCollationField}.
|
||||
*/
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestICUCollationFieldOptions extends SolrTestCaseJ4 {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
assumeFalse("preflex format only supports UTF-8 encoded bytes", "Lucene3x".equals(Codec.getDefault().getName()));
|
||||
initCore("solrconfig-icucollate.xml","schema-icucollateoptions.xml", "analysis-extras/solr");
|
||||
// add some docs
|
||||
assertU(adoc("id", "1", "text", "foo-bar"));
|
||||
|
|
|
@ -26,18 +26,18 @@ import java.util.Locale;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
* Tests {@link CollationField} with TermQueries, RangeQueries, and sort order.
|
||||
*/
|
||||
@SuppressCodecs("Lucene3x")
|
||||
public class TestCollationField extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
assumeFalse("preflex format only supports UTF-8 encoded bytes",
|
||||
"Lucene3x".equals(Codec.getDefault().getName()));
|
||||
String home = setupSolrHome();
|
||||
initCore("solrconfig.xml","schema.xml", home);
|
||||
// add some docs
|
||||
|
|
Loading…
Reference in New Issue