TotalFacetCountsCache (Lucene 3.6.2 API)
Keywords: org.apache.lucene.facet.search.TotalFacetCountsCache class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.facet.search
Class TotalFacetCountsCache

    java.lang.Object
      org.apache.lucene.facet.search.TotalFacetCountsCache

    public final class TotalFacetCountsCache

extends Object

Manage an LRU cache for `TotalFacetCounts` per index, taxonomy, and facet indexing params.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
`static int` | `DEFAULT_CACHE_SIZE` Default size of in memory cache for computed total facet counts.

Method Summary
`void` | `clear()` Clear the cache.
`int` | `getCacheSize()`
`static TotalFacetCountsCache` | `getSingleton()` Get the single instance of this cache
`TotalFacetCounts` | `getTotalCounts(org.apache.lucene.index.IndexReader indexReader, TaxonomyReader taxonomy, FacetIndexingParams facetIndexingParams, CategoryListCache clCache)` Get the total facet counts for a reader/taxonomy pair and facet indexing parameters.
`void` | `load(File inputFile, org.apache.lucene.index.IndexReader indexReader, TaxonomyReader taxonomy, FacetIndexingParams facetIndexingParams)` Load `TotalFacetCounts` matching input parameters from the provided outputFile and add them into the cache for the provided indexReader, taxonomy, and facetIndexingParams.
`void` | `setCacheSize(int size)` Set the number of TotalFacetCounts arrays that will remain in memory cache.
`void` | `store(File outputFile, org.apache.lucene.index.IndexReader indexReader, TaxonomyReader taxonomy, FacetIndexingParams facetIndexingParams, CategoryListCache clCache)` Store the `TotalFacetCounts` matching input parameters into the provided outputFile, making them available for a later call to `load(File, IndexReader, TaxonomyReader, FacetIndexingParams)`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_CACHE_SIZE

    public static final int DEFAULT_CACHE_SIZE

  Default size of in memory cache for computed total facet counts. Set to 2 for the case when an application reopened a reader and the original one is still in use (Otherwise there will be switching again and again between the two.)

  See Also:
    Constant Field Values

Method Detail

### getSingleton

    public static TotalFacetCountsCache getSingleton()

  Get the single instance of this cache

### getTotalCounts

    public TotalFacetCounts getTotalCounts(org.apache.lucene.index.IndexReader indexReader,
                                           TaxonomyReader taxonomy,
                                           FacetIndexingParams facetIndexingParams,
                                           CategoryListCache clCache)
                                    throws IOException

  Get the total facet counts for a reader/taxonomy pair and facet indexing parameters. If not in cache, computed here and added to the cache for later use.

  Parameters:
    `indexReader` - the documents index
    `taxonomy` - the taxonomy index
    `facetIndexingParams` - facet indexing parameters
    `clCache` - category list cache for faster computation, can be null
  Returns:
    the total facet counts.
  Throws:
    `IOException`

### load

    public void load(File inputFile,
                     org.apache.lucene.index.IndexReader indexReader,
                     TaxonomyReader taxonomy,
                     FacetIndexingParams facetIndexingParams)
              throws IOException

  Load `TotalFacetCounts` matching input parameters from the provided outputFile and add them into the cache for the provided indexReader, taxonomy, and facetIndexingParams. If a `TotalFacetCounts` for these parameters already exists in the cache, it will be replaced by the loaded one.

  Parameters:
    `inputFile` - file from which to read the data
    `indexReader` - the documents index
    `taxonomy` - the taxonomy index
    `facetIndexingParams` - the facet indexing parameters
  Throws:
    `IOException` - on error
  See Also:
    `store(File, IndexReader, TaxonomyReader, FacetIndexingParams, CategoryListCache)`

### store

    public void store(File outputFile,
                      org.apache.lucene.index.IndexReader indexReader,
                      TaxonomyReader taxonomy,
                      FacetIndexingParams facetIndexingParams,
                      CategoryListCache clCache)
               throws IOException

  Store the `TotalFacetCounts` matching input parameters into the provided outputFile, making them available for a later call to `load(File, IndexReader, TaxonomyReader, FacetIndexingParams)`. If these `TotalFacetCounts` are available in the cache, they are used. But if they are not in the cache, this call will first compute them (which will also add them to the cache).

  Parameters:
    `outputFile` - file to store in.
    `indexReader` - the documents index
    `taxonomy` - the taxonomy index
    `facetIndexingParams` - the facet indexing parameters
    `clCache` - category list cache for faster computation, can be null
  Throws:
    `IOException` - on error
  See Also:
    `load(File, IndexReader, TaxonomyReader, FacetIndexingParams)`, `getTotalCounts(IndexReader, TaxonomyReader, FacetIndexingParams, CategoryListCache)`

### clear

    public void clear()

  Clear the cache.

### getCacheSize

    public int getCacheSize()

  Returns:
    the maximal cache size

### setCacheSize

    public void setCacheSize(int size)

  Set the number of TotalFacetCounts arrays that will remain in memory cache.

  If new size is smaller than current size, the cache is appropriately trimmed.

  Minimal size is 1, so passing zero or negative size would result in size of 1.

  Parameters:
    `size` - new size to set

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD