Interface SimilarityCache
- All Superinterfaces:
Iterable<Map.Entry<DataObjectPair,
Similarity>>
- All Known Implementing Classes:
AbstractSimilarityCache
,CaffeineSimilarityCache
,FileBasedCaffeineSimilarityCache
,SimpleSimilarityCache
Main interface for all similarity caches
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(SimCacheListener listener) Adds a listener to the cachevoid
clear()
Removes all similarities from the cacheboolean
containsSimilarity
(DataObject queryObject, DataObject caseObject) long
getSimilarity
(DataObject queryObject, DataObject caseObject) boolean
isEmpty()
void
removeListener
(SimCacheListener listener) Removes a listener from the cachevoid
setSimilarity
(DataObject queryObject, DataObject caseObject, Similarity similarity) Puts a new entry into the cache, the IDs of queryObject and caseObject as the key and similarity as its value.long
size()
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
addListener
Adds a listener to the cache- Parameters:
listener
- the listener to be attached to the cache
-
removeListener
Removes a listener from the cache- Parameters:
listener
- the listener to be detached from the cache
-
containsSimilarity
- Parameters:
queryObject
- data objectcaseObject
- data object- Returns:
- whether the cache is holding an entry for queryObject and caseObject
-
getSimilarity
- Parameters:
queryObject
- data objectcaseObject
- data object- Returns:
- the similarity of queryObject and caseObject (if the cache contains such an entry), null (otherwise)
-
setSimilarity
Puts a new entry into the cache, the IDs of queryObject and caseObject as the key and similarity as its value.- Parameters:
queryObject
- data objectcaseObject
- data objectsimilarity
- the similarity of queryObject and caseObject
-
getSimilarities
Collection<Similarity> getSimilarities()- Returns:
- all similarity objects from the cache
-
clear
void clear()Removes all similarities from the cache -
size
long size()- Returns:
- number of entries in the cache
-
getLastTimeNanosForGetSimilarity
long getLastTimeNanosForGetSimilarity()- Returns:
- last time in nanoseconds for reading the cache
-
isEmpty
boolean isEmpty()- Returns:
- whether the cache holds no entries
-