org.deri.iris.rules.compiler
Class CompiledRule

java.lang.Object
  extended by org.deri.iris.rules.compiler.CompiledRule
All Implemented Interfaces:
ICompiledRule

public class CompiledRule
extends Object
implements ICompiledRule

A compiled rule.


Constructor Summary
CompiledRule(List<RuleElement> elements, IPredicate headPredicate, Configuration configuration)
          Constructor.
 
Method Summary
 IRelation evaluate()
          Evaluate the rule.
 IRelation evaluateIteratively(IFacts deltas)
          Evaluate the rule using deltas (see semi-naive evaluation) to more intelligently seek out tuples that have not already been computed.
 List<IVariable> getVariablesBindings()
          If this compiled rule represents a query, then return the variables bindings of the result relation.
 IPredicate headPredicate()
          If this compiled rule represents a rule, then return the head predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompiledRule

public CompiledRule(List<RuleElement> elements,
                    IPredicate headPredicate,
                    Configuration configuration)
Constructor.

Parameters:
elements - The rule elements produced by the rule compiler.
headPredicate - The head predicate of the original rule.
Method Detail

evaluate

public IRelation evaluate()
                   throws EvaluationException
Evaluate the rule. Each element is called in turn to produce tuples to pass on to the next rule element. If any rule element outputs an empty relation, then stop.

Specified by:
evaluate in interface ICompiledRule
Returns:
The result relation for this rule.
Throws:
EvaluationException

evaluateIteratively

public IRelation evaluateIteratively(IFacts deltas)
                              throws EvaluationException
Description copied from interface: ICompiledRule
Evaluate the rule using deltas (see semi-naive evaluation) to more intelligently seek out tuples that have not already been computed.

Specified by:
evaluateIteratively in interface ICompiledRule
Parameters:
deltas - The collection of recently discovered facts.
Returns:
The result relation for this rule.
Throws:
EvaluationException

headPredicate

public IPredicate headPredicate()
Description copied from interface: ICompiledRule
If this compiled rule represents a rule, then return the head predicate.

Specified by:
headPredicate in interface ICompiledRule
Returns:
The head predicate.

getVariablesBindings

public List<IVariable> getVariablesBindings()
Description copied from interface: ICompiledRule
If this compiled rule represents a query, then return the variables bindings of the result relation.

Specified by:
getVariablesBindings in interface ICompiledRule
Returns:
The list of variables in the order in which they are bound to terms of the result relation.