org.deri.iris.optimisations.magicsets
Class LeftToRightSip

java.lang.Object
  extended by org.deri.iris.optimisations.magicsets.LeftToRightSip
All Implemented Interfaces:
ISip

public class LeftToRightSip
extends Object
implements ISip

Sip, which examines the body literals from left to right.

This class is final, because the constructor is calling public non-final methods.

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

Constructor Summary
LeftToRightSip(IRule rule)
          Constructs a sip out of a rule.
LeftToRightSip(IRule rule, IQuery query)
          Creates a SIP for the given rule with bindings for the given query. NOTE: at the moment only the first literal of the head and the query are recognized.
 
Method Summary
 boolean containsVertex(ILiteral literal)
          Determines whether the sip constains a specific literal.
 boolean equals(Object object)
           
 Set<IVariable> getBoundVariables(ILiteral literal)
          Determines all variables, which are passed to this literal.
 Set<ILiteral> getDepends(ILiteral literal)
          Searches for literals on which the submitted literal depends.
 Set<LabeledEdge<ILiteral,Set<IVariable>>> getEdges()
          Returns an unmodifiable set of all edges of the sip.
 Set<LabeledEdge<ILiteral,Set<IVariable>>> getEdgesEnteringLiteral(ILiteral literal)
          Searches for edges entering this literal.
 Set<LabeledEdge<ILiteral,Set<IVariable>>> getEdgesLeavingLiteral(ILiteral literal)
          Searches for edges leaving this literal.
 Set<ILiteral> getLeafVertices()
          Determines the leafes of this graph.
 Comparator<ILiteral> getLiteralComparator()
          Returns the Comparator to compare literals according to their position in the sips.
 Set<ILiteral> getRootVertices()
          Determines the roots of this graph.
 int hashCode()
           
 String toString()
          Returns a simple string representation of this graph.
 Set<IVariable> variablesPassedByLiteral(ILiteral source, ILiteral target)
          Determines the set of variables passed to one literal by one specific edge.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LeftToRightSip

public LeftToRightSip(IRule rule,
                      IQuery query)
Creates a SIP for the given rule with bindings for the given query. NOTE: at the moment only the first literal of the head and the query are recognized.

Parameters:
rule - the rule for which to construct the graph
query - the query for this rule
Throws:
IllegalArgumentException - if the rule is null
IllegalArgumentException - if the query is null

LeftToRightSip

public LeftToRightSip(IRule rule)
Constructs a sip out of a rule.

Parameters:
rule - the rule for which to create the sip
Throws:
IllegalArgumentException - if the rule is null
Method Detail

getBoundVariables

public Set<IVariable> getBoundVariables(ILiteral literal)
Description copied from interface: ISip
Determines all variables, which are passed to this literal.

Specified by:
getBoundVariables in interface ISip
Parameters:
literal - the literal for which to determine the variables
Returns:
the set of variables

getDepends

public Set<ILiteral> getDepends(ILiteral literal)
Description copied from interface: ISip
Searches for literals on which the submitted literal depends.

Specified by:
getDepends in interface ISip
Parameters:
literal - the literal for which to search for dependencies
Returns:
the set of literal on which the submitted literal depends

getEdgesEnteringLiteral

public Set<LabeledEdge<ILiteral,Set<IVariable>>> getEdgesEnteringLiteral(ILiteral literal)
Description copied from interface: ISip
Searches for edges entering this literal.

Specified by:
getEdgesEnteringLiteral in interface ISip
Parameters:
literal - the literal for which to search for entering edges
Returns:
set of edges entering this literal

getEdgesLeavingLiteral

public Set<LabeledEdge<ILiteral,Set<IVariable>>> getEdgesLeavingLiteral(ILiteral literal)
Description copied from interface: ISip
Searches for edges leaving this literal.

Specified by:
getEdgesLeavingLiteral in interface ISip
Parameters:
literal - the literal for which to search for entering edges
Returns:
set of edges entering this literal

variablesPassedByLiteral

public Set<IVariable> variablesPassedByLiteral(ILiteral source,
                                               ILiteral target)
Description copied from interface: ISip
Determines the set of variables passed to one literal by one specific edge.

Specified by:
variablesPassedByLiteral in interface ISip
Parameters:
source - the source of the edge
target - the target of the edge
Returns:
the set of variables

toString

public String toString()
Returns a simple string representation of this graph. The subject of the returned string is to change. The returned string may be a list of all edges of this graph separated by newlines.

Overrides:
toString in class Object
Returns:
the string representation

containsVertex

public boolean containsVertex(ILiteral literal)
Description copied from interface: ISip
Determines whether the sip constains a specific literal.

Specified by:
containsVertex in interface ISip
Parameters:
literal - the literal for which to search for
Returns:
whether or not the literal is in the sip

getRootVertices

public Set<ILiteral> getRootVertices()
Description copied from interface: ISip
Determines the roots of this graph. A root is a Literal (vertex) with no entering arcs.

Specified by:
getRootVertices in interface ISip
Returns:
the set of literals with no entering arcs

getLeafVertices

public Set<ILiteral> getLeafVertices()
Description copied from interface: ISip
Determines the leafes of this graph. A leafe is a Literal (vertex) with no outfgoing arcs.

Specified by:
getLeafVertices in interface ISip
Returns:
the set of literals with no outfgoing arcs

getLiteralComparator

public Comparator<ILiteral> getLiteralComparator()
Description copied from interface: ISip
Returns the Comparator to compare literals according to their position in the sips. If you want to use this comparator with adorned literals use the SipHelper.getAdornedSip(AdornedRule) method to get the sip for adorned literals, otherwise it wont work as expected.

Specified by:
getLiteralComparator in interface ISip
Returns:
the comparator to compare literals
See Also:
SipHelper#getAdornedSip(org.deri.iris.evaluation.common.AdornedProgram.IAdornedRule)

getEdges

public Set<LabeledEdge<ILiteral,Set<IVariable>>> getEdges()
Returns an unmodifiable set of all edges of the sip.

Returns:
the set of edges.

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object