On 16/07/13 09:50, Nikolaos Konstantinou wrote:
Hi all, I would like to know how and if it is possible to append to an existing model and save only the difference, instead of the whole model. Specifically, the problem setting is the following: Suppose we read an RDF from the hard disk that has many (e.g. 1 million) triples, add another triple, and save the model again. This goes somehow like: model.read(...)Statement st = model.createStatement(s, p, o);model.add(st);model.write(new FileOutputStream(...), syntax); Is there a way to avoid writing the whole model to disk (which overwrites the old one), and instead append only the difference, i.e. the extra triple? If not for an RDF file on the hard disk, maybe this is possible for a persistent (TDB/SDB) model? If not programmatically, maybe using sparql/update? And if not out-of-the-box, any hints towards implementing it?
There's lots of approaches to this, depending on the details of your application. In particular whether your want explicit differences or just want to be able to save your changes efficiently.
For the latter then the easiest solution is to use TDB instead of files. When you change a TDB model only those changes are written out.
If really want to use files but you are in charge of the updates then you could record your updates separately and reduce the number of times you need to write out your whole model. For example, if you express your updates as SPARQL Update commands then you could store those as files that can be later read and replayed. Sort of a poor-man's journal.
There are also various proposals for how you can store a delta between two graphs.
However, if all you want to do is to change a persistent model efficiently then use TDB.
Dave
