|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimpledb.HeapFile
public class HeapFile
HeapFile is an implementation of a DbFile that stores a collection of tuples in no particular order. Tuples are stored on pages, each of which is a fixed size, and the file is simply a collection of those pages. HeapFile works closely with HeapPage. The format of HeapPages is described in the HeapPage constructor.
HeapPage.HeapPage(simpledb.HeapPageId, byte[])
Constructor Summary | |
---|---|
HeapFile(java.io.File f)
Constructor. |
Method Summary | |
---|---|
java.util.ArrayList<Page> |
addTuple(TransactionId tid,
Tuple t)
Adds the specified tuple to the table under the specified TransactionId. |
int |
bytesPerPage()
|
Page |
deleteTuple(TransactionId tid,
Tuple t)
Deletes the specified tuple from the table, under the specified TransactionId. |
java.io.File |
getFile()
Return a Java File corresponding to the data from this HeapFile on disk. |
int |
id()
|
DbFileIterator |
iterator(TransactionId tid)
An iterator over all tuples on this file, over all pages. |
int |
numPages()
Returns the number of pages in this HeapFile. |
Page |
readPage(PageId pid)
Returns a Page from the file. |
void |
writePage(Page page)
Writes the given page to the appropriate location in the file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HeapFile(java.io.File f)
f
- The file that stores the on-disk backing store for this DbFile.Method Detail |
---|
public java.io.File getFile()
public int id()
id
in interface DbFile
public Page readPage(PageId pid) throws java.util.NoSuchElementException
readPage
in interface DbFile
java.util.NoSuchElementException
- if the page does not exist in this filepublic void writePage(Page page) throws java.io.IOException
writePage
in interface DbFile
java.io.IOException
- if the write failspublic int numPages()
public java.util.ArrayList<Page> addTuple(TransactionId tid, Tuple t) throws DbException, java.io.IOException, TransactionAbortedException
addTuple
in interface DbFile
tid
- The transaction performing the updatet
- The tuple to add. This tuple will be updated to reflect that
it is now stored in this file.
DbException
java.io.IOException
TransactionAbortedException
public Page deleteTuple(TransactionId tid, Tuple t) throws DbException, TransactionAbortedException
deleteTuple
in interface DbFile
DbException
- if the tuple cannot be deleted or is not a member
of the file
TransactionAbortedException
public DbFileIterator iterator(TransactionId tid)
iterator
in interface DbFile
public int bytesPerPage()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |