MCPcopy Create free account
hub / github.com/1345414527/MIT6.830 / getRootPtrPage

Method getRootPtrPage

src/java/simpledb/index/BTreeFile.java:1081–1097  ·  view source on GitHub ↗

Get a read lock on the root pointer page. Create the root pointer page and root page if necessary. @param tid - the transaction id @param dirtypages - the list of dirty pages which should be updated with all new dirty pages @return the root pointer page¶ @throws DbException @throws IOException @thr

(TransactionId tid, Map<PageId, Page> dirtypages)

Source from the content-addressed store, hash-verified

1079 * @throws TransactionAbortedException
1080 */
1081 BTreeRootPtrPage getRootPtrPage(TransactionId tid, Map<PageId, Page> dirtypages) throws DbException, IOException, TransactionAbortedException {
1082 synchronized(this) {
1083 if(f.length() == 0) {
1084 // create the root pointer page and the root page
1085 BufferedOutputStream bw = new BufferedOutputStream(
1086 new FileOutputStream(f, true));
1087 byte[] emptyRootPtrData = BTreeRootPtrPage.createEmptyPageData();
1088 byte[] emptyLeafData = BTreeLeafPage.createEmptyPageData();
1089 bw.write(emptyRootPtrData);
1090 bw.write(emptyLeafData);
1091 bw.close();
1092 }
1093 }
1094
1095 // get a read lock on the root pointer page
1096 return (BTreeRootPtrPage) getPage(tid, dirtypages, BTreeRootPtrPage.getId(tableid), Permissions.READ_ONLY);
1097 }
1098
1099 /**
1100 * Get the page number of the first empty page in this BTreeFile.

Callers 4

insertTupleMethod · 0.95
getEmptyPageNoMethod · 0.95
setEmptyPageMethod · 0.95
checkRepMethod · 0.80

Calls 5

createEmptyPageDataMethod · 0.95
getPageMethod · 0.95
getIdMethod · 0.95
closeMethod · 0.65
createEmptyPageDataMethod · 0.45

Tested by

no test coverage detected