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

Method testRewind

test/simpledb/systemtest/ScanTest.java:53–74  ·  view source on GitHub ↗

Test that rewinding a SeqScan iterator works.

()

Source from the content-addressed store, hash-verified

51
52 /** Test that rewinding a SeqScan iterator works. */
53 @Test public void testRewind() throws IOException, DbException, TransactionAbortedException {
54 List<List<Integer>> tuples = new ArrayList<>();
55 HeapFile f = SystemTestUtil.createRandomHeapFile(2, 1000, null, tuples);
56
57 TransactionId tid = new TransactionId();
58 SeqScan scan = new SeqScan(tid, f.getId(), "table");
59 scan.open();
60 for (int i = 0; i < 100; ++i) {
61 assertTrue(scan.hasNext());
62 Tuple t = scan.next();
63 assertEquals(tuples.get(i), SystemTestUtil.tupleToList(t));
64 }
65
66 scan.rewind();
67 for (int i = 0; i < 100; ++i) {
68 assertTrue(scan.hasNext());
69 Tuple t = scan.next();
70 assertEquals(tuples.get(i), SystemTestUtil.tupleToList(t));
71 }
72 scan.close();
73 Database.getBufferPool().transactionComplete(tid);
74 }
75
76 /** Verifies that the buffer pool is actually caching data.
77 * @throws TransactionAbortedException

Callers

nothing calls this directly

Calls 11

createRandomHeapFileMethod · 0.95
getIdMethod · 0.95
openMethod · 0.95
hasNextMethod · 0.95
nextMethod · 0.95
tupleToListMethod · 0.95
rewindMethod · 0.95
closeMethod · 0.95
getBufferPoolMethod · 0.95
getMethod · 0.80
transactionCompleteMethod · 0.45

Tested by

no test coverage detected