Re: What's the diference between...

On Thu, Jul 23, 2009 at 1:24 PM, Samuel Pedro<> wrote:
> What's the diference between
> ?label FILTER (?label = "Tomato")
> and this
> ?class rdfs:label “Value"^^xsd:string
> Why use "Value"^^xsd:string and not just give the value direct to "?class" ?

I presume that you mean to compare:

  ?class rdfs:label “Tomato"^^xsd:string


  ?class rdfs:label ?label FILTER (?label = “Tomato")


There are a few differences. First, the filtered form introduces a new
variable that doesn't exist in the other form. It would usually be
bound to only one value, though it could also be unbound if the
expression appears inside an OPTIONAL.

Second, most stores will resolve the unfiltered form by doing an index
lookup for triples with the given predicate-object, with the result of
the lookup being the answer. By contrast, the filtered form will look
up an index for the given predicate, and will then iterate over the
results, skipping those triples that don't have an object equal to the
given string. For most stores this will be far less efficient.

Finally, several stores provide an extension to the = operator,
allowing it to return "true" for the same string that is either an
untyped literal or an xsd:string. Not every store does this however,
and then some stores can even differ depending on the type of graph
(for instance, IIRC Jena has this extension if the graph is in memory,
but not if it is on disk).

Paul Gearon

Received on Thursday, 23 July 2009 21:27:45 UTC