Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.hp.hpl.jena.reasoner.rulesys.impl.oldCode
Class GoalResults  view GoalResults download GoalResults.java

java.lang.Object
  extended bycom.hp.hpl.jena.reasoner.rulesys.impl.oldCode.GoalResults

public class GoalResults
extends java.lang.Object

Part of the backward chaining rule interpreter. The goal table is a table of partially evaluated goals. Each entry is an instance of GoalResults which contains the goal (a generalized triple pattern which supports structured literals), a set of triple values, a completion flag and a generator (which represents a continuation point for finding further goal values). This is essentially an encapsulation of the OR graph of the evaluation trace.

This implementation is not very space efficient. Once a GoalResult is complete we could flush all the results out to a single shared deductions graph in the inference engine wrapper. Care would be needed to do this in a thread-safe fashion since there can be multiple GoalStates scanning each GoalResult at any given time.

Version:
$Revision: 1.5 $ on $Date: 2005/02/21 12:18:04 $

Field Summary
protected  java.util.Set dependents
          The set of RuleStates which are currently blocked waiting for this table entry to have more results
protected  BRuleEngine engine
          The rule engine which this table entry is part of
protected  com.hp.hpl.jena.reasoner.TriplePattern goal
          The goal who values are being memoised by this entry
protected  boolean isComplete
          True if all the values for this goal are known
protected  boolean isSingleton
          Flag to indicate that the goal is a singleton and so should close once one result is in
(package private) static org.apache.commons.logging.Log logger
           
protected  int refCount
          Reference count of the number of rulestates working on values for this entry
protected  java.util.ArrayList resultSet
          The sequence of answers available so far
protected  java.util.HashSet resultSetIndex
          A searchable version of the resultSet
protected  boolean started
          True if this goal generator has started running
 
Constructor Summary
GoalResults(com.hp.hpl.jena.reasoner.TriplePattern goal, BRuleEngine ruleEngine)
          Contructor.
 
Method Summary
 void addDependent(RuleState dependent)
          Record that a rule node has suspened waiting for more results from this subgoal
 boolean addResult(com.hp.hpl.jena.graph.Triple result)
          Add a new result to the result set for this goal.
 void decRefCount()
          Decrement the reference count, called when a RuleState for this result set either fails or completes.
 void flushDependents()
          Move all the blocked dependents to the agenda for further processing.
 BRuleEngine getEngine()
          Return the rule engine processing this goal
 com.hp.hpl.jena.graph.Triple getResult(int n)
          Return the n'th memoized result for this goal.
 void incRefCount()
          Increment the reference count, called when a new RuleState refering to this result set is created.
 boolean isComplete()
          Return true of this goal is known to have been completely evaluated.
 int numResults()
          Return the number of available memoized results for this goal.
 void setAllComplete()
          Indicate that all goals have been completed, sets this to complete but does not bother to add the dependents to the agenda.
 void setComplete()
          Indicate that the goal has completed.
 void start()
          Start up a GoalResults stream.
 java.lang.String toString()
          Printable form
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

goal

protected com.hp.hpl.jena.reasoner.TriplePattern goal
The goal who values are being memoised by this entry


resultSet

protected java.util.ArrayList resultSet
The sequence of answers available so far


resultSetIndex

protected java.util.HashSet resultSetIndex
A searchable version of the resultSet


isComplete

protected boolean isComplete
True if all the values for this goal are known


started

protected boolean started
True if this goal generator has started running


dependents

protected java.util.Set dependents
The set of RuleStates which are currently blocked waiting for this table entry to have more results


engine

protected BRuleEngine engine
The rule engine which this table entry is part of


refCount

protected int refCount
Reference count of the number of rulestates working on values for this entry


isSingleton

protected boolean isSingleton
Flag to indicate that the goal is a singleton and so should close once one result is in


logger

static org.apache.commons.logging.Log logger
Constructor Detail

GoalResults

public GoalResults(com.hp.hpl.jena.reasoner.TriplePattern goal,
                   BRuleEngine ruleEngine)
Contructor.

Method Detail

isComplete

public boolean isComplete()
Return true of this goal is known to have been completely evaluated.


numResults

public int numResults()
Return the number of available memoized results for this goal.


getResult

public com.hp.hpl.jena.graph.Triple getResult(int n)
Return the n'th memoized result for this goal.


addDependent

public void addDependent(RuleState dependent)
Record that a rule node has suspened waiting for more results from this subgoal


flushDependents

public void flushDependents()
Move all the blocked dependents to the agenda for further processing.


getEngine

public BRuleEngine getEngine()
Return the rule engine processing this goal


setComplete

public void setComplete()
Indicate that the goal has completed.


setAllComplete

public void setAllComplete()
Indicate that all goals have been completed, sets this to complete but does not bother to add the dependents to the agenda.


start

public void start()
Start up a GoalResults stream. This finds all the relevant rules and adds initial states for them to the agenda.


addResult

public boolean addResult(com.hp.hpl.jena.graph.Triple result)
Add a new result to the result set for this goal.


incRefCount

public void incRefCount()
Increment the reference count, called when a new RuleState refering to this result set is created.


decRefCount

public void decRefCount()
Decrement the reference count, called when a RuleState for this result set either fails or completes.


toString

public java.lang.String toString()
Printable form