Class AllocationCache
- java.lang.Object
-
- org.apache.derby.impl.store.raw.data.AllocationCache
-
class AllocationCache extends java.lang.Object
An 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[]
extentPageNums
private AllocExtent[]
extents
private long[]
hiRange
private boolean[]
isDirty
private boolean
isValid
private long[]
lowRange
private int
numExtents
-
Constructor Summary
Constructors Modifier Constructor Description protected
AllocationCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
dumpAllocationCache()
dump the allocation cache informationprotected long
getAllocPageNumber(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber)
Get the page number for the allocation page that is managing this page numberprotected SpaceInformation
getAllPageCounts(BaseContainerHandle handle, long firstAllocPageNumber)
protected long
getEstimatedPageCount(BaseContainerHandle handle, long firstAllocPageNumber)
returns estimated number of allocated pagesprotected long
getLastPageNumber(BaseContainerHandle handle, long firstAllocPageNumber)
Get the last (allocated) page of the containerprotected long
getLastValidPage(BaseContainerHandle handle, long firstAllocPageNumber)
Get the last valid page of the file container.protected long
getNextValidPage(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber)
protected int
getPageStatus(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber)
Get the page status of a pageprotected long
getUnfilledPageNumber(BaseContainerHandle handle, long firstAllocPageNumber, long pagenum)
private void
growArrays(int size)
protected void
invalidate()
protected void
invalidate(AllocPage allocPage, long allocPagenum)
protected void
invalidateLastExtent()
protected void
reset()
private void
setArrays(int i, AllocPage allocPage)
protected void
trackUnfilledPage(long pagenumber, boolean unfilled)
Set the page number to be unfilledprivate void
validate(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
-
-