Thanks again Ivan

With some tinkering I was able to achieve the behavior I was after using
big:rdf_make_iid_of_qname() with a DELETE query

This won't work in all cases but should work for the common cases.

Cheers,

Rob

On 6/1/12 3:43 PM, "Rob Vesse" <rve...@vdesign-studios.com> wrote:

>Thanks Ivan that looks really helpful if somewhat tacky
>
>Most of the time I expect the triples that wants deleting will have been
>very recently retrieved from Virtuoso itself so it's likely I can modify
>my code to keep the original nodeID IRIs around and use those to look up
>the internal Ids.  In fact this may not require much modification since I
>believe I just take the nodeID IRIs and use the portion after the // as
>the blank node identifier for generated blank nodes anyway.
>
>I'll do some experiments and report back.
>
>Thanks,
>
>Rob
>
>
>On 6/1/12 2:28 PM, "Ivan Mikhailov" <imikhai...@openlinksw.com> wrote:
>
>>Hello Rob,
>>
>>Two ways to refer to a particular blank node are to refer to it via some
>>properties or to convert it to it's internal "serial number", a long
>>integer, and back.
>>
>>--- Start from scratch.
>>sparql clear graph <http://sample/>
>>
>>Done. -- 4 msec.
>>
>>--- Insert three blank nodes with two related triples each.
>>sparql insert in graph <http://sample/> { [] <p> <o1a> , <o1b> . [] <p>
>><o2a> , <o2b> . [] <p> <o3a> , <o3b> }
>>
>>Done. -- 15 msec.
>>
>>--- Delete one pair of triples.
>>sparql with <http://sample/> delete { ?s ?p ?o } where { ?s ?p ?o ; <p>
>><o1a> }
>>
>>Done. -- 7 msec.
>>
>>--- Ensure that we still have two bnodes, two triple per bnode.
>>sparql select * from <http://sample/> where { ?s ?p ?o }
>>s               p       o
>>VARCHAR         VARCHAR VARCHAR
>>________________
>>
>>nodeID://b10006 p       o3a
>>nodeID://b10006 p       o3b
>>nodeID://b10007 p       o2a
>>nodeID://b10007 p       o2b
>>
>>4 Rows. -- 4 msec.
>>
>>--- Each bnode (as well as any "named" node) is identified internally as
>>an integer
>>sparql select (<LONG::bif:iri_id_num>(?s)) as ?s_num, ?p, ?o from
>><http://sample/> where { ?s ?p ?o };
>>s_num                p       o
>>INTEGER              VARCHAR VARCHAR
>>_____________________________
>>
>>4611686018427397910  p       o3a
>>4611686018427397910  p       o3b
>>4611686018427397911  p       o2a
>>4611686018427397911  p       o2b
>>
>>4 Rows. -- 5 msec.
>>
>>--- The integer can be converted back to internal identifier. Say, here
>>we try to delete a triple that does not exist (even if the ID integer is
>>valid)
>>sparql delete from <http://sample/>
>>{ `bif:iri_id_from_num(4611686018427397911)` <p> <o3a> };
>>
>>Done. -- 5 msec.
>>
>>--- No effect, because 46..11 has <o2a> and <o2b>, not requested <o3a>
>>sparql select * from <http://sample/> where { ?s ?p ?o };
>>s               p        o
>>VARCHAR         VARCHAR  VARCHAR
>>________________
>>
>>nodeID://b10006 p        o3a
>>nodeID://b10006 p        o3b
>>nodeID://b10007 p        o2a
>>nodeID://b10007 p        o2b
>>
>>4 Rows. -- 5 msec.
>>
>>--- Now let's try to delete a triple that does actually exist. Note the
>>use of backquotes to insert an expression into template.
>>sparql delete from <http://sample/>
>>{ `bif:iri_id_from_num(4611686018427397911)` <p> <o2a> };
>>
>>Done. -- 4 msec.
>>
>>--- So there's an effect
>>sparql select * from <http://sample/> where { ?s ?p ?o };
>>s                p        o
>>VARCHAR          VARCHAR  VARCHAR
>>_________________
>>
>>nodeID://b10006  p        o3a
>>nodeID://b10006  p        o3b
>>nodeID://b10007  p        o2b
>>
>>3 Rows. -- 2 msec.
>>
>>--- Now delete everything related to nodeID://b10006 subject.
>>sparql with <http://sample/> delete { ?s ?p ?o } where { ?s ?p ?o .
>>filter (?s = bif:iri_id_from_num(4611686018427397910)) };
>>
>>Done. -- 18 msec.
>>
>>--- Three minus two gives one triple remaining.
>>SQL> sparql select * from <http://sample/> where { ?s ?p ?o };
>>s                p        o
>>VARCHAR          VARCHAR  VARCHAR
>>_________________
>>
>>nodeID://b10007  p        o2b
>>
>>1 Rows. -- 4 msec.
>>
>>IDs of bnodes will vary from server to server and even from run to run
>>in same server, so the application should identify bnodes by properties
>>before doing bif:iri_id_XXX tricks.
>>
>>Best Regards,
>>
>>Ivan Mikhailov
>>OpenLink Software
>>http://virtuoso.openlinksw.com
>>
>
>





Reply via email to