Class AllocExtent
- java.lang.Object
-
- org.apache.derby.impl.store.raw.data.AllocExtent
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable
public class AllocExtent extends java.lang.Object implements java.io.ExternalizableAn allocation extent row manages the page status of page in the extent. AllocExtent is externalizable and is written to the AllocPage directly, without being converted to a row first.- See Also:
AllocPage, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static intALL_FREEprotected static intALLOCATED_PAGEpublic Per Page statusprotected static intDEALLOCATED_PAGEprivate longextentEndprivate intextentLengthprivate longextentOffsetprivate longextentStart(package private) intextentStatusprotected static intFREE_PAGE(package private) FormatableBitSetfreePagesprivate static intHAS_DEALLOCATEDprivate static intHAS_FREEprivate static intHAS_UNFILLED_PAGESprivate static intKEEP_UNFILLED_PAGESprivate static intNO_DEALLOC_PAGE_MAPprivate intpreAllocLengthprivate intreserved1private longreserved2private longreserved3private static intRETIRED(package private) FormatableBitSetunFilledPages
-
Constructor Summary
Constructors Modifier Constructor Description AllocExtent()protectedAllocExtent(long offset, long start, int length, int pagesize, int maxlength)protectedAllocExtent(AllocExtent original)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidallocPage(long pagenum)Allocate this page - this is called underneath the log recordprotected booleancanAddFreePage(long lastAllocatedPage)private voidcheckInRange(long pagenum)protected intcompress(BaseContainerHandle owner, RawTransaction ntt, AllocPage alloc_page)Compress free pages at end of this extent.protected voidcompressPages(int new_highest_page, int num_pages_truncated)protected voiddeallocPage(long pagenum)Deallocate logical page pagenum - this is called underneath the log record.protected intgetAllocatedPageCount()Get the number of used page in this extentprotected longgetExtentEnd()protected longgetFirstPagenum()Get the first logical page number managed by this extent.protected longgetFreePageNumber(long pnum)Get a page number that is freeprotected longgetLastPagenum()Get the last logical page number managed by this extent.protected longgetLastPreallocPagenum()get the last preallocated pagenumber managed by this alloc pageprotected longgetLastValidPageNumber()protected longgetNextValidPageNumber(long prevPageNumber)protected longgetPagenum(int bit_pos)translate bit position in map to page number.protected longgetPageOffset(long pagenum, int pagesize, boolean deallocOK)Get the physical offset of pagenum.protected intgetPageStatus(long pagenum)Return the status of a particular pageprotected intgetTotalPageCount()Get the total number of pages in this extentprotected intgetUnfilledPageCount()Get the number of unfilled pages in this extentprotected longgetUnfilledPageNumber(long pagenum)Get a page number that is unfilled, pagenum is the last page that was rejected.protected booleanisRetired()Return the status of this extentprotected static intMAX_RANGE(int availspace)Statically calculates how many pages this extent can manage given the availspace number of bytes to store this extent in if read/writeExternal changes, this must change tooprivate booleanmayHaveFreePage()voidreadExternal(java.io.ObjectInput in)private voidsetExtentFreePageStatus(boolean hasFree)protected voidsetLastPreallocPagenum(long preAllocPagenum)preallocated N pages, passed in the last preallocated page number.protected java.lang.StringtoDebugString()protected booleantrackUnfilledPage(long pagenumber, boolean unfilled)protected voidundoCompressPages(int new_highest_page, int num_pages_truncated)Undo the compress space operation.protected voidupdateUnfilledPageInfo(AllocExtent inputExtent)voidwriteExternal(java.io.ObjectOutput out)
-
-
-
Field Detail
-
extentOffset
private long extentOffset
-
extentStart
private long extentStart
-
extentEnd
private long extentEnd
-
extentLength
private int extentLength
-
extentStatus
int extentStatus
-
preAllocLength
private int preAllocLength
-
reserved1
private int reserved1
-
reserved2
private long reserved2
-
reserved3
private long reserved3
-
HAS_DEALLOCATED
private static final int HAS_DEALLOCATED
- See Also:
- Constant Field Values
-
HAS_FREE
private static final int HAS_FREE
- See Also:
- Constant Field Values
-
ALL_FREE
private static final int ALL_FREE
- See Also:
- Constant Field Values
-
HAS_UNFILLED_PAGES
private static final int HAS_UNFILLED_PAGES
- See Also:
- Constant Field Values
-
KEEP_UNFILLED_PAGES
private static final int KEEP_UNFILLED_PAGES
- See Also:
- Constant Field Values
-
NO_DEALLOC_PAGE_MAP
private static final int NO_DEALLOC_PAGE_MAP
- See Also:
- Constant Field Values
-
RETIRED
private static final int RETIRED
- See Also:
- Constant Field Values
-
ALLOCATED_PAGE
protected static final int ALLOCATED_PAGE
public Per Page status- See Also:
- Constant Field Values
-
DEALLOCATED_PAGE
protected static final int DEALLOCATED_PAGE
- See Also:
- Constant Field Values
-
FREE_PAGE
protected static final int FREE_PAGE
- See Also:
- Constant Field Values
-
freePages
FormatableBitSet freePages
-
unFilledPages
FormatableBitSet unFilledPages
-
-
Constructor Detail
-
AllocExtent
protected AllocExtent(long offset, long start, int length, int pagesize, int maxlength)
-
AllocExtent
protected AllocExtent(AllocExtent original)
-
AllocExtent
public AllocExtent()
-
-
Method Detail
-
MAX_RANGE
protected static int MAX_RANGE(int availspace)
Statically calculates how many pages this extent can manage given the availspace number of bytes to store this extent in if read/writeExternal changes, this must change too
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
allocPage
protected void allocPage(long pagenum) throws StandardExceptionAllocate this page - this is called underneath the log record- Throws:
StandardException- Standard Derby error policy
-
deallocPage
protected void deallocPage(long pagenum) throws StandardExceptionDeallocate logical page pagenum - this is called underneath the log record. pagenum must be a page managed by this extent and it must be valid- Throws:
StandardException- Standard Derby error policy
-
compress
protected int compress(BaseContainerHandle owner, RawTransaction ntt, AllocPage alloc_page) throws StandardException
Compress free pages at end of this extent.Search backward from end of extent and prepare data structures to return pages at end of extent to the OS. Returns the lowest page that can be returned to the OS.
- Returns:
- Return bit of page where all pages that follow can be returned to the OS.
- Throws:
StandardException
-
compressPages
protected void compressPages(int new_highest_page, int num_pages_truncated)
-
undoCompressPages
protected void undoCompressPages(int new_highest_page, int num_pages_truncated)Undo the compress space operation.Undo of this operation doesn't really "undo" the operation, it just makes sure the data structures are ok after the undo. We are guaranteed at the point of the transaction doing the Undo of the compress space operation fixes up the bit maps to only point at pages within the new_highest_page range.
Prior to logging the compress space operation all pages greater than There are only 2 possibilities at this point: 1) the truncate of pages greater than new_highest_page happened before the abort took place. W 2)
-
getExtentEnd
protected long getExtentEnd()
-
getFreePageNumber
protected long getFreePageNumber(long pnum)
Get a page number that is free
-
getPageOffset
protected long getPageOffset(long pagenum, int pagesize, boolean deallocOK) throws StandardExceptionGet the physical offset of pagenum. If deallocOK is true, then even if pagenum is deallocated, it is OK. If deallocOK is false, then an exception is thrown if pagenum is deallocated. An exception is always thrown if pagenum is a free page- Throws:
StandardException- Standard Derby error policy
-
isRetired
protected boolean isRetired()
Return the status of this extent
-
mayHaveFreePage
private boolean mayHaveFreePage()
-
setExtentFreePageStatus
private void setExtentFreePageStatus(boolean hasFree)
-
canAddFreePage
protected boolean canAddFreePage(long lastAllocatedPage)
-
getPageStatus
protected int getPageStatus(long pagenum)
Return the status of a particular page
-
getFirstPagenum
protected long getFirstPagenum()
Get the first logical page number managed by this extent.
-
getLastPagenum
protected long getLastPagenum()
Get the last logical page number managed by this extent.
-
getPagenum
protected long getPagenum(int bit_pos)
translate bit position in map to page number.- Returns:
- The page number of this "bit" in the extent map.
-
getLastPreallocPagenum
protected long getLastPreallocPagenum()
get the last preallocated pagenumber managed by this alloc page
-
setLastPreallocPagenum
protected void setLastPreallocPagenum(long preAllocPagenum)
preallocated N pages, passed in the last preallocated page number.
-
getNextValidPageNumber
protected long getNextValidPageNumber(long prevPageNumber)
-
getLastValidPageNumber
protected long getLastValidPageNumber()
-
checkInRange
private void checkInRange(long pagenum)
-
updateUnfilledPageInfo
protected void updateUnfilledPageInfo(AllocExtent inputExtent)
-
trackUnfilledPage
protected boolean trackUnfilledPage(long pagenumber, boolean unfilled)
-
getUnfilledPageNumber
protected long getUnfilledPageNumber(long pagenum)
Get a page number that is unfilled, pagenum is the last page that was rejected.
-
getAllocatedPageCount
protected int getAllocatedPageCount()
Get the number of used page in this extent
-
getUnfilledPageCount
protected int getUnfilledPageCount()
Get the number of unfilled pages in this extent
-
getTotalPageCount
protected int getTotalPageCount()
Get the total number of pages in this extent
-
toDebugString
protected java.lang.String toDebugString()
-
-