[ https://issues.apache.org/jira/browse/LUCENE-986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523768 ]
Michael Busch commented on LUCENE-986: -------------------------------------- What do you think about this alternative approach: - SegmentReader, MultiSegmentReader and MultiReader all extend IndexReader - IndexReader.open() always returns a MultiSegmentReader instance, even if the index has only one segment. We can make some optimizations, so that e. g. MultiSegmentReader.termDocs() returns a SegmentTermDocs in case there's only one underlying SegmentReader. - All write lock and transaction logic goes into MultiSegmentReader, as it is the only reader that has to obtain a write lock. The advantage here is that only one class (MultiSegmentReader) is responsible for acquiring the write lock. It would also make IndexReader.open() simpler, because it can then return a MultiSegmentReader instance in all cases. The logic of opening the different segments could move from IndexReader.open() to the constructor of MultiSegmentReader. Also LUCENE-743 (IndexReader.reopen()) would become simpler. The disadvantage of this approach is apparently that always using a MultiSegmentReader would add some overhead when reading optimized indexes, but actually I don't think that this overhead would really be significant. If we go the DirectoryIndexReader way (where SegmentReader and MultiSegmentReader both extend DirectoryIndexReader), then we still need an ownDirectory variable that tells SegmentReader if it has to acquire a write lock or not, depending on whether it is a subreader of MultiSegmentReader or not. And of course we add another layer to the IndexReader hierachy. So I'm not sure which approach is the better one. I'm hoping to get some opionions here! Hoss? Others? > Refactor segmentInfos from IndexReader into its subclasses > ---------------------------------------------------------- > > Key: LUCENE-986 > URL: https://issues.apache.org/jira/browse/LUCENE-986 > Project: Lucene - Java > Issue Type: Improvement > Components: Index > Reporter: Michael Busch > Assignee: Michael Busch > Priority: Minor > Fix For: 2.3 > > > References to segmentInfos in IndexReader cause different kinds of problems > for subclasses of IndexReader, like e. g. MultiReader. > Only subclasses of IndexReader that own the index directory, namely > SegmentReader and MultiSegmentReader, should have a SegmentInfos object > and be able to access it. > Further information: > http://www.gossamer-threads.com/lists/lucene/java-dev/51808 > http://www.gossamer-threads.com/lists/lucene/java-user/52460 > A part of the refactoring work was already done in LUCENE-781 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]