RDF-syntax-check GH action

2023-02-28 Thread Martynas Jusevičius
Hi,

I made a riot-based RDF syntax checking GH action:
https://github.com/AtomGraph/RDF-syntax-check

Maybe it can be of use :)


Martynas


Re: sparql query performance jena v2, 3, 4

2023-02-28 Thread Andy Seaborne




On 28/02/2023 03:11, Paul Tyson wrote:
I maintain an old jena/fuseki application that has happily been using 
jena v2.13 and tdb v1.1.2 for several years. It loads 1b+ triples into a 
tdb database, and runs a couple dozen queries, some not so trivial, on 
the tdb.


Now it is time to update things. I first went to 3.17, to stay on java8. 
Many of the queries work fine, but a few have abysmal performance. A 
query that took maybe 10 minutes with v2.13 now runs for hours without 
finishing.


I am now trying v4.7 with java11. Testing is still in progress, but it 
doesn't look promising.


The troublesome queries have several FILTER EXISTS and FILTER NOT EXISTS 
clauses, some of which have UNION patterns. It is rather complicated, 
but also a fairly literal translation of the applicable business rules. 
I took a closer look at them, and adjusted the order of patterns to put 
the more-specific ones earlier, but that didn't help. I discovered that 
eliminating the UNION alternatives would let the query return some 
results, but obviously not what is wanted.


Did anything in particular change in the query processing since v2 that 
would cause this performance degradation?


v2.13 was March 2015. A lot has changed since then including fixes where 
optimization would get the wrong answers. Some are directly EXISTS, some 
aren't but if you have complex EXISTS patterns, they can be impacted. 
They aren't pattern orders.


(Mostly they will be in JIRA)

Should I expect any difference in tdb vs tdb2? I've tried both, and 
neither give satisfaction.


Unlikely. TDB2 is preferred.



Thanks in advance,
--Paul




Re: [SHACL] sh:prefixes

2023-02-28 Thread Holger Knublauch
I know, almost everybody stumbles there. It was bad editing by the editor :)

Unfortunately I cannot just go into that document and fix it. That's the bane 
of these formal specs, and why many people get work done quicker outside of 
such formal processes.

Holger


> On 28 Feb 2023, at 1:24 pm, Martynas Jusevičius  
> wrote:
> 
> Thanks Holger, that is the case :) The "sh:prefixes ex:" in the SHACL spec 
> was somewhat confusing without context, because it looks like a Turtle prefix 
> declaration.
> 
> This works:
> 
> :prefixes sh:declare [
> sh:prefix "skos" ;
> sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ;
> ] .
> 
> <#ConceptBroaderCycleShape> sh:prefixes :prefixes ;
> 
> 
> On Tue, Feb 28, 2023 at 2:16 PM Holger Knublauch  > wrote:
>> I suspect this is another instance of the common misunderstanding: the 
>> @prefix declarations are not mapped to any triples and are only a concept of 
>> the serialization. To make them visible to SHACL, you need to declare 
>> triples such as in
>> 
>> Shapes Constraint Language (SHACL)
>> w3.org
>> 
>>  Shapes Constraint Language 
>> (SHACL) 
>> w3.org  
>> 
>> in your case it would be skos: as subject.
>> 
>> Holger
>> 
>> 
>>> On 28 Feb 2023, at 12:56 pm, Martynas Jusevičius >> > wrote:
>>> 
>>> Hi,
>>> 
>>> Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?
>>> 
>>> The following test shape
>>> 
>>> @prefix skos:    .
>>> @prefix sh:  .
>>> 
>>> <#ConceptBroaderCycleShape>
>>>a sh:NodeShape ;
>>>sh:targetClass skos:Concept ;
>>>sh:sparql [
>>>a sh:SPARQLConstraint ;
>>>sh:message "Concept is broader than itself (directly or indirectly)" 
>>> ;
>>>sh:prefixes skos: ;
>>>sh:select """
>>>SELECT *
>>>{
>>>$this skos:broader+ $this .
>>>}
>>>""" ;
>>>] .
>>> 
>>> returns an error:
>>> 
>>> org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
>>> column 23: Unresolved prefixed name: skos:broader
>>> at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
>>> at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
>>> at 
>>> org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
>>> at 
>>> org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
>>> at 
>>> org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
>>> at 
>>> org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
>>> at 
>>> org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
>>> at 
>>> org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
>>> at 
>>> org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
>>> at 
>>> org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
>>> at 
>>> org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
>>> at 
>>> org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
>>> at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
>>> at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
>>> at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
>>> at 
>>> org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
>>> at 
>>> org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
>>> at shacl.shacl_validate.exec(shacl_validate.java:124)
>>> at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
>>> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
>>> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
>>> at shacl.shacl_validate.main(shacl_validate.java:60)
>>> at shacl.shacl.main(shacl.java:81)
>>> 
>>> 
>>> Martynas
>> 



Re: [SHACL] sh:prefixes

2023-02-28 Thread Martynas Jusevičius
Thanks Holger, that is the case :) The "sh:prefixes ex:" in the SHACL spec
was somewhat confusing without context, because it looks like a Turtle
prefix declaration.

This works:

:prefixes sh:declare [
sh:prefix "skos" ;
sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ;
] .

