[ 
https://issues.apache.org/jira/browse/LUCENE-1314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12607857#action_12607857
 ] 

Nadav Har'El commented on LUCENE-1314:
--------------------------------------

At first glance, my opinion was that adding this flag to reopen() is confusing. 
reopen()'s current behavior is explained well in the documentation, and has a 
particular use case in mind (checking if the index has changed, and if it has, 
reopen it). Frankly, I didn't understand why reopen() should (even with the 
addition of a new parameter) clone or "copy on write" the IndexReader when the 
index hasn't changed.
If this capability is needed, wouldn't it have been clearer if IndexReader had 
some new clone() or copyOnWrite() (in IndexReader's case, a write would 
actually be a delete...) method that can be called to get a new object that 
behaves independently from the previous one when it comes to writing (again, a 
delete)?
In your code, you could then do something like

newIndexReader = indexReader.reopen();
if(newIndexReader==indexReader)
  newIndexReader = indexReader.clone(); // copy on write
else {
   oldIndexReader.close(); // most applications won't do this here, but never 
mind now.
}
indexReader = newIndexReader;

I thought that this was a cleaner API, because reopen() isn't complicated with 
an extra flag that has nothing to do with its intended function, and the new 
clone() or copyOnWrite() method can also be used in other situations when you 
want different objects of the same index to handle deletes separately.

But on second glance, it dawned on me: You can't actually delete on both 
objects at once, because when you start deleting in one object, it holds a lock 
and then you can't do deletions in the second object! So I have to admit, the 
usefulness of of a general clone/copyOnWrite feature for IndexReader is quite 
limited. My suggestion above can still be the API, but I admit it will hardly 
be useful in any situation except (the rare situation nowadays of?) a reopen() 
and later deletes.

> IndexReader.reopen(boolean force)
> ---------------------------------
>
>                 Key: LUCENE-1314
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1314
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: Index
>    Affects Versions: 2.3.1
>            Reporter: Jason Rutherglen
>            Assignee: Michael McCandless
>            Priority: Minor
>         Attachments: lucene-1314.patch, lucene-1314.patch, lucene-1314.patch
>
>
> Based on discussion 
> http://www.nabble.com/IndexReader.reopen-issue-td18070256.html.  The problem 
> is reopen returns the same reader if there are no changes, so if docs are 
> deleted from the new reader, they are also reflected in the previous reader 
> which is not always desired behavior.

-- 
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