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

Method deleteTuple

src/java/simpledb/index/BTreeFile.java:1051–1068  ·  view source on GitHub ↗

Delete a tuple from this BTreeFile. May cause pages to merge or redistribute entries/tuples if the pages become less than half full. @param tid - the transaction id @param t - the tuple to delete @return a list of all pages that were dirtied by this operation. Could include many pages since parent

(TransactionId tid, Tuple t)

Source from the content-addressed store, hash-verified

1049 * @see #handleMinOccupancyPage(TransactionId, Map, BTreePage)
1050 */
1051 public List<Page> deleteTuple(TransactionId tid, Tuple t)
1052 throws DbException, IOException, TransactionAbortedException {
1053 Map<PageId, Page> dirtypages = new HashMap<>();
1054
1055 BTreePageId pageId = new BTreePageId(tableid, t.getRecordId().getPageId().getPageNumber(),
1056 BTreePageId.LEAF);
1057 BTreeLeafPage page = (BTreeLeafPage) getPage(tid, dirtypages, pageId, Permissions.READ_WRITE);
1058 page.deleteTuple(t);
1059
1060 // if the page is below minimum occupancy, get some tuples from its siblings
1061 // or merge with one of the siblings
1062 int maxEmptySlots = page.getMaxTuples() - page.getMaxTuples()/2; // ceiling
1063 if(page.getNumEmptySlots() > maxEmptySlots) {
1064 handleMinOccupancyPage(tid, dirtypages, page);
1065 }
1066
1067 return new ArrayList<>(dirtypages.values());
1068 }
1069
1070 /**
1071 * Get a read lock on the root pointer page. Create the root pointer page and root page

Callers 4

deleteTupleMethod · 0.95
testMergeLeafPagesMethod · 0.95
testDeleteRootPageMethod · 0.95

Calls 8

getPageMethod · 0.95
deleteTupleMethod · 0.95
getMaxTuplesMethod · 0.95
getNumEmptySlotsMethod · 0.95
getPageNumberMethod · 0.65
getPageIdMethod · 0.45
getRecordIdMethod · 0.45

Tested by 4

deleteTupleMethod · 0.76
testMergeLeafPagesMethod · 0.76
testDeleteRootPageMethod · 0.76