org.deri.iris.optimisations.rulefilter
Class RuleFilter

java.lang.Object
  extended by org.deri.iris.optimisations.rulefilter.RuleFilter
All Implemented Interfaces:
IProgramOptimisation

public class RuleFilter
extends Object
implements IProgramOptimisation

Methods to shrink rules to the absolute minimum of needed rules.

Author:
Richard P??ttler (richard dot poettler at deri dot at)

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.deri.iris.api.IProgramOptimisation
IProgramOptimisation.Result
 
Constructor Summary
RuleFilter()
           
 
Method Summary
static Set<IPredicate> getDepends(Collection<IRule> r, IQuery q)
          Determines which predicates must be evaluated to evaluate a given query.
static Set<IRule> getRulesForPredicates(Collection<IRule> r, Collection<IPredicate> p)
          Filters a set of rules so that it only contains rules defining a predicate out of a set of predicates.
 IProgramOptimisation.Result optimise(Collection<IRule> rules, IQuery query)
          Applies the optimisation algorithm to a set of rules.
static Set<IRule> shrinkRules(Collection<IRule> r, IQuery q)
          Shrinks a set of rules to the absolute minimum of needed rules to evaluate a given query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleFilter

public RuleFilter()
Method Detail

optimise

public IProgramOptimisation.Result optimise(Collection<IRule> rules,
                                            IQuery query)
Description copied from interface: IProgramOptimisation
Applies the optimisation algorithm to a set of rules. A Result which contains the transformed rules and the adjusted query.

Specified by:
optimise in interface IProgramOptimisation
Parameters:
rules - the rules to transform
query - the query for which to transform the rules
Returns:
a optimisation result or null, if the transformation failed.

shrinkRules

public static Set<IRule> shrinkRules(Collection<IRule> r,
                                     IQuery q)
Shrinks a set of rules to the absolute minimum of needed rules to evaluate a given query.

Parameters:
r - the rules to shrink
q - the query for which to shrink the rules
Returns:
the minimal set of needed rules
Throws:
NullPointerException - if the set of rules is null
NullPointerException - if the query is null

getRulesForPredicates

public static Set<IRule> getRulesForPredicates(Collection<IRule> r,
                                               Collection<IPredicate> p)
Filters a set of rules so that it only contains rules defining a predicate out of a set of predicates.

Parameters:
r - the rules to filter
p - the predicate for which to filter the rules
Returns:
the filtered rules
Throws:
NullPointerException - if the rules are null
NullPointerException - if the predicates are null

getDepends

public static Set<IPredicate> getDepends(Collection<IRule> r,
                                         IQuery q)
Determines which predicates must be evaluated to evaluate a given query.

Parameters:
r - the rules on which to determine on which predicate the query depends
q - the query for which to check the predicates
Returns:
the predicates the query depends on
Throws:
NullPointerException - if the set of rules is null
NullPointerException - if the query is null