class FreeListBlock extends Object
Tracks available pages for allocation using a linked list of blocks. Each block contains multiple free page references and fits on a single disk page.
On-disk format:
Magic number (long)
next freelist block page (unsigned int)
size (unsigned int)
that many free pages (unsigned ints)
Free page format:
Magic number (long)
| Modifier and Type | Field and Description |
|---|---|
int | pagePage number of this free list block. |
| Constructor and Description |
|---|
FreeListBlock(RandomAccessInterface file,
int startPage)Constructor. |
| Modifier and Type | Method and Description |
|---|---|
void | addPage(int freePage)Adds free page and writes new len to disk |
boolean | flbck(boolean fix) |
int | getNextPage() |
static void | initPage(RandomAccessInterface file,
int page)Initialize a new free list block page with default values. |
boolean | isEmpty() |
boolean | isFull() |
void | setNextPage(int nxt)Set and write the next page only |
int | takePage()Takes next page and writes new len to disk |
String | toString() |
void | writeBlock()Write this block's data to disk. |
public FreeListBlock(RandomAccessInterface file, int startPage) throws IOException
file - the block filestartPage - starting page numberIOException - on I/O errorpublic void addPage(int freePage)
throws IOExceptionIllegalStateException - if fullIOExceptionpublic boolean flbck(boolean fix)
throws IOExceptionIOExceptionpublic int getNextPage()
public static void initPage(RandomAccessInterface file, int page) throws IOException
IOExceptionpublic boolean isEmpty()
public boolean isFull()
public void setNextPage(int nxt)
throws IOExceptionIOExceptionpublic int takePage()
throws IOExceptionIllegalStateException - if emptyIOExceptionpublic String toString()
public void writeBlock()
throws IOExceptionIOException