Method to encapsulate the process of creating a new page. It reuses old pages if possible, and creates a new page if none are available. It wipes the page on disk and in the cache and returns a clean copy locked with read-write permission @param tid - the transaction id @param dirtypages - the li
(TransactionId tid, Map<PageId, Page> dirtypages, int pgcateg)
| 1173 | * @throws TransactionAbortedException |
| 1174 | */ |
| 1175 | private Page getEmptyPage(TransactionId tid, Map<PageId, Page> dirtypages, int pgcateg) |
| 1176 | throws DbException, IOException, TransactionAbortedException { |
| 1177 | // create the new page |
| 1178 | int emptyPageNo = getEmptyPageNo(tid, dirtypages); |
| 1179 | BTreePageId newPageId = new BTreePageId(tableid, emptyPageNo, pgcateg); |
| 1180 | |
| 1181 | // write empty page to disk |
| 1182 | RandomAccessFile rf = new RandomAccessFile(f, "rw"); |
| 1183 | rf.seek(BTreeRootPtrPage.getPageSize() + (long) (emptyPageNo - 1) * BufferPool.getPageSize()); |
| 1184 | rf.write(BTreePage.createEmptyPageData()); |
| 1185 | rf.close(); |
| 1186 | |
| 1187 | // make sure the page is not in the buffer pool or in the local cache |
| 1188 | Database.getBufferPool().discardPage(newPageId); |
| 1189 | dirtypages.remove(newPageId); |
| 1190 | |
| 1191 | return getPage(tid, dirtypages, newPageId, Permissions.READ_WRITE); |
| 1192 | } |
| 1193 | |
| 1194 | /** |
| 1195 | * Mark a page in this BTreeFile as empty. Find the corresponding header page |
no test coverage detected