Class AbstractSimilarityCache
java.lang.Object
de.uni_trier.wi2.procake.similarity.wf.AbstractSimilarityCache
- All Implemented Interfaces:
SimilarityCache
,Iterable<Map.Entry<DataObjectPair,
Similarity>>
- Direct Known Subclasses:
CaffeineSimilarityCache
,SimpleSimilarityCache
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected List<SimCacheListener>
protected boolean
protected boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(SimCacheListener listener) Adds a listener to the cachevoid
forEach
(Consumer<? super Map.Entry<DataObjectPair, Similarity>> action) protected abstract Similarity
get
(DataObject queryObject, DataObject caseObject) getCacheEntry
(DataObjectPair dataObjects) long
getSimilarity
(DataObject queryObject, DataObject caseObject) boolean
isEmpty()
protected void
notifyListeners
(DataObjectPair key, Similarity similarity, SimCacheListener.NotificationType notificationType) protected abstract void
void
Removes all entries with a query- and/or case id represented by the given idvoid
removeEntryByIds
(String queryId, String caseId) Removes the first entry found with the given queryId and caseId from the cache, if such an entry existsvoid
removeListener
(SimCacheListener listener) Removes a listener from the cacheprotected void
resetStats
(DataObjectPair dataObjects, Similarity similarity) protected void
setSimilarity
(Map<DataObjectPair, Similarity> cache, DataObject queryObject, DataObject caseObject, Similarity similarity) protected void
updateStats
(DataObjectPair dataObjects, Similarity similarity) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
iterator, spliterator
Methods inherited from interface de.uni_trier.wi2.procake.similarity.SimilarityCache
clear, containsSimilarity, getSimilarities, setSimilarity, size
-
Field Details
-
listeners
-
lastTimeNanosForGetSimilarity
protected long lastTimeNanosForGetSimilarity -
recordStats
protected boolean recordStats -
readOnly
protected boolean readOnly
-
-
Constructor Details
-
AbstractSimilarityCache
public AbstractSimilarityCache()
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceSimilarityCache
- Returns:
- whether the cache holds no entries
-
addListener
Description copied from interface:SimilarityCache
Adds a listener to the cache- Specified by:
addListener
in interfaceSimilarityCache
- Parameters:
listener
- the listener to be attached to the cache
-
removeListener
Description copied from interface:SimilarityCache
Removes a listener from the cache- Specified by:
removeListener
in interfaceSimilarityCache
- Parameters:
listener
- the listener to be detached from the cache
-
notifyListeners
protected void notifyListeners(DataObjectPair key, Similarity similarity, SimCacheListener.NotificationType notificationType) -
forEach
- Specified by:
forEach
in interfaceIterable<Map.Entry<DataObjectPair,
Similarity>>
-
getSimilarity
- Specified by:
getSimilarity
in interfaceSimilarityCache
- Parameters:
queryObject
- data objectcaseObject
- data object- Returns:
- the similarity of queryObject and caseObject (if the cache contains such an entry), null (otherwise)
-
get
-
setSimilarity
protected void setSimilarity(Map<DataObjectPair, Similarity> cache, DataObject queryObject, DataObject caseObject, Similarity similarity) -
removeEntryByIds
Removes the first entry found with the given queryId and caseId from the cache, if such an entry exists- Parameters:
queryId
- the id of the query objectcaseId
- the id of the case object
-
removeEntriesById
Removes all entries with a query- and/or case id represented by the given id- Parameters:
id
- a query- or case id
-
remove
-
getCacheEntry
- Parameters:
dataObjects
- a pair of data objects representing the key of the entry to be retrieved- Returns:
- the entry with the given key (if such an entry exists), null (otherwise)
-
updateStats
-
resetStats
-
getLastTimeNanosForGetSimilarity
public long getLastTimeNanosForGetSimilarity()- Specified by:
getLastTimeNanosForGetSimilarity
in interfaceSimilarityCache
- Returns:
- last time in nanoseconds for reading the cache
-