lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Goller <>
Subject Re: File timestamps / subclassing of IndexReader
Date Thu, 20 Nov 2003 16:48:06 GMT
Doug Cutting schrieb:
> My preference is that SegmentInfos remain package private.  The easiest 
> way to do this would just be to make the segmentInfos field of 
> IndexReader package private (i.e. with no public/private declaration). 
> The only problem is that then IndexReader would not be correctly 
> subclassable from outside the package.
> Alternately, segmentInfos could be made private, will all access from 
> IndexReader only.  Can you see a way to get things to work correctly 
> this way?

Making segmentInfos field of IndexReader package private would be
easy to do. I think FilterIndexReader would still work if we enforce
that all subclasses of FilterIndexReader (even from outside the package)
call super(IndexReader) in their constructors. Note that I call
super.segmentInfos = in.segmentInfos in FilterIndexReader(IndexReader).
Thus all sysnchronization is done by FilterIndexReader superclass
IndexReader using in.segmentInfos.

I don't see a problem for subclassing IndexReader directly either,
even from outside the package. With the segmentInfos field made package
private such classes simply would not see segmentInfos. It would be null
and consequently would not be used by delete(int). Of course such
subclasses would have to take care of versioning themselves. I am not
sure what kind of subclasses of IndexReader you have in mind. With the
segmentInfos field made package private I can imagine very general
subclasses e.g. implemented by a totally different full-text index.
However, IndexReader and all its subclasses need a directory and
synchronization (write.lock) is done by IndexReader in the final
methods delete(int) and close(). However that restriction is an old

This is a very complex subject. Maybe I am missing the point.


Ps: Patch with segmentInfos field made package private is attached.

View raw message