Menu

#16 Complete Virtuoso support

0.11
open
4
2011-01-19
2010-10-03
No

So far you can connect to a remote Virtuoso repository.

Clarify how to add Virtuoso repository in the "Add repository" tab.

Discussion

  • Anton Andreev

    Anton Andreev - 2010-10-15
    • priority: 5 --> 6
     
  • Anton Andreev

    Anton Andreev - 2010-12-17

    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");
    }
    }

     
  • Anton Andreev

    Anton Andreev - 2010-12-17

    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.

     
  • Anton Andreev

    Anton Andreev - 2010-12-18

    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.

     
  • Anton Andreev

    Anton Andreev - 2010-12-19

    Export is currently not fully working:

    VDS.RDF.NodeType.Literal is not supported in:
    dotSesame.Resource ToSesameResource(INode n, SesameMapping mapping) ?

     
  • Anton Andreev

    Anton Andreev - 2010-12-20

    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));
    }

     
  • Anton Andreev

    Anton Andreev - 2010-12-20

    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 .}";

     
  • Anton Andreev

    Anton Andreev - 2010-12-21

    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");
    }
    }

     
  • Anton Andreev

    Anton Andreev - 2010-12-21

    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);
    }

     
  • Anton Andreev

    Anton Andreev - 2010-12-22

    Method internal static IEnumerable<Uri> ToContexts(this dotSesame.Resource[] contexts)

    changed to:

    internal static IEnumerable<Uri> ToContexts(this dotSesame.Resource[] contexts, SesameMapping mapping)

     
  • Anton Andreev

    Anton Andreev - 2011-01-19
    • priority: 6 --> 4
     
  • Anton Andreev

    Anton Andreev - 2011-01-19

    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.

     
  • Anton Andreev

    Anton Andreev - 2011-02-23

    OpenLink will provide a new version of their connector virtado.dll that fixes some important problems.
    Remove our hack that deals with this problem.

     

Log in to post a comment.

MongoDB Logo MongoDB