Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-8489

Provide List type constructors for BaseCompositeReader based Readers

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • core/index
    • New

    Description

      Currently, Reader based on BaseCompositeReader(MultiReader, ParallelCompositeReader, DirectoryReader) does not support List type constructor.

      In fact, this does not make a big difference in performance, but users will think positively if the API supports more variants.

      I will add the following to support this.

      1) MultiReader

      public MultiReader(List<IndexReader> subReaders) throws IOException {
        this(subReaders, true);
      }
      
      public MultiReader(List<IndexReader> subReaders, boolean closeSubReaders) throws IOException {
        this(subReaders.toArray(new IndexReader[0]), closeSubReaders);
      }
      

      2) ParallelCompositeReader

      public ParallelCompositeReader(List<CompositeReader> readers) throws IOException {
        this(true, readers);
      }
      
      public ParallelCompositeReader(boolean closeSubReaders, List<CompositeReader> readers) throws IOException {
        this(closeSubReaders, readers, readers);
      }
      
      public ParallelCompositeReader(boolean closeSubReaders, List<CompositeReader> readers, List<CompositeReader> storedFieldReaders) throws IOException {
        this(closeSubReaders, readers.toArray(new CompositeReader[0]), storedFieldReaders.toArray(new CompositeReader[0]));
      }
      

      3) DirectoryReader

      protected DirectoryReader(Directory directory, List<LeafReader> segmentReaders) throws IOException {
        super(segmentReaders);
        this.directory = directory;
      }
      

      4) BaseCompositeReader

      @SuppressWarnings("unchecked")
      protected BaseCompositeReader(List<R> subReaders) throws IOException {
        this(subReaders.toArray((R[]) new IndexReader[subReaders.size()]));
      }
      

      5) Test
      I wrote a test case in "TestParallelCompositeReader".

      If you have any questions or requests, please left any comments

      Attachments

        1. LUCENE-8489.patch
          12 kB
          Namgyu Kim

        Activity

          People

            Unassigned Unassigned
            danmuzi Namgyu Kim
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: