From: Rob V. <rv...@vd...> - 2010-06-21 09:48:26
|
The best way to do this with the existing API is to create a new empty graph, use that Graph to create the nodes you need and generate two lists of triples - those to be added and those to be removed and then call the UpdateGraph() method passing in your graphs URI and the two lists. Do NOT use the SaveGraph() method as that typically overwrites any existing Graph completely rather than merging with it (this is the behaviour for Virtuoso) If you are willing to use the very latest (and potentially unstable) builds from SVN then revision 780 contains a new WriteOnlyStoreGraph class which fills in a hole in the API which your question highlights. This provides a write-only view onto a Graph stored in some arbitrary store so you pass in a Graph URI and a IGenericIOManager (in your case an instance of a VirtuosoManager) and then use the Assert() and Retract() methods as usual and your changes will get automatically persisted to the backing Store. Note that this persistence is done batched in the background so changes aren't persisted instantaneously and it's worth explicitly calling the Dispose() method on the Graph when you're done with it and this forces any remaining unpersisted changes to be persisted to the Store. Regards, Rob Vesse ---------------------------------------- From: Michael Friis <fr...@gm...> Sent: Monday, June 21, 2010 10:23 AM To: dot...@li..., rv...@vd... Subject: SPAM-LOW: Updating/inserting-into DB-backed graph without doing LoadGraph I have a very large graph which I persist in a SQL-database (switching to Virtuoso). Looking at the dotNetRDF API, it looks like you have to have a graph object to create nodes and triples. So, I've been doing manager.LoadGraph(), inserting/updating and then manager.SaveGraph(). Loading the graph takes a lot of time and consumes a lot of memory though. What's the performant way to do this? Should I just new up a new graph, set the various namespaces and then hope the manager merges it into the existing one when I do SaveGraph()? Regards Michael -- http://friism.com (+45) 27122799 Sapere aude |