Hi Diogo If you want to manipulate the query at the query level rather than the algebra level then you likely want to use a combination of QueryVisitor and ElementVisitor rather than an algebra optimizer. This way you can do your manipulations before the query gets executed I.e. after you have created it from QueryFactory.create()
Other comments inline: On 3/20/13 6:45 PM, "Diogo FC Patrao" <[email protected]> wrote: >Hello > >I'm working on a sparql query "expander", that is, it add triples and >filters to a query in order to emulate some inference (say you have A -> B >AND C, and a query SELECT * { ?s rdfs:type A }, it would return SELECT * { >?s rdfs:type B. ?s rdfs:type C}). > >I'm manipulating sparql queries on the algebra level (using Transformer), >and then I'm returning it as a query, using OpAsQuery. However, not all >algebras can be translated back, specifically, those using SERVICE. This is likely something that can be done, contributions are always welcome > >I found this link [1] and decided to execute the algebra directly. >However, >the example code in the link has two issues (for what I want): > >a) it returns a QueryIterator, not a Resultset. You can use ResultSetStream to wrap a QueryIterator as a ResultSet where necessary > >b) it`s not clear how I specify a remote sparql endpoint. A remote SPARQL endpoint for what? > >c) I feel like I would have to rewrite (or clone) some code > >So I thought that maybe the best thing for me would be to run my >transformation in the middle of the query execution pipeline. > >Is there a way to accomplish that? If not, what you feel as the best way >out (including implementing all stuff missing on OpAsQuery)? Implementing missing functionality is always welcome, if you have the cycles to do that we would love to receive the contribution. If not investigating the QueryVisitor + ElementVisitor based approach is likely your best option Rob > >Thanks in advance! > > > >[1]: >http://mail-archives.apache.org/mod_mbox/jena-users/201210.mbox/%3C508B0C5 >[email protected]%3E > >-- >diogo patrĂ£o
