From: Rob V. <rv...@do...> - 2011-02-08 10:49:52
|
Hi Felipe It depends upon your query. If your query does not explicitly reference any Graphs then it operates only over the Graphs currently in memory. If the query references Graphs then it will load those as the query requests them. SPARQL provides two mechanisms to reference Graphs - FROM/FROM NAMED and GRAPH clauses. FROM and FROM NAMED clauses specify the Graphs that the query operates over. Graphs mentioned in a FROM clause will be loaded at the start of processing a Query since they are used to form the Default Graph which the Query operates over. Graphs mentioned in a FROM NAMED clause are loaded only if the Query contains a GRAPH clause which has a variable specifier and that variable is not already bound. You can also use the GRAPH clause with a URI to specify a fixed Graph to use. Example 1: SELECT * FROM <http://example.org/graph1> FROM NAMED <http://example.org/graph2> WHERE { ?s ?p ?o } In this example graph1 would be loaded from the Store but graph2 would not as there is no relevant GRAPH clause to cause it to be loaded Example 2: SELECT * FROM <http://example.org/graph1> FROM NAMED <http://example.org/graph2> WHERE { ?s <http://example.org/hasGraph> ?g . GRAPH ?g { ?x ?y ?z } } In this example graph1 would be loaded but again graph2 would not as although there is a GRAPH clause the Graph Specifier ?g is already bound at that point in the query. But in this query for every possible distinct value for ?g the Store will attempt to load that Graph from the Store in order to answer the Graph clause Example 3: SELECT * FROM <http://example.org/graph1> FROM NAMED <http://example.org/graph2> WHERE { GRAPH ?g { ?s ?p ?o } } In this example graph1 gets loaded but then graph2 also gets loaded in order to answer the GRAPH clause as ?g is unbound so it uses all the values specified in FROM NAMED clauses to create a Graph for the GRAPH clause. Example 4: SELECT * WHERE { GRAPH <http://example.org/graph1> { ?x ?y ?z } } In this example graph1 would be loaded as it explicitly needed to answer the Graph clause A few points to remember when using the OnDemandTripleStore: If your query references a Graph that does not exist the query will fail with an exceptionThe Store is a read-only view of your underlying store. Changing the Graphs of the OnDemandTripleStore instance does not change the underlying store.Once a Graph is loaded in memory it stays there until you dispose of the OnDemandTripleStore (or it goes out of scope and gets GC'd by .Net) - if the Graph changes in the underlying store the OnDemandTripleStore will not reflect this changeHope this helps, as always let me know if you need more help Regards, Rob Vesse ---------------------------------------- From: "Felipe Guimarães Santos" <fel...@in...> Sent: 07 February 2011 22:17 To: "dot...@li..." <dot...@li...> Subject: [Dotnetrdf-support] OnDemandTripleStore If I use OnDemandTripleStore the SPARQL query will load the graphs on demand, or it will do the Query only with the loaded Graphs? Thanks Felipe Guimarães Santos | desenvolvedor fel...@in... | www.invit.com.br | @sigainvit Office: +55 34 3223.4000 - 11 5506.8280 | Mobile: +55 34 9993.5060 Confidencialidade: A informação contida nesta mensagem de e-mail, incluindo quaisquer anexos, é confidencial e está reservada apenas à pessoa ou entidade para a qual foi endereçada. Se você não é o destinatário ou a pessoa responsável por encaminhar esta mensagem ao destinatário, você está, por meio desta, notificado que não deverá rever, retransmitir, imprimir, copiar, usar ou distribuir esta mensagem de e-mail ou quaisquer anexos. Caso você tenha recebido esta mensagem por engano, por favor, contate o remetente imediatamente e apague esta mensagem de seu computador ou de qualquer outro banco de dados. Muito obrigado. Confidentiality Notice: The information contained in this email message, including any attachment, is confidential and is intended only for the person or entity to which it is addressed. If you are neither the intended recipient nor the employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you may not review, retransmit, convert to hard copy, copy, use or distribute this email message or any attachments to it. If you have received this email in error, please contact the sender immediately and delete this message from any computer or other data bank. Thank you. |