Write a page to disk. This should not be called directly but should be called from the BufferPool when pages are flushed to disk @param page - the page to write to disk
(Page page)
| 142 | * @param page - the page to write to disk |
| 143 | */ |
| 144 | public void writePage(Page page) throws IOException { |
| 145 | BTreePageId id = (BTreePageId) page.getId(); |
| 146 | |
| 147 | byte[] data = page.getPageData(); |
| 148 | RandomAccessFile rf = new RandomAccessFile(f, "rw"); |
| 149 | if(id.pgcateg() == BTreePageId.ROOT_PTR) { |
| 150 | rf.write(data); |
| 151 | rf.close(); |
| 152 | } |
| 153 | else { |
| 154 | rf.seek(BTreeRootPtrPage.getPageSize() + (long) (page.getId().getPageNumber() - 1) * BufferPool.getPageSize()); |
| 155 | rf.write(data); |
| 156 | rf.close(); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Returns the number of pages in this BTreeFile. |
no test coverage detected