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) void
clear()
private void
createCache
(int maxSize) (package private) Integer
get
(FacetLabel name) int
Maximum number of cache entries before eviction.int
getSize()
Number of entries currently in the cache.private boolean
(package private) Object
key
(FacetLabel name) Subclasses can override this to provide caching by e.g.(package private) Object
key
(FacetLabel name, int prefixLen) (package private) boolean
If cache is full remove least recently used entries from cache.(package private) boolean
put
(FacetLabel name, int prefixLen, Integer val) (package private) boolean
put
(FacetLabel name, Integer val) Add a new value to cache.(package private) String
stats()
-
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.
-