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 |
page |
| Constructor and Description |
|---|
FreeListBlock(RandomAccessInterface file,
int startPage) |
| Modifier and Type | Method and Description |
|---|---|
void |
addPage(int freePage)
Adds free page and writes new len to disk
|
boolean |
flbck(boolean fix)
Recursive.
|
int |
getNextPage() |
static void |
initPage(RandomAccessInterface file,
int page) |
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() |
public FreeListBlock(RandomAccessInterface file, int startPage) throws IOException
IOExceptionpublic void addPage(int freePage)
throws IOException
IllegalStateException - if fullIOExceptionpublic boolean flbck(boolean fix)
throws IOException
IOExceptionpublic int getNextPage()
public static void initPage(RandomAccessInterface file, int page) throws IOException
IOExceptionpublic boolean isEmpty()
public boolean isFull()
public void setNextPage(int nxt)
throws IOException
IOExceptionpublic int takePage()
throws IOException
IllegalStateException - if emptyIOExceptionpublic void writeBlock()
throws IOException
IOException