A virtual dataset: a read-set (union-over-history) + last-run clock.
| 37 | |
| 38 | |
| 39 | class Dataset: |
| 40 | """A virtual dataset: a read-set (union-over-history) + last-run clock.""" |
| 41 | |
| 42 | def __init__(self, reads): |
| 43 | self.reads = reads # slots its transform reads when it runs |
| 44 | self.read_slots = [] # discovered union read-set |
| 45 | self.last_run_clock = 0 |
| 46 | self.runs = 0 |
| 47 | |
| 48 | def should_run(self, store): |
| 49 | # empty read-set -> always run (R7); else run iff an input changed |
| 50 | return not self.read_slots or store.changed_since( |
| 51 | self.read_slots, self.last_run_clock |
| 52 | ) |
| 53 | |
| 54 | def run(self, store): |
| 55 | store.set_capture_target(self.read_slots) |
| 56 | for s in self.reads: |
| 57 | store.read(s) |
| 58 | store.set_capture_target(None) |
| 59 | self.last_run_clock = store.write_clock |
| 60 | self.runs += 1 |
| 61 | |
| 62 | |
| 63 | def frame(store, datasets): |
no outgoing calls