Class PagePool
java.lang.Object
org.apache.ignite.internal.pagemem.PagePool
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longPointer to the address of the free page list.static final longRelative null pointerprotected longprotected longPages base.protected final AtomicIntegerPool pages counter.protected final DirectMemoryRegionDirect memory region.static final longRelative pointer maskstatic final intNumber of lower bits which a relative page address may occupy. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPagePool(DirectMemoryRegion region, int sysPageSize, OffheapReadWriteLock rwLock) -
Method Summary
Modifier and TypeMethodDescriptionlongborrowOrAllocateFreePage(int tag) Allocates a new free page.static intestimateNumberOfPages(long memory, int sysPageSize) Returns upper bound for total number of pages in pool with the given parameters.static longestimateRequiredMemory(int numPages, int sysPageSize) Returns required memory in bytes to accommodate the given number of pages.intpages()intreleaseFreePage(long relPtr) intsize()
-
Field Details
-
REL_PTR_NUM_BITS
public static final int REL_PTR_NUM_BITSNumber of lower bits which a relative page address may occupy. Must be less than or equal to 32.- See Also:
-
REL_PTR_MASK
public static final long REL_PTR_MASKRelative pointer mask- See Also:
-
INVALID_REL_PTR
public static final long INVALID_REL_PTRRelative null pointer- See Also:
-
region
Direct memory region. -
pagesCntr
Pool pages counter. -
lastAllocatedIdxPtr
protected long lastAllocatedIdxPtr -
freePageListPtr
protected long freePageListPtrPointer to the address of the free page list. -
pagesBase
protected long pagesBasePages base.
-
-
Constructor Details
-
PagePool
- Parameters:
idx- Index.region- Region
-
-
Method Details
-
borrowOrAllocateFreePage
Allocates a new free page.- Parameters:
tag- Tag to initialize page RW lock.- Returns:
- Relative pointer to the allocated page.
- Throws:
GridOffHeapOutOfMemoryException- If failed to allocate new free page.
-
releaseFreePage
public int releaseFreePage(long relPtr) - Parameters:
relPtr- Relative pointer to free.- Returns:
- Resulting number of pages in pool if pages counter is enabled, 0 otherwise.
-
pages
public int pages()- Returns:
- Max number of pages in the pool.
-
size
public int size()- Returns:
- Number of pages in the list.
-
getMemoryRegion
- Returns:
- direct memory region used by the pool
-
estimateNumberOfPages
public static int estimateNumberOfPages(long memory, int sysPageSize) Returns upper bound for total number of pages in pool with the given parameters.- Parameters:
memory- total memory in bytessysPageSize- pages size in bytes- Returns:
- upper bound for total number of pages in pool with the given parameters
-
estimateRequiredMemory
public static long estimateRequiredMemory(int numPages, int sysPageSize) Returns required memory in bytes to accommodate the given number of pages.- Parameters:
numPages- number of pagessysPageSize- pages size in bytes- Returns:
- required memory in bytes to accommodate the given number of pages
-