Test that rewinding a SeqScan iterator works.
()
| 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 |
nothing calls this directly
no test coverage detected