Quad upload context ignored

0 views
Skip to first unread message

Rubén Navarro Piris

unread,
Dec 27, 2016, 10:41:36 AM12/27/16
to Stardog
Hi!

Using the Java API to upload quad data into Stardog 4.2.1 I found the following behaviour. After executing:

      aConn.begin();
      aConn.add().io()
           .context(
               SimpleValueFactory.getInstance().createIRI("urn:targetGraph"))
           .format(RDFFormat.TRIG)
           .stream(request.getInputStream());
      aConn.commit();


where the contents of the stream are:

{<urn:default> <urn:default> <urn:default> .}
GRAPH <urn:graph> {<urn:graph> <urn:graph> <urn:graph> .}

I noticed that the context URI is ignored, as shown by this queries (note: query.all.graphs = true):

# Query 1

SELECT * { ?s ?p ?o }

# - results

{
  "head": {
    "vars": [ "s" , "p" , "o" ]
  } ,
  "results": {
    "bindings": [
      {
        "s": { "type": "uri" , "value": "urn:default" } ,
        "p": { "type": "uri" , "value": "urn:default" } ,
        "o": { "type": "uri" , "value": "urn:default" }
      } ,
      {
        "s": { "type": "uri" , "value": "urn:graph" } ,
        "p": { "type": "uri" , "value": "urn:graph" } ,
        "o": { "type": "uri" , "value": "urn:graph" }
      }
    ]
  }
}

###

# Query 2
SELECT * { GRAPH ?g {?s ?p ?o} }

# - results
{
  "head": {
    "vars": [ "s" , "p" , "o" , "g" ]
  } ,
  "results": {
    "bindings": [
      {
        "s": { "type": "uri" , "value": "urn:graph" } ,
        "p": { "type": "uri" , "value": "urn:graph" } ,
        "o": { "type": "uri" , "value": "urn:graph" } ,
        "g": { "type": "uri" , "value": "urn:graph" }
      }
    ]
  }
}

### 

# Query 3
SELECT DISTINCT ?g { graph ?g { ?s ?p ?o }}

# - results
{
  "head": {
    "vars": [ "g" ]
  } ,
  "results": {
    "bindings": [
      {
        "g": { "type": "uri" , "value": "urn:graph" }
      }
    ]
  }
}

This shows, that the triples in the input trig dataset where stored in the default graph and 'urn:graph' and no information landed in 'urn:targetGraph'.

My question is, given 'urn:targetGraph' as request context, shouldn't the resulting dataset rather look like this?:

GRAPH <urn:targetGraph> {<urn:default> <urn:default> <urn:default> .}
GRAPH <urn:graph> {<urn:graph> <urn:graph> <urn:graph> .}

Thanks in advance!

Best regards,

Ruben


Stephen Nowell

unread,
Dec 27, 2016, 1:45:34 PM12/27/16
to sta...@clarkparsia.com
Hi Rubén,

The behavior you're seeing is actually the intended behavior. According to the IO javadocs [1], when an RDF format that can specify context is used, the value passed to context() will be ignored in favor of the contexts specified by the RDF. This includes your first line which has the implied context of the default graph and is therefore where it is put.

Cheers,
Stephen

[1] http://docs.stardog.com/java/snarl/com/complexible/stardog/api/IO.html#context-org.openrdf.model.Resource-
--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Reply all
Reply to author
Forward
0 new messages