|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectneustore.base.DBIndex
neustore.heapfile.HeapFile
public class HeapFile
A generic heap file that stores a list of (key, data) pairs.
insert(neustore.base.Key, neustore.base.Data)
, delete(neustore.base.Key)
, and search(neustore.base.Key)
a record.
HeapFilePage
Field Summary | |
---|---|
protected int |
firstFullPageID
pageID of the first full page. |
protected int |
firstNonFullPageID
pageID of the first non-full page. |
protected int |
numRecs
number of records |
Fields inherited from class neustore.base.DBIndex |
---|
buffer, CREATE, file, firstEmpty, numPages, OPEN, OVERHEAD, pageSize |
Constructor Summary | |
---|---|
HeapFile(DBBuffer _buffer,
java.lang.String filename,
boolean isCreate,
Key _sampleKey,
Data _sampleData)
The HeapFile constructor. |
Method Summary | |
---|---|
protected void |
addPageToFullList(int pageID,
HeapFilePage page)
Adds a page to the beginning of the full-page list. |
protected void |
addPageToNonFullList(int pageID,
HeapFilePage page)
Adds a page to the beginning of the nonfull-page list. |
boolean |
delete(Key key)
Deletes the record by the given key. |
protected void |
initIndexHead()
Initializes index head information. |
void |
insert(Key key,
Data data)
Inserts a new record into the heap file. |
protected HeapFilePage |
myReadPage(int pageID)
Reads a page from buffer and parse it if not parsed already. |
int |
numRecs()
Returns the number of records. |
void |
printInformation()
Prints some information about the index. |
protected void |
readIndexHead(byte[] indexHead)
Reads index head information from a byte array. |
protected void |
removePageFromList(int pageID,
HeapFilePage page)
Removes a page from its (full or nonfull) linked list. |
Data |
search(Key key)
Searches the record by the given key. |
protected void |
writeIndexHead(byte[] indexHead)
Writes index head information to a byte array. |
Methods inherited from class neustore.base.DBIndex |
---|
allocate, close, freePage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int numRecs
protected int firstFullPageID
protected int firstNonFullPageID
Constructor Detail |
---|
public HeapFile(DBBuffer _buffer, java.lang.String filename, boolean isCreate, Key _sampleKey, Data _sampleData) throws java.io.IOException
_buffer
- the bufferisCreate
- whether create (or open)_sampleKey
- the sample key_sampleData
- the sample data
java.io.IOException
Method Detail |
---|
public int numRecs()
protected HeapFilePage myReadPage(int pageID) throws java.io.IOException
pageID
-
java.io.IOException
protected void removePageFromList(int pageID, HeapFilePage page) throws java.io.IOException
pageID
- the pageIDpage
- the HeapFilePage object
java.io.IOException
protected void addPageToFullList(int pageID, HeapFilePage page) throws java.io.IOException
pageID
- the page IDpage
- the HeapFilePage object
java.io.IOException
protected void addPageToNonFullList(int pageID, HeapFilePage page) throws java.io.IOException
pageID
- the page IDpage
- the HeapFilePage object
java.io.IOException
public void insert(Key key, Data data) throws java.io.IOException
key
- the key to be inserteddata
- the data to be inserted
java.io.IOException
public boolean delete(Key key) throws java.io.IOException
key
- the key of the record to be deleted
java.io.IOException
public Data search(Key key) throws java.io.IOException
key
- the key to search
data
if found; null
otherwise
java.io.IOException
public void printInformation()
protected void readIndexHead(byte[] indexHead)
DBIndex
readIndexHead
in class DBIndex
indexHead
- the byte array of length pageSize-OVERHEADprotected void writeIndexHead(byte[] indexHead)
DBIndex
writeIndexHead
in class DBIndex
indexHead
- the byte array of length pageSize-OVERHEADprotected void initIndexHead()
DBIndex
initIndexHead
in class DBIndex
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |