"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 <
[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to