public abstract class AbstractClimber extends Object implements HillClimber
HillClimber.Adaptation, HillClimber.QueueType| Modifier and Type | Field and Description |
|---|---|
protected int |
hitsInMain |
protected int |
hitsInSample |
protected int |
hitsInWindow |
protected int |
missesInSample |
protected double |
previousHitRate |
protected int |
sampleSize |
| Constructor and Description |
|---|
AbstractClimber() |
| Modifier and Type | Method and Description |
|---|---|
HillClimber.Adaptation |
adapt(double windowSize,
double probationSize,
double protectedSize,
boolean isFull)
Determines how to adapt the segment sizes.
|
protected abstract double |
adjust(double hitRate)
Returns the amount to adapt by.
|
void |
onHit(long key,
HillClimber.QueueType queueType,
boolean isFull)
Records that a hit occurred with a full cache.
|
void |
onMiss(long key,
boolean isFull)
Records that a miss occurred with a full cache.
|
protected void |
resetSample(double hitRate)
Starts the next sample period.
|
protected int sampleSize
protected int hitsInMain
protected int hitsInWindow
protected int hitsInSample
protected int missesInSample
protected double previousHitRate
public void onMiss(long key,
boolean isFull)
HillClimberonMiss in interface HillClimberkey - the key accessedisFull - if the cache is fully populated and had to evictpublic void onHit(long key,
HillClimber.QueueType queueType,
boolean isFull)
HillClimberonHit in interface HillClimberkey - the key accessedqueueType - the queue the entry was found inisFull - if the cache is fully populatedpublic HillClimber.Adaptation adapt(double windowSize, double probationSize, double protectedSize, boolean isFull)
HillClimberadapt in interface HillClimberwindowSize - the current window sizeprobationSize - the current probation sizeprotectedSize - the current protected sizeisFull - if the cache is fully populatedprotected abstract double adjust(double hitRate)
protected void resetSample(double hitRate)