Rob, all

The query does work for my needs. Thanks!

Each Tree graph will consist of 10-20 triples for a given root. Given those
circumstances, what do you think performance would be?

As I mentioned, another idea is to put the RDF graph in a NG and then just
clear that NG.

What is the experience of using a high number of Named Graphs with small
number of triples in each named graph (~10-20 triples). The
operations/queries I am expecting to do are:

- Given a root, return me the tree graph associated to that root
CONSTRUCT {?s ?p ?o} { GRAPH <http://example/> { ?s ?p ?o } }

- Given a root, delete the tree graph associated to that root.
CLEAR GRAPH <http://example/>

- Insert a graph
INSERT DATA { GRAPH <http://example/> { ... } }

Thanks for the pointers.



--
Juan Sequeda, Ph.D
+1-575-SEQ-UEDA
www.juansequeda.com

On Mon, Nov 9, 2015 at 6:12 PM, Rob Vesse <[email protected]> wrote:

> Juan
>
> I haven't tested this but in principal the following should work:
>
> DELETE
> {
>   ?s ?p ?o
> }
> WHERE
> {
>   {
>     # Find things directly connected to the root
>     <root> ?p ?o .
>     BIND(<root> AS ?s)
>   }
>   UNION
>   {
>     # Find everything indirectly connected to the root
>     <root> (<>|!<>)+ ?s .
>     ?s ?p ?o .
>   }
> }
>
> In the first branch simply select any triples directly off of the root.
> In the second branch find any triples one/more steps away from the root
> and the associated triples.  Then in the DELETE template simply delete all
> the matched triples.
>
> The second branch uses Joshua Taylor's trick from
> http://stackoverflow.com/a/26707541/107591 of using a property path via a
> URI and its negation to find any subject that is reachable by 1 or more
> steps via any property from your root.  You can then simply grab things
> that are directly connected to that subject.
>
> This will probably perform badly and can be sped up if you have a specific
> property used to denote the tree hierarchy.  For example if the root is
> linked to child nodes via the property :child then we could rewrite the
> second branch as follows:
>
>     <root> :child+ ?s .
>     ?s ?p ?o .
>
> Which still requires a property path but will perform better because the
> path is simpler.
>
> Rob
>
> On 09/11/2015 15:32, "Charles Greer" <[email protected]> wrote:
>
> >Hi Juan,
> >
> >Seems that if you can do this efficiently
> >
> >"Another thought is to put the RDF graph in a NG and then just clear the
> >NG."
> >
> >then that will be more efficient than following property paths.
> >
> >Interesting question to be sure.
> >
> >Charles
> >
> >
> >________________________________________
> >From: Juan Sequeda [[email protected]]
> >Sent: Monday, November 09, 2015 3:28 PM
> >To: [email protected]
> >Subject: Deleting an entire RDF graph
> >
> >All,
> >
> >Assume I have an RDF graph which is a tree, hence there is a root node.
> >What is the best way of deleting that entire RDF graph given the root
> >node?
> >
> >Is there a way to do it with Property paths? And if so, I guess I would
> >have to have knowledge of the structure of the graph/tree?
> >
> >Another thought is to put the RDF graph in a NG and then just clear the
> >NG.
> >
> >Thoughts?
> >
> >Thanks,
> >
> >Juan
>
>
>
>
>

Reply via email to