com.bigdata.relation.rule
Interface IRule<E>

All Superinterfaces:
IStep, Serializable
All Known Implementing Classes:
AbstractRuleDistinctTermScan, AbstractRuleFastClosure_11_13, AbstractRuleFastClosure_3_5_6_7_9, AbstractRuleFastClosure_5_6_7_9, MatchRule, Rule, RuleFastClosure11, RuleFastClosure13, RuleFastClosure3, RuleFastClosure5, RuleFastClosure6, RuleFastClosure7, RuleFastClosure9, RuleOwlEquivalentClass, RuleOwlEquivalentProperty, RuleOwlHasValue, RuleOwlInverseOf1, RuleOwlInverseOf2, RuleOwlSameAs1, RuleOwlSameAs1b, RuleOwlSameAs2, RuleOwlSameAs3, RuleOwlTransitiveProperty1, RuleOwlTransitiveProperty2, RuleRdf01, RuleRdfs02, RuleRdfs03, RuleRdfs04a, RuleRdfs04b, RuleRdfs05, RuleRdfs06, RuleRdfs07, RuleRdfs08, RuleRdfs09, RuleRdfs10, RuleRdfs11, RuleRdfs12, RuleRdfs13

public interface IRule<E>
extends IStep

Conjunctive query of N IPredicates with optional IConstraints.

Version:
$Id: IRule.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Method Summary
 IBindingSet getConstants()
          Returns any variables that were bound to constants when an IRule was specialized.
 IConstraint getConstraint(int index)
          Return the constraint at the given index.
 int getConstraintCount()
          The #of constraints on the legal states for bindings of the variables declared by rule.
 Iterator<IConstraint> getConstraints()
          The optional constraints.
 IPredicate getHead()
          The head of the rule -or- null iff there is no head for this rule.
 String getName()
          The name of the rule.
 Set<IVariable> getSharedVars(int index1, int index2)
          Return the variables in common for two IPredicates.
 Iterator<IPredicate> getTail()
          Iterator visits the IPredicates in the body (ala tail) of the rule.
 IPredicate getTail(int index)
          Return the predicate at the given index from the tail of the rule.
 int getTailCount()
          The #of IPredicates in the body (aka tail) of the rule.
 IRuleTaskFactory getTaskFactory()
          An optional IRuleTaskFactory that will be used in place of the default IRuleTaskFactory to evaluate this rule (optional)
 int getVariableCount()
          The #of distinct variables declared by the rule.
 int getVariableCount(int index, IBindingSet bindingSet)
          The #of arguments in the selected predicate that are variables (vs constants) with the given the bindings.
 Iterator<IVariable> getVariables()
          The variables declared by the rule in no particular order.
 boolean isConsistent(IBindingSet bindingSet)
          Return true unless the IBindingSet violates a IConstraint declared for this Rule.
 boolean isDeclared(IVariable var)
          Return true iff the rule declares this variable.
 boolean isFullyBound(IBindingSet bindingSet)
          If the rule is fully bound for the given bindings.
 boolean isFullyBound(int index, IBindingSet bindingSet)
          Return true iff the selected predicate is fully bound.
 IRule<E> specialize(IBindingSet bindingSet, IConstraint[] constraints)
          Specialize a rule - the name of the new rule will be derived from the name of the old rule with an appended single quote to indicate that it is a derived variant.
 IRule<E> specialize(String name, IBindingSet bindingSet, IConstraint[] constraints)
          Specialize a rule by binding zero or more variables and adding zero or more constraints.
 String toString()
          Externalizes the rule displaying variable names and constants.
 String toString(IBindingSet bindingSet)
          Externalizes the rule displaying variable names, their bindings, and constants.
 
Methods inherited from interface com.bigdata.relation.rule.IStep
getQueryOptions, isRule
 

Method Detail

getVariableCount

int getVariableCount()
The #of distinct variables declared by the rule.


getVariables

Iterator<IVariable> getVariables()
The variables declared by the rule in no particular order.


getHead

IPredicate getHead()
The head of the rule -or- null iff there is no head for this rule. Note that rules that are executed as queries DO NOT need to specify a head. However, rules that will be executed as mutation operations (insert or delete) MUST specify the head as it determines the IRelation on which the rule will write.

See Also:
ActionEnum

getTailCount

int getTailCount()
The #of IPredicates in the body (aka tail) of the rule.


getTail

Iterator<IPredicate> getTail()
Iterator visits the IPredicates in the body (ala tail) of the rule.


getTail

IPredicate getTail(int index)
Return the predicate at the given index from the tail of the rule.

