[ 
https://issues.apache.org/jira/browse/JENA-1855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17055334#comment-17055334
 ] 

Claus Stadler edited comment on JENA-1855 at 3/9/20, 8:02 PM:
--------------------------------------------------------------

Yes, it is a consistency issue - but judging from the code it seems the goal is 
to completely remove null values in the graph position :)

I noted, that the issue with dataset.asDatasetGraph.size() is actually another 
issue:

{code}
#test.trig
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://www.example.org/alfa> {
 _:a foaf:name "Alfa" .
 _:a foaf:mbox <mailto:a...@work.example.org> .
 }
 {code}

{code}
#test.nq
_:a <http://xmlns.com/foaf/0.1/name> "Alfa" <http://www.example.org/alfa> .
_:a <http://xmlns.com/foaf/0.1/mbox> <mailto:a...@work.example.org> 
<http://www.example.org/alfa> .
{code}

{code:java}
RDFDataMgr.loadDataset("test.trig").asDatasetGraph().size();
RDFDataMgr.loadDataset("test.nq").asDatasetGraph().size();
{code}

Even though - or maybe because of - there is no default graph, in both cases I 
get a NPE in 
[QuadTableForm.listGraphNodes|https://github.com/apache/jena/blob/b18a09d7b954e3749480ff514d88c34528fd50f0/jena-arq/src/main/java/org/apache/jena/sparql/core/mem/QuadTableForm.java#L60]
 


was (Author: aklakan):
Yes, it is a consistency issue - but judging from the code it seems the goal is 
to completely remove null values in the graph position :)

I noted, that issue with dataset.asDatasetGraph.size() is actually another 
issue:

{code}
#test.trig
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://www.example.org/alfa> {
 _:a foaf:name "Alfa" .
 _:a foaf:mbox <mailto:a...@work.example.org> .
 }
 {code}

{code}
#test.nq
_:a <http://xmlns.com/foaf/0.1/name> "Alfa" <http://www.example.org/alfa> .
_:a <http://xmlns.com/foaf/0.1/mbox> <mailto:a...@work.example.org> 
<http://www.example.org/alfa> .
{code}

{code:java}
RDFDataMgr.loadDataset("test.trig").asDatasetGraph().size();
RDFDataMgr.loadDataset("test.nq").asDatasetGraph().size();
{code}

Even though - or maybe because of - there is no default graph, in both cases I 
get a NPE in 
[QuadTableForm.listGraphNodes|https://github.com/apache/jena/blob/b18a09d7b954e3749480ff514d88c34528fd50f0/jena-arq/src/main/java/org/apache/jena/sparql/core/mem/QuadTableForm.java#L60]
 

> TRIG parser yields NULL-graph for quads in default graph
> --------------------------------------------------------
>
>                 Key: JENA-1855
>                 URL: https://issues.apache.org/jira/browse/JENA-1855
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: RIOT
>    Affects Versions: Jena 3.14.0
>            Reporter: Claus Stadler
>            Priority: Major
>
> Hi Jena Team and Andy, thanks for all your great work on Jena and fixing all 
> my recent issues, but I found another one :)
> The Trig Parser yields quads with a null value in the graph component for 
> data in the default graph. It should be Quad.defaultGraphNodeGenerated.
> Test data:
> {code}
> # test.trig
> @base <http://www.example.org/base-> .
> @prefix : <http://www.example.org/prefx-> .
> <s> <p> <o> .
> :x :y :z .
> {code}
> {code:java}
> Iterator<Quad> it = 
> RDFDataMgr.createIteratorQuads(RDFDataMgr.open("test.trig"), Lang.TRIG, null);
> while(it.hasNext()) {
>       Quad q = it.next();
>       System.out.println(q.getGraph());
> }
> {code}
> {code}
> null
> null
> {code}
> This causes quite unexpected null pointer exceptions, such as in this simple 
> scenario:
> {code}                
> Dataset ds = RDFDataMgr.loadDataset("test.trig");
> System.out.println(ds.asDatasetGraph().size());
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to