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

Method deleteTuple

test/simpledb/BufferPoolWriteTest.java:94–124  ·  view source on GitHub ↗

Unit test for BufferPool.deleteTuple()

()

Source from the content-addressed store, hash-verified

92 * Unit test for BufferPool.deleteTuple()
93 */
94 @Test public void deleteTuple() throws Exception {
95
96 // heap file should have ~10 pages
97 HeapFile hf = SystemTestUtil.createRandomHeapFile(2, 504*10, null, null);
98 DbFileIterator it = hf.iterator(tid);
99 it.open();
100
101 List<Tuple> tuples = new ArrayList<>();
102 while(it.hasNext()) {
103 tuples.add(it.next());
104 }
105
106 // clear the cache
107 Database.resetBufferPool(BufferPool.DEFAULT_PAGES);
108
109 // delete 504 tuples from the first page
110 for (int i = 0; i < 504; ++i) {
111 Tuple t = tuples.get(i);
112 Database.getBufferPool().deleteTuple(tid, t);
113 HeapPage p = (HeapPage) Database.getBufferPool().getPage(tid, t.getRecordId().getPageId(), Permissions.READ_ONLY);
114 assertEquals(i+1, p.getNumEmptySlots());
115 }
116
117 // delete 504 tuples from the second page
118 for (int i = 0; i < 504; ++i) {
119 Tuple t = tuples.get(i+504);
120 Database.getBufferPool().deleteTuple(tid, t);
121 HeapPage p = (HeapPage) Database.getBufferPool().getPage(tid, t.getRecordId().getPageId(), Permissions.READ_ONLY);
122 assertEquals(i+1, p.getNumEmptySlots());
123 }
124 }
125
126 @Test public void handleManyDirtyPages() throws Exception {
127 HeapFileDuplicates hfd = new HeapFileDuplicates(empty.getFile(), empty.getTupleDesc(), 10);

Callers

nothing calls this directly

Calls 13

createRandomHeapFileMethod · 0.95
iteratorMethod · 0.95
openMethod · 0.95
hasNextMethod · 0.95
nextMethod · 0.95
resetBufferPoolMethod · 0.95
getBufferPoolMethod · 0.95
getRecordIdMethod · 0.95
getNumEmptySlotsMethod · 0.95
getMethod · 0.80
deleteTupleMethod · 0.65
getPageMethod · 0.45

Tested by

no test coverage detected