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
| 17 | * by operators. |
| 18 | */ |
| 19 | public interface DbFile { |
| 20 | /** |
| 21 | * Read the specified page from disk. |
| 22 | * |
| 23 | * @throws IllegalArgumentException if the page does not exist in this file. |
| 24 | */ |
| 25 | Page readPage(PageId id); |
| 26 | |
| 27 | /** |
| 28 | * Push the specified page to disk. |
| 29 | * |
| 30 | * @param p The page to write. page.getId().pageno() specifies the offset into the file where the page should be written. |
| 31 | * @throws IOException if the write fails |
| 32 | * |
| 33 | */ |
| 34 | void writePage(Page p) throws IOException; |
| 35 | |
| 36 | /** |
| 37 | * Inserts the specified tuple to the file on behalf of transaction. |
| 38 | * This method will acquire a lock on the affected pages of the file, and |
| 39 | * may block until the lock can be acquired. |
| 40 | * |
| 41 | * @param tid The transaction performing the update |
| 42 | * @param t The tuple to add. This tuple should be updated to reflect that |
| 43 | * it is now stored in this file. |
| 44 | * @return An ArrayList contain the pages that were modified |
| 45 | * @throws DbException if the tuple cannot be added |
| 46 | * @throws IOException if the needed file can't be read/written |
| 47 | */ |
| 48 | List<Page> insertTuple(TransactionId tid, Tuple t) |
| 49 | throws DbException, IOException, TransactionAbortedException; |
| 50 | |
| 51 | /** |
| 52 | * Removes the specified tuple from the file on behalf of the specified |
| 53 | * transaction. |
| 54 | * This method will acquire a lock on the affected pages of the file, and |
| 55 | * may block until the lock can be acquired. |
| 56 | * |
| 57 | * @param tid The transaction performing the update |
| 58 | * @param t The tuple to delete. This tuple should be updated to reflect that |
| 59 | * it is no longer stored on any page. |
| 60 | * @return An ArrayList contain the pages that were modified |
| 61 | * @throws DbException if the tuple cannot be deleted or is not a member |
| 62 | * of the file |
| 63 | */ |
| 64 | List<Page> deleteTuple(TransactionId tid, Tuple t) |
| 65 | throws DbException, IOException, TransactionAbortedException; |
| 66 | |
| 67 | /** |
| 68 | * Returns an iterator over all the tuples stored in this DbFile. The |
| 69 | * iterator must use {@link BufferPool#getPage}, rather than |
| 70 | * {@link #readPage} to iterate through the pages. |
| 71 | * |
| 72 | * @return an iterator over all the tuples stored in this DbFile. |
| 73 | */ |
| 74 | DbFileIterator iterator(TransactionId tid); |
| 75 | |
| 76 | /** |
no outgoing calls
no test coverage detected