[
https://issues.apache.org/jira/browse/LUCENE-2345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850067#action_12850067
]
Earwin Burrfoot commented on LUCENE-2345:
-----------------------------------------
bq. will this change really conflict w/ your ongoing refactoring (to have
DirReader subclass MultiReader)? It seems somewhat orthogonal?
Ongoing contains a massive rework of how open/reopen/clone/close is done.
Folding copypaste between DirReader and MultiReader is a byproduct.
The aim is to have clean initialization, get rid of of init/reinit/moreinit
methods, moving the code to constructors.
This alone plays bad with factories.
The next step, plugins - conflicts ideologically. Plugins allow extension by
composition, which is (in my view) much more clean than subclassing.
Landing them without refactoring all this mess beforehand is dangerous, I
already hit some places where reopen/clone were done wrong in respect to
existing reader fields. Even more - NRT reader lifecycle is really messy - it
beginnings as a reader aimed only for merging, and then being upgraded in two
separate stages is finally wrapped in DirReader to be used for actual
searching. The factory/init() approach ignores this, and each user of this API
will be on his own to separate lightweight readers from full-fledged ones.
> Make it possible to subclass SegmentReader
> ------------------------------------------
>
> Key: LUCENE-2345
> URL: https://issues.apache.org/jira/browse/LUCENE-2345
> 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 SegmentReader
> 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() (DirectoryReader.open,
> 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: [email protected]
For additional commands, e-mail: [email protected]