lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shai Erera (JIRA)" <>
Subject [jira] Commented: (LUCENE-2345) Make it possible to subclass SegmentReader
Date Fri, 26 Mar 2010 11:10:27 GMT


Shai Erera commented on LUCENE-2345:

Thanks Uwe, I know that ctor is the preferred way, and in the process of introducing IWC I
delete IW.init which all ctors called and pulled all the code to IW ctor. I will make that
init() on IW final. But sometimes putting code in init() is not bad (and it's used in Lucene
elsewhere too (e.g. PQ and up until recently IW).

> Make it possible to subclass SegmentReader
> ------------------------------------------
>                 Key: LUCENE-2345
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Wish
>          Components: Index
>            Reporter: Tim Smith
>             Fix For: 3.1
>         Attachments: LUCENE-2345_3.0.patch
> I would like the ability to subclass SegmentReader for numerous reasons:
> * to capture initialization/close events
> * attach custom objects to an instance of a segment reader (caches, statistics, so on
and so forth)
> * override methods on segment reader as needed
> currently this isn't really possible
> I propose adding a SegmentReaderFactory that would allow creating custom subclasses of
> default implementation would be something like:
> {code}
> public class SegmentReaderFactory {
>   public SegmentReader get(boolean readOnly) {
>     return readOnly ? new ReadOnlySegmentReader() : new SegmentReader();
>   }
>   public SegmentReader reopen(SegmentReader reader, boolean readOnly) {
>     return newSegmentReader(readOnly);
>   }
> }
> {code}
> It would then be made possible to pass a SegmentReaderFactory to IndexWriter (for pooled
readers) as well as to SegmentReader.get() (, etc)
> I could prepare a patch if others think this has merit
> Obviously, this API would be "experimental/advanced/will change in future"

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