Class SlowCompositeReaderWrapper

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public final class SlowCompositeReaderWrapper
    extends org.apache.lucene.index.LeafReader
    This class forces a composite reader (eg a MultiReader or DirectoryReader) to emulate a LeafReader. This requires implementing the postings APIs on-the-fly, using the static methods in MultiTerms, MultiDocValues, by stepping through the sub-readers to merge fields/terms, appending docs, etc.

    NOTE: this class almost always results in a performance hit. If this is important to your use case, you'll get better performance by gathering the sub readers using IndexReader.getContext() to get the leaves and then operate per-LeafReader, instead of using this class.

    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader

        org.apache.lucene.index.IndexReader.CacheHelper, org.apache.lucene.index.IndexReader.CacheKey, org.apache.lucene.index.IndexReader.ClosedListener
    • Method Detail

      • wrap

        public static org.apache.lucene.index.LeafReader wrap​(org.apache.lucene.index.IndexReader reader)
                                                       throws IOException
        This method is sugar for getting an LeafReader from an IndexReader of any kind. If the reader is already atomic, it is returned unchanged, otherwise wrapped by this class.
        Throws:
        IOException
      • getReaderCacheHelper

        public org.apache.lucene.index.IndexReader.CacheHelper getReaderCacheHelper()
        Specified by:
        getReaderCacheHelper in class org.apache.lucene.index.IndexReader
      • getCoreCacheHelper

        public org.apache.lucene.index.IndexReader.CacheHelper getCoreCacheHelper()
        Specified by:
        getCoreCacheHelper in class org.apache.lucene.index.LeafReader
      • terms

        public org.apache.lucene.index.Terms terms​(String field)
                                            throws IOException
        Specified by:
        terms in class org.apache.lucene.index.LeafReader
        Throws:
        IOException
      • getNumericDocValues

        public org.apache.lucene.index.NumericDocValues getNumericDocValues​(String field)
                                                                     throws IOException
        Specified by:
        getNumericDocValues in class org.apache.lucene.index.LeafReader
        Throws:
        IOException
      • getBinaryDocValues

        public org.apache.lucene.index.BinaryDocValues getBinaryDocValues​(String field)
                                                                   throws IOException
        Specified by:
        getBinaryDocValues in class org.apache.lucene.index.LeafReader
        Throws:
        IOException
      • getSortedNumericDocValues

        public org.apache.lucene.index.SortedNumericDocValues getSortedNumericDocValues​(String field)
                                                                                 throws IOException
        Specified by:
        getSortedNumericDocValues in class org.apache.lucene.index.LeafReader
        Throws:
        IOException
      • getSortedDocValues

        public org.apache.lucene.index.SortedDocValues getSortedDocValues​(String field)
                                                                   throws IOException
        Specified by:
        getSortedDocValues in class org.apache.lucene.index.LeafReader
        Throws:
        IOException
      • getSortedSetDocValues

        public org.apache.lucene.index.SortedSetDocValues getSortedSetDocValues​(String field)
                                                                         throws IOException
        Specified by:
        getSortedSetDocValues in class org.apache.lucene.index.LeafReader
        Throws:
        IOException
      • getNormValues

        public org.apache.lucene.index.NumericDocValues getNormValues​(String field)
                                                               throws IOException
        Specified by:
        getNormValues in class org.apache.lucene.index.LeafReader
        Throws:
        IOException
      • getTermVectors

        public org.apache.lucene.index.Fields getTermVectors​(int docID)
                                                      throws IOException
        Specified by:
        getTermVectors in class org.apache.lucene.index.IndexReader
        Throws:
        IOException
      • numDocs

        public int numDocs()
        Specified by:
        numDocs in class org.apache.lucene.index.IndexReader
      • maxDoc

        public int maxDoc()
        Specified by:
        maxDoc in class org.apache.lucene.index.IndexReader
      • document

        public void document​(int docID,
                             org.apache.lucene.index.StoredFieldVisitor visitor)
                      throws IOException
        Specified by:
        document in class org.apache.lucene.index.IndexReader
        Throws:
        IOException
      • getLiveDocs

        public org.apache.lucene.util.Bits getLiveDocs()
        Specified by:
        getLiveDocs in class org.apache.lucene.index.LeafReader
      • getPointValues

        public org.apache.lucene.index.PointValues getPointValues​(String field)
        Specified by:
        getPointValues in class org.apache.lucene.index.LeafReader
      • getFieldInfos

        public org.apache.lucene.index.FieldInfos getFieldInfos()
        Specified by:
        getFieldInfos in class org.apache.lucene.index.LeafReader
      • doClose

        protected void doClose()
                        throws IOException
        Specified by:
        doClose in class org.apache.lucene.index.IndexReader
        Throws:
        IOException
      • checkIntegrity

        public void checkIntegrity()
                            throws IOException
        Specified by:
        checkIntegrity in class org.apache.lucene.index.LeafReader
        Throws:
        IOException
      • getMetaData

        public org.apache.lucene.index.LeafMetaData getMetaData()
        Specified by:
        getMetaData in class org.apache.lucene.index.LeafReader