On 02/08/13 13:48, Amin beyranvand wrote:
I know how to parse a query with jena and convert it to a query algebra. but i 
don't know how to get triple patterns from the algebra and how to get query 
operators from it for evaluation.
Example: i hava a query like this:
PREFIX info:        <http://somewhere/peopleInfo#> PREFIX vcard:      
<http://www.w3.org/2001/vcard-rdf/3.0#> SELECT ?name ?age
WHERE
{ ?person vcard:FN  ?name . OPTIONAL { ?person info:age ?age . } FILTER ( 
!bound(?age) || ?age > 24 )
}
i convert query to a algebra:
Query q=QueryFactory.create(queryStr);
Op op = Algebra.compile(q) ;
the result is this algebra:
(project (?name ?age) (filter (|| (! (bound ?age)) (> ?age 24)) (leftjoin (bgp (triple 
?person <http://www.w3.org/2001/vcard-rdf/3.0#FN> ?name)) (bgp (triple ?person 
<http://somewhere/peopleInfo#age> ?age)))))
now what i want is to get operators from this algebra in a iterative manner from bottom to 
top. for example : bgp 1 -> bgp 2-> leftjoin -> filter -> project
can you give me an example for doing this?


There is an online service at sparql.org that produces readable output.

If you want operators in that order, do a traversal that visits the

So for (project VARS OP)
visit OP then do the project.

There is code to do this:

OpWalker.walk(op, opVisitor)

which visits subnodes before calling the visitor on the node. That's going to cause the deepest items to be actioned first, which is what you describe.

(Still unclear why you want to do this when there is OpExecutor).

        Andy

Reply via email to