Package edu.berkeley.nlp.lm.cache
Class ArrayEncodedDirectMappedLmCache
- java.lang.Object
-
- edu.berkeley.nlp.lm.cache.ArrayEncodedDirectMappedLmCache
-
- All Implemented Interfaces:
ArrayEncodedLmCache,java.io.Serializable
public final class ArrayEncodedDirectMappedLmCache extends java.lang.Object implements ArrayEncodedLmCache
A direct-mapped cache. This cache does not perform any collision resolution, but rather retains only the most recent key which gets hashed to a particular bucket.- Author:
- adampauls
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ArrayEncodedDirectMappedLmCache(int cacheBits, int maxNgramOrder, boolean threadSafe)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcapacity()How n-grams can be cached (at most).voidclear()floatgetCached(int[] ngram, int startPos, int endPos, int hash)Should return Float.NaN if the requested n-gram is not in the cachevoidputCached(int[] ngram, int startPos, int endPos, float f, int hash)
-
-
-
Method Detail
-
getCached
public float getCached(int[] ngram, int startPos, int endPos, int hash)Description copied from interface:ArrayEncodedLmCacheShould return Float.NaN if the requested n-gram is not in the cache- Specified by:
getCachedin interfaceArrayEncodedLmCache- Returns:
-
clear
public void clear()
- Specified by:
clearin interfaceArrayEncodedLmCache
-
putCached
public void putCached(int[] ngram, int startPos, int endPos, float f, int hash)- Specified by:
putCachedin interfaceArrayEncodedLmCache
-
capacity
public int capacity()
Description copied from interface:ArrayEncodedLmCacheHow n-grams can be cached (at most).- Specified by:
capacityin interfaceArrayEncodedLmCache- Returns:
-
-