lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Wettin <karl.wet...@gmail.com>
Subject Re: Lockless read-only deletions in IndexReader?
Date Thu, 30 Aug 2007 19:46:30 GMT

20 aug 2007 kl. 14.33 skrev Michael McCandless:

> "karl wettin" <karl.wettin@gmail.com> wrote:
>
>> I want to set documents in my IndexReader as deleted, but I will
>> never commit these deletions. Sort of a filter on a reader rather
>> than on a searcher, and no write-locks.
>

>> I could go hacking in IndexReader, definalizing it for decoration of
>> deleteDocument(int), or something like that, but would really
>> prefere not to.
>
> Yeah I think it may just be cleanest to modify IndexReader to not
> acquire the write lock nor commit its changes to the Directory on
> close.

How about something simple as this:

public class DeleteFilteredIndexReader extends FilterIndexReader {

   public DeleteFilteredIndexReader(IndexReader in) {
     super(in);
     filter = new BitSet(in.maxDoc());
   }

   private BitSet filter;

   public boolean isDeleted(int n) {
     return filter.get(n) || super.isDeleted(n);
   }

   public boolean hasDeletions() {
     return filter.nextSetBit(0) > -1 || super.hasDeletions();
   }


I did not look in the classpath code of BitSet yet, but I suppose
the nextSetBit(0) could be optimized.


-- 
karl

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message