Class FullPageIdTable
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.pagemem.FullPageIdTable
-
- All Implemented Interfaces:
LoadedPagesMap
public class FullPageIdTable extends Object implements LoadedPagesMap
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.persistence.pagemem.LoadedPagesMap
LoadedPagesMap.KeyPredicate
-
-
Field Summary
Fields Modifier and Type Field Description protected intcapacityMax size, in elements.static floatDFLT_LONG_LONG_HASH_MAP_LOAD_FACTORprotected intmaxStepsMaximum number of steps to try before failing.protected longvalPtrPointer to the values array.
-
Constructor Summary
Constructors Constructor Description FullPageIdTable(long addr, long len, boolean clear)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcapacity()voidclear()intdistanceFromIdeal(int cacheId, long pageId, int tag)Gets distance from the ideal key location to the actual location if this entry is present in the table, or returns negative distance that needed to be scanned to determine the absence of the mapping.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.static longrequiredMemory(long elementCnt)intsize()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.internal.processors.cache.persistence.pagemem.LoadedPagesMap
removeIf
-
-
-
-
Field Detail
-
DFLT_LONG_LONG_HASH_MAP_LOAD_FACTOR
public static final float DFLT_LONG_LONG_HASH_MAP_LOAD_FACTOR
-
capacity
protected int capacity
Max size, in elements.
-
maxSteps
protected int maxSteps
Maximum number of steps to try before failing.
-
valPtr
protected long valPtr
Pointer to the values array.
-
-
Constructor Detail
-
FullPageIdTable
public FullPageIdTable(long addr, long len, boolean clear)- Parameters:
addr- Base address.len- Allocated memory length.clear- Iftrue, then memory is considered dirty and will be cleared. Otherwise, map will assume that the given memory region is in valid state.
-
-
Method Detail
-
requiredMemory
public static long requiredMemory(long elementCnt)
- Returns:
- Estimated memory size required for this map to store the given number of elements.
-
size
public final int size()
- Specified by:
sizein interfaceLoadedPagesMap- Returns:
- Current number of entries in the map.
-
capacity
public final int capacity()
- Specified by:
capacityin interfaceLoadedPagesMap- Returns:
- Maximum number of entries in the map. This maximum can not be always reached.
-
get
public long get(int grpId, long pageId, int reqVer, long absent, long outdated)Gets value associated with the given key.- Specified by:
getin interfaceLoadedPagesMap- 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.
-
refresh
public 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 caseLoadedPagesMap.get(int, long, int, long, long)returnedoutdatedreturn value.- Specified by:
refreshin interfaceLoadedPagesMap- 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.
-
put
public void put(int grpId, long pageId, long val, int ver)Associates the given key with the given value.- Specified by:
putin interfaceLoadedPagesMap- 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.
-
remove
public boolean remove(int grpId, long pageId)Removes key-value association for the given key.- Specified by:
removein interfaceLoadedPagesMap- 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.
-
getNearestAt
public ReplaceCandidate getNearestAt(int idxStart)
Find nearest presented value from specified position to the right.- Specified by:
getNearestAtin interfaceLoadedPagesMap- Parameters:
idxStart- Index to start searching from. Bounded withLoadedPagesMap.capacity().- Returns:
- Closest value to the index and it's partition tag or
nullvalue that will be returned if no values present.
-
removeIf
public GridLongList removeIf(int startIdxToClear, int endIdxToClear, LoadedPagesMap.KeyPredicate keyPred)
Removes entities matching provided predicate at specified mapping range.- Specified by:
removeIfin interfaceLoadedPagesMap- Parameters:
startIdxToClear- Index to clear value at, inclusive. Bounded withLoadedPagesMap.capacity().endIdxToClear- Index to clear value at, inclusive. Bounded withLoadedPagesMap.capacity().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.
-
distanceFromIdeal
public int distanceFromIdeal(int cacheId, long pageId, int tag)Gets distance from the ideal key location to the actual location if this entry is present in the table, or returns negative distance that needed to be scanned to determine the absence of the mapping.- Parameters:
cacheId- Cache ID.pageId- Page ID.tag- Tag.- Returns:
- Distance scanned if the entry is found or negative distance scanned, if entry was not found.
-
forEach
public void forEach(BiConsumer<FullPageId,Long> act)
Scans all the elements in this table.- Specified by:
forEachin interfaceLoadedPagesMap- Parameters:
act- Visitor/action to be applied to each not empty cell.
-
clear
public void clear()
-
-