Class CaffeineSimilarityCache
java.lang.Object
de.uni_trier.wi2.procake.similarity.wf.AbstractSimilarityCache
de.uni_trier.wi2.procake.similarity.impl.CaffeineSimilarityCache
- All Implemented Interfaces:
SimilarityCache
,Iterable<Map.Entry<DataObjectPair,
Similarity>>
- Direct Known Subclasses:
FileBasedCaffeineSimilarityCache
Stores pairs of data object IDs with their similarity into an asynchronous runtime cache,
allowing read- and write operations on its entries.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.github.benmanes.caffeine.cache.Cache<DataObjectPair,
Similarity> The cache that is used at runtimeprotected Duration
protected Duration
protected long
The maximum amount of entries that the cache can hold.protected long
protected com.github.benmanes.caffeine.cache.Weigher<DataObjectPair,
Similarity> Fields inherited from class de.uni_trier.wi2.procake.similarity.wf.AbstractSimilarityCache
lastTimeNanosForGetSimilarity, listeners, readOnly, recordStats
-
Constructor Summary
ModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionThis method is invoked by the init method to build the cache.static CaffeineSimilarityCache.GenericBuilder<?>
builder()
void
clear()
Removes all similarities from the cacheboolean
containsSimilarity
(DataObject queryObject, DataObject caseObject) protected Similarity
get
(DataObject queryObject, DataObject caseObject) getAsMap()
@NotNull Iterator<Map.Entry<DataObjectPair,
Similarity>> iterator()
void
print()
protected void
void
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 class de.uni_trier.wi2.procake.similarity.wf.AbstractSimilarityCache
addListener, forEach, getCacheEntry, getLastTimeNanosForGetSimilarity, getSimilarity, isEmpty, notifyListeners, removeEntriesById, removeEntryByIds, removeListener, resetStats, setSimilarity, updateStats
-
Field Details
-
cache
The cache that is used at runtime -
maximumSize
protected long maximumSizeThe maximum amount of entries that the cache can hold. Note that there is no implicit default bound. -
maximumWeight
protected long maximumWeight -
weigher
-
expireAfterAccessDuration
-
expireAfterWriteDuration
-
-
Constructor Details
-
CaffeineSimilarityCache
-
-
Method Details
-
getAsMap
-
size
public long size()- Returns:
- number of entries in the cache
-
getSimilarities
- Returns:
- all similarity objects from the cache
-
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
- Parameters:
queryObject
- data objectcaseObject
- data object- Returns:
- whether the cache is holding an entry for queryObject and caseObject
-
get
- Specified by:
get
in classAbstractSimilarityCache
-
setSimilarity
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.- Parameters:
queryObject
- data objectcaseObject
- data objectsimilarity
- the similarity of queryObject and caseObject
-
clear
public void clear()Description copied from interface:SimilarityCache
Removes all similarities from the cache -
remove
- Specified by:
remove
in classAbstractSimilarityCache
-
print
public void print() -
builder
-
iterator
-
spliterator
-