public interface DbFile
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<Page> |
deleteTuple(TransactionId tid,
Tuple t)
Removes the specified tuple from the file on behalf of the specified
transaction.
|
int |
getId()
Returns a unique ID used to identify this DbFile in the Catalog.
|
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.
|
Page |
readPage(PageId id)
Read the specified page from disk.
|
void |
writePage(Page p)
Push the specified page to disk.
|
Page readPage(PageId id)
java.lang.IllegalArgumentException
- if the page does not exist in this file.void writePage(Page p) throws java.io.IOException
p
- 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 failsjava.util.ArrayList<Page> insertTuple(TransactionId tid, Tuple t) throws DbException, java.io.IOException, TransactionAbortedException
tid
- 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/writtenTransactionAbortedException
java.util.ArrayList<Page> deleteTuple(TransactionId tid, Tuple t) throws DbException, java.io.IOException, TransactionAbortedException
tid
- The transaction performing the updatet
- The tuple to delete. This tuple should be updated to reflect that
it is no longer stored on any page.DbException
- if the tuple cannot be deleted or is not a member
of the filejava.io.IOException
TransactionAbortedException
DbFileIterator iterator(TransactionId tid)
BufferPool.getPage(simpledb.TransactionId, simpledb.PageId, simpledb.Permissions)
, rather than
readPage(simpledb.PageId)
to iterate through the pages.int getId()
Catalog.getDatabaseFile(int)
and
Catalog.getTupleDesc(int)
.
Implementation note: you will need to generate this tableid somewhere,
ensure that each HeapFile has a "unique id," and that you always
return the same value for a particular HeapFile. A simple implementation
is to use the hash code of the absolute path of the file underlying
the HeapFile, i.e. f.getAbsoluteFile().hashCode()
.
TupleDesc getTupleDesc()