mirror of https://github.com/apache/lucene.git
LUCENE-5187: Make SlowCompositeReaderWrapper's constructor private.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1517447 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
84063af19a
commit
db2a2fdd7e
|
@ -267,6 +267,9 @@ Changes in backwards compatibility policy
|
|||
* LUCENE-5170: Changed method signatures of Analyzer.ReuseStrategy to take
|
||||
Analyzer. Closeable interface was removed because the class was changed to
|
||||
be stateless. (Uwe Schindler, Robert Muir, Shay Banon)
|
||||
|
||||
* LUCENE-5187: SlowCompositeReaderWrapper constructor is now private,
|
||||
SlowCompositeReaderWrapper.wrap should be used instead. (Adrien Grand)
|
||||
|
||||
Build
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
|
|||
Benchmark benchmark = execBenchmark(algLines);
|
||||
|
||||
DirectoryReader r = DirectoryReader.open(benchmark.getRunData().getDirectory());
|
||||
SortedDocValues idx = FieldCache.DEFAULT.getTermsIndex(new SlowCompositeReaderWrapper(r), "country");
|
||||
SortedDocValues idx = FieldCache.DEFAULT.getTermsIndex(SlowCompositeReaderWrapper.wrap(r), "country");
|
||||
final int maxDoc = r.maxDoc();
|
||||
assertEquals(1000, maxDoc);
|
||||
for(int i=0;i<1000;i++) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.lucene.document.Document;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.TextField;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.SlowCompositeReaderWrapper;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
@ -66,10 +67,10 @@ public abstract class ClassificationTestBase<T> extends LuceneTestCase {
|
|||
|
||||
|
||||
protected void checkCorrectClassification(Classifier<T> classifier, String inputDoc, T expectedResult, Analyzer analyzer, String classFieldName) throws Exception {
|
||||
SlowCompositeReaderWrapper compositeReaderWrapper = null;
|
||||
AtomicReader compositeReaderWrapper = null;
|
||||
try {
|
||||
populateIndex(analyzer);
|
||||
compositeReaderWrapper = new SlowCompositeReaderWrapper(indexWriter.getReader());
|
||||
compositeReaderWrapper = SlowCompositeReaderWrapper.wrap(indexWriter.getReader());
|
||||
classifier.train(compositeReaderWrapper, textFieldName, classFieldName, analyzer);
|
||||
ClassificationResult<T> classificationResult = classifier.assignClass(inputDoc);
|
||||
assertNotNull(classificationResult.getAssignedClass());
|
||||
|
|
|
@ -64,9 +64,7 @@ public final class SlowCompositeReaderWrapper extends AtomicReader {
|
|||
}
|
||||
}
|
||||
|
||||
/** Sole constructor, wrapping the provided {@link
|
||||
* CompositeReader}. */
|
||||
public SlowCompositeReaderWrapper(CompositeReader reader) throws IOException {
|
||||
private SlowCompositeReaderWrapper(CompositeReader reader) throws IOException {
|
||||
super();
|
||||
in = reader;
|
||||
fields = MultiFields.getFields(in);
|
||||
|
|
|
@ -209,7 +209,7 @@ public class TestDocValuesIndexing extends LuceneTestCase {
|
|||
writer.addDocument(doc);
|
||||
}
|
||||
DirectoryReader r = writer.getReader();
|
||||
SlowCompositeReaderWrapper slow = new SlowCompositeReaderWrapper(r);
|
||||
AtomicReader slow = SlowCompositeReaderWrapper.wrap(r);
|
||||
FieldInfos fi = slow.getFieldInfos();
|
||||
FieldInfo dvInfo = fi.fieldInfo("dv");
|
||||
assertTrue(dvInfo.hasDocValues());
|
||||
|
|
|
@ -379,7 +379,7 @@ public class TestPostingsOffsets extends LuceneTestCase {
|
|||
riw.addDocument(doc);
|
||||
}
|
||||
CompositeReader ir = riw.getReader();
|
||||
SlowCompositeReaderWrapper slow = new SlowCompositeReaderWrapper(ir);
|
||||
AtomicReader slow = SlowCompositeReaderWrapper.wrap(ir);
|
||||
FieldInfos fis = slow.getFieldInfos();
|
||||
assertEquals(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS, fis.fieldInfo("foo").getIndexOptions());
|
||||
slow.close();
|
||||
|
|
|
@ -76,7 +76,7 @@ public class TestSimilarityProvider extends LuceneTestCase {
|
|||
public void testBasics() throws Exception {
|
||||
// sanity check of norms writer
|
||||
// TODO: generalize
|
||||
AtomicReader slow = new SlowCompositeReaderWrapper(reader);
|
||||
AtomicReader slow = SlowCompositeReaderWrapper.wrap(reader);
|
||||
NumericDocValues fooNorms = slow.getNormValues("foo");
|
||||
NumericDocValues barNorms = slow.getNormValues("bar");
|
||||
for (int i = 0; i < slow.maxDoc(); i++) {
|
||||
|
|
|
@ -96,11 +96,7 @@ public final class SortedSetDocValuesReaderState {
|
|||
|
||||
// We need this to create thread-safe MultiSortedSetDV
|
||||
// per collector:
|
||||
if (reader instanceof AtomicReader) {
|
||||
topReader = (AtomicReader) reader;
|
||||
} else {
|
||||
topReader = new SlowCompositeReaderWrapper((CompositeReader) reader);
|
||||
}
|
||||
topReader = SlowCompositeReaderWrapper.wrap(reader);
|
||||
SortedSetDocValues dv = topReader.getSortedSetDocValues(field);
|
||||
if (dv == null) {
|
||||
throw new IllegalArgumentException("field \"" + field + "\" was not indexed with SortedSetDocValues");
|
||||
|
|
|
@ -302,7 +302,7 @@ public class AllGroupHeadsCollectorTest extends LuceneTestCase {
|
|||
w.close();
|
||||
|
||||
// NOTE: intentional but temporary field cache insanity!
|
||||
final FieldCache.Ints docIdToFieldId = FieldCache.DEFAULT.getInts(new SlowCompositeReaderWrapper(r), "id", false);
|
||||
final FieldCache.Ints docIdToFieldId = FieldCache.DEFAULT.getInts(SlowCompositeReaderWrapper.wrap(r), "id", false);
|
||||
final int[] fieldIdToDocID = new int[numDocs];
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
int fieldId = docIdToFieldId.get(i);
|
||||
|
|
|
@ -743,7 +743,7 @@ public class TestGrouping extends LuceneTestCase {
|
|||
w.close();
|
||||
|
||||
// NOTE: intentional but temporary field cache insanity!
|
||||
final FieldCache.Ints docIDToID = FieldCache.DEFAULT.getInts(new SlowCompositeReaderWrapper(r), "id", false);
|
||||
final FieldCache.Ints docIDToID = FieldCache.DEFAULT.getInts(SlowCompositeReaderWrapper.wrap(r), "id", false);
|
||||
DirectoryReader rBlocks = null;
|
||||
Directory dirBlocks = null;
|
||||
|
||||
|
@ -779,7 +779,7 @@ public class TestGrouping extends LuceneTestCase {
|
|||
dirBlocks = newDirectory();
|
||||
rBlocks = getDocBlockReader(dirBlocks, groupDocs);
|
||||
final Filter lastDocInBlock = new CachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("groupend", "x"))));
|
||||
final FieldCache.Ints docIDToIDBlocks = FieldCache.DEFAULT.getInts(new SlowCompositeReaderWrapper(rBlocks), "id", false);
|
||||
final FieldCache.Ints docIDToIDBlocks = FieldCache.DEFAULT.getInts(SlowCompositeReaderWrapper.wrap(rBlocks), "id", false);
|
||||
|
||||
final IndexSearcher sBlocks = newSearcher(rBlocks);
|
||||
final ShardState shardsBlocks = new ShardState(sBlocks);
|
||||
|
|
|
@ -176,7 +176,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
|
|||
|
||||
private void duellReaders(CompositeReader other, AtomicReader memIndexReader)
|
||||
throws IOException {
|
||||
AtomicReader competitor = new SlowCompositeReaderWrapper(other);
|
||||
AtomicReader competitor = SlowCompositeReaderWrapper.wrap(other);
|
||||
Fields memFields = memIndexReader.fields();
|
||||
for (String field : competitor.fields()) {
|
||||
Terms memTerms = memFields.terms(field);
|
||||
|
|
|
@ -70,9 +70,7 @@ public class OrdFieldSource extends ValueSource {
|
|||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final int off = readerContext.docBase;
|
||||
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();
|
||||
final AtomicReader r = topReader instanceof CompositeReader
|
||||
? new SlowCompositeReaderWrapper((CompositeReader)topReader)
|
||||
: (AtomicReader) topReader;
|
||||
final AtomicReader r = SlowCompositeReaderWrapper.wrap(topReader);
|
||||
final SortedDocValues sindex = FieldCache.DEFAULT.getTermsIndex(r, field);
|
||||
return new IntDocValues(this) {
|
||||
protected String toTerm(String readableValue) {
|
||||
|
|
|
@ -69,9 +69,7 @@ public class ReverseOrdFieldSource extends ValueSource {
|
|||
@Override
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();
|
||||
final AtomicReader r = topReader instanceof CompositeReader
|
||||
? new SlowCompositeReaderWrapper((CompositeReader)topReader)
|
||||
: (AtomicReader) topReader;
|
||||
final AtomicReader r = SlowCompositeReaderWrapper.wrap(topReader);
|
||||
final int off = readerContext.docBase;
|
||||
|
||||
final SortedDocValues sindex = FieldCache.DEFAULT.getTermsIndex(r, field);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BooleanFilterTest extends LuceneTestCase {
|
|||
addDoc(writer, "guest", "020", "20050101", "Y");
|
||||
addDoc(writer, "admin", "020", "20050101", "Maybe");
|
||||
addDoc(writer, "admin guest", "030", "20050101", "N");
|
||||
reader = new SlowCompositeReaderWrapper(writer.getReader());
|
||||
reader = SlowCompositeReaderWrapper.wrap(writer.getReader());
|
||||
writer.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
|||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
|
@ -311,7 +312,7 @@ public class CommonTermsQueryTest extends LuceneTestCase {
|
|||
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
|
||||
createRandomIndex(atLeast(50), w, random().nextLong());
|
||||
DirectoryReader reader = w.getReader();
|
||||
SlowCompositeReaderWrapper wrapper = new SlowCompositeReaderWrapper(reader);
|
||||
AtomicReader wrapper = SlowCompositeReaderWrapper.wrap(reader);
|
||||
String field = "body";
|
||||
Terms terms = wrapper.terms(field);
|
||||
PriorityQueue<TermAndFreq> lowFreqQueue = new PriorityQueue<CommonTermsQueryTest.TermAndFreq>(
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TermFilterTest extends LuceneTestCase {
|
|||
Document doc = new Document();
|
||||
doc.add(newStringField(fieldName, "value1", Field.Store.NO));
|
||||
w.addDocument(doc);
|
||||
IndexReader reader = new SlowCompositeReaderWrapper(w.getReader());
|
||||
IndexReader reader = SlowCompositeReaderWrapper.wrap(w.getReader());
|
||||
assertTrue(reader.getContext() instanceof AtomicReaderContext);
|
||||
AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
|
||||
w.close();
|
||||
|
|
|
@ -74,7 +74,7 @@ public class TermsFilterTest extends LuceneTestCase {
|
|||
doc.add(newStringField(fieldName, "" + term, Field.Store.YES));
|
||||
w.addDocument(doc);
|
||||
}
|
||||
IndexReader reader = new SlowCompositeReaderWrapper(w.getReader());
|
||||
IndexReader reader = SlowCompositeReaderWrapper.wrap(w.getReader());
|
||||
assertTrue(reader.getContext() instanceof AtomicReaderContext);
|
||||
AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
|
||||
w.close();
|
||||
|
|
|
@ -64,7 +64,7 @@ public class TestNumericRangeFilterBuilder extends LuceneTestCase {
|
|||
IndexWriter writer = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
|
||||
writer.commit();
|
||||
try {
|
||||
AtomicReader reader = new SlowCompositeReaderWrapper(DirectoryReader.open(ramDir));
|
||||
AtomicReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(ramDir));
|
||||
try {
|
||||
assertNull(filter.getDocIdSet(reader.getContext(), reader.getLiveDocs()));
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ public class AnalyzingInfixSuggester extends Lookup implements Closeable {
|
|||
}
|
||||
//System.out.println("initial indexing time: " + ((System.nanoTime()-t0)/1000000) + " msec");
|
||||
|
||||
r = new SlowCompositeReaderWrapper(DirectoryReader.open(w, false));
|
||||
r = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(w, false));
|
||||
//long t1 = System.nanoTime();
|
||||
w.rollback();
|
||||
|
||||
|
|
Loading…
Reference in New Issue