<#ConceptBroaderCycleShape> sh:prefixes :prefixes ;


On Tue, Feb 28, 2023 at 2:16 PM Holger Knublauch 
wrote:

> I suspect this is another instance of the common misunderstanding: the
> @prefix declarations are not mapped to any triples and are only a concept
> of the serialization. To make them visible to SHACL, you need to declare
> triples such as in
>
> Shapes Constraint Language (SHACL)
> 
> w3.org 
> [image: favicon.ico] 
> 
>
> in your case it would be skos: as subject.
>
> Holger
>
>
> On 28 Feb 2023, at 12:56 pm, Martynas Jusevičius 
> wrote:
>
> Hi,
>
> Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?
>
> The following test shape
>
> @prefix skos:    .
> @prefix sh:  .
>
> <#ConceptBroaderCycleShape>
>a sh:NodeShape ;
>sh:targetClass skos:Concept ;
>sh:sparql [
>a sh:SPARQLConstraint ;
>sh:message "Concept is broader than itself (directly or
> indirectly)" ;
>sh:prefixes skos: ;
>sh:select """
>SELECT *
>{
>$this skos:broader+ $this .
>}
>""" ;
>] .
>
> returns an error:
>
> org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
> column 23: Unresolved prefixed name: skos:broader
> at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
> at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
> at
> org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
> at
> org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
> at
> org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
> at
> org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
> at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
> at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
> at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
> at
> org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
> at
> org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
> at shacl.shacl_validate.exec(shacl_validate.java:124)
> at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
> at shacl.shacl_validate.main(shacl_validate.java:60)
> at shacl.shacl.main(shacl.java:81)
>
>
> Martynas
>
>
>


Re: [SHACL] sh:prefixes

2023-02-28 Thread Holger Knublauch
I suspect this is another instance of the common misunderstanding: the @prefix 
declarations are not mapped to any triples and are only a concept of the 
serialization. To make them visible to SHACL, you need to declare triples such 
as in

https://www.w3.org/TR/shacl/#sparql-prefixes
in your case it would be skos: as subject.

Holger


> On 28 Feb 2023, at 12:56 pm, Martynas Jusevičius  
> wrote:
> 
> Hi,
> 
> Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?
> 
> The following test shape
> 
> @prefix skos:    .
> @prefix sh:  .
> 
> <#ConceptBroaderCycleShape>
>a sh:NodeShape ;
>sh:targetClass skos:Concept ;
>sh:sparql [
>a sh:SPARQLConstraint ;
>sh:message "Concept is broader than itself (directly or indirectly)" ;
>sh:prefixes skos: ;
>sh:select """
>SELECT *
>{
>$this skos:broader+ $this .
>}
>""" ;
>] .
> 
> returns an error:
> 
> org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
> column 23: Unresolved prefixed name: skos:broader
> at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
> at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
> at 
> org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
> at 
> org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
> at 
> org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
> at 
> org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
> at 
> org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
> at 
> org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
> at org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
> at 
> org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
> at 
> org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
> at 
> org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
> at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
> at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
> at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
> at 
> org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
> at 
> org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
> at shacl.shacl_validate.exec(shacl_validate.java:124)
> at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
> at shacl.shacl_validate.main(shacl_validate.java:60)
> at shacl.shacl.main(shacl.java:81)
> 
> 
> Martynas



Re: [SHACL] sh:prefixes

2023-02-28 Thread Andy Seaborne

Is there something in the WG test suite for this?

Andy

On 28/02/2023 12:56, Martynas Jusevičius wrote:

Hi,

Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?

The following test shape

@prefix skos:    .
@prefix sh:  .

<#ConceptBroaderCycleShape>
 a sh:NodeShape ;
 sh:targetClass skos:Concept ;
 sh:sparql [
 a sh:SPARQLConstraint ;
 sh:message "Concept is broader than itself (directly or indirectly)" ;
 sh:prefixes skos: ;
 sh:select """
 SELECT *
 {
 $this skos:broader+ $this .
 }
 """ ;
 ] .

returns an error:

org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
column 23: Unresolved prefixed name: skos:broader
at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
at 
org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
at 
org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
at 
org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
at 
org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
at org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
at 
org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
at org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
at 
org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
at org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
at org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
at 
org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
at 
org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
at shacl.shacl_validate.exec(shacl_validate.java:124)
at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
at shacl.shacl_validate.main(shacl_validate.java:60)
at shacl.shacl.main(shacl.java:81)


Martynas


[SHACL] sh:prefixes

2023-02-28 Thread Martynas Jusevičius
Hi,

Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?

The following test shape

@prefix skos:    .
@prefix sh:  .

<#ConceptBroaderCycleShape>
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:message "Concept is broader than itself (directly or indirectly)" ;
sh:prefixes skos: ;
sh:select """
SELECT *
{
$this skos:broader+ $this .
}
""" ;
] .

returns an error:

org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
column 23: Unresolved prefixed name: skos:broader
at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
at 
org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
at 
org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
at 
org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
at 
org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
at org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
at 
org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
at org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
at 
org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
at org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
at org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
at 
org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
at 
org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
at shacl.shacl_validate.exec(shacl_validate.java:124)
at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
at shacl.shacl_validate.main(shacl_validate.java:60)
at shacl.shacl.main(shacl.java:81)


Martynas