Flushes a certain page to disk @param pid an ID indicating the page to flush
(PageId pid)
| 283 | * @param pid an ID indicating the page to flush |
| 284 | */ |
| 285 | private synchronized void flushPage(PageId pid) throws IOException { |
| 286 | // some code goes here |
| 287 | // not necessary for lab1 |
| 288 | Page page = buffer.get(pid); |
| 289 | |
| 290 | if(page.isDirty()!=null){ |
| 291 | DbFile dbFile = Database.getCatalog().getDatabaseFile(pid.getTableId()); |
| 292 | try{ |
| 293 | Database.getLogFile().logWrite(page.isDirty(),page.getBeforeImage(),page); |
| 294 | Database.getLogFile().force(); |
| 295 | page.markDirty(false,null); |
| 296 | dbFile.writePage(page); |
| 297 | }catch (IOException e){ |
| 298 | e.printStackTrace(); |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | /** Write all pages of the specified transaction to disk. |
| 304 | */ |
nothing calls this directly
no test coverage detected