ERRS_0 37000 SP031 SPARQL compiler: No INTO GRAPH IDENTIFIED BY clause and the IRI in preamble refers to default graph group, not a single default graph
Method from dotNetRDF.Interop.Sesame org.openrdf.repository.RepositoryResult GetStatementsInternal(string sparqlQuery, SesameMapping mapping) is putting literals as subjects which seems not to be supported in Sesame.
The problem to me is that things that are not literals are marked as literals in VDS.RDF.Storage.VirtuosoManager.Query(String sparqlQuery)
I am using the data which is by default found in a Virtuoso repository and I see non-literals coming as such.
I did a rewrite of: org.openrdf.repository.RepositoryResult GetStatementsInternal(string sparqlQuery, SesameMapping mapping) and in the end it turned out that there were no results at all to return by this method.
Object results = ((IQueryableGenericIOManager)this._manager).Query(sparqlQuery);
if (results is SparqlResultSet)
{
//IEnumerable<dotSesame.Statement>
// stmts = from result in (SparqlResultSet)results
// select this._factory.createStatement
// (
// SesameConverter.ToSesameResource(result["subj"], mapping),
// SesameConverter.ToSesameUri(result["pred"], mapping),
// SesameConverter.ToSesameValue(result["obj"], mapping)
// );
List<dotSesame.Statement> stmts = new List<dotSesame.Statement>();
foreach(SparqlResult result in (SparqlResultSet)results)
{
if (result["subj"].NodeType == NodeType.Literal || result["pred"].NodeType==NodeType.Literal)
continue;
Null reference exception when context is supplied. mapping is null.
internal static INode FromSesameResource(dotSesame.Resource resource, SesameMapping mapping)
{
if (resource is dotSesame.URI)
{
Uri u = new Uri(((dotSesame.URI)resource).stringValue());
return mapping.Graph.CreateUriNode(u);
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Virtuoso support is implemented through patched version of dotNetRDF. Still there are some problems to be solved. OpenLink assistance is needed for thier .NET Virtuoso database provider which returns wrong datatypes in my opinion.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I get this error:
ERRS_0 37000 SP031 SPARQL compiler: No INTO GRAPH IDENTIFIED BY clause and the IRI in preamble refers to default graph group, not a single default graph
I used this thread:
http://boards.openlinksw.com/phpBB3/viewtopic.php?f=12&t=215
which pointed out that a default graph is needed.
I had to change the code in dotnetrdf in order to add "insert += " INTO <" + "test" + ">";".
VDS.RDF.Storage.VirtuosoManager.UpdateGraph(Uri graphUri, IEnumerable<Triple> additions, IEnumerable<Triple> removals)
//Build the Insert Data Command
if (additions != null)
{
if (additions.Any())
{
VirtuosoCommand insertCmd = new VirtuosoCommand();
Graph insertGraph = new Graph();
insertGraph.Assert(additions);
String insertData = VDS.RDF.Writing.StringWriter.Write(insertGraph, new NTriplesWriter());
String insert = "SPARQL define output:format '_JAVA_' INSERT DATA";
//if (graphUri != null)
//{
// insert += " INTO <" + graphUri.ToString() + ">";
//}
insert += " INTO <" + "test" + ">";
insert += "{ " + insertData + " }";
insertCmd.CommandText = insert;
insertCmd.Connection = this._db;
insertCmd.Transaction = this._dbtrans;
r = insertCmd.ExecuteNonQuery();
if (r < 0) throw new RdfStorageException("Virtuoso encountered an error when inserting Triples");
}
}
There is also a "time out" exception when the loading process takes more than 10-15 minutes. Sometimes it does not occur.
The source of this timeout is currently unknown and should be investigated.
No server check is made when connecting.
This gives the illusion that every thing is OK, until a query fail.
The Initialize method should also check the server availability.
Export is currently not fully working:
VDS.RDF.NodeType.Literal is not supported in:
dotSesame.Resource ToSesameResource(INode n, SesameMapping mapping) ?
Method from dotNetRDF.Interop.Sesame org.openrdf.repository.RepositoryResult GetStatementsInternal(string sparqlQuery, SesameMapping mapping) is putting literals as subjects which seems not to be supported in Sesame.
The problem to me is that things that are not literals are marked as literals in VDS.RDF.Storage.VirtuosoManager.Query(String sparqlQuery)
I am using the data which is by default found in a Virtuoso repository and I see non-literals coming as such.
I did a rewrite of: org.openrdf.repository.RepositoryResult GetStatementsInternal(string sparqlQuery, SesameMapping mapping) and in the end it turned out that there were no results at all to return by this method.
Object results = ((IQueryableGenericIOManager)this._manager).Query(sparqlQuery);
if (results is SparqlResultSet)
{
//IEnumerable<dotSesame.Statement>
// stmts = from result in (SparqlResultSet)results
// select this._factory.createStatement
// (
// SesameConverter.ToSesameResource(result["subj"], mapping),
// SesameConverter.ToSesameUri(result["pred"], mapping),
// SesameConverter.ToSesameValue(result["obj"], mapping)
// );
List<dotSesame.Statement> stmts = new List<dotSesame.Statement>();
foreach(SparqlResult result in (SparqlResultSet)results)
{
if (result["subj"].NodeType == NodeType.Literal || result["pred"].NodeType==NodeType.Literal)
continue;
dotSesame.Resource r=SesameConverter.ToSesameResource(result["subj"], mapping);
dotSesame.URI u=SesameConverter.ToSesameUri(result["pred"], mapping);
dotSesame.Value v=SesameConverter.ToSesameValue(result["obj"], mapping);
dotSesame.Statement s=this._factory.createStatement(r,u,v);
stmts.Add(s);
}
return new dotSesameRepo.RepositoryResult(new DotNetAdunaIterationWrapper(stmts));
}
Sesame bridge should use SPARQL 1.0 query when retrieving all statements for the export.
queryString.QueryText = "SELECT ?subj ?pred ?obj WHERE { ?subj
?pred ?obj .}";
Patched to make it work with Virtuoso. Not a real fix, but will do the work for now.
internal static dotSesame.Resource ToSesameResource(INode n, SesameMapping mapping)
{
#region patch
if (n.NodeType==NodeType.Literal && n.ToString().StartsWith("http://"))
{
Uri uri=new Uri(n.ToString());
n = n.Graph.CreateUriNode(uri);
}
if (n.ToString().ToLower() == "test")
{
Uri uri = new Uri("http://test.com");
n = n.Graph.CreateUriNode(uri);
}
#endregion
switch (n.NodeType)
{
case NodeType.Uri:
return mapping.ValueFactory.createURI(((UriNode)n).Uri.ToString());
case NodeType.Blank:
if (mapping.OutputMapping.ContainsKey(n))
{
return mapping.OutputMapping[n];
}
else
{
dotSesame.BNode bnode = mapping.ValueFactory.createBNode();
lock (mapping)
{
if (!mapping.OutputMapping.ContainsKey(n))
{
mapping.OutputMapping.Add(n, bnode);
}
else
{
bnode = mapping.OutputMapping[n];
}
if (!mapping.InputMapping.ContainsKey(bnode)) mapping.InputMapping.Add(bnode, n);
}
return bnode;
}
default:
throw new RdfException("Only URI and Blank Node subjects are not supported in Sesame");
}
}
Null reference exception when context is supplied. mapping is null.
internal static INode FromSesameResource(dotSesame.Resource resource, SesameMapping mapping)
{
if (resource is dotSesame.URI)
{
Uri u = new Uri(((dotSesame.URI)resource).stringValue());
return mapping.Graph.CreateUriNode(u);
}
Method internal static IEnumerable<Uri> ToContexts(this dotSesame.Resource[] contexts)
changed to:
internal static IEnumerable<Uri> ToContexts(this dotSesame.Resource[] contexts, SesameMapping mapping)
Virtuoso support is implemented through patched version of dotNetRDF. Still there are some problems to be solved. OpenLink assistance is needed for thier .NET Virtuoso database provider which returns wrong datatypes in my opinion.
OpenLink will provide a new version of their connector virtado.dll that fixes some important problems.
Remove our hack that deals with this problem.