Class AllocationCache
java.lang.Object
org.apache.derby.impl.store.raw.data.AllocationCache
An auxiliary object to cache the allocation information for a file container.
Only a FileContainer should use this object
The 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
FieldsModifier and TypeFieldDescriptionprivate long[]private AllocExtent[]private long[]private boolean[]private booleanprivate long[]private int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddump 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 voidprotected voidinvalidate(AllocPage allocPage, long allocPagenum) protected voidprotected voidreset()private voidprotected 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 Details
-
numExtents
private int numExtents -
lowRange
private long[] lowRange -
hiRange
private long[] hiRange -
isDirty
private boolean[] isDirty -
extents
-
extentPageNums
private long[] extentPageNums -
isValid
private boolean isValid
-
-
Constructor Details
-
AllocationCache
protected AllocationCache()
-
-
Method Details
-
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
- 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
-
growArrays
private void growArrays(int size) -
dumpAllocationCache
protected void dumpAllocationCache()dump the allocation cache information
-