Excellent, a much simpler approach! I think it should work? Maybe override numDocs() as well?
Mike "Karl Wettin" <[EMAIL PROTECTED]> wrote: > > 20 aug 2007 kl. 14.33 skrev Michael McCandless: > > > "karl wettin" <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]