(HeapFile table, TransactionId tid, Predicate predicate)
| 21 | List<List<Integer>> expectedTuples = null; |
| 22 | |
| 23 | @Override |
| 24 | protected int applyPredicate(HeapFile table, TransactionId tid, Predicate predicate) |
| 25 | throws DbException, TransactionAbortedException { |
| 26 | SeqScan ss = new SeqScan(tid, table.getId(), ""); |
| 27 | Filter filter = new Filter(predicate, ss); |
| 28 | Delete deleteOperator = new Delete(tid, filter); |
| 29 | // Query q = new Query(deleteOperator, tid); |
| 30 | |
| 31 | // q.start(); |
| 32 | deleteOperator.open(); |
| 33 | boolean hasResult = false; |
| 34 | int result = -1; |
| 35 | while (deleteOperator.hasNext()) { |
| 36 | Tuple t = deleteOperator.next(); |
| 37 | assertFalse(hasResult); |
| 38 | hasResult = true; |
| 39 | assertEquals(SystemTestUtil.SINGLE_INT_DESCRIPTOR, t.getTupleDesc()); |
| 40 | result = ((IntField) t.getField(0)).getValue(); |
| 41 | } |
| 42 | assertTrue(hasResult); |
| 43 | |
| 44 | deleteOperator.close(); |
| 45 | |
| 46 | // As part of the same transaction, scan the table |
| 47 | if (result == 0) { |
| 48 | // Deleted zero tuples: all tuples still in table |
| 49 | expectedTuples = createdTuples; |
| 50 | } else { |
| 51 | assert result == createdTuples.size(); |
| 52 | expectedTuples = new ArrayList<>(); |
| 53 | } |
| 54 | SystemTestUtil.matchTuples(table, tid, expectedTuples); |
| 55 | return result; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | protected void validateAfter(HeapFile table) |
nothing calls this directly
no test coverage detected