lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Busch (JIRA)" <>
Subject [jira] Commented: (LUCENE-986) Refactor segmentInfos from IndexReader into its subclasses
Date Thu, 30 Aug 2007 05:36:31 GMT


Michael Busch commented on LUCENE-986:

What do you think about this alternative approach:

- SegmentReader, MultiSegmentReader and MultiReader all extend IndexReader
- 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 simpler,  because it can then return a 
MultiSegmentReader instance in all cases. The logic of opening the 
different segments could move from 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

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:
>             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:
> 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:
For additional commands, e-mail:

View raw message