You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Miguel Bento Alves <mb...@gmail.com> on 2014/06/06 17:40:01 UTC

processing of jena rules

A doubt about processing  of jena rules:

new triples generated by rules are saved in the model? or processed in
runtime, when the rule is invoked?

for instance, 
I have the following triples:
eg:A eg:p eg:B .
    eg:B eg:p eg:C .
    eg:C eg:p eg:D .
    
and the rule: 
[rule1: (?a <eg:p> ?b) (?b <eg:p> ?c) -> (?a <eg:p> ?c)]

The following triples are saved in the model or are generated every time the
rule is invoked?
eg:B eg:p eg:D .
eg:A eg:p eg:D .
eg:A eg:p eg:C .

Miguel



Re: processing of jena rules

Posted by Dave Reynolds <da...@gmail.com>.
On 06/06/14 16:40, Miguel Bento Alves wrote:
> A doubt about processing  of jena rules:
>
> new triples generated by rules are saved in the model? or processed in
> runtime, when the rule is invoked?
>
> for instance,
> I have the following triples:
> eg:A eg:p eg:B .
>      eg:B eg:p eg:C .
>      eg:C eg:p eg:D .
>
> and the rule:
> [rule1: (?a <eg:p> ?b) (?b <eg:p> ?c) -> (?a <eg:p> ?c)]
>
> The following triples are saved in the model or are generated every time the
> rule is invoked?

For the forward engine (which that rule will use unless you override it) 
then the triples are generated in the separate deductionsModel and not 
regenerated at each query. In addition the partial matches for each 
pattern will be stored in the RETE network.

For the backward engine then it depends on tabling. With the backward 
engine you can set predicates to be tabled (essentially any goal with 
that predicate in will be cached). So if <eg:p> is tabled then results 
aren't added to the model but repeats of the same or related queries 
will reuse information from the tables. If it is not tabled then the 
information is recreated each time.

Dave