Parameters:
index - The index.
Returns:
The predicate at that index.
Throws:
IndexOutOfBoundsException

getConstraintCount

int getConstraintCount()
The #of constraints on the legal states for bindings of the variables declared by rule.


getConstraints

Iterator<IConstraint> getConstraints()
The optional constraints.


getConstraint

IConstraint getConstraint(int index)
Return the constraint at the given index.

Parameters:
index - The index.
Returns:
The constraint.
Throws:
IndexOutOfBoundsException

getName

String getName()
The name of the rule.

Specified by:
getName in interface IStep

toString

String toString()
Externalizes the rule displaying variable names and constants.

Specified by:
toString in interface IStep
Overrides:
toString in class Object

toString

String toString(IBindingSet bindingSet)
Externalizes the rule displaying variable names, their bindings, and constants.

Parameters:
bindingSet - When non-null, the current variable bindings will be displayed. Otherwise, the names of variables will be displayed rather than their bindings.

specialize

IRule<E> specialize(IBindingSet bindingSet,
                    IConstraint[] constraints)
Specialize a rule - the name of the new rule will be derived from the name of the old rule with an appended single quote to indicate that it is a derived variant.

Parameters:
bindingSet - Bindings for zero or more free variables in this rule. The rule will be rewritten such that the variable is replaced by the binding throughout the rule. An attempt to bind a variable not declared by the rule will be ignored.
constraints - An array of additional constraints to be imposed on the rule (optional).
Returns:
The specialized rule.
Throws:
IllegalArgumentException - if bindingSet is null.

specialize

IRule<E> specialize(String name,
                    IBindingSet bindingSet,
                    IConstraint[] constraints)
Specialize a rule by binding zero or more variables and adding zero or more constraints.

Parameters:
bindingSet - Bindings for zero or more free variables in this rule. The rule will be rewritten such that the variable is replaced by the binding throughout the rule. An attempt to bind a variable not declared by the rule will be ignored.
constraints - An array of additional constraints to be imposed on the rule (optional).
Returns:
The specialized rule.
Throws:
IllegalArgumentException - if name is null.
IllegalArgumentException - if bindingSet is null.

getConstants

IBindingSet getConstants()
Returns any variables that were bound to constants when an IRule was specialized.

Note: IJoinNexus.newBindingSet(IRule) MUST apply the constants before returning the bindings to the caller.

Returns:
The bound constants.

getSharedVars

Set<IVariable> getSharedVars(int index1,
                             int index2)
Return the variables in common for two IPredicates.

Parameters:
index1 - The index of a predicate in the #tail.
index2 - The index of a different predicate in the #tail.
Returns:
The variables in common -or- null iff there are no variables in common.
Throws:
IllegalArgumentException - if the two predicate indices are the same.
IndexOutOfBoundsException - if either index is out of bounds.

isFullyBound

boolean isFullyBound(int index,
                     IBindingSet bindingSet)
Return true iff the selected predicate is fully bound.

Parameters:
index - The index of a predicate declared the tail of the IRule.
bindingSet - The variable bindings.
Returns:
True iff it is fully bound (a mixture of constants and/or bound variables).
Throws:
IndexOutOfBoundsException - if the index is out of bounds.
IllegalArgumentException - if bindingSet is null.

isFullyBound

boolean isFullyBound(IBindingSet bindingSet)
If the rule is fully bound for the given bindings.

Parameters:
bindingSet - The bindings.
Returns:
true if there are no unbound variables in the rule given those bindings.

getVariableCount

int getVariableCount(int index,
                     IBindingSet bindingSet)
The #of arguments in the selected predicate that are variables (vs constants) with the given the bindings.

Parameters:
index - The index of a predicate declared the tail of the IRule.
bindingSet - The bindings under which the variable count will be obtained (any variables in the predicate that are bound in the binding set will be treated as constants for the purposes of this method).

isConsistent

boolean isConsistent(IBindingSet bindingSet)
Return true unless the IBindingSet violates a IConstraint declared for this Rule.

Parameters:
bindingSet - The binding set.
Returns:
true unless a constraint is violated by the bindings.

isDeclared

boolean isDeclared(IVariable var)
Return true iff the rule declares this variable.

Parameters:
var - Some variable.
Returns:
True if the rule declares that variable.
Throws:
IllegalArgumentException - if var is null.

getTaskFactory

IRuleTaskFactory getTaskFactory()
An optional IRuleTaskFactory that will be used in place of the default IRuleTaskFactory to evaluate this rule (optional)

Returns:
null unless custom evaluation is desired.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.