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

Method addTuple

test/simpledb/HeapFileWriteTest.java:35–55  ·  view source on GitHub ↗

Unit test for HeapFile.addTuple()

()

Source from the content-addressed store, hash-verified

33 * Unit test for HeapFile.addTuple()
34 */
35 @Test public void addTuple() throws Exception {
36 // we should be able to add 504 tuples on an empty page.
37 for (int i = 0; i < 504; ++i) {
38 empty.insertTuple(tid, Utility.getHeapTuple(i, 2));
39 assertEquals(1, empty.numPages());
40 }
41
42 // the next 512 additions should live on a new page
43 for (int i = 0; i < 504; ++i) {
44 System.out.println(empty.getFile().length());
45 System.out.println(Utility.getHeapTuple(i, 2));
46 empty.insertTuple(tid, Utility.getHeapTuple(i, 2));
47 System.out.println(empty.numPages());
48 System.out.println(empty.getFile().length());
49 assertEquals(2, empty.numPages());
50 }
51
52 // and one more, just for fun...
53 empty.insertTuple(tid, Utility.getHeapTuple(0, 2));
54 assertEquals(3, empty.numPages());
55 }
56
57 @Test
58 public void testAlternateEmptyAndFullPagesThenIterate() throws Exception {

Callers

nothing calls this directly

Calls 4

getHeapTupleMethod · 0.95
insertTupleMethod · 0.65
numPagesMethod · 0.45
getFileMethod · 0.45

Tested by

no test coverage detected