T - The type of BaseEntity the list will contain.public class FixedCacheList<T extends BaseEntity> extends StreamFixedList<T> implements ICacheLoader<Integer,T>, ICacheList
Entities in the underlying data structure are either fixed length where the data that represents them always contains the same number of bytes, or variable length where the number of bytes to represent the entity varies.
This class uses the index of the entity in the accessor. The list is typically used by entities that need to be found quickly using a divide and conquer algorithm.
The constructor will read the header information about the underlying data structure. The data for each entity is only loaded when requested via the accessor. A cache is used to avoid creating duplicate objects when requested multiple times.
Data sources which don't support seeking can not be used. Specifically compressed data structures can not be used with these lists.
Objects of this class should not be created directly as they are part of the internal logic
| Modifier and Type | Field and Description |
|---|---|
protected Cache<T> |
cache
Used to store previously accessed items to improve performance and
reduce memory consumption associated with creating new instances of
entities already in use.
|
dataSet, header| Constructor and Description |
|---|
FixedCacheList(Dataset dataSet,
BinaryReader reader,
BaseEntityFactory<T> entityFactory,
int cacheSize)
Constructs a new instance of FixedCacheList{T}.
|
| 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 list status for the list.
|
close, createEntity, getRange, iterator, sizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprotected final Cache<T extends BaseEntity> cache
public FixedCacheList(Dataset dataSet, BinaryReader reader, BaseEntityFactory<T> entityFactory, int cacheSize)
dataSet - The DataSet being createdreader - Reader connected to the source data structure and
positioned to start reading.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 interface IReadonlyList<T extends BaseEntity>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.