On 19/03/14 16:46, Christophe FAGOT wrote:
Hi Jena folks,

since I need to use Jena with its RETEEngine, I’m actually investigating what 
is actually feasible / usable with this engine functionalities.

I would like to develop my own BuiltIn, used in the head of a forward rule, and 
doing some actions when a new rule context appears (due to triples adding) for 
the body rule, while doing some other actions when a rule context disappears 
(dur to triples removal) for this body rule.

It appears in the RETEConflictSet (line 180) that a BuiltIn can receive only … 
added RETERuleContext. Hence a BuiltIn action can only be called when a 
RETERuleContext is added, never when a RETERuleContext is removed.

Is their a reason for that ?

The existing head builtins expect to only be fired when a potitive deduction is made. This is a legacy of the fact that the rule system was designed for monotonic inference and all the remove/non-monotonic processing is a hack. It was added due to requests on the user's list but was a mistake.

Note also that since there's no reference counting in the rule system it's notion of removal is not reliable.

Would it be possible to add in the context whether it’s a context added or 
removed, and to call the BuiltIn head action in both cases ?

No because that would change behaviour for existing rules sets, especially any with custom builtins.

I guess you could have a custom sort of builtin which does support firing a head-action on a remove and modify RETEConflictSet to check for such builtins and allow those (and only those) to fire - passing the isAdd flag as part of the call.

Dave

Reply via email to