1 package org.apache.lucene.facet.search.cache;
3 import java.io.IOException;
4 import java.util.HashMap;
6 import org.apache.lucene.index.IndexReader;
8 import org.apache.lucene.facet.index.params.CategoryListParams;
9 import org.apache.lucene.facet.index.params.FacetIndexingParams;
10 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
13 * Licensed to the Apache Software Foundation (ASF) under one or more
14 * contributor license agreements. See the NOTICE file distributed with
15 * this work for additional information regarding copyright ownership.
16 * The ASF licenses this file to You under the Apache License, Version 2.0
17 * (the "License"); you may not use this file except in compliance with
18 * the License. You may obtain a copy of the License at
20 * http://www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
30 * Cache for {@link CategoryListData}, per {@link CategoryListParams}.
32 * @lucene.experimental
34 public class CategoryListCache {
36 private HashMap<CategoryListParams, CategoryListData>
37 cldMap = new HashMap<CategoryListParams,CategoryListData>();
40 * Fetch the cached {@link CategoryListData} for a given {@link CategoryListParams}.
42 public CategoryListData get(CategoryListParams clp) {
43 return cldMap.get(clp);
47 * Register a pre-computed {@link CategoryListData}.
49 public void register(CategoryListParams clp, CategoryListData clData) {
50 cldMap.put(clp,clData);
54 * Load and register {@link CategoryListData}.
56 public void loadAndRegister(CategoryListParams clp,
57 IndexReader reader, TaxonomyReader taxo, FacetIndexingParams iparams) throws IOException {
58 CategoryListData clData = new CategoryListData(reader, taxo, iparams, clp);