I guess I had some wrong assumptions about DELETE/INSERT. Will review spec more 
closely. Takeaway for me is that in general DELETE/INSERT is not equivalent to 
DELETE followed by INSERT.

Thanks,
--Paul

> On Nov 2, 2015, at 03:34, Andy Seaborne <[email protected]> wrote:
> 
>> On 01/11/15 23:00, Paul Tyson wrote:
>>> On Sun, 2015-11-01 at 10:32 +0000, Andy Seaborne wrote:
>>> Paul,
>>> 
>>> Could you simplify the example please?
>> 
>>  I will work on that, but ran into some puzzling differences between
>> windows and Linux implementations of jena-3.0.0. Specifically, the linux
>> tdbupdate doesn't recognize --loc argument while Windows does. Anyway
>> that's a side issue.
>> 
>>> 
>>> What is the output of a query that does the WHERE clause when executed
>>> after the first update?
>> 
>> This should be six records: the blank node that " is defined
>> by" ?thing_doc, its type, its term, a blank node that is its gAlt, and
>> the gAlt's type and gSyn.
> 
> Did you run the query?
> 
> I get two rows.
> 
> So 18 triples inserted, not 9.
> 
> Every triple in the template has a blank node. New and different blank nodes 
> are created on each template instantiation.
> 
> c.f. CONSTRUCT.
> 
>>> 
>>> If it has multiple matches (and it looks to me as if it will, so
>>> multiple rows with ?thing_doc, same value each time), then the INSERT in
>>> update 2 is going to put in different blank nodes, for each time the
>>> template is instantiated. If there are >= 2 rods from the WHERE, that's
>>> multiple, different blank nodes.
>> 
>> I assumed the DELETE and INSERT were separate operations, and that the
>> INSERT operated on the dataset after the DELETE had been performed. But
>> if INSERT is calculated concurrently with DELETE, then the observed
>> results might make more sense. I will study this further. It is
>> obviously behaving differently with a combined DELETE/INSERT than with a
>> discrete DELETE followed by an INSERT (in separate updates).
>> 
>> I guess that's the crux of my question: should a DELETE/INSERT update
>> operation yield the same results as a DELETE update followed by an
>> INSERT update, if the DELETE, INSERT, and WHERE clauses are the same?
>> 
>>> 
>>>    Andy
>>> 
>>> PS Did you mean a doubly hested OPTIONAL?  The layout suggests not.
>> 
>> Yes, the intent is to make the same pattern work for datasets that do
>> not have any matching records yet in the dataset, as  well as those that
>> have been populated with the INSERT triples. The ex:gAlt property on
>> ex:Thing1 instances is optional. If the outer OPTIONAL were removed we
>> would need different patterns based on whether the dataset already held
>> the target triples.
>> 
>>> 
>>>> On 31/10/15 23:37, Paul Tyson wrote:
>>>> DELETE/INSERT operation does not work as expected using tdbupdate in
>>>> jena-3.0.0.
>>>> 
>>>> Starting with an empty TDB, I run the following two updates. The first
>>>> works as expected, adding 6 triples. The second should remove those
>>>> triples and add 9 new ones. Instead, the graph now has 20 triples. I did
>>>> not analyze them closely to see where they might be coming from.
>>>> 
>>>> If I run the DELETE clause of the 2nd update separately, it removes the
>>>> expected triples, and then the INSERT by itself will add the expected
>>>> triples.
>>>> 
>>>> ===== 1st DELETE/INSERT =====
>>>> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>> prefix ex: <http://example.org/ns/foo#>
>>>> DELETE {
>>>> ?thing_old rdfs:isDefinedBy ?thing_doc ;
>>>>    rdf:type ?old_type;
>>>>    ex:term ?old_term;
>>>>    ex:gAlt ?old_alt .
>>>> ?old_alt ?old_alt_p ?old_alt_o .
>>>> }
>>>> INSERT {
>>>> _:b1 a ex:Thing1 ;
>>>>   rdfs:isDefinedBy ?thing_doc;
>>>>   ex:term "ABCD";
>>>>   ex:gAlt [a ex:Thing2;ex:gSyn "Automatic Widget"];
>>>> .
>>>> }
>>>> WHERE {
>>>> VALUES (?thing_doc) {(<http://example.org/doc/20849DBD>)}
>>>> OPTIONAL {?thing_old rdfs:isDefinedBy ?thing_doc ;
>>>>    rdf:type ?old_type ;
>>>>    ex:term ?old_term .
>>>> OPTIONAL {?thing_old ex:gAlt ?old_alt.
>>>>    ?old_alt ?old_alt_p ?old_alt_o.}}
>>>> }
>>>> 
>>>> ===== 2nd DELETE/INSERT =====
>>>> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>> prefix ex: <http://example.org/ns/foo#>
>>>> DELETE {
>>>> ?thing_old rdfs:isDefinedBy ?thing_doc ;
>>>>    rdf:type ?old_type;
>>>>    ex:term ?old_term;
>>>>    ex:gAlt ?old_alt .
>>>> ?old_alt ?old_alt_p ?old_alt_o .
>>>> }
>>>> INSERT {
>>>> _:b1 a ex:Thing1 ;
>>>>   rdfs:isDefinedBy ?thing_doc;
>>>>   ex:term "ABCD";
>>>>   ex:gAlt [a ex:Thing2;ex:gSyn "Automatic Widget"];
>>>>   ex:gAlt [a ex:Thing2;ex:gSyn "Automated Widget"];
>>>> .
>>>> 
>>>> }
>>>> WHERE {
>>>> VALUES (?thing_doc) {(<http://example.org/doc/20849DBD>)}
>>>> OPTIONAL {?thing_old rdfs:isDefinedBy ?thing_doc ;
>>>>    rdf:type ?old_type ;
>>>>    ex:term ?old_term .
>>>> OPTIONAL {?thing_old ex:gAlt ?old_alt.
>>>>    ?old_alt ?old_alt_p ?old_alt_o.}}
>>>> }
> 

Reply via email to