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

Method applyPredicate

test/simpledb/systemtest/DeleteTest.java:23–56  ·  view source on GitHub ↗
(HeapFile table, TransactionId tid, Predicate predicate)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 9

openMethod · 0.95
getTupleDescMethod · 0.95
getFieldMethod · 0.95
closeMethod · 0.95
matchTuplesMethod · 0.95
getIdMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65
getValueMethod · 0.45

Tested by

no test coverage detected