Index: CHANGES.txt =================================================================== --- CHANGES.txt (revision 722053) +++ CHANGES.txt (working copy) @@ -105,6 +105,10 @@ slower first-time usage due to populating the FieldCache. (Tim Sturge via Mike McCandless) + 8. LUCENE-1296: add protected method CachingWrapperFilter.docIdSetToCache + to allow subclasses to choose which DocIdSet implementation to use + (Paul Elschot via Mike McCandless) + Optimizations 1. LUCENE-1427: Fixed QueryWrapperFilter to not waste time computing Index: src/java/org/apache/lucene/search/CachingWrapperFilter.java =================================================================== --- src/java/org/apache/lucene/search/CachingWrapperFilter.java (revision 722053) +++ src/java/org/apache/lucene/search/CachingWrapperFilter.java (working copy) @@ -73,6 +73,14 @@ return bits; } + + /** Provide the DocIdSet to be cached, using the DocIdSet provided + * by the wrapped Filter. + * This implementation returns the given DocIdSet. + */ + protected DocIdSet docIdSetToCache(DocIdSet docIdSet, IndexReader reader) { + return docIdSet; + } public DocIdSet getDocIdSet(IndexReader reader) throws IOException { if (cache == null) { @@ -91,7 +99,7 @@ return new DocIdBitSet((BitSet) cached); } - final DocIdSet docIdSet = filter.getDocIdSet(reader); + final DocIdSet docIdSet = docIdSetToCache(filter.getDocIdSet(reader), reader); synchronized (cache) { // update cache cache.put(reader, docIdSet); Index: contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java =================================================================== --- contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java (revision 722055) +++ contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java (working copy) @@ -177,7 +177,10 @@ return result; } - /** Provide a SortedVIntList when it is definitely smaller than an OpenBitSet */ + /** Provide a SortedVIntList when it is definitely + * smaller than an OpenBitSet + * @deprecated Either use CachingWrapperFilter, or + * switch to a different DocIdSet implementation yourself. */ protected DocIdSet finalResult(OpenBitSetDISI result, int maxDocs) { return (result.cardinality() < (maxDocs / 9)) ? (DocIdSet) new SortedVIntList(result) Index: contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java =================================================================== --- contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java (revision 722055) +++ contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java (working copy) @@ -116,7 +116,10 @@ return emptyDocIdSet; } - /** Provide a SortedVIntList when it is definitely smaller than an OpenBitSet */ + /** Provide a SortedVIntList when it is definitely smaller + * than an OpenBitSet. + * @deprecated Either use CachingWrapperFilter, or + * switch to a different DocIdSet implementation yourself. */ protected DocIdSet finalResult(OpenBitSetDISI result, int maxDocs) { return (result.cardinality() < (maxDocs / 9)) ? (DocIdSet) new SortedVIntList(result)