Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Won't Fix
-
None
-
None
-
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