Interface LoadedPagesMap
-
- All Known Implementing Classes:
FullPageIdTable,RobinHoodBackwardShiftHashMap
public interface LoadedPagesMapInterface for storing correspondence of page ID in a cache group to long value (address in offheap segment).
Map support versioning of entries. Outdated entry (entry having version lower than requested), is not provided in case of get, outdated return value is provided instead.
This mapping is not thread safe. Operations should be protected by outside locking.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceLoadedPagesMap.KeyPredicateInterface describing a predicate for Key (cache group ID, page ID).
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intcapacity()voidforEach(BiConsumer<FullPageId,Long> act)Scans all the elements in this table.longget(int grpId, long pageId, int reqVer, long absent, long outdated)Gets value associated with the given key.ReplaceCandidategetNearestAt(int idxStart)Find nearest presented value from specified position to the right.voidput(int grpId, long pageId, long val, int ver)Associates the given key with the given value.longrefresh(int grpId, long pageId, int ver)Refresh outdated value.booleanremove(int grpId, long pageId)Removes key-value association for the given key.GridLongListremoveIf(int startIdxToClear, int endIdxToClear, LoadedPagesMap.KeyPredicate keyPred)Removes entities matching provided predicate at specified mapping range.default GridLongListremoveIf(LoadedPagesMap.KeyPredicate keyPred)Removes entities matching provided predicate.intsize()
-
-
-
Method Detail
-
get
long get(int grpId, long pageId, int reqVer, long absent, long outdated)Gets value associated with the given key.- Parameters:
grpId- Cache Group ID. First part of the key.pageId- Page ID. Second part of the key.reqVer- Requested entry version, counter associated with value.absent- return if provided page is not presented in map.outdated- return if providedreqVerversion is greater than value in map (was used for put).- Returns:
- A value associated with the given key.
-
put
void put(int grpId, long pageId, long val, int ver)Associates the given key with the given value.- Parameters:
grpId- Cache Group ID. First part of the key.pageId- Page ID. Second part of the key.val- Value to set.ver- Version/counter associated with value, can be used to check if value is outdated.
-
refresh
long refresh(int grpId, long pageId, int ver)Refresh outdated value. Sets provided version to value associated with cache and page. Method should be called only for key present and only if version was outdated. Method may be called in caseget(int, long, int, long, long)returnedoutdatedreturn value.- Parameters:
grpId- First part of the key. Cache Group ID.pageId- Second part of the key. Page ID.ver- Partition tag.- Returns:
- A value associated with the given key.
- Throws:
IllegalArgumentException- if method is called for absent key or key with fresh version.
-
remove
boolean remove(int grpId, long pageId)Removes key-value association for the given key.- Parameters:
grpId- First part of the key. Cache Group ID.pageId- Second part of the key. Page ID.- Returns:
Trueif value was actually found and removed.
-
capacity
int capacity()
- Returns:
- Maximum number of entries in the map. This maximum can not be always reached.
-
size
int size()
- Returns:
- Current number of entries in the map.
-
getNearestAt
ReplaceCandidate getNearestAt(int idxStart)
Find nearest presented value from specified position to the right.- Parameters:
idxStart- Index to start searching from. Bounded withcapacity().- Returns:
- Closest value to the index and it's partition tag or
nullvalue that will be returned if no values present.
-
removeIf
GridLongList removeIf(int startIdxToClear, int endIdxToClear, LoadedPagesMap.KeyPredicate keyPred)
Removes entities matching provided predicate at specified mapping range.- Parameters:
startIdxToClear- Index to clear value at, inclusive. Bounded withcapacity().endIdxToClear- Index to clear value at, inclusive. Bounded withcapacity().keyPred- Test predicate for (cache group ID, page ID).- Returns:
- List with removed values, value is not added to list for empty cell or if key is not matching to predicate.
-
removeIf
default GridLongList removeIf(LoadedPagesMap.KeyPredicate keyPred)
Removes entities matching provided predicate.- Parameters:
keyPred- Test predicate for (cache group ID, page ID).- Returns:
- List with removed values, value is not added to list for empty cell or if key is not matching to predicate.
-
forEach
void forEach(BiConsumer<FullPageId,Long> act)
Scans all the elements in this table.- Parameters:
act- Visitor/action to be applied to each not empty cell.
-
-