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

Method checkRep

src/java/simpledb/index/BTreeChecker.java:68–80  ·  view source on GitHub ↗

checks the integrity of the tree: 1) parent pointers. 2) sibling pointers. 3) range invariants. 4) record to page pointers. 5) occupancy invariants. (if enabled)

(BTreeFile bt, TransactionId tid, Map<PageId, Page> dirtypages,
                                boolean checkOccupancy)

Source from the content-addressed store, hash-verified

66 * 5) occupancy invariants. (if enabled)
67 */
68 public static void checkRep(BTreeFile bt, TransactionId tid, Map<PageId, Page> dirtypages,
69 boolean checkOccupancy) throws
70 DbException, IOException, TransactionAbortedException {
71 BTreeRootPtrPage rtptr = bt.getRootPtrPage(tid, dirtypages);
72
73 if (rtptr.getRootId() == null) { // non existent root is a legal state.
74 } else {
75 SubtreeSummary res = checkSubTree(bt, tid, dirtypages,
76 rtptr.getRootId(), null, null, rtptr.getId(), checkOccupancy, 0);
77 assert (res.ptrLeft == null);
78 assert (res.ptrRight == null);
79 }
80 }
81
82 static SubtreeSummary checkSubTree(BTreeFile bt, TransactionId tid, Map<PageId, Page> dirtypages,
83 BTreePageId pageId, Field lowerBound, Field upperBound,

Callers 7

addDuplicateTuplesMethod · 0.95
testMergeLeafPagesMethod · 0.95
testDeleteRootPageMethod · 0.95
testReuseDeletedPagesMethod · 0.95

Calls 4

getRootIdMethod · 0.95
checkSubTreeMethod · 0.95
getIdMethod · 0.95
getRootPtrPageMethod · 0.80

Tested by 7

addDuplicateTuplesMethod · 0.76
testMergeLeafPagesMethod · 0.76
testDeleteRootPageMethod · 0.76
testReuseDeletedPagesMethod · 0.76