org.apache.lucene.facet.taxonomy.writercache

## Class Cl2oTaxonomyWriterCache

- java.lang.Object
- - org.apache.lucene.facet.taxonomy.writercache.Cl2oTaxonomyWriterCache

- All Implemented Interfaces:
    TaxonomyWriterCache

      public class Cl2oTaxonomyWriterCache
      extends Object
      implements TaxonomyWriterCache

  `TaxonomyWriterCache` using `CompactLabelToOrdinal`. Although called cache, it maintains in memory all the mappings from category to ordinal, relying on that `CompactLabelToOrdinal` is an efficient mapping for this purpose.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Cl2oTaxonomyWriterCache(int initialCapcity, float loadFactor, int numHashArrays)` Sole constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clears the content of the cache.
    `void` | `close()` Let go of whatever resources the cache is holding.
    `int` | `get(FacetLabel categoryPath)` Lookup a category in the cache, returning its ordinal, or a negative number if the category is not in the cache.
    `int` | `getMemoryUsage()` Returns the number of bytes in memory used by this object.
    `boolean` | `isFull()` Returns true if the cache is full, such that the next `TaxonomyWriterCache.put(org.apache.lucene.facet.taxonomy.FacetLabel, int)` will evict entries from it, false otherwise.
    `boolean` | `put(FacetLabel categoryPath, int ordinal)` Add a category to the cache, with the given ordinal as the value.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Cl2oTaxonomyWriterCache

          public Cl2oTaxonomyWriterCache(int initialCapcity,
                                         float loadFactor,
                                         int numHashArrays)

      Sole constructor.

  - ### Method Detail

    - #### clear

          public void clear()

      Description copied from interface: `TaxonomyWriterCache`
      Clears the content of the cache. Unlike `TaxonomyWriterCache.close()`, the caller can assume that the cache is still operable after this method returns.
      Specified by:
        `clear` in interface `TaxonomyWriterCache`

    - #### close

          public void close()

      Description copied from interface: `TaxonomyWriterCache`
      Let go of whatever resources the cache is holding. After a close(), this object can no longer be used.
      Specified by:
        `close` in interface `TaxonomyWriterCache`

    - #### isFull

          public boolean isFull()

      Description copied from interface: `TaxonomyWriterCache`
      Returns true if the cache is full, such that the next `TaxonomyWriterCache.put(org.apache.lucene.facet.taxonomy.FacetLabel, int)` will evict entries from it, false otherwise.
      Specified by:
        `isFull` in interface `TaxonomyWriterCache`

    - #### get

          public int get(FacetLabel categoryPath)

      Description copied from interface: `TaxonomyWriterCache`
      Lookup a category in the cache, returning its ordinal, or a negative number if the category is not in the cache.

      It is up to the caller to remember what a negative response means: If the caller knows the cache is complete (it was initially fed with all the categories, and since then put() never returned true) it means the category does not exist. Otherwise, the category might still exist, but just be missing from the cache.

      Specified by:
        `get` in interface `TaxonomyWriterCache`

    - #### put

          public boolean put(FacetLabel categoryPath,
                             int ordinal)

      Description copied from interface: `TaxonomyWriterCache`
      Add a category to the cache, with the given ordinal as the value.

      If the implementation keeps only a partial cache (e.g., an LRU cache) and finds that its cache is full, it should clear up part of the cache and return `true`. Otherwise, it should return `false`.

      The reason why the caller needs to know if part of the cache was cleared is that in that case it will have to commit its on-disk index (so that all the latest category additions can be searched on disk, if we can't rely on the cache to contain them).

      Ordinals should be non-negative. Currently there is no defined way to specify that a cache should remember a category does NOT exist. It doesn't really matter, because normally the next thing we do after finding that a category does not exist is to add it.

      Specified by:
        `put` in interface `TaxonomyWriterCache`

    - #### getMemoryUsage

          public int getMemoryUsage()

      Returns the number of bytes in memory used by this object.

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.