add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / remote / src / java / org / apache / lucene / search / RemoteCachingWrapperFilter.java
1 package org.apache.lucene.search;
2
3 /**
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 import java.io.IOException;
21
22 import org.apache.lucene.index.IndexReader;
23
24 /**
25  * Provides caching of {@link org.apache.lucene.search.Filter}s themselves on the remote end of an RMI connection.
26  * The cache is keyed on Filter's hashCode(), so if it sees the same filter twice
27  * it will reuse the original version.
28  * <p/>
29  * NOTE: This does NOT cache the Filter bits, but rather the Filter itself.
30  * Thus, this works hand-in-hand with {@link org.apache.lucene.search.CachingWrapperFilter} to keep both
31  * file Filter cache and the Filter bits on the remote end, close to the searcher.
32  * <p/>
33  * Usage:
34  * <p/>
35  * To cache a result you must do something like 
36  * RemoteCachingWrapperFilter f = new RemoteCachingWrapperFilter(new CachingWrapperFilter(myFilter));
37  * <p/>
38  *
39  * @deprecated This package (all of contrib/remote) will be
40  * removed in 4.0.
41  */
42 @Deprecated
43 public class RemoteCachingWrapperFilter extends Filter {
44   protected Filter filter;
45
46   public RemoteCachingWrapperFilter(Filter filter) {
47     this.filter = filter;
48   }
49   
50   /**
51    * Uses the {@link org.apache.lucene.search.FilterManager} to keep the cache for a filter on the 
52    * searcher side of a remote connection.
53    * @param reader the index reader for the Filter
54    * @return the DocIdSet
55    */
56   @Override
57   public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
58     Filter cachedFilter = FilterManager.getInstance().getFilter(filter);
59     return cachedFilter.getDocIdSet(reader);
60   }
61 }