Exemplo n.º 1
0
        private void InsertGraph(AllegroGraphConnector connector, IGraph g)
        {
            var length = 10000;

            if (g.Triples.Count > length)
            {
                var newGraph = new Graph
                {
                    BaseUri = g.BaseUri
                };
                connector.SaveGraph(newGraph);
                var section = new List <Triple>(length);
                foreach (var t in g.Triples)
                {
                    section.Add(t);
                    if (section.Count == length)
                    {
                        connector.UpdateGraph(g.BaseUri, section, null);
                        section = new List <Triple>(length);
                    }
                }
                if (section.Count > 0)
                {
                    connector.UpdateGraph(g.BaseUri, section, null);
                }
            }
            else
            {
                connector.SaveGraph(g);
            }
        }
Exemplo n.º 2
0
        public void SparqlViewNativeAllegroGraph()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();
            PersistentTripleStore store  = new PersistentTripleStore(agraph);

            //Load a Graph into the Store to ensure there is some data for the view to retrieve
            Graph g = new Graph();

            FileLoader.Load(g, "resources\\InferenceTest.ttl");
            agraph.SaveGraph(g);

            //Create the SPARQL View
            NativeSparqlView view = new NativeSparqlView("CONSTRUCT { ?s ?p ?o } WHERE { GRAPH ?g { ?s ?p ?o . FILTER(IsLiteral(?o)) } }", store);

            Console.WriteLine("SPARQL View Populated");
            TestTools.ShowGraph(view);
            Console.WriteLine();
        }