Package herddb.core
Class ClockAdaptiveReplacement
- java.lang.Object
-
- herddb.core.ClockAdaptiveReplacement
-
- All Implemented Interfaces:
PageReplacementPolicy
public class ClockAdaptiveReplacement extends Object implements PageReplacementPolicy
Basic implementation of CAR algorithm.Based on the original work:
CAR: Clock with Adaptive Replacement Sorav Bansal† and Dharmendra S. Modha‡ †Stanford University, ‡IBM Almaden Research Center
See http://www-cs.stanford.edu/~sbansal/pubs/fast04.pdf
- Author:
- diego.salvi
-
-
Constructor Summary
Constructors Constructor Description ClockAdaptiveReplacement(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Page.Metadataadd(Page<?> page)Add a newPageto memory.intcapacity()Returns the maximum number ofPagesmemorizable.voidclear()Clear any memorized data.voidpageHit(Page<?> page)Track a page cache hit.Page.Metadatapop()booleanremove(Page<?> page)Remove aPagefrom memory.<P extends Page<?>>
voidremove(Collection<P> pages)Remove manyPage Pagesfrom memory.intsize()Returns the current number ofPagesmemorized.
-
-
-
Method Detail
-
capacity
public int capacity()
Description copied from interface:PageReplacementPolicyReturns the maximum number ofPagesmemorizable.- Specified by:
capacityin interfacePageReplacementPolicy- Returns:
- maximum number of Pages
-
size
public int size()
Description copied from interface:PageReplacementPolicyReturns the current number ofPagesmemorized.- Specified by:
sizein interfacePageReplacementPolicy- Returns:
- current number of Pages
-
add
public Page.Metadata add(Page<?> page)
Description copied from interface:PageReplacementPolicyAdd a newPageto memory.Adding a new page could force an older page to be unloaded
- Specified by:
addin interfacePageReplacementPolicy- Parameters:
page- page to be added- Returns:
- selected page to be unloaded or
null
-
pop
public Page.Metadata pop()
-
remove
public <P extends Page<?>> void remove(Collection<P> pages)
Description copied from interface:PageReplacementPolicyRemove manyPage Pagesfrom memory.This method is logically equivalent to multiple
PageReplacementPolicy.remove(Page)invocations but is expected to be more efficient.- Specified by:
removein interfacePageReplacementPolicy- Parameters:
pages- pages to be removed.
-
remove
public boolean remove(Page<?> page)
Description copied from interface:PageReplacementPolicyRemove aPagefrom memory.- Specified by:
removein interfacePageReplacementPolicy- Parameters:
page- page to be removed.- Returns:
trueif the memory really contained the given page
-
clear
public void clear()
Description copied from interface:PageReplacementPolicyClear any memorized data.- Specified by:
clearin interfacePageReplacementPolicy
-
pageHit
public void pageHit(Page<?> page)
Description copied from interface:PageReplacementPolicyTrack a page cache hit.- Specified by:
pageHitin interfacePageReplacementPolicy- Parameters:
page- for which track an hit
-
-