Remove deprecated API in 10.x (#11998)

This commit is contained in:
Robert Muir 2022-12-13 10:32:15 -05:00
parent 47f8c1baa2
commit 9eeab8c4a6
No known key found for this signature in database
GPG Key ID: 817AE1DD322D7ECA
20 changed files with 1 additions and 359 deletions

View File

@ -111,13 +111,6 @@ public abstract class BaseCompositeReader<R extends IndexReader> extends Composi
starts[subReaders.length] = this.maxDoc;
}
@Override
public final Fields getTermVectors(int docID) throws IOException {
ensureOpen();
final int i = readerIndex(docID); // find subreader num
return subReaders[i].getTermVectors(docID - starts[i]); // dispatch to subreader
}
@Override
public final TermVectors termVectors() throws IOException {
ensureOpen();
@ -164,13 +157,6 @@ public abstract class BaseCompositeReader<R extends IndexReader> extends Composi
return maxDoc;
}
@Override
public final void document(int docID, StoredFieldVisitor visitor) throws IOException {
ensureOpen();
final int i = readerIndex(docID); // find subreader num
subReaders[i].document(docID - starts[i], visitor); // dispatch to subreader
}
@Override
public final StoredFields storedFields() throws IOException {
ensureOpen();

View File

@ -83,21 +83,6 @@ public abstract class CodecReader extends LeafReader {
*/
public abstract KnnVectorsReader getVectorReader();
// intentionally throw UOE for deprecated APIs: keep CodecReader clean!
// (IndexWriter should not be triggering threadlocals in any way)
@Override
@Deprecated
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
throw new UnsupportedOperationException("deprecated document access is not supported");
}
@Override
@Deprecated
public Fields getTermVectors(int docID) throws IOException {
throw new UnsupportedOperationException("deprecated term vector access is not supported");
}
@Override
public final StoredFields storedFields() throws IOException {
final StoredFields reader = getFieldsReader();

View File

@ -68,11 +68,6 @@ abstract class DocValuesLeafReader extends LeafReader {
throw new UnsupportedOperationException();
}
@Override
public final Fields getTermVectors(int docID) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public final TermVectors termVectors() throws IOException {
throw new UnsupportedOperationException();
@ -88,11 +83,6 @@ abstract class DocValuesLeafReader extends LeafReader {
throw new UnsupportedOperationException();
}
@Override
public final void document(int docID, StoredFieldVisitor visitor) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public final StoredFields storedFields() throws IOException {
throw new UnsupportedOperationException();

View File

@ -84,18 +84,6 @@ public abstract class FilterCodecReader extends CodecReader {
return in.getPostingsReader();
}
@Override
@Deprecated
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
in.document(docID, visitor);
}
@Override
@Deprecated
public Fields getTermVectors(int docID) throws IOException {
return in.getTermVectors(docID);
}
@Override
public Bits getLiveDocs() {
return in.getLiveDocs();

View File

@ -357,12 +357,6 @@ public abstract class FilterLeafReader extends LeafReader {
return in.searchNearestVectors(field, target, k, acceptDocs, visitedLimit);
}
@Override
public Fields getTermVectors(int docID) throws IOException {
ensureOpen();
return in.getTermVectors(docID);
}
@Override
public TermVectors termVectors() throws IOException {
ensureOpen();
@ -387,12 +381,6 @@ public abstract class FilterLeafReader extends LeafReader {
return in.storedFields();
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
ensureOpen();
in.document(docID, visitor);
}
@Override
protected void doClose() throws IOException {
in.close();

View File

@ -23,10 +23,7 @@ import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DocumentStoredFieldVisitor;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.util.Bits;
/**
* IndexReader is an abstract class, providing an interface for accessing a point-in-time view of an
@ -308,30 +305,6 @@ public abstract class IndexReader implements Closeable {
return System.identityHashCode(this);
}
/**
* Retrieve term vectors for this document, or null if term vectors were not indexed. The returned
* Fields instance acts like a single-document inverted index (the docID will be 0).
*
* @deprecated use {@link #termVectors()} to retrieve one or more documents
*/
@Deprecated
public abstract Fields getTermVectors(int docID) throws IOException;
/**
* Retrieve term vector for this document and field, or null if term vectors were not indexed. The
* returned Fields instance acts like a single-document inverted index (the docID will be 0).
*
* @deprecated use {@link #termVectors()} to retrieve one or more documents
*/
@Deprecated
public final Terms getTermVector(int docID, String field) throws IOException {
Fields vectors = getTermVectors(docID);
if (vectors == null) {
return null;
}
return vectors.terms(field);
}
/**
* Returns a {@link TermVectors} reader for the term vectors of this index.
*
@ -376,55 +349,6 @@ public abstract class IndexReader implements Closeable {
return maxDoc() - numDocs();
}
/**
* Expert: visits the fields of a stored document, for custom processing/loading of each field. If
* you simply want to load all fields, use {@link #document(int)}. If you want to load a subset,
* use {@link DocumentStoredFieldVisitor}.
*
* @deprecated use {@link #storedFields()} to retrieve one or more documents
*/
@Deprecated
public abstract void document(int docID, StoredFieldVisitor visitor) throws IOException;
/**
* Returns the stored fields of the <code>n</code><sup>th</sup> <code>Document</code> in this
* index. This is just sugar for using {@link DocumentStoredFieldVisitor}.
*
* <p><b>NOTE:</b> for performance reasons, this method does not check if the requested document
* is deleted, and therefore asking for a deleted document may yield unspecified results. Usually
* this is not required, however you can test if the doc is deleted by checking the {@link Bits}
* returned from {@link MultiBits#getLiveDocs}.
*
* <p><b>NOTE:</b> only the content of a field is returned, if that field was stored during
* indexing. Metadata like boost, omitNorm, IndexOptions, tokenized, etc., are not preserved.
*
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
* @deprecated use {@link #storedFields()} to retrieve one or more documents
*/
// TODO: we need a separate StoredField, so that the
// Document returned here contains that class not
// IndexableField
@Deprecated
public final Document document(int docID) throws IOException {
final DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor();
document(docID, visitor);
return visitor.getDocument();
}
/**
* Like {@link #document(int)} but only loads the specified fields. Note that this is simply sugar
* for {@link DocumentStoredFieldVisitor#DocumentStoredFieldVisitor(Set)}.
*
* @deprecated use {@link #storedFields()} to retrieve one or more documents
*/
@Deprecated
public final Document document(int docID, Set<String> fieldsToLoad) throws IOException {
final DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(fieldsToLoad);
document(docID, visitor);
return visitor.getDocument();
}
/**
* Returns a {@link StoredFields} reader for the stored fields of this index.
*

View File

@ -265,14 +265,6 @@ public class ParallelLeafReader extends LeafReader {
return maxDoc;
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
ensureOpen();
for (final LeafReader reader : storedFieldsReaders) {
reader.document(docID, visitor);
}
}
@Override
public StoredFields storedFields() throws IOException {
ensureOpen();
@ -316,24 +308,6 @@ public class ParallelLeafReader extends LeafReader {
return null;
}
@Override
public Fields getTermVectors(int docID) throws IOException {
ensureOpen();
ParallelFields fields = null;
for (Map.Entry<String, LeafReader> ent : tvFieldToReader.entrySet()) {
String fieldName = ent.getKey();
Terms vector = ent.getValue().getTermVector(docID, fieldName);
if (vector != null) {
if (fields == null) {
fields = new ParallelFields();
}
fields.addField(fieldName, vector);
}
}
return fields;
}
@Override
public TermVectors termVectors() throws IOException {
ensureOpen();

View File

@ -39,7 +39,6 @@ import org.apache.lucene.index.IndexReader.ClosedListener;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.CloseableThreadLocal;
import org.apache.lucene.util.IOUtils;
/** Holds core readers that are shared (unchanged) when SegmentReader is cloned or reopened */
@ -68,26 +67,6 @@ final class SegmentCoreReaders {
*/
final FieldInfos coreFieldInfos;
// TODO: make a single thread local w/ a
// Thingy class holding fieldsReader, termVectorsReader,
// normsProducer
final CloseableThreadLocal<StoredFieldsReader> fieldsReaderLocal =
new CloseableThreadLocal<StoredFieldsReader>() {
@Override
protected StoredFieldsReader initialValue() {
return fieldsReaderOrig.clone();
}
};
final CloseableThreadLocal<TermVectorsReader> termVectorsLocal =
new CloseableThreadLocal<TermVectorsReader>() {
@Override
protected TermVectorsReader initialValue() {
return (termVectorsReaderOrig == null) ? null : termVectorsReaderOrig.clone();
}
};
private final Set<IndexReader.ClosedListener> coreClosedListeners =
Collections.synchronizedSet(new LinkedHashSet<IndexReader.ClosedListener>());
@ -190,8 +169,6 @@ final class SegmentCoreReaders {
if (ref.decrementAndGet() == 0) {
try (Closeable finalizer = this::notifyCoreClosedListeners) {
IOUtils.close(
termVectorsLocal,
fieldsReaderLocal,
fields,
termVectorsReaderOrig,
fieldsReaderOrig,

View File

@ -18,7 +18,6 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import org.apache.lucene.codecs.Codec;
@ -245,38 +244,6 @@ public final class SegmentReader extends CodecReader {
return si.info.maxDoc();
}
/* Support for deprecated threadlocal document/vectors APIs */
@Override
public final void document(int docID, StoredFieldVisitor visitor) throws IOException {
Objects.checkIndex(docID, maxDoc());
getThreadLocalFieldsReader().document(docID, visitor);
}
@Override
public final Fields getTermVectors(int docID) throws IOException {
Objects.checkIndex(docID, maxDoc());
TermVectorsReader termVectorsReader = getThreadLocalTermVectorsReader();
if (termVectorsReader == null) {
return null;
}
return termVectorsReader.get(docID);
}
@Deprecated
private TermVectorsReader getThreadLocalTermVectorsReader() {
ensureOpen();
return core.termVectorsLocal.get();
}
@Deprecated
private StoredFieldsReader getThreadLocalFieldsReader() {
ensureOpen();
return core.fieldsReaderLocal.get();
}
/* end support for deprecated threadlocal document/vectors APIs */
@Override
public TermVectorsReader getTermVectorsReader() {
ensureOpen();

View File

@ -24,14 +24,12 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.function.Supplier;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReaderContext;
@ -39,7 +37,6 @@ import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.QueryTimeout;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.StoredFields;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
@ -379,39 +376,6 @@ public class IndexSearcher {
return reader;
}
/**
* Sugar for <code>.getIndexReader().document(docID)</code>
*
* @see IndexReader#document(int)
* @deprecated Use {@link #storedFields()} to access fields for one or more documents
*/
@Deprecated
public Document doc(int docID) throws IOException {
return reader.document(docID);
}
/**
* Sugar for <code>.getIndexReader().document(docID, fieldVisitor)</code>
*
* @see IndexReader#document(int, StoredFieldVisitor)
* @deprecated Use {@link #storedFields()} to access fields for one or more documents
*/
@Deprecated
public void doc(int docID, StoredFieldVisitor fieldVisitor) throws IOException {
reader.document(docID, fieldVisitor);
}
/**
* Sugar for <code>.getIndexReader().document(docID, fieldsToLoad)</code>
*
* @see IndexReader#document(int, Set)
* @deprecated Use {@link #storedFields()} to access fields for one or more documents
*/
@Deprecated
public Document doc(int docID, Set<String> fieldsToLoad) throws IOException {
return reader.document(docID, fieldsToLoad);
}
/**
* Returns a {@link StoredFields} reader for the stored fields of this index.
*

View File

@ -66,11 +66,6 @@ public class TestSegmentToThreadMapping extends LuceneTestCase {
return null;
}
@Override
public Fields getTermVectors(int doc) {
return null;
}
@Override
public TermVectors termVectors() {
return TermVectors.EMPTY;
@ -125,9 +120,6 @@ public class TestSegmentToThreadMapping extends LuceneTestCase {
@Override
protected void doClose() {}
@Override
public void document(int doc, StoredFieldVisitor visitor) {}
@Override
public StoredFields storedFields() {
return new StoredFields() {

View File

@ -173,14 +173,6 @@ public class TermVectorLeafReader extends LeafReader {
@Override
public void checkIntegrity() throws IOException {}
@Override
public Fields getTermVectors(int docID) throws IOException {
if (docID != 0) {
return null;
}
return fields;
}
@Override
public TermVectors termVectors() throws IOException {
return new TermVectors() {
@ -205,9 +197,6 @@ public class TermVectorLeafReader extends LeafReader {
return 1;
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {}
@Override
public StoredFields storedFields() throws IOException {
return new StoredFields() {

View File

@ -1452,15 +1452,6 @@ public class UnifiedHighlighter {
super(in);
}
@Override
public Fields getTermVectors(int docID) throws IOException {
if (docID != lastDocId) {
lastDocId = docID;
tvFields = in.getTermVectors(docID);
}
return tvFields;
}
@Override
public TermVectors termVectors() throws IOException {
TermVectors orig = in.termVectors();

View File

@ -1803,15 +1803,6 @@ public class MemoryIndex {
}
}
@Override
public Fields getTermVectors(int docID) {
if (docID == 0) {
return memoryFields;
} else {
return null;
}
}
@Override
public TermVectors termVectors() {
return new TermVectors() {
@ -1838,12 +1829,6 @@ public class MemoryIndex {
return 1;
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
if (DEBUG) System.err.println("MemoryIndexReader.document");
storedFields().document(docID, visitor);
}
@Override
public StoredFields storedFields() {
return new StoredFields() {

View File

@ -110,12 +110,6 @@ public class AssertingLeafReader extends FilterLeafReader {
return terms == null ? null : new AssertingTerms(terms);
}
@Override
public Fields getTermVectors(int docID) throws IOException {
Fields fields = super.getTermVectors(docID);
return fields == null ? null : new AssertingFields(fields);
}
@Override
public TermVectors termVectors() throws IOException {
return new AssertingTermVectors(super.termVectors());

View File

@ -620,11 +620,6 @@ public abstract class BaseStoredFieldsFormatTestCase extends BaseIndexFileFormat
super(in);
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
super.document(maxDoc() - 1 - docID, visitor);
}
@Override
public StoredFields storedFields() throws IOException {
StoredFields orig = in.storedFields();

View File

@ -69,11 +69,6 @@ public final class FieldFilterLeafReader extends FilterLeafReader {
return fieldInfos;
}
@Override
public Fields getTermVectors(int docID) throws IOException {
return termVectors().get(docID);
}
@Override
public TermVectors termVectors() throws IOException {
TermVectors orig = super.termVectors();
@ -92,11 +87,6 @@ public final class FieldFilterLeafReader extends FilterLeafReader {
};
}
@Override
public void document(final int docID, final StoredFieldVisitor visitor) throws IOException {
storedFields().document(docID, visitor);
}
@Override
public StoredFields storedFields() throws IOException {
StoredFields orig = super.storedFields();
@ -184,6 +174,7 @@ public final class FieldFilterLeafReader extends FilterLeafReader {
return sb.append(fields).append(')').toString();
}
@SuppressWarnings("unused")
private class FieldFilterFields extends FilterFields {
public FieldFilterFields(Fields in) {

View File

@ -18,7 +18,6 @@
package org.apache.lucene.tests.index;
import java.io.IOException;
import java.util.Objects;
import org.apache.lucene.codecs.DocValuesProducer;
import org.apache.lucene.codecs.FieldsProducer;
import org.apache.lucene.codecs.NormsProducer;
@ -29,7 +28,6 @@ import org.apache.lucene.index.CodecReader;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.LeafMetaData;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.NumericDocValues;
@ -37,7 +35,6 @@ import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.StoredFields;
import org.apache.lucene.index.TermVectors;
import org.apache.lucene.index.Terms;
@ -204,16 +201,6 @@ class MergeReaderWrapper extends LeafReader {
in.checkIntegrity();
}
@Override
public Fields getTermVectors(int docID) throws IOException {
ensureOpen();
checkBounds(docID);
if (vectors == null) {
return null;
}
return vectors.get(docID);
}
@Override
public TermVectors termVectors() throws IOException {
ensureOpen();
@ -250,13 +237,6 @@ class MergeReaderWrapper extends LeafReader {
return in.maxDoc();
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
ensureOpen();
checkBounds(docID);
store.document(docID, visitor);
}
@Override
public StoredFields storedFields() throws IOException {
ensureOpen();
@ -278,10 +258,6 @@ class MergeReaderWrapper extends LeafReader {
return in.getReaderCacheHelper();
}
private void checkBounds(int docID) {
Objects.checkIndex(docID, maxDoc());
}
@Override
public String toString() {
return "MergeReaderWrapper(" + in + ")";

View File

@ -47,11 +47,6 @@ public class MismatchedLeafReader extends FilterLeafReader {
return shuffled;
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
in.document(docID, new MismatchedVisitor(visitor));
}
@Override
public StoredFields storedFields() throws IOException {
final StoredFields inStoredFields = in.storedFields();

View File

@ -25,7 +25,6 @@ import java.util.List;
import java.util.Random;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafMetaData;
import org.apache.lucene.index.LeafReader;
@ -255,11 +254,6 @@ public class QueryUtils {
@Override
public void checkIntegrity() throws IOException {}
@Override
public Fields getTermVectors(int docID) throws IOException {
return null;
}
@Override
public TermVectors termVectors() {
return TermVectors.EMPTY;
@ -275,9 +269,6 @@ public class QueryUtils {
return maxDoc;
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {}
@Override
public StoredFields storedFields() {
return new StoredFields() {