lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Busch (JIRA)" <>
Subject [jira] Commented: (LUCENE-743) IndexReader.reopen()
Date Fri, 17 Aug 2007 07:12:40 GMT


Michael Busch commented on LUCENE-743:

>   IndexReader a, b, c = ...
>   MultiReader ab = new MultiReader({a, b})
>   MultiReader bc = new MultiReader({b, c})
>   ...b changes on disk...
>   ab.reopen(); // this shouldn't affect bc;
> one possibility would be for the semantics of reopen to close old readers only 
> if it completely owns them; ie: MultiReader should never close anything in 
> reopen, MultiSegmentReader should close all of the subreaders since it opened 
> them in the first place

So if 'b' in your example is a MultiSegmentReader, then the reopen() call 
triggered from MultiReader.reopen() would close old readers, because it owns them, 
thus 'bc' wouldn't work anymore. So it depends on the caller of 
MultiSegmentReader.reopen() whether or not to close the subreaders. I think this 
is kind of messy. Well instead of reopen() we could add 
reopen(boolean closeOldReaders), but then...

>   IndexReader r = ...
>   ...
>   IndexReader tmp = r.reopen();
>   if (tmp != r) r.close(); 
>   r = tmp;
>   ...

... is actually easy enough as you pointed out, so that the extra complexity is not 
really worth it IMO.

> In general i think the safest thing to do is for reopen to never close.  

So yes, I agree.

> why is the meat of reopen still in "IndexReader" with a "if (reader instanceof 
> SegmentReader)" style logic in it?  can't the different reopen mechanisms be 
> refactored down into SegmentReader and MultiSegmentReader respectively? 

I'm not sure if the code would become cleaner if we did that. Sometimes a 
SegmentReader would then have to return a MultiSegmentReader instance and vice
versa. So we'd probably have to duplicate some of the code in these two classes.

> IndexReader.reopen()
> --------------------
>                 Key: LUCENE-743
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Index
>            Reporter: Otis Gospodnetic
>            Assignee: Michael Busch
>            Priority: Minor
>             Fix For: 2.3
>         Attachments:, lucene-743.patch, lucene-743.patch, lucene-743.patch,,
> This is Robert Engels' implementation of IndexReader.reopen() functionality, as a set
of 3 new classes (this was easier for him to implement, but should probably be folded into
the core, if this looks good).

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