Class AllocationCache
- java.lang.Object
-
- org.apache.derby.impl.store.raw.data.AllocationCache
-
class AllocationCache extends java.lang.ObjectAn auxiliary object to cache the allocation information for a file container. Only a FileContainer should use this objectThe allocation cache contains an array of AllocExtents and 3 arrays of longs:
- ExtentPageNums[i] is the page number of the i'th extent
- lowRange[i] is the smallest page number managed by extent i
- hiRange[i] is the largest page number managed by extent i
Note thate extentPageNums and lowRange does not change once the extent has been created, but hiRange will change for the last extent as more pages are allocated.
Extents can be individually invalidated or the entire cache (all extends) can be invalidated at once.
MT - unsafe Synrhonized access to all methods must be enforced by the caller of AllocationCache
-
-
Field Summary
Fields Modifier and Type Field Description private long[]extentPageNumsprivate AllocExtent[]extentsprivate long[]hiRangeprivate boolean[]isDirtyprivate booleanisValidprivate long[]lowRangeprivate intnumExtents
-
Constructor Summary
Constructors Modifier Constructor Description protectedAllocationCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddumpAllocationCache()dump the allocation cache informationprotected longgetAllocPageNumber(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber)Get the page number for the allocation page that is managing this page numberprotected SpaceInformationgetAllPageCounts(BaseContainerHandle handle, long firstAllocPageNumber)protected longgetEstimatedPageCount(BaseContainerHandle handle, long firstAllocPageNumber)returns estimated number of allocated pagesprotected longgetLastPageNumber(BaseContainerHandle handle, long firstAllocPageNumber)Get the last (allocated) page of the containerprotected longgetLastValidPage(BaseContainerHandle handle, long firstAllocPageNumber)Get the last valid page of the file container.protected longgetNextValidPage(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber)protected intgetPageStatus(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber)Get the page status of a pageprotected longgetUnfilledPageNumber(BaseContainerHandle handle, long firstAllocPageNumber, long pagenum)private voidgrowArrays(int size)protected voidinvalidate()protected voidinvalidate(AllocPage allocPage, long allocPagenum)protected voidinvalidateLastExtent()protected voidreset()private voidsetArrays(int i, AllocPage allocPage)protected voidtrackUnfilledPage(long pagenumber, boolean unfilled)Set the page number to be unfilledprivate voidvalidate(BaseContainerHandle handle, long firstAllocPageNumber)Validate the cache, find all alloc pages and fill in the arrays
-
-
-
Field Detail
-
numExtents
private int numExtents
-
lowRange
private long[] lowRange
-
hiRange
private long[] hiRange
-
isDirty
private boolean[] isDirty
-
extents
private AllocExtent[] extents
-
extentPageNums
private long[] extentPageNums
-
isValid
private boolean isValid
-
-
Method Detail
-
reset
protected void reset()
-
getAllocPageNumber
protected long getAllocPageNumber(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber) throws StandardException
Get the page number for the allocation page that is managing this page number- Throws:
StandardException
-
getLastPageNumber
protected long getLastPageNumber(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException
Get the last (allocated) page of the container- Throws:
StandardException
-
trackUnfilledPage
protected void trackUnfilledPage(long pagenumber, boolean unfilled)Set the page number to be unfilled
-
getUnfilledPageNumber
protected long getUnfilledPageNumber(BaseContainerHandle handle, long firstAllocPageNumber, long pagenum) throws StandardException
- Throws:
StandardException
-
getEstimatedPageCount
protected long getEstimatedPageCount(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException
returns estimated number of allocated pages- Throws:
StandardException
-
getAllPageCounts
protected SpaceInformation getAllPageCounts(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException
- Throws:
StandardException
-
invalidate
protected void invalidate()
-
invalidate
protected void invalidate(AllocPage allocPage, long allocPagenum) throws StandardException
- Throws:
StandardException
-
invalidateLastExtent
protected void invalidateLastExtent()
-
getLastValidPage
protected long getLastValidPage(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException
Get the last valid page of the file container. A valid page is one that is not deallocated or freed.- Throws:
StandardException
-
getNextValidPage
protected long getNextValidPage(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber) throws StandardException
- Throws:
StandardException
-
getPageStatus
protected int getPageStatus(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber) throws StandardException
Get the page status of a page- Throws:
StandardException
-
validate
private void validate(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException
Validate the cache, find all alloc pages and fill in the arrays- Throws:
StandardException
-
setArrays
private void setArrays(int i, AllocPage allocPage)
-
growArrays
private void growArrays(int size)
-
dumpAllocationCache
protected void dumpAllocationCache()
dump the allocation cache information
-
-