|
||||||||
| 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,
TupleDesc td)
Constructs a heap file backed by the specified file. |
|
| Method Summary | |
|---|---|
Page |
deleteTuple(TransactionId tid,
Tuple t)
Removes the specifed tuple from the file on behalf of the specified transaction. |
java.io.File |
getFile()
Returns the File backing this HeapFile on disk. |
int |
getId()
Returns an ID uniquely identifying this HeapFile. |
TupleDesc |
getTupleDesc()
Returns the TupleDesc of the table stored in this DbFile. |
java.util.ArrayList<Page> |
insertTuple(TransactionId tid,
Tuple t)
Inserts the specified tuple to the file on behalf of transaction. |
DbFileIterator |
iterator(TransactionId tid)
Returns an iterator over all the tuples stored in this DbFile. |
int |
numPages()
Returns the number of pages in this HeapFile. |
Page |
readPage(PageId pid)
Read the specified page from disk. |
void |
writePage(Page page)
Push the specified page to disk. |
| 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,
TupleDesc td)
f - the file that stores the on-disk backing store for this heap file.| Method Detail |
|---|
public java.io.File getFile()
public int getId()
getId in interface DbFilepublic TupleDesc getTupleDesc()
getTupleDesc in interface DbFilepublic Page readPage(PageId pid)
DbFile
readPage in interface DbFile
public void writePage(Page page)
throws java.io.IOException
DbFile
writePage in interface DbFilepage - The page to write. page.getId().pageno() specifies the offset into the file where the page should be written.
java.io.IOException - if the write failspublic int numPages()
public java.util.ArrayList<Page> insertTuple(TransactionId tid,
Tuple t)
throws DbException,
java.io.IOException,
TransactionAbortedException
DbFile
insertTuple in interface DbFiletid - The transaction performing the updatet - The tuple to add. This tuple should be updated to reflect that
it is now stored in this file.
DbException - if the tuple cannot be added
java.io.IOException - if the needed file can't be read/written
TransactionAbortedException
public Page deleteTuple(TransactionId tid,
Tuple t)
throws DbException,
TransactionAbortedException
DbFile
deleteTuple in interface DbFileDbException - if the tuple cannot be deleted or is not a member
of the file
TransactionAbortedExceptionpublic DbFileIterator iterator(TransactionId tid)
DbFileBufferPool.getPage(simpledb.TransactionId, simpledb.PageId, simpledb.Permissions), rather than
DbFile.readPage(simpledb.PageId) to iterate through the pages.
iterator in interface DbFile
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||