|
Joshua
open source statistical hierarchical phrase-based machine translation system
|
Public Member Functions | |
| Cache (int maxCapacity) | |
| Cache () | |
| V | get (Object key) |
| V | put (K key, V value) |
| boolean | containsKey (Object key) |
Static Public Attributes | |
| static final int | DEFAULT_CAPACITY = 100000000 |
| static final int | INITIAL_CAPACITY = 1000000 |
| static final float | LOAD_FACTOR = 0.75f |
| static final boolean | ACCESS_ORDER = true |
Protected Member Functions | |
| boolean | removeEldestEntry (Map.Entry< K, V > eldest) |
Package Attributes | |
| int | maxCapacity |
Static Private Attributes | |
| static final long | serialVersionUID = 6073387072740892061L |
| static Logger | logger = Logger.getLogger(Cache.class.getName()) |
Cache is a class that implements a least recently used cache. It is a straightforward extension of java.util.LinkedHashMap with its removeEldestEntry method overridden, so that stale entries are deleted once we reach the specified capacity of the Cache.
This class is quite useful for storing the results of computations that we would do many times over in the FeatureFunctions.
| joshua.util.Cache< K, V >.Cache | ( | int | maxCapacity | ) |
Creates a Cache with a set capacity.
| maxCapacity | the maximum capacity of the cache. |
| joshua.util.Cache< K, V >.Cache | ( | ) |
Creates a Cache with the DEFAULT_CAPACITY.
| boolean joshua.util.Cache< K, V >.containsKey | ( | Object | key | ) |
| V joshua.util.Cache< K, V >.get | ( | Object | key | ) |
| V joshua.util.Cache< K, V >.put | ( | K | key, |
| V | value | ||
| ) |
| boolean joshua.util.Cache< K, V >.removeEldestEntry | ( | Map.Entry< K, V > | eldest | ) | [protected] |
This method is invoked by put and putAll after inserting a new entry into the map. Once we reach the capacity of the cache, we remove the oldest entry each time a new entry is added. This reduces memory consumption by deleting stale entries.
| eldest | the eldest entry |
final boolean joshua.util.Cache< K, V >.ACCESS_ORDER = true [static] |
By default, ordering mode of the cache is access order (true).
final int joshua.util.Cache< K, V >.DEFAULT_CAPACITY = 100000000 [static] |
A constant is used as the default the cache size if none is specified.
final int joshua.util.Cache< K, V >.INITIAL_CAPACITY = 1000000 [static] |
Default initial capacity of the cache.
final float joshua.util.Cache< K, V >.LOAD_FACTOR = 0.75f [static] |
Default load factor of the cache.
Logger joshua.util.Cache< K, V >.logger = Logger.getLogger(Cache.class.getName()) [static, private] |
Logger for this class.
int joshua.util.Cache< K, V >.maxCapacity [package] |
Maximum number of items that the cache can contain.
final long joshua.util.Cache< K, V >.serialVersionUID = 6073387072740892061L [static, private] |