|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
public interface DbFile
The interface for database files on disk. Each table is represented by a single DbFile. DbFiles can fetch pages and iterate through tuples. Each file has a unique id used to store metadata about the table in the Catalog. DbFiles are generally accessed through the buffer pool, rather than directly by operators.
| Method Summary | |
|---|---|
Page |
deleteTuple(TransactionId tid,
Tuple t)
Removes the specifed 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. |
| Method Detail |
|---|
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 fails
java.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 added
java.io.IOException - if the needed file can't be read/written
TransactionAbortedException
Page deleteTuple(TransactionId tid,
Tuple t)
throws DbException,
TransactionAbortedException
DbException - if the tuple cannot be deleted or is not a member
of the file
TransactionAbortedExceptionDbFileIterator iterator(TransactionId tid)
BufferPool.getPage(simpledb.TransactionId, simpledb.PageId, simpledb.Permissions), rather than
readPage(simpledb.PageId) to iterate through the pages.
int getId()
Catalog.getDbFile(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()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||