[ 
https://issues.apache.org/jira/browse/LUCENE-743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539359
 ] 

Michael McCandless commented on LUCENE-743:
-------------------------------------------

{quote}
Hmm I was thinking about this before (that's actually why I put that
method in there). But I don't think this is gonna work. For example,
let's say we use a MultiReader that has two SegmentReader SR1 and SR2.
Now only SR2 changed, we reopen the MR which increases the refCount on
SR1, because it shares that SR. Now we close the old MultiReader, which
calls close() on SR1. If now SegmentReader.close() calls Norm.decRef(), 
then it will close the norms even though they are still used by the new
MultiReader.
{quote}

Ugh, you're right.  The challenge is sometimes a reference to SR means
"I will use norms" (this is when MultiReader incRefs) but other times
it means "I will not use norms" (this is when SR incRefs due to
reopen).

OK, I like your original proposal: SR overrides incRef() and incrs its
RC as well as the RC for each Norm it's using.  Then, in SR's
reopenSegment, you carefully incRef the "original" SR without
incRef'ing its Norms (except for those Norms you will keep).

Likewise, SR overrides decRef() to decr its RC and RC for each Norm.
But, when a reopened SR1.doClose() is called, you must carefully
decRef the RD of the original SR but not decRef each of its Norms
(except for those you had actually shared).

This way when MR calls SR.incRef/decRef then all Norms and the SR's RC
are incr'd/decr'd.  But when SR1 shares resources with an original SR
it only incr's/decr's the refCount of the SR.


> IndexReader.reopen()
> --------------------
>
>                 Key: LUCENE-743
>                 URL: https://issues.apache.org/jira/browse/LUCENE-743
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Index
>            Reporter: Otis Gospodnetic
>            Assignee: Michael Busch
>            Priority: Minor
>             Fix For: 2.3
>
>         Attachments: IndexReaderUtils.java, lucene-743-take2.patch, 
> lucene-743-take3.patch, lucene-743-take4.patch, lucene-743.patch, 
> lucene-743.patch, lucene-743.patch, MyMultiReader.java, MySegmentReader.java, 
> varient-no-isCloneSupported.BROKEN.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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to