T - The type of BaseEntity the list will containpublic abstract class StreamCacheList<T extends BaseEntity> extends StreamBaseList<T> implements ICacheLoader<Integer,T>, ICacheList
This class provides core functions needed for lists which load objects as required. It implements the Cache{T} to store frequently requested objects and improve memory usage and performance.
Delegate methods are used to create new instances of items to add to the list in order to avoid creating many inherited list classes for each BaseEntity type.
Objects of this class should not be created directly as they are part of the internal logic.
dataSet, header| Constructor and Description |
|---|
StreamCacheList(Dataset dataSet,
BinaryReader reader,
BaseEntityFactory<T> entityFactory,
int cacheSize)
Constructs a new instance of StreamBaseList{T} ready to read entities
from the source.
|
| Modifier and Type | Method and Description |
|---|---|
T |
fetch(Integer key)
Used to retrieve items from the underlying list.
|
T |
get(int key)
Retrieves the entity at the offset or index requested.
|
double |
getPercentageMisses()
Returns Percentage of request that were not already held in the cache.
|
long |
getSwitches()
Deprecated.
|
void |
resetCache()
Resets the cache.
|
createEntity, sizepublic StreamCacheList(Dataset dataSet, BinaryReader reader, BaseEntityFactory<T> entityFactory, int cacheSize)
dataSet - Dataset being created.reader - Reader used to initialise the header only.entityFactory - Used to create new instances of the entity.cacheSize - Number of items in list to have capacity to cache.public double getPercentageMisses()
getPercentageMisses in interface ICacheList@Deprecated public long getSwitches()
getSwitches in interface ICacheListpublic void resetCache()
resetCache in interface ICacheListpublic T get(int key) throws IOException
get in class StreamBaseList<T extends BaseEntity>key - Index or offset of the entity required.IOException - if there was a problem accessing data file.public T fetch(Integer key) throws IOException
fetch in interface ICacheLoader<Integer,T extends BaseEntity>key - index or offset of the entity requiredIOException - if there was a problem accessing data file.Copyright © 2015 51Degrees. All rights reserved.