Class DirectoryTaxonomyReader

  • All Implemented Interfaces:, java.lang.AutoCloseable

    public class DirectoryTaxonomyReader
    extends TaxonomyReader
    A TaxonomyReader which retrieves stored taxonomy information from a Directory.

    Reading from the on-disk index on every method call is too slow, so this implementation employs caching: Some methods cache recent requests and their results, while other methods prefetch all the data into memory and then provide answers directly from in-memory tables. See the documentation of individual methods for comments on their performance.

    • Method Detail

      • getOrdinal

        public int getOrdinal​(FacetLabel cp)
        Description copied from class: TaxonomyReader
        Returns the ordinal of the category given as a path. The ordinal is the category's serial number, an integer which starts with 0 and grows as more categories are added (note that once a category is added, it can never be deleted).
        Specified by:
        getOrdinal in class TaxonomyReader
        the category's ordinal or TaxonomyReader.INVALID_ORDINAL if the category wasn't foun.
      • getPath

        public FacetLabel getPath​(int ordinal)
        Description copied from class: TaxonomyReader
        Returns the path name of the category with the given ordinal.
        Specified by:
        getPath in class TaxonomyReader
      • getSize

        public int getSize()
        Description copied from class: TaxonomyReader
        Returns the number of categories in the taxonomy. Note that the number of categories returned is often slightly higher than the number of categories inserted into the taxonomy; This is because when a category is added to the taxonomy, its ancestors are also added automatically (including the root, which always get ordinal 0).
        Specified by:
        getSize in class TaxonomyReader
      • setCacheSize

        public void setCacheSize​(int size)
        setCacheSize controls the maximum allowed size of each of the caches used by getPath(int) and getOrdinal(FacetLabel).

        Currently, if the given size is smaller than the current size of a cache, it will not shrink, and rather we be limited to its current size.

        size - the new maximum cache size, in number of entries.
      • toString

        public java.lang.String toString​(int max)
        Returns ordinal -> label mapping, up to the provided max ordinal or number of ordinals, whichever is smaller.