lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Rutherglen" <jason.rutherg...@gmail.com>
Subject Re: IndexReader.reopen issue
Date Mon, 23 Jun 2008 15:00:21 GMT
"you need to forcefully get a new reader which you can make changes to, such
that it does not affect the original reader"

exactly.  I was thinking reopen(boolean forceNew) given people probably
expect to use reopen for this behavior, and may not think to look at clone.
Currently the reopen seems to reuse all of the internal data structures if
there have been no changes except for creating a new fieldsReader.  What
data structures need to be cloned besides deletedDocs?  It looks like a
clone of norms is made already.

On Mon, Jun 23, 2008 at 10:28 AM, Michael McCandless <
lucene@mikemccandless.com> wrote:

>
> My guess is your newIndexReader is in fact the same as your
> previousIndexReader, in which case getting the same gen in your LOG.info is
> expected.
>
> It seems like what you want is a way to force a new reader to be returned
> by reopen() even if there were no changes to the index.  Ie, you need to
> forcefully get a new reader which you can make changes to, such that it does
> not affect the original reader.  Maybe we need a reopen(boolean forced)?
>
> Alternatively, we could implement IndexReader.clone() for this situation.
>  Then one could first clone() an IndexReader, do a reopen() on the clone if
> others may have changed the index, then make changes through the new reader.
>
> Mike
>
>
> Jason Rutherglen wrote:
>
>  When this code is run, why are the generation numbers the same?  The
>> desired behavior is that the delete happens only to the newIndexReader,
>> leaving the previousIndexReader unaffected.
>>
>> IndexReader previousIndexReader = latestIndexSnapshot.getIndexReader();
>> IndexReader newIndexReader = previousIndexReader.reopen(); // returns the
>> same reader?
>> newIndexReader.deleteDocument(10);
>> newIndexReader.flush();
>> newIndexReader = newIndexReader.reopen();
>> LOG.info("previous reader gen:
>> "+previousIndexReader.getIndexCommit().getGeneration()+" newIndexReader gen:
>> "+newIndexReader.getIndexCommit().getGeneration());
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>

Mime
View raw message