Bulk removal of triples

0 views
Skip to first unread message

Tze-John Tang

unread,
May 1, 2014, 3:51:37 PM5/1/14
to sta...@clarkparsia.com
Is there a good way to programatically remove a set of triples? As I am updating records in the store, I am removing all triples for a given subject, and then adding new ones later. In my code, I am doing:

 Iterator<Resource> personIterator = GraphUtil.getSubjectIterator(newGraph, RDF.TYPE, IInfrastructureSchema.personType);
 
while (personIterator.hasNext()) {
 
Resource personResource = personIterator.next();
 logger
.info("Removing {}", personResource);
 conn
.remove().statements(personResource, null, null, adContextUri);
 
}

In the newGraph, I have built up a graph of new triples that will be added. But before there are added, I want to remove all of the existing triples where the subject is in the newGraph. I want to remove a whole set of triples based on the subject.

Mike Grove

unread,
May 2, 2014, 7:07:21 AM5/2/14
to stardog
You could do that entire code snippet with a single SPARQL update query which would be a bit more succinct, but as Evren mention, update queries are run in their own transaction, so if you wanted those changes to be a part of a larger transaction, this type of programmatic approach is better.

You might also check out the Getter [1] API as a convenient way to grab triples out of the database.  We also provide some convenience classes around the Sesame API; some are on Github [2] and some are in Stardog in the com.complexible.common.openrdf namespace.

Cheers,

Mike

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Reply all
Reply to author
Forward
0 new messages