Class CaffeineSimilarityCache

All Implemented Interfaces:
SimilarityCache, Iterable<Map.Entry<DataObjectPair,Similarity>>
Direct Known Subclasses:

public class CaffeineSimilarityCache extends AbstractSimilarityCache
Stores pairs of data object IDs with their similarity into an asynchronous runtime cache, allowing read- and write operations on its entries.
  • Field Details

    • cache

      protected com.github.benmanes.caffeine.cache.Cache<DataObjectPair,Similarity> cache
      The cache that is used at runtime
    • maximumSize

      protected long maximumSize
      The maximum amount of entries that the cache can hold. Note that there is no implicit default bound.
    • maximumWeight

      protected long maximumWeight
    • weigher

      protected com.github.benmanes.caffeine.cache.Weigher<DataObjectPair,Similarity> weigher
    • expireAfterAccessDuration

      protected Duration expireAfterAccessDuration
    • expireAfterWriteDuration

      protected Duration expireAfterWriteDuration
  • Constructor Details

  • Method Details

    • getAsMap

    • size

      public long size()
      number of entries in the cache
    • getSimilarities

      public Collection<Similarity> getSimilarities()
      all similarity objects from the cache
    • buildCache

      protected com.github.benmanes.caffeine.cache.Caffeine<Object,Object> buildCache()
      This method is invoked by the init method to build the cache. If specified, builds the cache with the set maximum size of entries it can hold. The cache will automatically remove an entry if an incoming one would exceed the maximum size.
    • containsSimilarity

      public boolean containsSimilarity(DataObject queryObject, DataObject caseObject)
      queryObject - data object
      caseObject - data object
      whether the cache is holding an entry for queryObject and caseObject
    • get

      protected Similarity get(DataObject queryObject, DataObject caseObject)
      Specified by:
      get in class AbstractSimilarityCache
    • setSimilarity

      public void setSimilarity(DataObject queryObject, DataObject caseObject, Similarity similarity)
      Description copied from interface: SimilarityCache
      Puts a new entry into the cache, the IDs of queryObject and caseObject as the key and similarity as its value.
      queryObject - data object
      caseObject - data object
      similarity - the similarity of queryObject and caseObject
    • clear

      public void clear()
      Description copied from interface: SimilarityCache
      Removes all similarities from the cache
    • remove

      protected void remove(String queryId, String caseId)
      Specified by:
      remove in class AbstractSimilarityCache
    • print

      public void print()
    • builder

      public static CaffeineSimilarityCache.GenericBuilder<?> builder()
    • iterator

      @NotNull public @NotNull Iterator<Map.Entry<DataObjectPair,Similarity>> iterator()
    • spliterator