Re: Incrementing a literal

On 12 November 2012 00:11, Paul Gearon <gearon@ieee.org> wrote:

> While some may agree with this, a lot of people will disagree with such an
> operation. An "increment" operation implies that you're changing a value.
> While some people certainly see an RDF property in this way, it doesn't
> match the other concept of "triples", wherein a triple with one
> subject/property/value is removed, and another is inserted (where the
> subject and property are the same, and the value is one more than the value
> from the removed triple). The latter view matches SPARQL, so I doubt there
> will be much traction for an operation that supports the "change a value"
> perspective.


Much of the value of the sem web is that it is a powerful topology.  Indeed
the "principles of least power" purposefully did not build a programming
language into the web, and that is delegated elsewhere.

However when you move into the world of programming and change, and
consider the web as a giant data store, increment can be a useful
operation, imho.  Many programming language have increment built into the
syntax e.g. the ++ operator.

So in some case it would be nice to have both.  For my particular use case,
which involves aggregated distributed credits, SPARQL Update seems to be a
great candidate.


>
> Regards,
> Paul
>
>
> On Sun, Nov 11, 2012 at 1:11 PM, Stephen Williams <sdw@lig.net> wrote:
>
>>  On 11/11/12 9:06 AM, Andy Seaborne wrote:
>>
>>
>>
>> On 10/11/12 11:54, Melvin Carvalho wrote:
>>
>> Is there a pattern for incrementing a literal counter?
>>
>> Alice stores turtle in http://example.org/counter
>>
>> The initial operation should generate something like
>>
>> <#> <#counter> 1.
>>
>> Then the subsequent operation
>>
>> <#> <#counter> 2.
>>
>> And after that.
>>
>> <#> <#counter> 3.
>>
>> And so on ...
>>
>> Is there a neat way to do this in  distributed way?  SPARQL update?
>> Maybe using Etags?
>>
>>
>> SPARQL Update:
>>
>> DELETE { <#> <#counter> ?c1 }
>> INSERT { <#> <#counter> ?c2 }
>> WHERE  { <#> <#counter> ?c1 .
>>          BIND(?c1+1 AS ?c2) }
>>
>> There are various ways to deal with the initial condition at the same
>> time:
>>
>> All in one operation:
>>
>> DELETE { <#> <#counter> ?c1 }
>> INSERT { <#> <#counter> ?c2 }
>> WHERE  {
>>    OPTIONAL { <#> <#counter> ?c1 . }
>>    BIND(COALESCE(?c1+1, 1) AS ?c2) }
>>
>> where the assignment can also be written:
>>
>>    BIND(IF (BOUND(?c1) , ?c1+1 , 1) AS ?c2)
>>
>> You can also use two operations in one request: (requests should be
>> atomic i.e the two operations together):
>>
>> # Does a triple for the counter exist?
>> INSERT { <#> <#counter> 0 }
>> WHERE   { FILTER NOT EXISTS { <#> <#counter> ?c } }
>> ;
>>
>> # Increment always - hence initialize to zero above
>> DELETE { <#> <#counter> ?c1 }
>> INSERT { <#> <#counter> ?c2 }
>> WHERE  { <#> <#counter> ?c1 .
>>          BIND(?c1+1 AS ?c2) }
>>
>>     Andy
>>
>>
>> At some point, a better solution should exist, such as an increment
>> operation.  Integrated semantics on another axis.
>> For now, perhaps linking a semantic store with some values delegated to a
>> Redis database might solve performance, scalability, and similar problems.
>>
>> sdw
>>
>> --
>> Stephen D. Williams sdw@lig.net stephendwilliams@gmail.com LinkedIn: http://sdw.st/in
>> V:650-450-UNIX (8649) V:866.SDW.UNIX V:703.371.9362 F:703.995.0407AIM:sdw Skype:StephenDWilliams Yahoo:sdwlignet Resume: http://sdw.st/gres
>> Personal: http://sdw.st facebook.com/sdwlig twitter.com/scienteer
>>
>>
>

Received on Monday, 12 November 2012 08:40:38 UTC