Module org.apache.lucene.facet
Class NameIntCacheLRU
java.lang.Object
org.apache.lucene.facet.taxonomy.writercache.NameIntCacheLRU
- Direct Known Subclasses:
NameHashIntCacheLRU
An LRU cache of mapping from name to int. Used to cache Ordinals of category paths.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidclear()private voidcreateCache(int maxSize) (package private) Integerget(FacetLabel name) intMaximum number of cache entries before eviction.intgetSize()Number of entries currently in the cache.private boolean(package private) Objectkey(FacetLabel name) Subclasses can override this to provide caching by e.g.(package private) Objectkey(FacetLabel name, int prefixLen) (package private) booleanIf cache is full remove least recently used entries from cache.(package private) booleanput(FacetLabel name, int prefixLen, Integer val) (package private) booleanput(FacetLabel name, Integer val) Add a new value to cache.(package private) Stringstats()
-
Field Details
-
cache
-
nMisses
long nMisses -
nHits
long nHits -
maxCacheSize
private int maxCacheSize
-
-
Constructor Details
-
NameIntCacheLRU
NameIntCacheLRU(int maxCacheSize)
-
-
Method Details
-
getMaxSize
public int getMaxSize()Maximum number of cache entries before eviction. -
getSize
public int getSize()Number of entries currently in the cache. -
createCache
private void createCache(int maxSize) -
get
-
key
Subclasses can override this to provide caching by e.g. hash of the string. -
key
-
put
Add a new value to cache. Return true if cache became full and some room need to be made. -
put
-
isCacheFull
private boolean isCacheFull() -
clear
void clear() -
stats
String stats() -
makeRoomLRU
boolean makeRoomLRU()If cache is full remove least recently used entries from cache. Return true if anything was removed, false otherwise.See comment in DirectoryTaxonomyWriter.addToCache(CategoryPath, int) for an explanation why we clean 1/3rd of the cache, and not just one entry.
-