simpledb
Interface DbFile

All Known Implementing Classes:
HeapFile

public interface DbFile

The interface for database files on disk . Database files need to be able to fetch pages and iterate through tuples. They may also support sargable predictes for efficient index searches. DbFile's are generally access through the buffer pool (rather than directly by operators.)


Method Summary
 java.util.ArrayList<Page> addTuple(TransactionId tid, Tuple t)
          Adds the specified tuple to the file on behalf of transaction.
 Page deleteTuple(TransactionId tid, Tuple t)
          Removes the specifed tuple from the file on behalf of the specified transaction.
 int id()
           
 DbFileIterator iterator(TransactionId tid)
           
 Page readPage(PageId id)
          Read the specified page from disk.
 void writePage(Page p)
          Push the specified page to disk.
 

Method Detail

readPage

Page readPage(PageId id)
              throws java.util.NoSuchElementException
Read the specified page from disk.

Throws:
java.util.NoSuchElementException - if the page does not exist in this file

writePage

void writePage(Page p)
               throws java.io.IOException
Push the specified page to disk. This page must have been previously read from this file via a call to readPage.

Throws:
java.io.IOException - if the write fails

addTuple

java.util.ArrayList<Page> addTuple(TransactionId tid,
                                   Tuple t)
                                   throws DbException,
                                          java.io.IOException,
                                          TransactionAbortedException
Adds the specified tuple to the file on behalf of transaction. This method will acquire a lock on the affected pages of the file, and may block until the lock can be acquired.

Parameters:
tid - The transaction performing the update
t - The tuple to add. This tuple will be updated to reflect that it is now stored in this file.
Throws:
DbException - if the tuple cannot be added
java.io.IOException - if the needed file can't be read/written
TransactionAbortedException

deleteTuple

Page deleteTuple(TransactionId tid,
                 Tuple t)
                 throws DbException,
                        TransactionAbortedException
Removes the specifed tuple from the file on behalf of the specified transaction. This method will acquire a lock on the affected pages of the file, and may block until the lock can be acquired.

Throws:
DbException - if the tuple cannot be deleted or is not a member of the file
TransactionAbortedException

iterator

DbFileIterator iterator(TransactionId tid)

id

int id()
Returns:
a table id for this table.