openworm / owmeta-core

Core library for owmeta
MIT License
3 stars 2 forks source link

Add change tracking for contexts #21

Open mwatts15 opened 6 years ago

mwatts15 commented 6 years ago

In order to reduce the amount of work that goes into identifying changes made to a graph, we can track when changes are made as we make them rather than sorting, serializing, and writing to disk ALL contexts as we do now.

Three approaches occur to me:

  1. When triples are added to a context graph mark it as 'dirty'. Then we only need ever to serialize dirty graphs
  2. Like 1, but compute a sort of hash function, h, of adds and removes where h([add(t1), add(t2), remove(t1)]) == h([add(t2)]). Typically, we don't do many removals, but if we did, this would detect. Technically, would need to handle collisions as well.
  3. Record the actual adds and removes to each context literally in a journal. Updates would then just be writing to this journal and commits would read from it.

relates to openworm/owmeta#350