lucene-dev mailing list archives

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


Earwin Burrfoot commented on LUCENE-2345:

I mentioned this issue earlier. My patch removes loadTermsIndex method from SegmentReader
and requires you to reopen it. At that moment you can stuff it with a set of plugins without
leaving 'final' paradise.

There are still things to consider. Some SR guts could be converted to plugins themselves,
so you can override them with your implementation if you wish. If that is so, there should
be a way to decide which of the plugins should be loaded for current SR mode. My previous
design loaded plugins only for full-fledged readers.

bq. Is there a ticket or wiki page that details the "plugin" architecture/design so i could
take a look?
The design itself was never published, rather it was discussed several times on a mailing
list, and simmered inside my head for some time. I have a first impl running at my workplace,
but it is really fugly :) I will flesh out a proper description after the refactoring, but
it has all your points in one or another form. Biggest differences are - they are keyed by
Class not by String, they declare multiple interfaces they provide, they declare dependencies,
they don't have to implement/extend anything, as all the hooks are on the factory classes.
Also, they extend not only SegmentReader, but the whole hierarchy - SR, MR, DR, whatever.

The problem of overriding SR methods is solved by delegating these methods to plugins, which
can be either default or user-provided. (But remember the question of which subset should
be initialized for which SR mode)

> 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, LUCENE-2345_3.0.plugins.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