2 * Copyright 2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System
.Runtime
.InteropServices
;
18 using IndexReader
= Lucene
.Net
.Index
.IndexReader
;
19 namespace Lucene
.Net
.Search
22 /// <summary> Wraps another filters result and caches it. The caching
23 /// behavior is like {@link QueryFilter}. The purpose is to allow
24 /// filters to simply filter, and then wrap with this class to add
25 /// caching, keeping the two concerns decoupled yet composable.
28 public class CachingWrapperFilter
:Filter
30 private Filter filter
;
32 /// <todo> What about serialization in RemoteSearchable? Caching won't work. </todo>
33 /// <summary> Should transient be removed?
36 private System
.Collections
.IDictionary cache
;
38 /// <param name="filter">Filter to cache results of
40 public CachingWrapperFilter(Filter filter
)
45 public override System
.Collections
.BitArray
Bits(IndexReader reader
)
49 cache
= new System
.Collections
.Hashtable();
55 System
.Collections
.BitArray cached
= (System
.Collections
.BitArray
) cache
[reader
];
62 System
.Collections
.BitArray bits
= filter
.Bits(reader
);
73 public override System
.String
ToString()
75 return "CachingWrapperFilter(" + filter
+ ")";