public class HeapFile extends java.lang.Object implements DbFile
HeapPage.HeapPage(simpledb.HeapPageId, byte[]),
Serialized Form| Modifier and Type | Class and Description |
|---|---|
class |
HeapFile.HeapFileIterator
Class for iterating over all tuples of this file
|
| Modifier and Type | Field and Description |
|---|---|
private java.io.File |
file |
private TupleDesc |
tupleDesc |
| Constructor and Description |
|---|
HeapFile(java.io.File f,
TupleDesc td)
Constructs a heap file backed by the specified file.
|
| Modifier and Type | Method and Description |
|---|---|
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 iterator to all the tuples in this file
|
int |
numPages()
Returns the number of pages in this HeapFile.
|
Page |
readPage(PageId pid)
Reads page from the file with given id
|
void |
writePage(Page page)
Write given page to disk
|
private java.io.File file
private TupleDesc tupleDesc
public HeapFile(java.io.File f,
TupleDesc td)
f - the file that stores the on-disk backing store for this heap
file.td - the tuple desc of the filepublic java.io.File getFile()
public int getId()
public TupleDesc getTupleDesc()
getTupleDesc in interface DbFilepublic void writePage(Page page) throws java.io.IOException
public int numPages()
public java.util.ArrayList<Page> insertTuple(TransactionId tid, Tuple t) throws DbException, java.io.IOException, TransactionAbortedException
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 addedjava.io.IOException - if the needed file can't be read/writtenTransactionAbortedExceptionpublic Page deleteTuple(TransactionId tid, Tuple t) throws DbException, TransactionAbortedException
DbFiledeleteTuple in interface DbFileDbException - if the tuple cannot be deleted or is not a member
of the fileTransactionAbortedExceptionpublic DbFileIterator iterator(TransactionId tid)