You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Andy Seaborne <an...@apache.org> on 2015/12/10 12:21:39 UTC

Re: [] Release Jena 3.0.1 and Fuseki 2.3.1

What happens if you put the text:query should be inside the GRAPH?

	Andy

On 10/12/15 10:57, Osma Suominen wrote:
> On 10/12/15 11:57, Osma Suominen wrote:
>
>> I'll try to investigate further and isolate a more minimal example. I
>> just wanted to raise this ASAP.
>
> The query execution order seems to have changed for this kind of query:
>
> PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
> PREFIX text: <http://jena.apache.org/text#>
>
> SELECT *
> WHERE {
>    (?s ?score ?literal) text:query 'musiikkikasv*' .
>    GRAPH <http://www.yso.fi/onto/yso/> {
>      OPTIONAL {
>        ?s skos:prefLabel ?label .
>        FILTER (lang(?label) = lang(?literal))
>      }
>    }
> }
>
>
> (The YSO data that I have in the named graph is available at
> http://finto.fi/rest/v1/yso/data if you need it)
>
> With Fuseki 1.3.0, I get a single result row with ?label bound to
> "musiikkikasvatus"@fi and it takes about 40 ms.
>
> With Fuseki 1.3.1-SNAPSHOT I get a result with ?label unbound and it
> takes about 600 ms.
>
> My guess is that the new version is evaluating the GRAPH block first,
> when ?literal is still unbound. The old version performed the text:query
> part first, which is what I'd expect.
>
> -Osma
>
>


Re: [] Release Jena 3.0.1 and Fuseki 2.3.1

Posted by Andy Seaborne <an...@apache.org>.
On 10/12/15 11:21, Andy Seaborne wrote:
> What happens if you put the text:query should be inside the GRAPH?

s/should be //



>
>      Andy
>
> On 10/12/15 10:57, Osma Suominen wrote:
>> On 10/12/15 11:57, Osma Suominen wrote:
>>
>>> I'll try to investigate further and isolate a more minimal example. I
>>> just wanted to raise this ASAP.
>>
>> The query execution order seems to have changed for this kind of query:
>>
>> PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
>> PREFIX text: <http://jena.apache.org/text#>
>>
>> SELECT *
>> WHERE {
>>    (?s ?score ?literal) text:query 'musiikkikasv*' .
>>    GRAPH <http://www.yso.fi/onto/yso/> {
>>      OPTIONAL {
>>        ?s skos:prefLabel ?label .
>>        FILTER (lang(?label) = lang(?literal))
>>      }
>>    }
>> }
>>
>>
>> (The YSO data that I have in the named graph is available at
>> http://finto.fi/rest/v1/yso/data if you need it)
>>
>> With Fuseki 1.3.0, I get a single result row with ?label bound to
>> "musiikkikasvatus"@fi and it takes about 40 ms.
>>
>> With Fuseki 1.3.1-SNAPSHOT I get a result with ?label unbound and it
>> takes about 600 ms.
>>
>> My guess is that the new version is evaluating the GRAPH block first,
>> when ?literal is still unbound. The old version performed the text:query
>> part first, which is what I'd expect.
>>
>> -Osma
>>
>>
>


Re: [] Release Jena 3.0.1 and Fuseki 2.3.1

Posted by Andy Seaborne <an...@apache.org>.
On 10/12/15 11:25, Osma Suominen wrote:
> On 10/12/15 13:21, Andy Seaborne wrote:
>> What happens if you put the text:query should be inside the GRAPH?
>
> That sort of works for this case, i.e. the query becomes fast (~20ms)
> and I get a result with ?label bound, as with Fuseki 1.3.0.
>
> But in the original query I'm deliberately placing the text:query
> outside the GRAPH because I want to target all graphs, not just a
> specific one. (the jena-text index is graph-aware)
>
> -Osma
>

This is not related to the performance issue although work in that area 
seems to have fixed an unknown old bug.

Simpler query:

PREFIX  :     <http://example/>
PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT  *
WHERE
   { ?s  :p  ?literal
     GRAPH :g
       { ?s  rdfs:label  ?label
         FILTER ( ?label = ?literal )
       }
   }

Note also putting the text:query inside {} makes things worse.  It 
isolates that part

In this case the ?literal in the FILTER is out of scope of the basic 
graph pattern it is defined in.

Algebra:

(prefix ((: <http://example/>)
          (rdfs: <http://www.w3.org/2000/01/rdf-schema#>))
   (join
     (bgp (triple ?s :p ?literal))
     (graph :g
       (filter (= ?label ?literal)
         (bgp (triple ?s rdfs:label ?label))))))

In this simpler case there is even an optimizer step that spots that and 
replaces the inner {} by the empty table because the inner {} block 
always evaluates to empty.

(prefix ((: <http://example/>)
          (rdfs: <http://www.w3.org/2000/01/rdf-schema#>))
   (sequence
     (bgp (triple ?s :p ?literal))
     (table empty)))

It is the same effect as FILTER inside {}

SELECT  *
WHERE
   { ?s  :p  ?literal
     { FILTER ( ?literal = "WORD" ) }
   }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   (join
     (bgp (triple ?s :p ?literal))
     (filter (= ?literal "WORD")
       (table unit)))

	Andy


Re: [] Release Jena 3.0.1 and Fuseki 2.3.1

Posted by Osma Suominen <os...@helsinki.fi>.
On 10/12/15 13:21, Andy Seaborne wrote:
> What happens if you put the text:query should be inside the GRAPH?

That sort of works for this case, i.e. the query becomes fast (~20ms) 
and I get a result with ?label bound, as with Fuseki 1.3.0.

But in the original query I'm deliberately placing the text:query 
outside the GRAPH because I want to target all graphs, not just a 
specific one. (the jena-text index is graph-aware)

-Osma

-- 
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Kaikukatu 4)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suominen@helsinki.fi
http://www.nationallibrary.fi