Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.data

pack-priv Class AllocationCache

extends Object
Class Inheritance
Imports
org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.raw.ContainerHandle, org.apache.derby.impl.store.raw.data.BaseContainerHandle

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:

  1. ExtentPageNums[i] is the page number of the i'th extent
  2. lowRange[i] is the smallest page number managed by extent i
  3. 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

Modifier and TypeField and Description
private long[]
private AllocExtent[]
private long[]
private boolean[]
private boolean
private long[]
private int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected void
dumpAllocationCache()

dump the allocation cache information

protected long
getAllocPageNumber(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber)

Get the page number for the allocation page that is managing this page number

protected SpaceInformation
getAllPageCounts(BaseContainerHandle handle, long firstAllocPageNumber)

protected long
getEstimatedPageCount(BaseContainerHandle handle, long firstAllocPageNumber)

returns estimated number of allocated pages

protected long
getLastPageNumber(BaseContainerHandle handle, long firstAllocPageNumber)

Get the last (allocated) page of the container

protected 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 page

protected long
getUnfilledPageNumber(BaseContainerHandle handle, long firstAllocPageNumber, long pagenum)

private void
growArrays(int size)

protected void
protected void
invalidate(AllocPage allocPage, long allocPagenum)

protected void
protected void
private void
setArrays(int i, AllocPage allocPage)

protected void
trackUnfilledPage(long pagenumber, boolean unfilled)

Set the page number to be unfilled

private void
validate(BaseContainerHandle handle, long firstAllocPageNumber)

Validate the cache, find all alloc pages and fill in the arrays

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

extentPageNumsback to summary
private long[] extentPageNums
extentsback to summary
private AllocExtent[] extents
hiRangeback to summary
private long[] hiRange
isDirtyback to summary
private boolean[] isDirty
isValidback to summary
private boolean isValid
lowRangeback to summary
private long[] lowRange
numExtentsback to summary
private int numExtents

Constructor Detail

AllocationCacheback to summary
protected AllocationCache()

Method Detail

dumpAllocationCacheback to summary
protected void dumpAllocationCache()

dump the allocation cache information

getAllocPageNumberback to summary
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

getAllPageCountsback to summary
protected SpaceInformation getAllPageCounts(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException
getEstimatedPageCountback to summary
protected long getEstimatedPageCount(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException

returns estimated number of allocated pages

getLastPageNumberback to summary
protected long getLastPageNumber(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException

Get the last (allocated) page of the container

getLastValidPageback to summary
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.

getNextValidPageback to summary
protected long getNextValidPage(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber) throws StandardException
getPageStatusback to summary
protected int getPageStatus(BaseContainerHandle handle, long pageNumber, long firstAllocPageNumber) throws StandardException

Get the page status of a page

getUnfilledPageNumberback to summary
protected long getUnfilledPageNumber(BaseContainerHandle handle, long firstAllocPageNumber, long pagenum) throws StandardException
growArraysback to summary
private void growArrays(int size)
invalidateback to summary
protected void invalidate()
invalidateback to summary
protected void invalidate(AllocPage allocPage, long allocPagenum) throws StandardException
invalidateLastExtentback to summary
protected void invalidateLastExtent()
resetback to summary
protected void reset()
setArraysback to summary
private void setArrays(int i, AllocPage allocPage)
trackUnfilledPageback to summary
protected void trackUnfilledPage(long pagenumber, boolean unfilled)

Set the page number to be unfilled

validateback to summary
private void validate(BaseContainerHandle handle, long firstAllocPageNumber) throws StandardException

Validate the cache, find all alloc pages and fill in the arrays