org.apache.derby.impl.store.raw.data
Class AllocationCache

java.lang.Object
  extended byorg.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 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
private  long[] extentPageNums
           
private  AllocExtent[] extents
           
private  long[] hiRange
           
private  boolean[] isDirty
           
private  boolean isValid
           
private  long[] lowRange
           
private  int numExtents
           
 
Constructor Summary
protected AllocationCache()
           
 
Method Summary
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 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 unfilled
private  void validate(BaseContainerHandle handle, long firstAllocPageNumber)
          Validate the cache, find all alloc pages and fill in the arrays
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

AllocationCache

protected AllocationCache()
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


Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.