|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exist.storage.index.FreeList
public class FreeList
Manages a list of pages containing unused sections.
Class BFile
stores all data in variable
length records. As records may grow or shrink, the database has to keep
track of the amount of free space currently available in pages. Class
BFile
will always check if FreeList has a page
that can be filled before creating a new page.
FreeList implements a linked list of FreeSpace
objects. Each object
in the list describes a page and the unused space in this page.
FreeList
Field Summary | |
---|---|
static int |
MAX_FREE_LIST_LEN
|
Constructor Summary | |
---|---|
FreeList()
|
Method Summary | |
---|---|
void |
add(FreeSpace free)
Append a new FreeSpace object to the list,
describing the amount of free space available on a page. |
FreeSpace |
find(int requiredSize)
Try to find a page that has at least requiredSize bytes available. |
int |
read(byte[] buf,
int offset)
Read the list from a RandomAccessFile . |
void |
remove(FreeSpace node)
Remove a record from the list. |
FreeSpace |
retrieve(long pageNum)
Retrieve the record stored for the given page number. |
String |
toString()
|
int |
write(byte[] buf,
int offset)
Write the list to a RandomAccessFile . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MAX_FREE_LIST_LEN
Constructor Detail |
---|
public FreeList()
Method Detail |
---|
public void add(FreeSpace free)
FreeSpace
object to the list,
describing the amount of free space available on a page.
free
- public void remove(FreeSpace node)
node
- public FreeSpace retrieve(long pageNum)
pageNum
- public FreeSpace find(int requiredSize)
requiredSize
- public String toString()
toString
in class Object
public int read(byte[] buf, int offset) throws IOException
RandomAccessFile
.
buf
- offset
-
IOException
public int write(byte[] buf, int offset) throws IOException
RandomAccessFile
.
As the list is written to the file header, its maximum length
has to be restricted. The method will thus only store
MAX_FREE_LIST_LEN
entries and throw away the
rest. Usually, this should not happen very often, so it is ok to
waste some space.
buf
- offset
-
IOException
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |