T
- Type of the cached data.public class GenericTimeStampedCache<T extends TimeStamped> extends Object implements TimeStampedCache<T>
time-stamped
data.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CACHED_SLOTS_NUMBER
Default number of independent cached time slots.
|
Constructor and Description |
---|
GenericTimeStampedCache(int neighborsSize,
int maxSlots,
double maxSpan,
double newSlotInterval,
TimeStampedGenerator<T> generator)
Simple constructor.
|
Modifier and Type | Method and Description |
---|---|
T |
getEarliest()
Get the earliest cached entry.
|
int |
getEntries()
Get the total number of entries cached.
|
int |
getGenerateCalls()
Get the number of calls to the generate method.
|
TimeStampedGenerator<T> |
getGenerator()
Get the generator.
|
int |
getGetNeighborsCalls()
Get the number of calls to the
getNeighbors(AbsoluteDate) method. |
T |
getLatest()
Get the latest cached entry.
|
int |
getMaxSlots()
Get the maximum number of independent cached time slots.
|
double |
getMaxSpan()
Get the maximum duration span in seconds of one slot.
|
Stream<T> |
getNeighbors(AbsoluteDate central)
Get the entries surrounding a central date.
|
int |
getNeighborsSize()
Get the fixed size of the arrays to be returned by
getNeighbors(AbsoluteDate) . |
double |
getNewSlotQuantumGap()
Get quantum gap above which a new slot is created instead of extending an existing one.
|
int |
getSlots()
Get the number of slots in use.
|
int |
getSlotsEvictions()
Get the number of slots evictions.
|
public static final int DEFAULT_CACHED_SLOTS_NUMBER
public GenericTimeStampedCache(int neighborsSize, int maxSlots, double maxSpan, double newSlotInterval, TimeStampedGenerator<T> generator)
neighborsSize
- fixed size of the arrays to be returned by getNeighbors(AbsoluteDate)
, must be at least 2maxSlots
- maximum number of independent cached time slotsmaxSpan
- maximum duration span in seconds of one slot
(can be set to Double.POSITIVE_INFINITY
if desired)newSlotInterval
- time interval above which a new slot is created
instead of extending an existing onegenerator
- generator to use for yet non-existent datapublic TimeStampedGenerator<T> getGenerator()
public int getMaxSlots()
public double getMaxSpan()
public double getNewSlotQuantumGap()
The quantum gap is the newSlotInterval
value provided at construction
rounded to the nearest quantum step used internally by the cache.
public int getGetNeighborsCalls()
getNeighbors(AbsoluteDate)
method.
This number of calls is used as a reference to interpret getGenerateCalls()
.
getNeighbors(AbsoluteDate)
methodgetGenerateCalls()
public int getGenerateCalls()
This number of calls is related to the number of cache misses and may be used to tune the cache configuration. Each cache miss implies at least one call is performed, but may require several calls if the new date is far offset from the existing cache, depending on the number of elements and step between elements in the arrays returned by the generator.
getGetNeighborsCalls()
public int getSlotsEvictions()
This number should remain small when the max number of slots is sufficient
with respect to the number of concurrent requests to the cache. If it
increases too much, then the cache configuration is probably bad and cache
does not really improve things (in this case, the number of calls to the generate method
will probably increase too.
public int getSlots()
public int getEntries()
public T getEarliest() throws IllegalStateException
getEarliest
in interface TimeStampedCache<T extends TimeStamped>
IllegalStateException
- if the cache has no slots at allgetSlots()
public T getLatest() throws IllegalStateException
getLatest
in interface TimeStampedCache<T extends TimeStamped>
IllegalStateException
- if the cache has no slots at allgetSlots()
public int getNeighborsSize()
getNeighbors(AbsoluteDate)
.getNeighborsSize
in interface TimeStampedCache<T extends TimeStamped>
public Stream<T> getNeighbors(AbsoluteDate central)
If the central date is well within covered range, the returned array will be balanced with half the points before central date and half the points after it (depending on n parity, of course). If the central date is near the generator range boundary, then the returned array will be unbalanced and will contain only the n earliest (or latest) generated (and cached) entries. A typical example of the later case is leap seconds cache, since the number of leap seconds cannot be arbitrarily increased.
getNeighbors
in interface TimeStampedCache<T extends TimeStamped>
central
- central dateGenericTimeStampedCache(int, int, double, double, TimeStampedGenerator)
getEarliest()
,
getLatest()
Copyright © 2002-2020 CS GROUP. All rights reserved.